/* BFD back-end for IBM RS/6000 "XCOFF" files.
- Copyright (C) 1990-2018 Free Software Foundation, Inc.
+ Copyright (C) 1990-2019 Free Software Foundation, Inc.
Written by Metin G. Ozisik, Mimi Phuong-Thao Vo, and John Gilmore.
Archive support from Damon A. Permezel.
Contributed by IBM Corporation and Cygnus Support.
#define bfd_pe_print_pdata NULL
#endif
-#include <stdint.h>
#include "coffcode.h"
/* The main body of code is in coffcode.h. */
}
/* Macro to read an ASCII value stored in an archive header field. */
-#define GET_VALUE_IN_FIELD(VAR, FIELD) \
- do \
- { \
- (VAR) = sizeof (VAR) > sizeof (long) \
- ? _bfd_strntoll (FIELD, 10, sizeof FIELD) \
- : _bfd_strntol (FIELD, 10, sizeof FIELD); \
- } \
+#define GET_VALUE_IN_FIELD(VAR, FIELD, BASE) \
+ do \
+ { \
+ (VAR) = (sizeof (VAR) > sizeof (long) \
+ ? _bfd_strntoll (FIELD, BASE, sizeof FIELD) \
+ : _bfd_strntol (FIELD, BASE, sizeof FIELD)); \
+ } \
while (0)
-#define EQ_VALUE_IN_FIELD(VAR, FIELD) \
- (sizeof (VAR) > sizeof (long) \
- ? (VAR) ==_bfd_strntoll (FIELD, 10, sizeof FIELD) \
- : (VAR) == _bfd_strntol (FIELD, 10, sizeof FIELD))
+#define EQ_VALUE_IN_FIELD(VAR, FIELD, BASE) \
+ (sizeof (VAR) > sizeof (long) \
+ ? (VAR) == _bfd_strntoll (FIELD, BASE, sizeof FIELD) \
+ : (VAR) == _bfd_strntol (FIELD, BASE, sizeof FIELD))
/* Read in the armap of an XCOFF archive. */
/* This is for the old format. */
struct xcoff_ar_hdr hdr;
- GET_VALUE_IN_FIELD (off, xcoff_ardata (abfd)->symoff);
+ GET_VALUE_IN_FIELD (off, xcoff_ardata (abfd)->symoff, 10);
if (off == 0)
{
bfd_has_map (abfd) = FALSE;
return FALSE;
/* Skip the name (normally empty). */
- GET_VALUE_IN_FIELD (namlen, hdr.namlen);
+ GET_VALUE_IN_FIELD (namlen, hdr.namlen, 10);
off = ((namlen + 1) & ~ (size_t) 1) + SXCOFFARFMAG;
if (bfd_seek (abfd, off, SEEK_CUR) != 0)
return FALSE;
- GET_VALUE_IN_FIELD (sz, hdr.size);
+ GET_VALUE_IN_FIELD (sz, hdr.size, 10);
/* Read in the entire symbol table. */
contents = (bfd_byte *) bfd_alloc (abfd, sz);
/* This is for the new format. */
struct xcoff_ar_hdr_big hdr;
- GET_VALUE_IN_FIELD (off, xcoff_ardata_big (abfd)->symoff);
+ GET_VALUE_IN_FIELD (off, xcoff_ardata_big (abfd)->symoff, 10);
if (off == 0)
{
bfd_has_map (abfd) = FALSE;
return FALSE;
/* Skip the name (normally empty). */
- GET_VALUE_IN_FIELD (namlen, hdr.namlen);
+ GET_VALUE_IN_FIELD (namlen, hdr.namlen, 10);
off = ((namlen + 1) & ~ (size_t) 1) + SXCOFFARFMAG;
if (bfd_seek (abfd, off, SEEK_CUR) != 0)
return FALSE;
- GET_VALUE_IN_FIELD (sz, hdr.size);
+ GET_VALUE_IN_FIELD (sz, hdr.size, 10);
/* Read in the entire symbol table. */
contents = (bfd_byte *) bfd_alloc (abfd, sz);
}
GET_VALUE_IN_FIELD (bfd_ardata (abfd)->first_file_filepos,
- hdr.firstmemoff);
+ hdr.firstmemoff, 10);
amt = SIZEOF_AR_FILE_HDR;
bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, amt);
return NULL;
}
- GET_VALUE_IN_FIELD (namlen, hdr.namlen);
+ GET_VALUE_IN_FIELD (namlen, hdr.namlen, 10);
amt = SIZEOF_AR_HDR + namlen + 1;
hdrp = (struct xcoff_ar_hdr *) bfd_alloc (abfd, amt);
if (hdrp == NULL)
((char *) hdrp)[SIZEOF_AR_HDR + namlen] = '\0';
ret->arch_header = (char *) hdrp;
- GET_VALUE_IN_FIELD (ret->parsed_size, hdr.size);
+ GET_VALUE_IN_FIELD (ret->parsed_size, hdr.size, 10);
ret->filename = (char *) hdrp + SIZEOF_AR_HDR;
}
else
return NULL;
}
- GET_VALUE_IN_FIELD (namlen, hdr.namlen);
+ GET_VALUE_IN_FIELD (namlen, hdr.namlen, 10);
amt = SIZEOF_AR_HDR_BIG + namlen + 1;
hdrp = (struct xcoff_ar_hdr_big *) bfd_alloc (abfd, amt);
if (hdrp == NULL)
((char *) hdrp)[SIZEOF_AR_HDR_BIG + namlen] = '\0';
ret->arch_header = (char *) hdrp;
- GET_VALUE_IN_FIELD (ret->parsed_size, hdr.size);
+ GET_VALUE_IN_FIELD (ret->parsed_size, hdr.size, 10);
ret->filename = (char *) hdrp + SIZEOF_AR_HDR_BIG;
}
if (last_file == NULL)
filestart = bfd_ardata (archive)->first_file_filepos;
else
- GET_VALUE_IN_FIELD (filestart, arch_xhdr (last_file)->nextoff);
+ GET_VALUE_IN_FIELD (filestart, arch_xhdr (last_file)->nextoff, 10);
if (filestart == 0
- || EQ_VALUE_IN_FIELD (filestart, xcoff_ardata (archive)->memoff)
- || EQ_VALUE_IN_FIELD (filestart, xcoff_ardata (archive)->symoff))
+ || EQ_VALUE_IN_FIELD (filestart, xcoff_ardata (archive)->memoff, 10)
+ || EQ_VALUE_IN_FIELD (filestart, xcoff_ardata (archive)->symoff, 10))
{
bfd_set_error (bfd_error_no_more_archived_files);
return NULL;
if (last_file == NULL)
filestart = bfd_ardata (archive)->first_file_filepos;
else
- GET_VALUE_IN_FIELD (filestart, arch_xhdr_big (last_file)->nextoff);
+ GET_VALUE_IN_FIELD (filestart, arch_xhdr_big (last_file)->nextoff, 10);
if (filestart == 0
- || EQ_VALUE_IN_FIELD (filestart, xcoff_ardata_big (archive)->memoff)
- || EQ_VALUE_IN_FIELD (filestart, xcoff_ardata_big (archive)->symoff))
+ || EQ_VALUE_IN_FIELD (filestart, xcoff_ardata_big (archive)->memoff, 10)
+ || EQ_VALUE_IN_FIELD (filestart, xcoff_ardata_big (archive)->symoff, 10))
{
bfd_set_error (bfd_error_no_more_archived_files);
return NULL;
{
struct xcoff_ar_hdr *hdrp = arch_xhdr (abfd);
- GET_VALUE_IN_FIELD (s->st_mtime, hdrp->date);
- GET_VALUE_IN_FIELD (s->st_uid, hdrp->uid);
- GET_VALUE_IN_FIELD (s->st_gid, hdrp->gid);
- GET_VALUE_IN_FIELD (s->st_mode, hdrp->mode);
+ GET_VALUE_IN_FIELD (s->st_mtime, hdrp->date, 10);
+ GET_VALUE_IN_FIELD (s->st_uid, hdrp->uid, 10);
+ GET_VALUE_IN_FIELD (s->st_gid, hdrp->gid, 10);
+ GET_VALUE_IN_FIELD (s->st_mode, hdrp->mode, 8);
s->st_size = arch_eltdata (abfd)->parsed_size;
}
else
{
struct xcoff_ar_hdr_big *hdrp = arch_xhdr_big (abfd);
- GET_VALUE_IN_FIELD (s->st_mtime, hdrp->date);
- GET_VALUE_IN_FIELD (s->st_uid, hdrp->uid);
- GET_VALUE_IN_FIELD (s->st_gid, hdrp->gid);
- GET_VALUE_IN_FIELD (s->st_mode, hdrp->mode);
+ GET_VALUE_IN_FIELD (s->st_mtime, hdrp->date, 10);
+ GET_VALUE_IN_FIELD (s->st_uid, hdrp->uid, 10);
+ GET_VALUE_IN_FIELD (s->st_gid, hdrp->gid, 10);
+ GET_VALUE_IN_FIELD (s->st_mode, hdrp->mode, 8);
s->st_size = arch_eltdata (abfd)->parsed_size;
}
{
_bfd_error_handler
/* xgettext: c-format */
- (_("%B: unsupported relocation type 0x%02x"),
+ (_("%pB: unsupported relocation type %#x"),
input_bfd, (unsigned int) rel->r_type);
bfd_set_error (bfd_error_bad_value);
return FALSE;
{
_bfd_error_handler
/* xgettext: c-format */
- (_("%B: TOC reloc at %#Lx to symbol `%s' with no TOC entry"),
- input_bfd, rel->r_vaddr, h->root.root.string);
+ (_("%pB: TOC reloc at %#" PRIx64 " to symbol `%s' with no TOC entry"),
+ input_bfd, (uint64_t) rel->r_vaddr, h->root.root.string);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
relies on it, and it is the only way to write assembler
code which can run when loaded at a location 0x80000000
away from the location at which it is linked. */
- if (howto->bitsize + howto->rightshift
+ if ((unsigned) howto->bitsize + howto->rightshift
== bfd_arch_bits_per_address (input_bfd))
return FALSE;
operation, which would be tedious, or we must do the computations
in a type larger than bfd_vma, which would be inefficient. */
- if ((unsigned int) howto.complain_on_overflow
- >= XCOFF_MAX_COMPLAIN_OVERFLOW)
- abort ();
-
if (((*xcoff_complain_overflow[howto.complain_on_overflow])
(input_bfd, value_to_relocate, relocation, &howto)))
{
return TRUE;
}
+/* gcc-8 warns (*) on all the strncpy calls in this function about
+ possible string truncation. The "truncation" is not a bug. We
+ have an external representation of structs with fields that are not
+ necessarily NULL terminated and corresponding internal
+ representation fields that are one larger so that they can always
+ be NULL terminated.
+ gcc versions between 4.2 and 4.6 do not allow pragma control of
+ diagnostics inside functions, giving a hard error if you try to use
+ the finer control available with later versions.
+ gcc prior to 4.2 warns about diagnostic push and pop.
+ gcc-5, gcc-6 and gcc-7 warn that -Wstringop-truncation is unknown,
+ unless you also add #pragma GCC diagnostic ignored "-Wpragma".
+ (*) Depending on your system header files! */
+#if GCC_VERSION >= 8000
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wstringop-truncation"
+#endif
static bfd_boolean
_bfd_xcoff_put_ldsymbol_name (bfd *abfd ATTRIBUTE_UNUSED,
struct xcoff_loader_info *ldinfo,
}
return TRUE;
}
+#if GCC_VERSION >= 8000
+# pragma GCC diagnostic pop
+#endif
static asection *
xcoff_create_csect_from_smclas (bfd *abfd,
{
_bfd_error_handler
/* xgettext: c-format */
- (_("%B: symbol `%s' has unrecognized smclas %d"),
+ (_("%pB: symbol `%s' has unrecognized smclas %d"),
abfd, symbol_name, aux->x_csect.x_smclas);
bfd_set_error (bfd_error_bad_value);
}
#define _bfd_xcoff_bfd_discard_group bfd_generic_discard_group
#define _bfd_xcoff_section_already_linked _bfd_generic_section_already_linked
#define _bfd_xcoff_bfd_define_common_symbol _bfd_xcoff_define_common_symbol
+#define _bfd_xcoff_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
#define _bfd_xcoff_bfd_define_start_stop bfd_generic_define_start_stop
#define _bfd_xcoff_bfd_link_check_relocs _bfd_generic_link_check_relocs