aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
2016-12-22Automatic date update in version.inGDB Administrator1-1/+1
2016-12-22Don't make_bfd_vms_lib archive functions NULLAlan Modra3-16/+31
Contrary to the comment, they can in fact be called. * libbfd-in.h (_bfd_vms_lib_slurp_armap): Use _bfd_noarchive function. (_bfd_vms_lib_slurp_extended_name_table: Likewise. (_bfd_vms_lib_construct_extended_name_table: Likewise. (_bfd_vms_lib_truncate_arname: Likewise. (_bfd_vms_lib_write_armap: Likewise. (_bfd_vms_lib_read_ar_hdr: Likewise. (_bfd_vms_lib_write_ar_hdr: Likewise. * libbfd.h: Regenerate.
2016-12-21bfd: aarch64: fix word and arrdess size declaration in ilp32 modeYury Norov2-4/+11
ILP32 has 32-bit word and address, but currently they declared as 64-bit in bfd_aarch64_arch_ilp32, which breaks further logic of bfd. This patch fixes it. Glibc testsuite build with patched binutils shows that next tests stop to fail: iconvdata/mtrace-tst-loading iconvdata/tst-loading iconvdata/tst-tables localedata/mtrace-tst-leaks localedata/tst-leaks posix/tst-getaddrinfo4 posix/tst-getaddrinfo5 posix/tst-regex2
2016-12-21Automatic date update in version.inGDB Administrator1-1/+1
2016-12-20Re-work RISC-V gas flags: now we just support -mabi and -marchAndrew Waterman2-2/+7
We've decided to standardize on two flags for RISC-V: "-march" sets the target architecture (which determines which instructions can be generated), and "-mabi" sets the target ABI. We needed to rework this because the old flag set didn't support soft-float or single-float ABIs, and didn't support an x32-style ABI on RISC-V. Additionally, we've changed the behavior of the -march flag: it's now a lot stricter and only parses things we can actually understand. Additionally, it's now lowercase-only: the rationale is that while the RISC-V ISA manual specifies that ISA strings are case-insensitive, in Linux-land things are usually case-sensitive. Since this flag can be used to determine library paths, we didn't want to bake some case-insensitivity in there that would case trouble later. This patch implements these two new flags and removes the old flags that could conflict with these. There wasn't a RISC-V release before, so we want to just support a clean flag set. include/ * elf/riscv.h (EF_RISCV_SOFT_FLOAT): Don't define. (EF_RISCV_FLOAT_ABI, EF_RISCV_FLOAT_ABI_SOFT): Define. (EF_RISCV_FLOAT_ABI_SINGLE, EF_RISCV_FLOAT_ABI_DOUBLE): Define. (EF_RISCV_FLOAT_ABI_QUAD): Define. bfd/ * elfnn-riscv.c (_bfd_riscv_elf_merge_private_bfd_data): Use EF_RISCV_FLOAT_ABI_SOFT instead of EF_RISCV_SOFT_FLOAT. binutils/ * readelf.c (get_machine_flags): Use EF_RISCV_FLOAT_ABI_{SOFT,SINGLE,DOBULE,QUAD) instead of EF_RISCV_{SOFT,HARD}_FLOAT. gas/ * config/tc-riscv.h (xlen): Delete. * config/tc-riscv.c (xlen): Make static. (abi_xlen): New variable. (options): Replace OPTION_{M32,M64,MSOFT_FLOAT,MHARD_FLOAT,MRVC} with OPTION_MABI. (md_longopts): Likewise. (md_parse_option): Likewise. (riscv_elf_final_processing): Likewise. * doc/as.texinfo (Target RISC-V options): Likewise. * doc/c-riscv.texi (OPTIONS): Likewise. * config/tc-riscv.c (float_mode): Removed. (float_abi): New type, specifies the floating-point ABI. (riscv_set_abi): New function. (riscv_add_subset): Only allow lower-case ISA names and require them to start with "rv". (riscv_after_parse_args): Likewise. opcodes/ * riscv-dis.c (riscv_disassemble_insn): Default to the ELF's XLEN when none is provided.
2016-12-20Fix an integer overflow in RISC-V relocation handlingAndrew Waterman2-2/+7
* elfnn-riscv.c (bfd_riscv_get_max_alignment): Return bfd_vma instead of unsigned int.
2016-12-20Rework RISC-V relocationsAndrew Waterman6-17/+274
Before this commit we didn't cleanly support CFI directives because the internal offsets used to get relaxed which broke them. This patch significantly reworks how we handle linker relaxations: * DWARF is now properly supported * There is a ".option norelax" to disable relaxations, for when users write assembly that can't be relaxed (if it's to be later patched up, for example). * There is an additional _RELAX relocation that specifies when previous relocations can be relaxed. We're in the process of documenting the RISC-V ELF ABI, which will include documentation of our relocations https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md but we expect that this relocation set will remain ABI compatible in the future (ie, it's safe to release). Thanks to Kuan-Lin Chen for figuring out how to correctly relax the debug info! include/ * elf/riscv.h: Add R_RISCV_TPREL_I through R_RISCV_SET32. bfd/ * reloc.c (BFD_RELOC_RISCV_TPREL_I): New relocation. (BFD_RELOC_RISCV_TPREL_S): Likewise. (BFD_RELOC_RISCV_RELAX): Likewise. (BFD_RELOC_RISCV_CFA): Likewise. (BFD_RELOC_RISCV_SUB6): Likewise. (BFD_RELOC_RISCV_SET8): Likewise. (BFD_RELOC_RISCV_SET8): Likewise. (BFD_RELOC_RISCV_SET16): Likewise. (BFD_RELOC_RISCV_SET32): Likewise. * elfnn-riscv.c (perform_relocation): Handle the new relocations. (_bfd_riscv_relax_tls_le): Likewise. (_bfd_riscv_relax_align): Likewise. (_bfd_riscv_relax_section): Likewise. (howto_table): Likewise. (riscv_reloc_map): Likewise. (relax_func_t): New type. (_bfd_riscv_relax_call): Add reserve_size argument, which controls the maximal offset pessimism. Correct type of max_alignment. (_bfd_riscv_relax_lui): Likewise. (_bfd_riscv_relax_tls_le): Likewise. (_bfd_riscv_relax_align): Likewise. (_bfd_riscv_relax_section): Compute the required reserve size when relocating and use it to when calling relax_func. * bfd-in2.h: Regenerate. * libbfd.h: Likewise. gas/ * config/tc-riscv.c (riscv_set_options): Add relax. (riscv_opts): Likewise. (s_riscv_option): Add relax and norelax. (riscv_apply_const_reloc): New function. (append_insn): Move constant relocation handling to riscv_apply_const_reloc. (md_pcrel_from): Likewise. (parse_relocation): Skip BFD_RELOC_UNUSED. (md_pcrel_from): Handle BFD_RELOC_RISCV_SUB6, BFD_RELOC_RISCV_RELAX, BFD_RELOC_RISCV_CFA. (md_apply_fix): Likewise. (riscv_pre_output_hook): New function. * config/tc-riscv.h (md_pre_output_hook): Define. (riscv_pre_output_hook): Declare. (DWARF_CIE_DATA_ALIGNMENT): Always -4.
2016-12-20Formatting changes for RISC-VAndrew Waterman3-24/+26
This is a mixed bag of format changes: * Replacing constants with macros (0xffffffff with MINUS_ONE, for example). There's one technically functional change in here (some MINUS_ONEs are changed to 0), but it only changes the behavior of an otherwise-unused field. * Using 0 instead of 0x0 in the relocation table. * There were some missing spaces before parens, the spaces have been added. * A handful of comments are now more descriptive. * A bunch of whitespace-only changes, mostly alignment and brace newlines. bfd/ * elfnn-riscv.c: Formatting and comment fixes throughout. * elfxx-riscv.c: Likewise. (howto_table): Change the src_mask field from MINUS_ONE to 0 for R_RISCV_TLS_DTPMOD32, R_RISCV_TLS_DTPMOD64, R_RISCV_TLS_DTPREL32, R_RISCV_TLS_DTPREL64, R_RISCV_TLS_TPREL32, R_RISCV_TLS_TPREL64. opcodes/ * riscv-opc.c: Formatting fixes. gas/ * config/tc-riscv.c: Formatting and comment fixes throughout.
2016-12-20Improve RISC-V LD error messagePalmer Dabbelt2-2/+8
I recently ran into this error message and found it's not helpful: it just tells me some temporary file can't be linked. This slightly improved one at least tells me it's because of an elf32/elf64 conflict. * elfnn-riscv.c (_bfd_riscv_elf_merge_private_bfd_data): Improve error message when linking elf32 and elf64.
2016-12-20Automatic date update in version.inGDB Administrator1-1/+1
2016-12-19bfd/elf32-arm.c: Rename 'popcount' to 'elf32_arm_popcount'Christian Groessler2-7/+13
bfd/elf32_arm.c contains a function 'popcount' which conflicts with a function of the same name in NetBSD's libc. This change also changes popcount's 'sum' variable to signed since the function returns a signed integer. bfd/ * elf32-arm.c (elf32_arm_popcount): Rename from 'popcount'. Make 'sum' local variable signed.
2016-12-19Automatic date update in version.inGDB Administrator1-1/+1
2016-12-18Automatic date update in version.inGDB Administrator1-1/+1
2016-12-17Automatic date update in version.inGDB Administrator1-1/+1
2016-12-16Implement and document --gc-keep-exportedfincs2-1/+8
include/ * bfdlink.h (struct bfd_link_info): Add gc_keep_exported. bfd/ * elflink.c (bfd_elf_gc_mark_dynamic_ref_symbol): Add handling for info->gc_keep_exported. (bfd_elf_gc_sections): Likewise. ld/ * ld.texinfo: Document --gc-keep-exported. * ldlex.h (enum option_values): Add OPTION_GC_KEEP_EXPORTED. * lexsup.c (parse_args): Add handling for --gc-keep-exported.
2016-12-16Automatic date update in version.inGDB Administrator1-1/+1
2016-12-15Linking non-ELF file broken by PR20908 fixAlan Modra2-28/+30
PR ld/20968 PR ld/20908 * elflink.c (bfd_elf_final_link): Revert 2016-12-02 change. Move reloc counting code later after ELF flavour test.
2016-12-15Automatic date update in version.inGDB Administrator1-1/+1
2016-12-14MIPS/opcodes: Also set disassembler's ASE flags from ELF structuresMaciej W. Rozycki4-0/+25
Respect any ASE flags recorded in ELF file structures for the purpose of selecting instructions to be disassembled, preventing code from being hex-dumped even though having been clearly indicated as valid at the assembly time. Use date from the MIPS ABI flags structure if present, and otherwise there may be an MDMX ASE flag set in the ELF file header. For backwards compatibility only set extra flags and do not clear any, preserving all previously set by the architecture selected to be disassembled for. include/ * elf/mips.h (Elf_Internal_ABIFlags_v0): Also declare struct typedef as `elf_internal_abiflags_v0'. bfd/ * bfd-in.h (elf_internal_abiflags_v0): New struct declaration. (bfd_mips_elf_get_abiflags): New prototype. * elfxx-mips.c (bfd_mips_elf_get_abiflags): New function. * bfd-in2.h: Regenerate. opcodes/ * mips-dis.c (mips_convert_abiflags_ases): New function. (set_default_mips_dis_options): Also infer ASE flags from ELF file structures. binutils/ * testsuite/binutils-all/mips/mips-ase-1.d: New test. * testsuite/binutils-all/mips/mips-ase-2.d: New test. * testsuite/binutils-all/mips/mips-ase-3.d: New test. * testsuite/binutils-all/mips/mips-ase-1.s: New test source. * testsuite/binutils-all/mips/mips-ase-2.s: New test source. * testsuite/binutils-all/mips/mips.exp: Run the new tests.
2016-12-14ld: aarch64: fix TLS relaxation where TCB_SIZE is usedYury Norov2-5/+20
TCB_SIZE is 2*sizeof(void *), which is 0x10 for lp64, and 0x8 for ilp32. During relaxation, ld goes to do a replace: bl __tls_get_addr => add R0, R0, TCB_SIZE But actual implementation is: bfd_putl32 (0x91004000, contents + rel->r_offset + 4); Which is equivalent of add x0, x0, 0x10. This is wrong for ilp32. The possible fix for it is: bfd_putl32 (0x91000000 | (TCB_SIZE<<10), contents + rel->r_offset + 4); But ilp32 also needs w-registers, so it's simpler to put proper instruction in #if/#else condition. There are 2 such relaxations in elfNN_aarch64_tls_relax(), and so 2 new tests added for ilp32 mode to test it. Yury * bfd/elfnn-aarch64.c: fix TLS relaxations for ilp32 where TCB_SIZE is used. * ld/testsuite/ld-aarch64/aarch64-elf.exp: Add tests for the case. * ld/testsuite/ld-aarch64/tls-relax-ld-le-small-ilp32.d: New file. * ld/testsuite/ld-aarch64/tls-relax-ld-le-tiny-ilp32.d: New file. Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
2016-12-14Revert "bfd: aarch64: fix word and arrdess size declaration in ilp32 mode"Yury Norov1-4/+4
This reverts commit a02c3512655cc2c8ad68e4b656959b7d284acc7d.
2016-12-14Revert "ld: aarch64: fix TLS relaxation where TCB_SIZE is used"Yury Norov1-15/+3
This reverts commit 6650f7bd18f8161b9f666d3e65a6346e23a9d85f.
2016-12-14bfd: aarch64: fix word and arrdess size declaration in ilp32 modeYury Norov1-4/+4
2016-12-14ld: aarch64: fix TLS relaxation where TCB_SIZE is usedYury Norov1-3/+15
TCB_SIZE is 2*sizeof(void *), which is 0x10 for lp64, and 0x8 for ilp32. During relaxation, ld goes to do a replace: bl __tls_get_addr => add R0, R0, TCB_SIZE But actual implementation is: bfd_putl32 (0x91004000, contents + rel->r_offset + 4); Which is equivalent of add x0, x0, 0x10. This is wrong for ilp32. The possible fix for it is: bfd_putl32 (0x91000000 | (TCB_SIZE<<10), contents + rel->r_offset + 4); But ilp32 also needs w-registers, so it's simpler to put proper instruction in #if/#else condition. THere are 2 such relaxations in elfNN_aarch64_tls_relax(), and so 2 new tests added for ilp32 mode to test it. Yury
2016-12-14Automatic date update in version.inGDB Administrator1-1/+1
2016-12-13Automatic date update in version.inGDB Administrator1-1/+1
2016-12-13Don't add PHDR for objcopy/strip or ld script specifying PHDRSAlan Modra2-23/+19
HPPA64 needs to add a DT_PHDR header for shared libs. That's fine when linking but shouldn't happen for strip/objcopy. Also PHDR must come first so there's no need to look at all program headers. bfd/ * elf64-hppa.c (elf64_hppa_modify_segment_map): Don't add PHDR for objcopy/strip or when a ld script specifies PHDRS. ld/ * testsuite/ld-elf/nobits-1.d: Remove xfail for hppa64. * testsuite/ld-elf/note-1.d: Likewise. * testsuite/ld-elf/note-2.d: Likewise.
2016-12-13Don't fudge p_vaddr when PHDR in segmentAlan Modra2-1/+20
RX does horrible fudges to PT_LOAD p_vaddr, that affect the testsuite and mean the target won't support dynamic objects. The latter probably doesn't matter too much since RX is an embedded target, but it's easy to stop some of the fudges in order to reduce special cases for RX in the testsuite. The changes make sense in isolation too. bfd/ * elf32-rx.c (elf32_rx_modify_program_headers): Don't adjust segments that include the ELF file header or program headers. ld/ * testsuite/ld-elf/flags1.d: Run for RX. * testsuite/ld-scripts/phdrs.exp: Likewise. * testsuite/ld-scripts/pr14962.d: Likewise. * testsuite/ld-scripts/pr14962-2.d: Likewise.
2016-12-12Automatic date update in version.inGDB Administrator1-1/+1
2016-12-11Automatic date update in version.inGDB Administrator1-1/+1
2016-12-10Automatic date update in version.inGDB Administrator1-1/+1
2016-12-09Automatic date update in version.inGDB Administrator1-1/+1
2016-12-08PR20932, Internal error during record link assignmentAlan Modra2-5/+10
PR ld/20932 * elflink.c (bfd_elf_record_link_assignment): Handle warning symbols.
2016-12-08Automatic date update in version.inGDB Administrator1-1/+1
2016-12-07Fix internal error in the linker by replacing a call to abort with an error ↵Nick Clifton2-2/+11
message. PR ld/20932 * elflink.c (bfd_elf_record_link_assignment): Replace call to abort with an error message and error return value.
2016-12-07Automatic date update in version.inGDB Administrator1-1/+1
2016-12-06Fix seg-fault in strip when copying a corrupt binary.Nick Clifton2-0/+14
PR binutils/20931 * elf.c (copy_special_section_fields): Check for an invalid sh_link field before attempting to follow it.
2016-12-06Fix seg-fault running strip on a corrupt binary.Nick Clifton2-6/+17
PR binutils/20929 * aoutx.h (squirt_out_relocs): Check for relocs without an associated symbol.
2016-12-06PowerPC64 toc optimisation for power9Alan Modra2-9/+26
Recognize power9 and a few other insns from older machines. Fixes linker complaints like "toc optimization is not supported for 0xf4090002 instruction". 0xf4090002 is stxsd v0,0(r9) bfd/ * elf64-ppc.c (ok_lo_toc_insn): Add r_type param. Recognize lq,lfq,lxv,lxsd,lxssp,lfdp,stq,stfq,stxv,stxsd,stxssp,stfdp. Don't match lmd and stmd. ld/ * testsuite/ld-powerpc/tocopt7.s, * testsuite/ld-powerpc/tocopt7.out, * testsuite/ld-powerpc/tocopt7.d: New test. * testsuite/ld-powerpc/tocopt8.s, * testsuite/ld-powerpc/tocopt8.d: New test. * testsuite/ld-powerpc/powerpc.exp: Run them.
2016-12-06Automatic date update in version.inGDB Administrator1-1/+1
2016-12-05Fix seg-fault in the binutils utilities when reading a corrupt input file.Nick Clifton2-1/+6
PR binutils/20905 * peicode.h (pe_ILF_object_p): Use strnlen to avoid running over the end of the string buffer.
2016-12-05Fix abort when running tools on a bogus binary.Nick Clifton2-2/+5
PR binutils/20907 * peicode.h (pe_ILF_build_a_bfd): Replace abort with error return.
2016-12-05Fix seg-fault running strip on a corrupt binary.Nick Clifton2-4/+27
PR binutils/20921 * aoutx.h (squirt_out_relocs): Check for and report any relocs that could not be recognised.
2016-12-04bfd,ld: Continue after partially-successful relaxed call relocations in sparc.Alyssa Milburn2-2/+7
bfd/ChangeLog: 2016-12-05 Alyssa Milburn <amilburn@zall.org> * elfxx-sparc.c: Do not stop processing relocations after partially relaxing a call with WDISP30. ld/ChangeLog: 2016-12-05 Alyssa Milburn <amilburn@zall.org> * testsuite/ld-sparc/wdispcall.s: New file. * testsuite/ld-sparc/wdispcall.dd: Likewise. * testsuite/ld-sparc/sparc.exp: Run new test.
2016-12-05Fix seg-fault attempting to strip a corrupt binary.Nick Clifton2-1/+11
PR binutils/20922 * elf.c (find_link): Check for null headers before attempting to match them.
2016-12-05Fix seg-fault in linker parsing a corrupt input file.Nick Clifton2-2/+6
PR ld/20924 (aout_link_add_symbols): Fix off by one error checking for overflow of string offset.
2016-12-05Fix assertion failure in linker triggered by corrupt input file.Nick Clifton2-1/+9
PR ld/20925 * aoutx.h (aout_link_add_symbols): Replace BFD_ASSERT with return FALSE.
2016-12-05fix typoNick Clifton1-1/+1
2016-12-05Automatic date update in version.inGDB Administrator1-1/+1
2016-12-04Automatic date update in version.inGDB Administrator1-1/+1