aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
2017-03-03Fix thinko in previous changelog entry.Nick Clifton1-1/+1
PR ld/21212 * elf.c (rewrite_elf_program_header): Do not issue a warning for empty segments which have a zero filesz, but a non-zero memsz.
2017-03-03Automatic date update in version.inGDB Administrator1-1/+1
2017-03-02Disable warning message about a program header with no associated sections ↵Nick Clifton2-4/+15
when that header's file size is non-zero. PR ld/21212 * elf.c (rewrite_elf_program_header): Do not issue a warning for empty segments which have a non-zero filesz.
2017-03-02PowerPC VLE typo fixAlan Modra2-1/+5
* elf32-ppc.c (ppc_elf_vle_split16): Correct insn mask typo.
2017-03-02Automatic date update in version.inGDB Administrator1-1/+1
2017-03-01Automatic date update in version.inGDB Administrator1-1/+1
2017-02-28PowerPC addpcis fix againAlan Modra2-9/+12
In the last patch I said "The patch also fixes overflow checking". In fact, there wasn't anything wrong with the previous code. So, revert that change. The new checks are OK too, so this is just a tidy. * elf64-ppc.c (ppc64_elf_ha_reloc): Revert last change. (ppc64_elf_relocate_section): Likewise.
2017-02-28Nios2 dynobj handling fixesAlan Modra2-101/+77
A number of places in elf32-nios.c created dynamic sections but didn't set the hash table dynobj. That meant we could have duplicate dynamic sections connected to a number of bfds, so size_dynamic_sections didn't properly discard or allocate contents. Also, the entire set of dynamic sections was created in check_relocs on seeing GOT relocs, when only .got related sections are needed, probably done to hide segfaults later in finish_dynamic_sections. The patch fixes these issues and makes the assembler emit errors when nios2 lacks the necessary pc-relative relocs for subtraction expressions, rather than silently generating bad code. eg. ld-elf/merge. I've also tidied uses of elf32_nios2_hash_table and elf_hash_table. bfd/ PR 20995 * elf32-nios2.c (nios2_elf32_relocate_section): Use htab rather than elf32_nios2_hash_table or elf_hash_table. (create_got_section): Likewise. (nios2_elf32_finish_dynamic_symbol): Likewise. (nios2_elf32_adjust_dynamic_symbol): Likewise. (nios2_elf32_size_dynamic_sections): Likewise. (nios2_elf32_check_relocs): Delete dynobj, sgot, and srelgot vars. Use htab equivalents directly instead. Don't create all dynamic sections on needing just the GOT. Use a goto rather than a fall-through with reloc test. Ensure htab->dynobj is set when making dynamic sreloc section. (nios2_elf32_finish_dynamic_sections): Delete dynobj, use htab equivalent directly instead. Don't segfault on looking for .dynamic when dynamic sections have not been created. Don't segfault on .got.plt being discarded. (nios2_elf32_size_dynamic_sections): Delete plt and got vars. Don't set "relocs" on .rela.plt. Do handle .sbss. Delete fixme and another not so relevant comment. (nios2_elf_add_symbol_hook): Delete dynobj var. If not already set, set hash table dynobj on creating .sbss. gas/ * config/tc-nios2.h (TC_FORCE_RELOCATION_SUB_LOCAL): Define. ld/ * testsuite/ld-elf/merge.d: xfail for nios.
2017-02-28PowerPC addpcis fixAlan Modra6-7/+60
This came up because I was looking at ld/tmpdir/addpcis.o and noticed the odd addends on REL16DX_HA. They ought to both be -4. The error crept in due REL16DX_HA howto being pc-relative (as indeed it should be), and code at gas/write.c:1001 after this comment /* Make it pc-relative. If the back-end code has not selected a pc-relative reloc, cancel the adjustment we do later on all pc-relative relocs. */ *not* cancelling the pc-relative adjustment. So I've made a dummy non-relative split reloc so that the generic code handles this, rather than attempting to add hacks later in md_apply_fix which would not be very robust. Having the new internal reloc also makes it easy to support addpcis rx,sym@ha as an equivalent to addpcis rx,(sym-0f)@ha 0: The patch also fixes overflow checking, which must test whether the addi will overflow too since @l relocs don't have any overflow check. Lastly, since I was poking at md_apply_fix, I arranged to have the generic gas/write.c code emit errors for subtraction expressions where we lack reloc support. include/ * elf/ppc64.h (R_PPC64_16DX_HA): New. Expand fake reloc comment. * elf/ppc.h (R_PPC_16DX_HA): Likewise. bfd/ * reloc.c (BFD_RELOC_PPC_16DX_HA): New. * elf64-ppc.c (ppc64_elf_howto_raw <R_PPC64_16DX_HA>): New howto. (ppc64_elf_reloc_type_lookup): Translate new bfd reloc. (ppc64_elf_ha_reloc): Correct overflow test on REL16DX_HA. (ppc64_elf_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_howto_raw <R_PPC_16DX_HA>): New howto. (ppc_elf_reloc_type_lookup): Translate new bfd reloc. (ppc_elf_check_relocs): Handle R_PPC_16DX_HA to pacify gcc. * libbfd.h: Regenerate. * bfd-in2.h: Regenerate. gas/ * config/tc-ppc.c (md_assemble): Use BFD_RELOC_PPC_16DX_HA for addpcis. (md_apply_fix): Remove fx_subsy check. Move code converting to pcrel reloc earlier and handle BFD_RELOC_PPC_16DX_HA. Remove code emiiting errors on seeing fx_pcrel set on unexpected relocs, as that is done now by the generic code via.. * config/tc-ppc.h (TC_FORCE_RELOCATION_SUB_LOCAL): ..this. Define. (TC_VALIDATE_FIX_SUB): Define. ld/ * testsuite/ld-powerpc/addpcis.d: Define ext1 and ext2 at limits of addpcis range.
2017-02-28Don't make dynamic .data.rel.ro SEC_READONLYAlan Modra22-25/+50
I'd made this dynamic section read-only so a flag test distinguished it from .dynbss, but like any other .data.rel.ro section it really should be marked read-write. (It is read-only after relocation, not before.) When using the standard linker scripts this usually doesn't matter since the output section is among other read-write sections and not page aligned. However, it might matter in the extraordinary case of the dynamic section being the only .data.rel.ro section with the output section just happening to be page aligned and a multiple of a page in size. In that case the output section would be read-only, and live it its own read-only PT_LOAD segment, which is incorrect. * elflink.c (_bfd_elf_create_dynamic_sections): Don't make dynamic .data.rel.ro read-only. * elf32-arm.c (elf32_arm_finish_dynamic_symbol): Compare section rather than section flags when deciding where copy reloc goes. * elf32-cris.c (elf_cris_finish_dynamic_symbol): Likewise. * elf32-hppa.c (elf32_hppa_finish_dynamic_symbol): Likewise. * elf32-i386.c (elf_i386_finish_dynamic_symbol): Likewise. * elf32-metag.c (elf_metag_finish_dynamic_symbol): Likewise. * elf32-microblaze.c (microblaze_elf_finish_dynamic_symbol): Likewise. * elf32-nios2.c (nios2_elf32_finish_dynamic_symbol): Likewise. * elf32-or1k.c (or1k_elf_finish_dynamic_symbol): Likewise. * elf32-ppc.c (ppc_elf_finish_dynamic_symbol): Likewise. * elf32-s390.c (elf_s390_finish_dynamic_symbol): Likewise. * elf32-tic6x.c (elf32_tic6x_finish_dynamic_symbol): Likewise. * elf32-tilepro.c (tilepro_elf_finish_dynamic_symbol): Likewise. * elf64-ppc.c (ppc64_elf_finish_dynamic_symbol): Likewise. * elf64-s390.c (elf_s390_finish_dynamic_symbol): Likewise. * elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Likewise. * elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_symbol): Likewise. * elfnn-riscv.c (riscv_elf_finish_dynamic_symbol): Likewise. * elfxx-mips.c (_bfd_mips_vxworks_finish_dynamic_symbol): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_finish_dynamic_symbol): Likewise. * elfxx-tilegx.c (tilegx_elf_finish_dynamic_symbol): Likewise.
2017-02-28MIPS/BFD: Also handle `jalr $0, $25' with R_MIPS_JALRMaciej W. Rozycki2-4/+9
Interpret the `jalr $0, $25' instruction encoding with an R_MIPS_JALR relocation attached as an alias to `jr $25' and convert the jump to an equivalent branch where possible, consequently covering the MIPSr6 architecture for the purpose of this optimization too. bfd/ * elfxx-mips.c (mips_elf_perform_relocation): Also handle the `jalr $0, $25' instruction encoding. gas/ * testsuite/gas/mips/jalr4.s: Add `jalr $0, $25' instructions. * testsuite/gas/mips/jalr4.d: Adjust accordingly. Remove MIPSr6 encoding patterns. * testsuite/gas/mips/jalr4-n64.d: Likewise. * testsuite/gas/mips/mipsr6@jalr4.d: New test. * testsuite/gas/mips/mipsr6@jalr4-n32.d: New test. * testsuite/gas/mips/mipsr6@jalr4-n64.d: New test. ld/ * testsuite/ld-mips-elf/jalr4.dd: Adjust for `jalr $0, $25' instructions. * testsuite/ld-mips-elf/jalr4-r6.dd: New test. * testsuite/ld-mips-elf/mips-elf.exp: Run the new test.
2017-02-28Automatic date update in version.inGDB Administrator1-1/+1
2017-02-27Fix segfault in microblaze linker when garbage collection removes a symbol ↵Nick Clifton2-3/+17
scheduled for a slot in the PLT. PR ld/21180 * elf32-microblaze.c (microblaze_elf_finish_dynamic_symbol): Avoid generating a seg-fault when encountering a symbol that has been deleted by garbage collection.
2017-02-27Automatic date update in version.inGDB Administrator1-1/+1
2017-02-26Automatic date update in version.inGDB Administrator1-1/+1
2017-02-25ARC naughtiness causing assertion fail at elf-strtab.c:302Alan Modra2-135/+78
This patch fixes a number of issues in the ARC backend. - The ARC size_dynamic_sections was trashing dynamic section contents, in particular the .gnu.version_d contents. Those versions definitions are therefore lost so they do not drain from the strtab, resulting in assertion failures. - The code attempting to set DT_TEXTREL was completely bogus. - The ARC finish_dynamic_sections would segfault on trying to set sh_entsize for .rela.plt if that section had been discarded. - arc_create_dynamic_sections wouldn't have ever created dynamics sections, which was just as well since the places it was called were way too late to create dynamic sections. Its usefulness then devolved down to finding just one dynamic section. All the others packaged into a struct were unused. - .interp wasn't set for PIEs. * elf32-arc.c (struct dynamic_sections): Delete. (enum dyn_section_types): Delete. (dyn_section_names): Delete. (arc_create_dynamic_sections): Delete. (elf_arc_finish_dynamic_sections): Don't call the above. Don't segfault on discarded .rela.plt section. (elf_arc_size_dynamic_sections): Formatting. Don't call arc_create_dynamic_sections. Don't allocate memory for sections handled by the generic linker. Correct code finding relocs in read-only sections. Set SEC_EXCLUDE on zero size .got, .got.plt, and .dynbss sections. Do set .interp for pies.
2017-02-25Automatic date update in version.inGDB Administrator1-1/+1
2017-02-24bfd: RISC-V: relax to gp in more cases.Andrew Waterman2-1/+22
bfd/ChangeLog: 2017-02-24 Andrew Waterman <andrew@sifive.com> * elfnn-riscv.c (GP_NAME): New macro. (riscv_global_pointer_value): Use it. (_bfd_riscv_relax_lui): If symbol and global pointer are in same output section, consider only that section's alignment.
2017-02-24Automatic date update in version.inGDB Administrator1-1/+1
2017-02-23MIPS/BFD: Remove duplicate NewABI JALR relocation handlingMaciej W. Rozycki5-165/+7
Remove separate original NewABI JALR relocation handling, introduced with commit d06471104a83 ("relax jalr $t9 [R_MIPS_JALR symbol] to bal symbol"), <https://sourceware.org/ml/binutils/2003-03/msg00394.html>, and only used by LD with the `--relax' option specified, and rely solely on `mips_elf_perform_relocation' code, which has been introduced with commit 1367d393bb74 ("On the RM9000 convert jal to bal if in range"), <https://www.sourceware.org/ml/binutils/2004-12/msg00088.html> and since made more complete, across all the three ABIs. Also remove the `--relax' option, now irrelevant, from the tests added with the former commit. bfd/ * elfxx-mips.h (_bfd_mips_relax_section): Remove prototype. * elfxx-mips.c (_bfd_mips_relax_section): Remove function. * elf64-mips.c (bfd_elf64_bfd_relax_section): Remove macro. * elfn32-mips.c (bfd_elf32_bfd_relax_section): Likewise. ld/ * testsuite/ld-mips-elf/relax-jalr-n32.d: Remove `--relax' option. * testsuite/ld-mips-elf/relax-jalr-n32-shared.d: Likewise. * testsuite/ld-mips-elf/relax-jalr-n64.d: Likewise. * testsuite/ld-mips-elf/relax-jalr-n64-shared.d: Likewise.
2017-02-23MIPS/BFD: Discard ineligible JALR relocations right awayMaciej W. Rozycki2-0/+12
Discard R_MIPS_JALR and R_MICROMIPS_JALR relocations associated with jumps that cannot be converted to an equivalent branch right away in `mips_elf_calculate_relocation' rather than letting them through to `mips_elf_perform_relocation'. This includes cross-mode jumps which need to flip the ISA bit or jumps to a misaligned location that cannot be encoded with a branch, in addition to preemptible symbol references already handled. Cross-mode jumps are actually already rejected as the conversion is made in `mips_elf_perform_relocation', so in this case this change only saves some processing. Jumps to a misaligned location are however converted, with bits causing misalignment lost, making resulting code functionally different even if the lone effect is avoiding an address error exception with an instruction fetch at the jump destination requested. Add test cases suitable, also including GAS verification to confirm that the JALR relocations explicitly requested have indeed been output in the intermediate objects used. bfd/ * elfxx-mips.c (mips_elf_calculate_relocation) <R_MIPS_JALR> <R_MICROMIPS_JALR>: Discard relocation if `cross_mode_jump_p' or misaligned. gas/ * testsuite/gas/mips/jalr4.d: New test. * testsuite/gas/mips/jalr4-n32.d: New test. * testsuite/gas/mips/jalr4-n64.d: New test. * testsuite/gas/mips/jalr4.s: New test source. * testsuite/gas/mips/mips.exp: Run the new tests. ld/ * testsuite/ld-mips-elf/jalr4.dd: New test. * testsuite/ld-mips-elf/mips-elf.exp: Run the new test.
2017-02-23Correct VLE 16D and SDAREL relocationsAlan Modra2-27/+23
PR 20744 bfd/ * elf32-ppc.c (ppc_elf_howto_raw): Correct dst_mask on all VLE 16D relocations. (ppc_elf_vle_split16): Correct field mask and shift for 16D relocs. (ppc_elf_relocate_section): Correct calculation for VLE SDAREL relocs. ld/ * testsuite/ld-powerpc/vle-reloc-2.s: Use r6 for last insn of each group. * testsuite/ld-powerpc/vle-reloc-2.d: Update for above change and sdarel reloc fix.
2017-02-23Automatic date update in version.inGDB Administrator1-1/+1
2017-02-22PR ld/20828: Move symbol version processing ahead of GC symbol sweepMaciej W. Rozycki2-335/+360
Complement commit b531344c34b0 ("PR ld/20828: Reorder the symbol sweep stage of section GC") and commit 81ff47b3a546 ("PR ld/20828: Fix linker script symbols wrongly forced local with section GC") and move symbol version processing ahead of the symbol sweep stage of section GC, all in `bfd_elf_size_dynamic_sections', so that version symbols created stay in the global scope and are not output as local symbols to the dynamic symbol table in the presence of corresponding symbol definitions pulled from a DSO involved in a link. Consolidate the whole of symbol version processing into a single block from all parts scattered across the function and rearranging the local variables used as necessary, however leaving the setting of dynamic entries associated with the DT_VERDEF, DT_VERDEFNUM, DT_VERNEED and DT_VERNEEDNUM tags and the SEC_EXCLUDE flag for unused `.gnu.version' section in the original places. With the rearrangement of code blocks `Elf_Internal_Verneed *t' would shadow the previous definition of `struct bfd_elf_version_tree *t', so rename the former variable to `vn'. bfd/ PR ld/20828 * elflink.c (bfd_elf_size_dynamic_sections): Move symbol version processing ahead of the call to `elf_gc_sweep_symbol'. ld/ PR ld/20828 * testsuite/ld-elf/pr20828-d.sd: New test. * testsuite/ld-elf/pr20828-e.sd: New test. * testsuite/ld-elf/pr20828-v.od: New test. * testsuite/ld-elf/pr20828-v.ver: New test version script. * testsuite/ld-elf/pr20828-v.ld: New test linker script. * testsuite/ld-elf/pr20828.ld: Add `.gnu.version' and `.gnu.version_d'. * testsuite/ld-elf/shared.exp: Run the new tests.
2017-02-22Align .gnu_debuglink sections on a 4-byte boundary.Nick Clifton2-0/+13
PR binutils/21193 * opncls.c (bfd_create_gnu_debuglink_section): Give the newly created section 4-byte alignment.
2017-02-22Automatic date update in version.inGDB Administrator1-1/+1
2017-02-22PowerPC ld segfault on script discarding dynamic sectionsAlan Modra3-9/+18
bfd/ * elf64-ppc.c (ppc64_elf_finish_dynamic_sections): Don't segfault on .got or .plt output section being discarded by script. * elf32-ppc.c (ppc_elf_finish_dynamic_sections): Likewise. Move vxworks splt temp. gold/ * powerpc.cc (Target_powerpc::make_iplt_section): Check that output_section exists before attempting add_output_section_data. (Target_powerpc::make_brlt_section): Likewise.
2017-02-21Alpha DT_RELAAlan Modra2-8/+19
* elf64-alpha.c (elf64_alpha_size_dynamic_sections): Only emit DT_RELA, DT_RELASZ, and DT_RELAENT when DT_RELASZ is non-zero.
2017-02-21Automatic date update in version.inGDB Administrator1-1/+1
2017-02-20Alpha executables segfault when linked with -z,nowAlan Modra2-15/+37
PR 21181 * elflink.c (bfd_elf_final_link): Make DT_REL/DT_RELA zero if DT_RELSZ/DT_RELASZ is zero.
2017-02-20Automatic date update in version.inGDB Administrator1-1/+1
2017-02-19Automatic date update in version.inGDB Administrator1-1/+1
2017-02-18Automatic date update in version.inGDB Administrator1-1/+1
2017-02-17Fix potential illegal memory access in ZLIB because of an erroneous ↵Nick Clifton2-1/+7
declaration of the size of the input buffer. * compress.c (bfd_get_full_section_contents): Remember to reduce compressed size by the sizeof the compression header when decompressing the contents.
2017-02-17bfd: Rename Chunk and S3ForcedPedro Alves2-11/+19
The direct references in objcopy kind of look like a hack to me, so I'm calling these symbols internal too. Certainly they aren't named and documented as a public BFD symbol today anyway. So ... give these bfd-internal symbols with external linkage a _bfd_ prefix to avoid collisions in the global symbol namespace. While at it, give them names that more closely match the corresponding option name that toggles them. Also while at it, fix a few related comment typos. gdb/ChangeLog: 2017-02-17 Pedro Alves <palves@redhat.com> * srec.c (Chunk): Rename to ... (_bfd_srec_len): ... this. (S3Forced): Rename to ... (_bfd_srec_forceS3): ... this. * objcopy.c: Adjust all references.
2017-02-17bfd: Rename bsd_write_armap and coff_write_armapPedro Alves6-22/+35
Give these bfd-internal symbols with external linkage a _bfd_ prefix to avoid collisions in the global symbol namespace. bfd/ChangeLog: 2017-02-17 Pedro Alves <palves@redhat.com> * archive.c (bsd_write_armap): Rename to ... (_bfd_bsd_write_armap): ... this. (coff_write_armap): Rename to ... (_bfd_coff_write_armap): ... this. * libbfd-in.h (bsd_write_armap): Rename to ... (_bfd_bsd_write_armap): ... this. (coff_write_armap): Rename to ... (_bfd_coff_write_armap): ... this. * aout-target.h, aout-tic30.c: Adjust all users. * libbfd.h: Regenerate.
2017-02-17bfd: Rename warn_deprecatedPedro Alves4-14/+23
Give this bfd-internal symbol with external linkage a _bfd_ prefix to avoid collisions in the global symbol namespace. bfd/ChangeLog: 2017-02-17 Pedro Alves <palves@redhat.com> * bfd-in.h (bfd_read, bfd_write): Adjust to rename. (warn_deprecated): Rename to ... (_bfd_warn_deprecated): ... this. * libbfd.c (warn_deprecated): Rename to ... (_bfd_warn_deprecated): ... this. * bfd-in2.h: Regenerate.
2017-02-17bfd: Rename real_{ftell, fseek, fopen}Pedro Alves7-22/+41
Give these bfd-internal symbols with external linkage a _bfd_ prefix to avoid collisions in the global symbol namespace. bfd/ChangeLog: 2017-02-17 Pedro Alves <palves@redhat.com> * bfdio.c (real_ftell): Rename to ... (_bfd_real_ftell): ... this. (real_fseek): Rename to ... (_bfd_real_fseek): ... this. (real_fopen): Rename to ... (_bfd_real_fopen): ... this. * libbfd-in.h (real_ftell): Rename to ... (_bfd_real_ftell): ... this. (real_fseek): Rename to ... (_bfd_real_fseek): ... this. (real_fopen): Rename to ... (_bfd_real_fopen): ... this. * cache.c, dwarf2.c, opncls.c: Adjust all callers. * libbfd.h: Regenerate.
2017-02-17bfd: Rename read_{signed,unsigned}_leb128, safe_read_leb128Pedro Alves7-55/+99
Give these bfd-internal symbols with external linkage a _bfd_ prefix to avoid collisions in the global symbol namespace. bfd/ChangeLog: 2017-02-17 Pedro Alves <palves@redhat.com> * dwarf2.c, elf-attrs.c, elf32-nds32.c: Adjust all callers. * libbfd.c (read_unsigned_leb128): Rename to ... (_bfd_read_unsigned_leb128): ... this. (read_signed_leb128): Rename to ... (_bfd_read_signed_leb128): ... this. (safe_read_leb128): Rename to ... (_bfd_safe_read_leb128): ... this. * libbfd-in.h (read_unsigned_leb128): Rename to ... (_bfd_read_unsigned_leb128): ... this. (read_signed_leb128): Rename to ... (_bfd_read_signed_leb128): ... this. (safe_read_leb128): Rename to ... (_bfd_safe_read_leb128): ... this. * libbfd.h: Renegerate.
2017-02-17Automatic date update in version.inGDB Administrator1-1/+1
2017-02-16bfd: Improve lookup of file / line information for errorsAndrew Burgess2-0/+37
When looking up file and line information (used from the linker to report error messages) if no symbol is passed in, then use the symbol list to look for a matching symbol. If a matching symbol is found then use this to look up the file / line information. This should improve errors when looking up file / line information for data sections. Hopefully we should find a matching data symbol, which should, in turn (we hope) match a DW_TAG_variable in the DWARF, this should allow us to give accurate file / line errors for data symbols. As the hope is to find a matching DW_TAG_variable in the DWARF then we ignore section symbols, and prefer global symbols to locals. bfd/ChangeLog: * dwarf2.c (_bfd_dwarf2_find_nearest_line): Perform symbol lookup before trying to fine matching file and line information. ld/ChangeLog: * testsuite/ld-elf/shared.exp: Update expected results. * testsuite/ld-elf/dwarf2.err: Likewise
2017-02-16bfd/dwarf: Improve use of previously loaded dwarf informationAndrew Burgess2-2/+30
When parsing DWARF data in order to report file/line type error messages we perform section placement to make section addresses unique within relocatable object files. Currently, if we reuse previously loaded (and cached) dwarf data then we neglect to perform section placement, the result is that the section addresses will not be unique, and we might, incorrectly associate an address with the wrong debug information, and so report an incorrect file and line number. Further we neglect to check that that bfd for which we are looking up debug information is actually the bfd for which the previous debug information was loaded, it is possible that we will reuse previously loaded debug information for a different bfd. And finally, due to following of gnu_debuglink links in one bfd to another, the process of checking that the cached debug information is valid requires us to track the original bfd in the cached debug information. The original debug information here is either the bfd that we're interested in, not the bfd we finally load the debug information from. bfd/ChangeLog: * dwarf2.c (struct dwarf2_debug): Add orig_bfd member. (_bfd_dwarf2_slurp_debug_info): If stashed debug information does not match current bfd, then reload debug information. Record bfd we're loading debug info for in the stash. If we have debug informatin in the cache then perform section placement before returning. ld/ChangeLog: * testsuite/ld-elf/dwarf.exp (build_tests): Add new tests. * testsuite/ld-elf/dwarf2.err: New file. * testsuite/ld-elf/dwarf2a.c: New file. * testsuite/ld-elf/dwarf2b.c: New file. * testsuite/ld-elf/dwarf3.c: New file. * testsuite/ld-elf/dwarf3.err: New file.
2017-02-16hppa -z relro againAlan Modra5-0/+30
I misunderstood the hppa alias problem. File offsets of segments need to be such that no page is mapped twice with different permissions. (Which still seems to me like something the kernel could fix, but anyhow, this is not so difficult to achieve in ld.) PR 21000 bfd/ * elf-bfd.h (struct elf_backend_data): Add no_page_alias. * elfxx-target.h (elf_backend_no_page_alias): Define. (elfNN_bed): Init new field. * elf.c (assign_file_positions_for_load_sections): If no_page_alias ensure PT_LOAD segment starts on a new page. * elf32-hppa.c (elf_backend_no_page_alias): Define. ld/ * testsuite/ld-elf/loadaddr1.d: Adjust for hppa file offsets. * testsuite/ld-elf/loadaddr2.d: Likewise. * testsuite/ld-elf/loadaddr3a.d: Likewise. * testsuite/ld-scripts/rgn-at5.d: Likewise.
2017-02-16PR21132, hppa-linux pie support doesn't workAlan Modra2-0/+8
This fixes a long-standing hppa bug seen when generating PIEs, and I think possible to trigger with forced local symbols in shared libraries. Not allocating enough space for PLT relocs results in ld writing outside of the buffer. PR 21132 * elf32-hppa.c (allocate_plt_static): Allocate space for relocs if pic.
2017-02-16[Patch] Add BFD_LINKER_CREATED to BFD_FLAGS_SAVEDJiong Wang3-4/+11
bfd/ * bfd.c (BFD_FLAGS_SAVED): Add BFD_LINKER_CREATED. * bfd-in2.h: Regenerated. Bug exposed by https://sourceware.org/ml/binutils/2017-02/msg00128.html
2017-02-16Automatic date update in version.inGDB Administrator1-1/+1
2017-02-15i386: Allow "lea foo@GOT, %reg" in PICH.J. Lu2-4/+14
"lea foo@GOT, %reg" is OK in PIC since it only loads the GOT offset into register, which can be used later with a GOT base register to get the value in the GOT entry. bfd/ PR ld/21168 * elf32-i386.c (elf_i386_relocate_section): Allow "lea foo@GOT, %reg" in PIC. ld/ PR ld/21168 * testsuite/ld-i386/i386.exp: Run pr21168. * testsuite/ld-i386/pr21168a.c: New file. * testsuite/ld-i386/pr21168b.S: Likewise.
2017-02-15Add a test for R_386_GOT32/R_386_GOT32X IFUNC reloc errorH.J. Lu2-1/+9
bfd/ PR ld/20244 * elf32-i386.c (elf_i386_relocate_section): Properly get IFUNC symbol name when reporting R_386_GOT32/R_386_GOT32X relocation error against local IFUNC symbol without a base register for PIC. ld/ PR ld/20244 * testsuite/ld-i386/i386.exp: Run pr20244-4a, pr20244-4b and pr20244-4c. * testsuite/ld-i386/pr20244-4.s: New file. * testsuite/ld-i386/pr20244-4a.d: Likewise. * testsuite/ld-i386/pr20244-4b.d: Likewise. * testsuite/ld-i386/pr20244-4c.d: Likewise.
2017-02-15PowerPC/BFD: Convert `%P: %H:' to `%H:' in error messagesMaciej W. Rozycki3-23/+32
Remove an inconsistency in BFD linker error messages across the PowerPC backends, where in the presence of line information the `%P: %H:' format sequence makes the first error message produced for any given function different from subsequent ones. Taking the `ld/testsuite/ld-powerpc/tocopt7.s' test case source as an example and the `powerpc-linux' target we have: $ as -gdwarf2 -o tocopt.o -a64 tocopt.s $ ld -o tocopt -melf64ppc tocopt.o ld: tocopt.o: In function `_start': tocopt.s:35:(.text+0x14): toc optimization is not supported for 0x3fa00000 instruction. ld: tocopt.s:49:(.text+0x34): toc optimization is not supported for 0x3fa00000 instruction. $ where the first error message does not have the source file name prefixed with the linker program executable's name, i.e. `ld:', whereas the second error message does, as would any subsequent. This is because with a multiple-line error message such as `%H' produces `%P' only prints the program executable's name on the first line and not any later ones. Also the PowerPC backend is the only part of BFD which uses `%P' along with one of the clever `%C', `%D', `%G', `%H' format specifiers. And last but not least this breaks a GNU Coding Standard's requirement that error messages from compilers should look like this: source-file-name:lineno: message also quoted in `vfinfo' code handling these specifiers. Convert `%P: %H:' to `%H:' in error messages across the PowerPC backends then, yielding: $ as -gdwarf2 -o tocopt.o -a64 tocopt.s $ ld -o tocopt -melf64ppc tocopt.o tocopt.o: In function `_start': tocopt.s:35:(.text+0x14): toc optimization is not supported for 0x3fa00000 instruction. tocopt.s:49:(.text+0x34): toc optimization is not supported for 0x3fa00000 instruction. $ instead, making it consistent and matching the GNU Coding Standard's requirement. bfd/ * elf32-ppc.c (ppc_elf_check_relocs): Use `%H:' rather than `%P: %H:' with `info->callbacks->einfo'. (ppc_elf_relocate_section): Likewise. * elf64-ppc.c (ppc64_elf_check_relocs): Likewise. (ppc64_elf_edit_toc): Likewise. (ppc64_elf_relocate_section): Likewise.
2017-02-15Automatic date update in version.inGDB Administrator1-1/+1