From b9511c9413e8e303828bddd2bf162b2960080916 Mon Sep 17 00:00:00 2001 From: bebbo Date: Mon, 6 Feb 2017 15:04:37 +0100 Subject: [PATCH] @B fix compatibilty issues for VC --- bfd/aout-amiga.c | 2 ++ bfd/aoutx.h | 5 +++-- bfd/archive.c | 3 ++- bfd/binary.c | 1 + bfd/format.c | 11 +++++++++-- bfd/ihex.c | 7 ++++--- bfd/reloc.c | 8 ++++---- bfd/srec.c | 1 + bfd/stab-syms.c | 1 + bfd/tekhex.c | 1 + include/fopen-same.h | 12 ++++++------ ld/ldexp.c | 4 ++-- ld/ldlang.c | 2 +- ld/ldlex.c | 2 +- libiberty/lrealpath.c | 6 +++++- libiberty/pex-os2.c | 3 ++- libiberty/pex-win32.c | 2 +- libiberty/physmem.c | 4 ++-- libiberty/rename.c | 2 +- libiberty/tmpnam.c | 2 +- libiberty/xstrerror.c | 2 +- 21 files changed, 51 insertions(+), 30 deletions(-) diff --git a/bfd/aout-amiga.c b/bfd/aout-amiga.c index ced7584..f73ea99 100644 --- a/bfd/aout-amiga.c +++ b/bfd/aout-amiga.c @@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "config.h" + #define TARGETNAME "a.out-amiga" #define MACHTYPE_OK(m) ((m)==M_UNKNOWN || (m)==M_68010 || (m)==M_68020) #define TARGET_IS_BIG_ENDIAN_P diff --git a/bfd/aoutx.h b/bfd/aoutx.h index f3faca6..b2032ad 100644 --- a/bfd/aoutx.h +++ b/bfd/aoutx.h @@ -118,6 +118,7 @@ DESCRIPTION #define KEEPIT udata.i +#include "config.h" #include "bfd.h" #include "sysdep.h" #include "safe-ctype.h" @@ -998,7 +999,7 @@ adjust_z_magic (abfd, execp) text_pad = ((obj_textsec (abfd)->filepos - obj_textsec (abfd)->vma) & (adata (abfd).page_size - 1)); else - text_pad = ((- obj_textsec (abfd)->vma) + text_pad = ((- (long)obj_textsec (abfd)->vma) & (adata (abfd).page_size - 1)); } @@ -4727,7 +4728,7 @@ aout_link_write_other_symbol (h, data) H_PUT_16 (output_bfd, 0, outsym.e_desc); indx = add_to_stringtab (output_bfd, finfo->strtab, h->root.root.string, FALSE); - if (indx == - (bfd_size_type) 1) + if (indx == - (long)(bfd_size_type) 1) { /* FIXME: No way to handle errors. */ abort (); diff --git a/bfd/archive.c b/bfd/archive.c index 00045a3..0c8f414 100644 --- a/bfd/archive.c +++ b/bfd/archive.c @@ -127,6 +127,7 @@ DESCRIPTION " 18 " - Long name 18 characters long, extended pseudo-BSD. */ +#include "config.h" #include "bfd.h" #include "sysdep.h" #include "libbfd.h" @@ -625,7 +626,7 @@ bfd_generic_archive_p (abfd) struct artdata *tdata_hold; char armag[SARMAG + 1]; bfd_size_type amt; - + printf("bfd_generic_archive_p\n"); if (bfd_bread ((PTR) armag, (bfd_size_type) SARMAG, abfd) != SARMAG) { if (bfd_get_error () != bfd_error_system_call) diff --git a/bfd/binary.c b/bfd/binary.c index a27eb95..530238f 100644 --- a/bfd/binary.c +++ b/bfd/binary.c @@ -32,6 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ the file. objcopy cooperates by specially setting the start address to zero by default. */ +#include "config.h" #include "bfd.h" #include "sysdep.h" #include "safe-ctype.h" diff --git a/bfd/format.c b/bfd/format.c index 6415b8d..1a23f16 100644 --- a/bfd/format.c +++ b/bfd/format.c @@ -40,10 +40,16 @@ SECTION */ +#include "config.h" #include "bfd.h" #include "sysdep.h" #include "libbfd.h" +#ifdef DEBUGPRINT +#define DBGPRINT(a) printf a +#else +#define DBGPRINT(a) + /* IMPORT from targets.c. */ extern const size_t _bfd_target_vector_entries; @@ -230,8 +236,9 @@ bfd_check_format_matches (abfd, format, matching) _bfd_check_format might have this problem. */ bfd_set_error (bfd_error_wrong_format); - temp = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd)); - + DBGPRINT(("%s using %s: %p\n", abfd->filename, abfd->xvec->name, abfd->xvec->_bfd_check_format)); + temp = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd)); + DBGPRINT(("%s using %s: %p -> %p\n", abfd->filename, abfd->xvec->name, abfd->xvec->_bfd_check_format, temp)); if (temp) { /* This format checks out as ok! */ diff --git a/bfd/ihex.c b/bfd/ihex.c index 2f4aa56..5440c93 100644 --- a/bfd/ihex.c +++ b/bfd/ihex.c @@ -119,6 +119,7 @@ The MRI compiler uses this, which is a repeat of type 5: 20..21 Carriage return, line feed */ +#include "config.h" #include "bfd.h" #include "sysdep.h" #include "libbfd.h" @@ -366,12 +367,12 @@ ihex_scan (abfd) chksum = len + addr + (addr >> 8) + type; for (i = 0; i < len; i++) chksum += HEX2 (buf + 2 * i); - if (((- chksum) & 0xff) != (unsigned int) HEX2 (buf + 2 * i)) + if (((- (int)chksum) & 0xff) != (unsigned int) HEX2 (buf + 2 * i)) { (*_bfd_error_handler) (_("%s:%u: bad checksum in Intel Hex file (expected %u, found %u)"), bfd_archive_filename (abfd), lineno, - (- chksum) & 0xff, (unsigned int) HEX2 (buf + 2 * i)); + (- (int)chksum) & 0xff, (unsigned int) HEX2 (buf + 2 * i)); bfd_set_error (bfd_error_bad_value); goto error_return; } @@ -788,7 +789,7 @@ ihex_write_record (abfd, count, addr, type, data) chksum += *data; } - TOHEX (p, (- chksum) & 0xff); + TOHEX (p, (- (int)chksum) & 0xff); p[2] = '\r'; p[3] = '\n'; diff --git a/bfd/reloc.c b/bfd/reloc.c index 7ebeb99..b4e9270 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -916,7 +916,7 @@ space consuming. For each target: case -2: { long x = bfd_get_32 (abfd, (bfd_byte *) data + octets); - relocation = -relocation; + relocation = -(long)relocation; DOIT (x); bfd_put_32 (abfd, (bfd_vma) x, (bfd_byte *) data + octets); } @@ -925,7 +925,7 @@ space consuming. For each target: case -1: { long x = bfd_get_16 (abfd, (bfd_byte *) data + octets); - relocation = -relocation; + relocation = -(long)relocation; DOIT (x); bfd_put_16 (abfd, (bfd_vma) x, (bfd_byte *) data + octets); } @@ -1300,7 +1300,7 @@ space consuming. For each target: case -2: { long x = bfd_get_32 (abfd, (bfd_byte *) data); - relocation = -relocation; + relocation = -(long)relocation; DOIT (x); bfd_put_32 (abfd, (bfd_vma) x, (bfd_byte *) data); } @@ -1409,7 +1409,7 @@ _bfd_relocate_contents (howto, input_bfd, relocation, location) /* If the size is negative, negate RELOCATION. This isn't very general. */ if (howto->size < 0) - relocation = -relocation; + relocation = -(long)relocation; /* Get the value we are going to relocate. */ size = bfd_get_reloc_size (howto); diff --git a/bfd/srec.c b/bfd/srec.c index cd31907..ee59986 100644 --- a/bfd/srec.c +++ b/bfd/srec.c @@ -104,6 +104,7 @@ DESCRIPTION */ +#include "config.h" #include "bfd.h" #include "sysdep.h" #include "libbfd.h" diff --git a/bfd/stab-syms.c b/bfd/stab-syms.c index a685e31..a59c878 100644 --- a/bfd/stab-syms.c +++ b/bfd/stab-syms.c @@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "config.h" #include "bfd.h" #define ARCH_SIZE 32 /* Value doesn't matter. */ diff --git a/bfd/tekhex.c b/bfd/tekhex.c index 77b471a..b451413 100644 --- a/bfd/tekhex.c +++ b/bfd/tekhex.c @@ -67,6 +67,7 @@ The data can come out of order, and may be discontigous. This is a serial protocol, so big files are unlikely, so we keep a list of 8k chunks */ +#include "config.h" #include "bfd.h" #include "sysdep.h" #include "libbfd.h" diff --git a/include/fopen-same.h b/include/fopen-same.h index 0f37529..63486e4 100644 --- a/include/fopen-same.h +++ b/include/fopen-same.h @@ -12,12 +12,12 @@ the application unable to be configured for both "same" and "binary" variant systems. */ -#define FOPEN_RB "r" -#define FOPEN_WB "w" -#define FOPEN_AB "a" -#define FOPEN_RUB "r+" -#define FOPEN_WUB "w+" -#define FOPEN_AUB "a+" +#define FOPEN_RB "rb" +#define FOPEN_WB "wb" +#define FOPEN_AB "ab" +#define FOPEN_RUB "r+b" +#define FOPEN_WUB "w+b" +#define FOPEN_AUB "a+b" #define FOPEN_RT "r" #define FOPEN_WT "w" diff --git a/ld/ldexp.c b/ld/ldexp.c index 9227dd6..74cecc3 100644 --- a/ld/ldexp.c +++ b/ld/ldexp.c @@ -307,7 +307,7 @@ fold_unary (tree, current_section, allocation_done, dot, dotp) case '-': make_abs (&result); - result.value = -result.value; + result.value = -(long)result.value; break; case NEXT: @@ -668,7 +668,7 @@ exp_fold_tree (tree, current_section, allocation_done, dot, dotp) bfd_vma dot; bfd_vma *dotp; { - etree_value_type result; + etree_value_type result = { 0, 0, 0, 0 }; if (tree == NULL) { diff --git a/ld/ldlang.c b/ld/ldlang.c index 8846917..4c67077 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -3377,7 +3377,7 @@ lang_size_sections (s, output_section_statement, prev, fill, dot, relax, a page could be saved in the data segment. */ bfd_vma first, last; - first = -exp_data_seg.base & (exp_data_seg.pagesize - 1); + first = -(long)exp_data_seg.base & (exp_data_seg.pagesize - 1); last = exp_data_seg.end & (exp_data_seg.pagesize - 1); if (first && last && ((exp_data_seg.base & ~(exp_data_seg.pagesize - 1)) diff --git a/ld/ldlex.c b/ld/ldlex.c index 0de7865..176a9c9 100644 --- a/ld/ldlex.c +++ b/ld/ldlex.c @@ -14,7 +14,7 @@ #endif /* First, we deal with platform-specific or compiler-specific issues. */ - +#include "config.h" /* begin standard C headers. */ #include #include diff --git a/libiberty/lrealpath.c b/libiberty/lrealpath.c index f9b930b..dd69835 100644 --- a/libiberty/lrealpath.c +++ b/libiberty/lrealpath.c @@ -50,6 +50,10 @@ components will be simplified. The returned value will be allocated using #include #endif +#ifndef DIR_SEPARATOR_S +#define DIR_SEPARATOR_S "/" +#endif + /* On GNU libc systems the declaration is only visible with _GNU_SOURCE. */ #if defined(HAVE_CANONICALIZE_FILE_NAME) \ && defined(NEED_DECLARATION_CANONICALIZE_FILE_NAME) @@ -113,7 +117,7 @@ lrealpath (filename) #if defined (HAVE_REALPATH) && defined (HAVE_UNISTD_H) { /* Find out the max path size. */ - long path_max = pathconf ("/", _PC_PATH_MAX); + long path_max = pathconf (DIR_SEPARATOR_S, _PC_PATH_MAX); if (path_max > 0) { /* PATH_MAX is bounded. */ diff --git a/libiberty/pex-os2.c b/libiberty/pex-os2.c index d9eacf1..11bc26a 100644 --- a/libiberty/pex-os2.c +++ b/libiberty/pex-os2.c @@ -67,6 +67,7 @@ pwait (pid, status, flags) { /* ??? Here's an opportunity to canonicalize the values in STATUS. Needed? */ - int pid = wait (status); + //int + pid = wait (status); return pid; } diff --git a/libiberty/pex-win32.c b/libiberty/pex-win32.c index bd097a4..9000302 100644 --- a/libiberty/pex-win32.c +++ b/libiberty/pex-win32.c @@ -132,7 +132,7 @@ pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags) char * const *argv; const char *this_pname; const char *temp_base; - char **errmsg_fmt, **errmsg_arg; + const char **errmsg_fmt, **errmsg_arg; int flags; { int pid; diff --git a/libiberty/physmem.c b/libiberty/physmem.c index 9185c12..e1f3520 100644 --- a/libiberty/physmem.c +++ b/libiberty/physmem.c @@ -152,7 +152,7 @@ physmem_total () #if defined _WIN32 { /* this works on windows */ PFN_MS_EX pfnex; - HMODULE h = GetModuleHandle ("kernel32.dll"); + HMODULE h = GetModuleHandleA ("kernel32.dll"); if (!h) return 0.0; @@ -253,7 +253,7 @@ physmem_available () #if defined _WIN32 { /* this works on windows */ PFN_MS_EX pfnex; - HMODULE h = GetModuleHandle ("kernel32.dll"); + HMODULE h = GetModuleHandleA ("kernel32.dll"); if (!h) return 0.0; diff --git a/libiberty/rename.c b/libiberty/rename.c index 399980a..6393100 100644 --- a/libiberty/rename.c +++ b/libiberty/rename.c @@ -12,10 +12,10 @@ exists, it is removed. */ -#include "ansidecl.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif +#include "ansidecl.h" #include #ifdef HAVE_UNISTD_H #include diff --git a/libiberty/tmpnam.c b/libiberty/tmpnam.c index 406878c..767742b 100644 --- a/libiberty/tmpnam.c +++ b/libiberty/tmpnam.c @@ -11,7 +11,7 @@ not be used in new projects. Use @code{mkstemp} instead. @end deftypefn */ - +#include "config.h" #include #ifndef L_tmpnam diff --git a/libiberty/xstrerror.c b/libiberty/xstrerror.c index 9000d17..a253954 100644 --- a/libiberty/xstrerror.c +++ b/libiberty/xstrerror.c @@ -13,10 +13,10 @@ will never return a @code{NULL} pointer. */ +#include "config.h" #include #include "libiberty.h" -#include "config.h" #ifdef VMS #include