aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
2017-09-25PR22202, buffer overflow in parse_dieAlan Modra2-18/+45
There was a complete lack of sanity checking in dwarf1.c PR 22202 * dwarf1.c (parse_die): Sanity check pointer against section limit before dereferencing. (parse_line_table): Likewise.
2017-09-25PR22201, DW_AT_name with out of bounds referenceAlan Modra2-2/+11
DW_AT_name ought to always have a string value. PR 22201 * dwarf2.c (scan_unit_for_symbols): Ignore DW_AT_name unless it has string form. (parse_comp_unit): Likewise.
2017-09-25PR22200, DWARF5 .debug_line sanity checkAlan Modra2-0/+12
The format_count entry can't be zero unless the count is also zero. PR 22200 * dwarf2.c (read_formatted_entries): Error on format_count zero.
2017-09-25Automatic date update in version.inGDB Administrator1-1/+1
2017-09-24PR22197, buffer overflow in bfd_get_debug_link_info_1Alan Modra2-1/+7
PR 22197 * opncls.c (bfd_get_debug_link_info_1): Properly check that crc is within section bounds.
2017-09-24PR22191, memory leak in dwarf2.cAlan Modra2-2/+11
table->sequences is a linked list before it is replaced by a bfd_alloc array in sort_line_sequences. PR 22191 * dwarf2.c (decode_line_info): Properly free line sequences on error.
2017-09-24PR22187, infinite loop in find_abstract_instance_nameAlan Modra2-25/+61
This patch prevents the simple case of infinite recursion in find_abstract_instance_name by ensuring that the attributes being processed are not the same as the previous call. The patch also does a little cleanup, and leaves in place some changes to the nested_funcs array that I made when I wrongly thought looping might occur in scan_unit_for_symbols. PR 22187 * dwarf2.c (find_abstract_instance_name): Add orig_info_ptr and pname param. Return status. Make name const. Don't abort, return an error. Formatting. Exit if current info_ptr matches orig_info_ptr. Update callers. (scan_unit_for_symbols): Start at nesting_level of zero. Make nested_funcs an array of structs for extensibility. Formatting.
2017-09-24PR22186, divide-by-zero in decode_line_infoAlan Modra2-0/+8
PR 22186 * dwarf2.c (decode_line_info): Fail on lh.line_range of zero rather than dividing by zero.
2017-09-24PR22169, heap-based buffer overflow in read_1_byteAlan Modra2-3/+9
The .debug_line header length field doesn't include the length field itself, ie. it's the size of the rest of .debug_line. PR 22169 * dwarf2.c (decode_line_info): Correct .debug_line unit_length check.
2017-09-24PR22167, NULL pointer dereference in scan_unit_for_symbolsAlan Modra2-1/+7
PR 22167 * dwarf2.c (scan_unit_for_symbols): Check u.blk->data is non-NULL.
2017-09-24PR22166, SHT_GNU_verneed memory allocationAlan Modra2-2/+10
The sanity check covers the previous minimim size, plus that the size is at least enough for sh_info verneed entries. Also, since we write all verneed fields or exit with an error, there isn't any need to zero the memory allocated for verneed entries. PR 22166 * elf.c (_bfd_elf_slurp_version_tables): Test sh_info on SHT_GNU_verneed section for sanity. Don't zalloc memory for verref.
2017-09-24Automatic date update in version.inGDB Administrator1-1/+1
2017-09-23Automatic date update in version.inGDB Administrator1-1/+1
2017-09-22x86: Guard against corrupted PLTH.J. Lu2-0/+10
There should be only one entry in PLT for a given symbol. Set howto to NULL after processing a PLT entry to guard against corrupted PLT so that the duplicated PLT entries are skipped. PR binutils/22170 * elfxx-x86.c (_bfd_x86_elf_get_synthetic_symtab): Guard against corrupted PLT.
2017-09-22Update ChangeLog entry for PR 22163H.J. Lu1-1/+1
2017-09-22x86: Return -1 if bfd_canonicalize_dynamic_reloc returns 0H.J. Lu2-1/+7
Stop if bfd_canonicalize_dynamic_reloc returns 0. PR ld/22163 * elfxx-x86.c (_bfd_x86_elf_get_synthetic_symtab): Also return -1 if bfd_canonicalize_dynamic_reloc returns 0.
2017-09-22bfd/version.h: Add rationale for BFD_VERSION_DATEPedro Alves2-0/+23
bfd/ChangeLog: 2017-09-22 Pedro Alves <palves@redhat.com> Alan Modra <amodra@gmail.com> * version.h: Add comment.
2017-09-22Automatic date update in version.inGDB Administrator1-1/+1
2017-09-21S/390: Fix Elf note swap s390_gs_bc vs. s390_gs_cbAndreas Arnez2-2/+8
Fix two typos that resulted in swapping the BFD names for the core note register sections NT_S390_GS_CB and NT_S390_GS_BC. bfd/ChangeLog: * elf.c (elfcore_grok_note): For the cases NT_S390_GS_CB and NT_S390_GS_BC, correct the previously swapped invocations of elfcore_grok_s390_gs_bc and elfcore_grok_s390_gs_cb.
2017-09-21Automatic date update in version.inGDB Administrator1-1/+1
2017-09-20Automatic date update in version.inGDB Administrator1-1/+1
2017-09-19PowerPC64 stubs don't match calculated sizeAlan Modra2-6/+7
After the PR 21411 fix, the linker generated .eh_frame for ppc64 glink can be edited by the generic code. The sequence of events goes something like: 1) Some object file adds .eh_frame aligned to 8, making the output .eh_frame aligned to at least 8, so linker generated .eh_frame FDE is padded to an 8 byte boundary. 2) All .eh_frame past the glink .eh_frame is garbage collected. 3) Generic code detects that last FDE (the glink .eh_frame) doesn't need to be padded to an 8 byte boundary, reducing size from 88 to 84. 4) elf64-ppc.c check fails. PR 21441 * elf64-ppc.c (ppc64_elf_build_stubs): Don't check glink_eh_frame size.
2017-09-19PR22150, ld keeps a version reference for gc'd symbolsAlan Modra2-117/+118
elf_gc_sweep_symbol should run after verdefs are calculated, since the verdef code creates symbols for the versions. However, elf_gc_sweep_symbol needs to run before verrefs so as to not emit useless verrefs for symbols that are gc'd. I've also removed a _bfd_elf_link_renumber_dynsyms calls added by Maciej after I fussed about it when reviewing. On further examination the call appears to be unnecessary. Looking at renumber_dynsyms also made me realize that the test to exclude .gnu.version has been wrong since 2016-04-26 (git commit d5486c4372), so fix that too. PR 22150 * elflink.c (bfd_elf_size_dynamic_sections): Garbage collect symbols before calculating verrefs. Don't renumber dynsyms after gc. Exclude .gnu.version when zero or one dynsym. Localize some vars and reindent.
2017-09-19Automatic date update in version.inGDB Administrator1-1/+1
2017-09-18Check error return from bfd_canonicalize_dynamic_relocH.J. Lu2-0/+8
Since bfd_canonicalize_dynamic_reloc returns -1 on error, check it in _bfd_x86_elf_get_synthetic_symtab. PR ld/22148 * elfxx-x86.c (_bfd_x86_elf_get_synthetic_symtab): Check error return from bfd_canonicalize_dynamic_reloc.
2017-09-18Automatic date update in version.inGDB Administrator1-1/+1
2017-09-17Automatic date update in version.inGDB Administrator1-1/+1
2017-09-16Automatic date update in version.inGDB Administrator1-1/+1
2017-09-15Error when 32-bit ar tries to handle 4G or larger filesAlan Modra2-0/+12
We used to silently truncate the size returned by stat() to 32 bits. While it is possible to make binutils handle a 64-bit off_t on a 32-bit host, to me the effort needed doesn't seem worth the benefit. Instead, error if we truncate the size. I've written the test the way I have to avoid a signed/unsigned warning. PR 22116 * archive.c (bfd_ar_hdr_from_filesystem): Detect when status.st_size overflows bfd_size_type.
2017-09-15Automatic date update in version.inGDB Administrator1-1/+1
2017-09-14x86: Cache section contents and relocationsH.J. Lu3-5/+38
bfd/ PR ld/22135 * elf32-i386.c (elf_i386_convert_load_reloc): Add an argument to indicate if conversion is performed. (elf_i386_check_relocs): Cache section contents and relocations if conversion is performed. * elf64-x86-64.c (elf_x86_64_check_relocs): Cache section contents and relocations if conversion is performed. ld/ PR ld/22135 * testsuite/ld-i386/i386.exp: Run pr22135. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr22135.d: New file. * testsuite/ld-i386/pr22135.s: Likewise. * testsuite/ld-x86-64/pr22135.d: Likewise. * testsuite/ld-x86-64/pr22135.s: Likewise.
2017-09-14Fix address violation when parsing a corrupt PE binary.Nick Clifton2-2/+9
PR binutils/22113 * peXXigen.c (pe_print_idata): Extend check for HintName vector entries.
2017-09-14Automatic date update in version.inGDB Administrator1-1/+1
2017-09-13elfxx-x86.h: Fix a typo in commentsH.J. Lu2-1/+5
* elfxx-x86.h: Fix a typo in comments.
2017-09-13Automatic date update in version.inGDB Administrator1-1/+1
2017-09-12Automatic date update in version.inGDB Administrator1-1/+1
2017-09-11nds32: Rename __BIT() to N32_BIT().Kuan-Lin Chen2-13/+17
2017-09-11Automatic date update in version.inGDB Administrator1-1/+1
2017-09-10Automatic date update in version.inGDB Administrator1-1/+1
2017-09-10PowerPC64 --plt-alignAlan Modra2-3/+21
This changes the PowerPC64 --plt-align option to perform the usual alignment of code as suggested by its name, as well as the previous behaviour of padding so as to reduce boundary crossing. The old behaviour is had by using a negative parameter. The default is also changed to align plt stub code by default to 32 byte boundaries, the point being to get better bctr branch prediction on power8 and power9 hardware. bfd/ * elf64-ppp.c (plt_stub_pad): Handle positive and negative plt_stub_align. ld/ * ld.texinfo (--plt-align): Describe new behaviour of option. * emultempl/ppc64elf.em (params): Default plt_stub_align to 5. * testsuite/ld-powerpc/powerpc.exp: Pass --no-plt-align for selected tests. * testsuite/ld-powerpc/relbrlt.d: Pass --no-plt-align. * testsuite/ld-powerpc/elfv2so.d: Adjust expected output.
2017-09-09x86: Update UNDEFINED_WEAK_RESOLVED_TO_ZEROH.J. Lu5-36/+23
Since the only information which SYMBOL_REFERENCES_LOCAL_P doesn't check is relocations, UNDEFINED_WEAK_RESOLVED_TO_ZERO only needs to check for relocations with SYMBOL_REFERENCES_LOCAL_P. * elf32-i386.c (elf_i386_relocate_section): Update usage of UNDEFINED_WEAK_RESOLVED_TO_ZERO. (elf_i386_finish_dynamic_symbol): Likewise. * elf64-x86-64.c (elf_x86_64_relocate_section): Likewise. (elf_x86_64_finish_dynamic_symbol): Likewise. * elfxx-x86.c (elf_x86_allocate_dynrelocs): Likewise. (_bfd_x86_elf_fixup_symbol): Likewise.
2017-09-09x86: Don't check has_non_got_relocH.J. Lu2-3/+7
_bfd_x86_elf_link_symbol_references_local should depend only on symbol references, not relocations, to work in check_relocs. * elfxx-x86.c (_bfd_x86_elf_link_symbol_references_local): Don't check has_non_got_reloc.
2017-09-09x86: Properly handle __ehdr_startH.J. Lu5-23/+77
After _bfd_i386_elf_convert_load and _bfd_x86_64_elf_convert_load are removed, elf_i386_convert_load_reloc and elf_x86_64_convert_load_reloc see __ehdr_start as an undefined symbol when they are called from check_relocs to convert GOT relocations against local symbols. But __ehdr_start will be defined as a hidden symbol by linker at the later stage if it is referenced. This patch marks __ehdr_start as a defined local symbol at the start of check_relocs if it is referenced and not defined. bfd/ PR ld/22115 * elf32-i386.c (elf_i386_convert_load_reloc): Check linker_def. Don't use UNDEFINED_WEAK_RESOLVED_TO_ZERO. * elf64-x86-64.c (elf_x86_64_convert_load_reloc): Check linker_def. Don't use UNDEFINED_WEAK_RESOLVED_TO_ZERO. * elfxx-x86.c (_bfd_x86_elf_link_check_relocs): Set local_ref and linker_def on __ehdr_start if it is referenced and not defined. (_bfd_x86_elf_link_symbol_references_local): Also set local_ref and return TRUE when building executable, if a symbol has non-GOT/non-PLT relocations in text section or there is no dynamic linker. * elfxx-x86.h (elf_x86_link_hash_entry): Add linker_def. ld/ PR ld/22115 * ld-i386/i386.exp: Run PR ld/22115 tests, * ld/testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr22115-1.s: New file. * testsuite/ld-i386/pr22115-1a.d: Likewise. * testsuite/ld-i386/pr22115-1b.d: Likewise. * testsuite/ld-i386/pr22115-1c.d: Likewise. * testsuite/ld-i386/pr22115-1d.d: Likewise. * testsuite/ld-x86-64/pr22115-1.s: Likewise. * testsuite/ld-x86-64/pr22115-1a-x32.d: Likewise. * testsuite/ld-x86-64/pr22115-1a.d: Likewise. * testsuite/ld-x86-64/pr22115-1b-x32.d: Likewise. * testsuite/ld-x86-64/pr22115-1b.d: Likewise. * testsuite/ld-x86-64/pr22115-1c-x32.d: Likewise. * testsuite/ld-x86-64/pr22115-1c.d: Likewise. * testsuite/ld-x86-64/pr22115-1d-x32.d: Likewise. * testsuite/ld-x86-64/pr22115-1d.d: Likewise.
2017-09-09Automatic date update in version.inGDB Administrator1-1/+1
2017-09-08x86: Update comments in elfxx-x86.hH.J. Lu2-2/+6
* elfxx-x86.h: Update comments.
2017-09-08x86: Replace elf_x86_plt_layout_table with elf_x86_init_tableH.J. Lu5-54/+66
* elf32-i386.c (elf_i386_link_setup_gnu_properties): Replace elf_x86_plt_layout_table with elf_x86_init_table. * elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties): Likewise. * elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Likewise. * elfxx-x86.h (elf_x86_plt_layout_table): Renamed to ... (elf_x86_init_table): This. (_bfd_x86_elf_link_setup_gnu_properties): Replace elf_x86_plt_layout_table with elf_x86_init_table.
2017-09-07x86; Don't add elf64-x86-64.lo nor elf64.lo together with elfxx-x86.loH.J. Lu7-26/+38
Don't set r_info and r_sym fields in _bfd_x86_elf_link_hash_table_create. Instead, set them in _bfd_x86_elf_link_setup_gnu_properties. We can avoid adding elf64-x86-64.lo and elf64.lo together with elfxx-x86.lo to bfd_backends. * configure.ac (bfd_backends): Don't add elf64-x86-64.lo nor elf64.lo together with elfxx-x86.lo for 64-bit BFD. * configure: Regenerated. * elf32-i386.c (elf_i386_link_setup_gnu_properties): Set r_info and r_sym fields of plt_layout. * elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties): Likewise. * elfxx-x86.c (elf_x86_64_is_reloc_section): Remove BFD64 check. (_bfd_x86_elf_link_hash_table_create): Likewise. Don't set r_info nor r_sym fields. (_bfd_x86_elf_link_setup_gnu_properties): Set r_info and r_sym fields of htab. * elfxx-x86.h (elf_x86_plt_layout_table): Add r_info and r_sym.
2017-09-08Automatic date update in version.inGDB Administrator1-1/+1
2017-09-07RISC-V: Print an error when unable to align a sectionPalmer Dabbelt2-2/+14
This used to just print "can't relax section: Success", which is a silly error message. bfd/ChangeLog 2017-09-07 Palmer Dabbelt <palmer@dabbelt.com> * elfnn-riscv.c (_bfd_riscv_relax_align): Call bfd_set_error and print an error message when unable to relax a .align directive.
2017-09-07RISC-V: Support PCREL_* relocations agaist weak undefined symbolsPalmer Dabbelt2-5/+76
I recently modified our Linux port's base address such the absolute address 0 is no longer addressable as a 32-bit PC-relative offset. Since Linux links a weak undefined symbol in an intermediate binary, it needs to be able to reference absolute address 0. This patch changes R_RISCV_PCREL_* relocations to absolute relocations while resolving them in order to allow these symbols to be referenced in PC-relative programs linked at high addresses. Note that this doesn't apply to PIC, which also uses PC-relative relocations, just to position-dependent objects, which we use to allow programs to be linked at high addresses. In case some of our embedded users are using R_RISCV_PCREL_* as a hacked up method of getting position-independent binaries (which can work if you have very simple programs), we only convert the relocations when the PC-relative version would overflow. bfd/ChangeLog: 2017-09-07 Palmer Dabbelt <palmer@dabbelt.com> * elfnn-riscv.c (riscv_zero_pcrel_hi_reloc): New function. (riscv_record_pcrel_hi_reloc): Add absolute argument. (riscv_elf_relocate_section): Call riscv_zero_pcrel_hi_reloc for R_RISCV_PCREL_HI20 relocs, and pass the result to riscv_record_pcrel_hi_reloc.