+2017-07-03 Alan Modra <amodra@gmail.com>
+
+ * bfd.c (_doprnt): Rewrite "ll" and "L" modifiers to "I64" for
+ __MSVCRT__. Support "L" modifier for bfd_vma. Formatting.
+ * elf.c (setup_group): Use "Lx" to print sh_size.
+ (_bfd_elf_setup_sections): Remove unnecessary cast and print
+ unknown section type in hex.
+ (copy_special_section_fields): Style fix.
+ (bfd_section_from_shdr): Correct format for sh_link. Use a
+ common error message for all the variants of unrecognized
+ section types.
+ (assign_file_positions_for_load_sections): Use "Lx" for lma
+ adjust error message.
+ (assign_file_positions_for_non_load_sections): Formatting.
+ (rewrite_elf_program_header): Formatting. Use "Lx" for
+ bfd_vma values in error messages.
+ * elfcode.h (elf_slurp_reloc_table_from_section): Cast
+ ELF_R_SYM value to type expected by format.
+ * elflink.c (elf_link_read_relocs_from_section): Use "Lx"
+ in error messages.
+ (elf_link_add_object_symbols): Use "Lu" for symbol sizes.
+ (elf_link_input_bfd): Use "Lx" for r_info.
+ (bfd_elf_gc_record_vtinherit): Use "Lx" for offset.
+
2017-07-03 Alan Modra <amodra@gmail.com>
* bfd.c (bfd_scan_vma): Don't use long long unless HAVE_LONG_LONG.
static const char *_bfd_error_program_name;
/* This macro and _doprnt taken from libiberty _doprnt.c, tidied a
- little and extended to handle '%A' and '%B'. */
+ little and extended to handle '%A' and '%B'. 'L' as a modifer for
+ integer formats is used for bfd_vma and bfd_size_type args, which
+ vary in size depending on BFD configuration. */
#define PRINT_TYPE(TYPE) \
do \
PRINT_TYPE (int);
else
{
+ /* L modifier for bfd_vma or bfd_size_type may be
+ either long long or long. */
+ if ((BFD_ARCH_SIZE < 64 || BFD_HOST_64BIT_LONG)
+ && sptr[-2] == 'L')
+ wide_width = 1;
+
switch (wide_width)
{
case 0:
break;
case 2:
default:
-#if defined(__GNUC__) || defined(HAVE_LONG_LONG)
+#if defined (__GNUC__) || defined (HAVE_LONG_LONG)
+# if defined (__MSVCRT__)
+ sptr--;
+ while (sptr[-1] == 'L' || sptr[-1] == 'l')
+ sptr--;
+ *sptr++ = 'I';
+ *sptr++ = '6';
+ *sptr++ = '4';
+ *sptr++ = ptr[-1];
+ *sptr = '\0';
+# endif
PRINT_TYPE (long long);
#else
/* Fake it and hope for the best. */
PRINT_TYPE (double);
else
{
-#if defined(__GNUC__) || defined(HAVE_LONG_DOUBLE)
+#if defined (__GNUC__) || defined (HAVE_LONG_DOUBLE)
PRINT_TYPE (long double);
#else
/* Fake it and hope for the best. */
_bfd_error_handler
/* xgettext:c-format */
(_("%B: corrupt size field in group section"
- " header: 0x%lx"), abfd, shdr->sh_size);
+ " header: %#Lx"), abfd, shdr->sh_size);
bfd_set_error (bfd_error_bad_value);
-- num_group;
continue;
_bfd_error_handler
/* xgettext:c-format */
(_("%B: invalid size field in group section"
- " header: 0x%lx"), abfd, shdr->sh_size);
+ " header: %#Lx"), abfd, shdr->sh_size);
bfd_set_error (bfd_error_bad_value);
-- num_group;
/* PR 17510: If the group contents are even
/* There are some unknown sections in the group. */
_bfd_error_handler
/* xgettext:c-format */
- (_("%B: unknown [%d] section `%s' in group [%A]"),
+ (_("%B: unknown type [%#x] section `%s' in group [%A]"),
abfd,
- (unsigned int) idx->shdr->sh_type,
+ idx->shdr->sh_type,
bfd_elf_string_from_elf_section (abfd,
(elf_elfheader (abfd)
->e_shstrndx),
/* See PR 20931 for a reproducer. */
if (iheader->sh_link >= elf_numsections (ibfd))
{
- (* _bfd_error_handler)
+ _bfd_error_handler
/* xgettext:c-format */
(_("%B: Invalid sh_link field (%d) in section number %d"),
ibfd, iheader->sh_link, secnum);
else
/* FIXME: Should we install iheader->sh_link
if we could not find a match ? */
- (* _bfd_error_handler)
+ _bfd_error_handler
/* xgettext:c-format */
(_("%B: Failed to find link section for section %d"), obfd, secnum);
}
changed = TRUE;
}
else
- (* _bfd_error_handler)
+ _bfd_error_handler
/* xgettext:c-format */
(_("%B: Failed to find info section for section %d"), obfd, secnum);
}
{
_bfd_error_handler
/* xgettext:c-format */
- (_("%B: invalid link %lu for reloc section %s (index %u)"),
+ (_("%B: invalid link %u for reloc section %s (index %u)"),
abfd, hdr->sh_link, name, shindex);
ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name,
shindex);
for applications? */
_bfd_error_handler
/* xgettext:c-format */
- (_("%B: don't know how to handle allocated, application "
- "specific section `%s' [0x%8x]"),
- abfd, name, hdr->sh_type);
+ (_("%B: unknown type [%#x] section `%s'"),
+ abfd, hdr->sh_type, name);
else
{
/* Allow sections reserved for applications. */
/* FIXME: We should handle this section. */
_bfd_error_handler
/* xgettext:c-format */
- (_("%B: don't know how to handle processor specific section "
- "`%s' [0x%8x]"),
- abfd, name, hdr->sh_type);
+ (_("%B: unknown type [%#x] section `%s'"),
+ abfd, hdr->sh_type, name);
else if (hdr->sh_type >= SHT_LOOS && hdr->sh_type <= SHT_HIOS)
{
/* Unrecognised OS-specific sections. */
be rejected with an error message. */
_bfd_error_handler
/* xgettext:c-format */
- (_("%B: don't know how to handle OS specific section "
- "`%s' [0x%8x]"),
- abfd, name, hdr->sh_type);
+ (_("%B: unknown type [%#x] section `%s'"),
+ abfd, hdr->sh_type, name);
else
{
/* Otherwise it should be processed. */
/* FIXME: We should handle this section. */
_bfd_error_handler
/* xgettext:c-format */
- (_("%B: don't know how to handle section `%s' [0x%8x]"),
- abfd, name, hdr->sh_type);
+ (_("%B: unknown type [%#x] section `%s'"),
+ abfd, hdr->sh_type, name);
goto fail;
}
{
_bfd_error_handler
/* xgettext:c-format */
- (_("%B: section %A lma %#lx adjusted to %#lx"), abfd, sec,
- (unsigned long) s_start, (unsigned long) p_end);
+ (_("%B: section %A lma %#Lx adjusted to %#Lx"),
+ abfd, sec, s_start, p_end);
adjust = 0;
sec->lma = p_end;
}
{
/* PR 17512: file: 2195325e. */
_bfd_error_handler
- (_("%B: error: non-load segment %d includes file header and/or program header"),
- abfd, (int)(p - phdrs));
+ (_("%B: error: non-load segment %d includes file header "
+ "and/or program header"),
+ abfd, (int) (p - phdrs));
return FALSE;
}
if (segment->p_type == PT_LOAD
&& (segment->p_filesz > 0 || segment->p_memsz == 0))
/* xgettext:c-format */
- _bfd_error_handler (_("\
-%B: warning: Empty loadable segment detected at vaddr=0x%.8x, is this intentional ?"),
+ _bfd_error_handler (_("%B: warning: Empty loadable segment detected"
+ " at vaddr=%#Lx, is this intentional?"),
ibfd, segment->p_vaddr);
map->count = 0;
/* PR 17512: file: f17299af. */
if (segment->p_align > (bfd_vma) 1 << ((sizeof (bfd_vma) * 8) - 2))
/* xgettext:c-format */
- _bfd_error_handler (_("\
-%B: warning: segment alignment of 0x%llx is too large"),
- ibfd, (long long) segment->p_align);
+ _bfd_error_handler (_("%B: warning: segment alignment of %#Lx"
+ " is too large"),
+ ibfd, segment->p_align);
else
maxpagesize = segment->p_align;
}
{
_bfd_error_handler
/* xgettext:c-format */
- (_("%B: bad reloc symbol index (0x%lx >= 0x%lx)"
- " for offset 0x%lx in section `%A'"),
+ (_("%B: bad reloc symbol index (%#lx >= %#lx)"
+ " for offset %#Lx in section `%A'"),
abfd, (unsigned long) r_symndx, (unsigned long) nsyms,
irela->r_offset, sec);
bfd_set_error (bfd_error_bad_value);
{
_bfd_error_handler
/* xgettext:c-format */
- (_("%B: non-zero symbol index (0x%lx)"
- " for offset 0x%lx in section `%A'"
+ (_("%B: non-zero symbol index (%#lx)"
+ " for offset %#Lx in section `%A'"
" when the object file has no symbol table"),
abfd, (unsigned long) r_symndx, (unsigned long) nsyms,
irela->r_offset, sec);
_bfd_error_handler
/* xgettext:c-format */
(_("Warning: size of symbol `%s' changed"
- " from %lu in %B to %lu in %B"),
- name, (unsigned long) h->size, old_bfd,
- (unsigned long) isym->st_size, abfd);
+ " from %Lu in %B to %Lu in %B"),
+ name, h->size, old_bfd, isym->st_size, abfd);
h->size = isym->st_size;
}
we do not seg fault. */
if (h == NULL)
{
- char buffer [32];
-
- sprintf_vma (buffer, rel->r_info);
_bfd_error_handler
/* xgettext:c-format */
- (_("error: %B contains a reloc (0x%s) for section %A "
+ (_("error: %B contains a reloc (%#Lx) for section %A "
"that references a non-existent global symbol"),
- input_bfd, buffer, o);
+ input_bfd, rel->r_info, o);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
}
/* xgettext:c-format */
- _bfd_error_handler (_("%B: %A+%lu: No symbol found for INHERIT"),
- abfd, sec, (unsigned long) offset);
+ _bfd_error_handler (_("%B: %A+%#Lx: No symbol found for INHERIT"),
+ abfd, sec, offset);
bfd_set_error (bfd_error_invalid_operation);
return FALSE;