From 76cfced5addbd827652688a13f9cfa02afce51a5 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 3 Jul 2017 21:59:45 +0930 Subject: Support %Lx, %Lu, %Ld in _bfd_error_handler format One way to print 64-bit bfd_vma or bfd_size_type values on 32-bit hosts is to cast the value to long long and use the 'll' modifier in printf format strings. However, that's awkward because we also support the Microsoft C library printf that uses 'I64' as a modifier instead, and having variants of translated strings would not endear us to the translation project. So, rewrite the 'll' modifier in _doprint for Microsoft. Even with that capability it's not so nice for 32-bit code to need casts to long long, so this patch makes 'L' a modifier for bfd_vma rather than an alias for 'll'. I've then used the new 'L' modifier to fix selected format strings. * 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. --- bfd/elflink.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'bfd/elflink.c') diff --git a/bfd/elflink.c b/bfd/elflink.c index 471e8ad..bb1a30a 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -2394,8 +2394,8 @@ elf_link_read_relocs_from_section (bfd *abfd, { _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); @@ -2406,8 +2406,8 @@ elf_link_read_relocs_from_section (bfd *abfd, { _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); @@ -4752,9 +4752,8 @@ error_free_dyn: _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; } @@ -10477,14 +10476,11 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd) 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; } @@ -13422,8 +13418,8 @@ bfd_elf_gc_record_vtinherit (bfd *abfd, } /* 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; -- cgit v1.1