aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
2020-04-18bfd_is_const_section thinkoAlan Modra3-2/+12
* section.c (bfd_is_const_section): Correct test for special sections. * bfd-in2.h: Regenerate.
2020-04-18Automatic date update in version.inGDB Administrator1-1/+1
2020-04-17PR25842, Null pointer dereference in nm-newAlan Modra2-2/+12
PR 25842 * elf.c (_bfd_elf_get_symbol_version_string): Don't segfault on NULL nodename.
2020-04-17Automatic date update in version.inGDB Administrator1-1/+1
2020-04-16Stop the MIPS assembler from accepting ifunc symbols.Nick Clifton2-6/+21
PR 25803 gas * config/obj-elf.c (obj_elf_type): Reject ifunc symbols on MIPS targets. * testsuite/gas/elf/elf.exp: Add MIPS targets to the list to skip for the type-2 test. * testsuite/gas/elf/type-noifunc.e: Update to allow for MIPS targets running this test. bfd * elfxx-mips.c (_bfd_mips_elf_adjust_dynamic_symbol): Replace an abort with a more helpful error message.
2020-04-16PR25827, Null pointer dereferencing in scan_unit_for_symbolsAlan Modra2-5/+13
PR 25827 * dwarf2.c (scan_unit_for_symbols): Wrap overlong lines. Don't strdup(0).
2020-04-16PowerPC64 GOT reloc reserving PLT entry for ifuncAlan Modra1-8/+0
I can't see any reason why ELFv2 should create a PLT entry for ifuncs referenced by GOT relocs as long as the GOT entry remains. The GOT entry ought to be resolved by ld.so to the value returned by the ifunc resolver, or if there is global entry stub created for some other reason, by the linker to the stub address. * elf64-ppc.c (ppc64_elf_check_relocs): Don't create plt entries for GOT relocs against ifuncs.
2020-04-16PowerPC64 GOT reloc optimisationAlan Modra1-0/+9
When the symbol referenced by a GOT reloc is an ifunc, we can't optimise away the GOT indirection. Well, we can, but only if a global entry stub is created with the ifunc symbol redefined to the stub. But that results in slower code and an indirection via the PLT so there isn't much to like about that solution. * elf64-ppc.c (ppc64_elf_edit_toc): Exclude ifunc from GOT optimisation. (ppc64_elf_relocate_section): Likewise.
2020-04-16Automatic date update in version.inGDB Administrator1-1/+1
2020-04-15Unify the behaviour of ld.bfd and ld.gold with respect to warning about ↵Fangrui Song12-52/+79
unresolved symbol references. (PR 24613) PR binutils/24613 include * bfdlink.h (enum report_method): Delete RM_GENERATE_WARNING and RM_GENERATE_ERROR. Add RM_DIAGNOSE. (struct bfd_link_info): Add warn_unresolved_syms. ld * lexsup.c (parse_args): Change RM_GENERATE_WARNING and RM_GENERATE_ERROR to RM_DIAGNOSE. * emultempl/aix.em (ld_${EMULATION_NAME}_emulation): Change RM_GENERATE_ERROR to RM_DIAGNOSE. * emultempl/elf.em (ld_${EMULATION_NAME}_emulation): Likewise. bfd * coff-rs6000.c (xcoff_ppc_relocate_section): Change RM_GENERATE_ERROR to RM_DIAGNOSE plus a check of warn_unresolved_syms. * coff64-rs6000.c (xcoff_ppc_relocate_section): Likewise. * elf-bfd.h (_bfd_elf_large_com_section): Likewise. * elf32-m32r.c (m32r_elf_relocate_section): Likewise. * elf32-score.c (s3_bfd_score_elf_relocate_section): Likewise. * elf32-score7.c (s7_bfd_score_elf_relocate_section): Likewise. * elf32-sh.c (sh_elf_relocate_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-hppa.c (elf64_hppa_relocate_section): Likewise. * elflink.c (elf_link_output_extsym): Likewise. * elfxx-mips.c (mips_elf_calculate_relocation): Likewise.
2020-04-15PR25823, Use after free in bfd_hash_lookupAlan Modra2-10/+17
PR 25823 * peXXigen.c (_bfd_XXi_swap_sym_in <C_SECTION>): Don't use a pointer into strings that may be freed for section name, always allocate a new string.
2020-04-15Automatic date update in version.inGDB Administrator1-1/+1
2020-04-14[PATCH v2 2/2] coff-go32: support extended relocationsJuan Manuel Guerrero8-28/+250
This patch extends the relocation and line number counters for coff-go32 and coff-go32-exe to 32 bits. As I understand it works the same as for PE-COFF: If the number of relocations in an object file exceeds 65534, the NRELOC field is set to 65535 and the actual number of relocations is stored in the VADDR field of the first relocation entry. Executable files have no relocations, and thus the NRELOC field is repurposed to extend NLNNO to 32-bits. bfd * coff-go32.c (COFF_GO32, IMAGE_SCN_LNK_NRELOC_OVFL) (coff_SWAP_scnhdr_in, coff_SWAP_scnhdr_out): Define. (_bfd_go32_swap_scnhdr_in, _bfd_go32_swap_scnhdr_out) (_bfd_go32_mkobject): New functions. * coff-stgo32.c (IMAGE_SCN_LNK_NRELOC_OVFL) (coff_SWAP_scnhdr_in, coff_SWAP_scnhdr_out): Define. (go32exe_mkobject): Call _bfd_go32_mkobject. * coffcode.h (COFF_WITH_EXTENDED_RELOC_COUNTER): Define. (coff_set_alignment_hook): Define function for COFF_GO32_EXE and COFF_GO32. (coff_write_relocs): Enable extended reloc counter code if COFF_WITH_EXTENDED_RELOC_COUNTER is defined. Test for obj_go32. (coff_write_object_contents): Likewise. Pad section headers for COFF_GO32 and COFF_GO32EXE. Use bfd_coff_swap_scnhdr_out instead of coff_swap_scnhdr_out. * cofflink.c (_bfd_coff_final_link): Test also for obj_go32 to enable extended reloc counter. * coffswap.h: (coff_swap_scnhdr_in, coff_swap_scnhdr_out): Declare with ATTRIBUTE_UNUSED. * libcoff-in.h: (struct coff_tdata): New field go32. (obj_go32): Define. * libcoff.h: Regenerate.
2020-04-14The assembler only supports 32-bit stabs. So set sh_entsize unconditionally ↵Fangrui Song2-3/+7
to 12. PR gas/25768 * elf.c (assign_section_numbers): Always set .stab sh_entsize to 12.
2020-04-14Fixes for the magic number used in PDP11 AOUT binaries.Stephen Casner3-4/+68
PR ld/25677 include * aout/aout64.h (N_DATADDR): Add IMAGIC case. bfd * pdp11.c: Add implementation of --imagic option. (adjust_o_magic): Fix objcopy --extract-symbol test. * libaout.h (enum aout_magic): Add i_magic. ld * emulparams/pdp11.sh (SCRIPT_NAME): Change to pdp11. (EXTRA_EM_FILE): New, add emulation file pdp11. * scripttempl/pdp11.sc: New, derived from aout.sc without irrelevant input sections. * emultempl/pdp11.em (_add_options, _handle_option) (_list_options): New. Add options -z, --imagic for pdp11-aout. (_before_parse): Make --omagic be default instead of --nmagic. (_get_script): Modify special-case linker script for --imagic. * lexsup.c (parse_args): Explictly set config.text_read_only for -n. * ld.texi (Options): Add documentation of PDP11-specific options. (Options): Fix unrelated typo to --no-compact-branches. * gen-doc.texi: @set PDP11. * testsuite/ld-pdp11/pdp11.exp: New, start pdp11 testing. * testsuite/ld-pdp11/sections.s: New, source for options tests. * testsuite/ld-pdp11/imagic.d: New, test --imagic format. * testsuite/ld-pdp11/imagicz.d: New, test -z (imagic) format. * testsuite/ld-pdp11/nmagic.d: New, test --nmagic format. * testsuite/ld-pdp11/omagic.d: New, test --omagic format.
2020-04-14Automatic date update in version.inGDB Administrator1-1/+1
2020-04-13Automatic date update in version.inGDB Administrator1-1/+1
2020-04-12Automatic date update in version.inGDB Administrator1-1/+1
2020-04-11Automatic date update in version.inGDB Administrator1-1/+1
2020-04-10Automatic date update in version.inGDB Administrator1-1/+1
2020-04-09Automatic date update in version.inGDB Administrator1-1/+1
2020-04-08Automatic date update in version.inGDB Administrator1-1/+1
2020-04-07ChangeLog entry for last change.Rainer Orth1-0/+7
2020-04-07ld: Fix several 32-bit SPARC plugin testsRainer Orth1-15/+19
Several ld plugin tests currently FAIL on 32-bit Solaris/SPARC: FAIL: load plugin with source FAIL: plugin claimfile lost symbol with source FAIL: plugin claimfile replace symbol with source FAIL: plugin claimfile resolve symbol with source FAIL: plugin claimfile replace file with source FAIL: plugin set symbol visibility with source FAIL: plugin ignore lib with source FAIL: plugin claimfile replace lib with source FAIL: plugin 2 with source lib FAIL: load plugin 2 with source FAIL: load plugin 2 with source and -r FAIL: plugin 3 with source lib FAIL: load plugin 3 with source FAIL: load plugin 3 with source and -r FAIL: PR ld/20070 all of them in the same way: ./ld-new: BFD (GNU Binutils) 2.34.50.20200328 internal error, aborting at /vol/src/gnu/binutils/hg/master/git/bfd/elf32-sparc.c:154 in sparc_final_write_processing This happens when bfd_get_mach returns 0 when abfd refers to a source file: $11 = { filename = 0x28c358 "/vol/src/gnu/binutils/hg/master/local/ld/testsuite/ld-plugin/func.c (symbol from plugin)", xvec = 0x24ed6c <sparc_elf32_sol2_vec>, [...] While I could find no specification what abfd's are allowed/expected in *_final_write_processing, I could find no other target that behaved the same. And indeed ignoring the 0 case fixes the failures. The code now errors for other values. 64-bit SPARC is not affected because it doesn't have a specific implementation of elf_backend_final_write_processing. Tested on sparc-sun-solaris2.11. 2020-04-07 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> Nick Clifton <nickc@redhat.com> * elf32-sparc.c (sparc_final_write_processing): Fix whitespace. <0>: Ignore. <default>: Error rather than abort.
2020-04-07Automatic date update in version.inGDB Administrator1-1/+1
2020-04-06Automatic date update in version.inGDB Administrator1-1/+1
2020-04-05Automatic date update in version.inGDB Administrator1-1/+1
2020-04-03elf: Remove zero-sized relocation section from section groupH.J. Lu2-11/+32
Remove zero-sized relocation section from a section group since it has been removed from the output. PR ld/25767 * elf.c (_bfd_elf_fixup_group_sections): Remove zero-sized relocation section from section group.
2020-04-04Automatic date update in version.inGDB Administrator1-1/+1
2020-04-03Automatic date update in version.inGDB Administrator1-1/+1
2020-04-02coff-go32-exe: support variable-length stubsJan W. Jagersma10-280/+270
The stub size in GO32 executables has historically been fixed at 2048 bytes, due to hardcoded limitations in bfd. Recent patches to djgpp by Stas Sergeev (CC'd) have pushed the stub right up to this limit, so if any further expansion is desired, this must first be patched in bfd. This series includes three patches: The first changes the meaning of the bfd->origin field slightly, so that target code can use this to specify an offset into the file where the actual bfd is located. The second patch then uses this to enable support for variable-sized stubs in the coff-go32-exe format. The final patch is only a cleanup, it normalizes function and variable names in coff-stgo32.c so that they all begin with the same prefix. bfd * bfdio.c (bfd_bread, bfd_tell, bfd_seek, bfd_mmap): Always add bfd->origin to file offset. * bfdwin.c (bfd_get_file_window): Likewise. * bfd.c: Clarify the use of the bfd->origin field. * bfd-in2.h: Regenerate. * coff-i386.c: Don't include go32exe.h. Allow overriding coff_write_object_contents via COFF_WRITE_CONTENTS. * coff-stgo32.c (go32exe_cleanup, go32exe_mkobject) (go32exe_write_object_contents): New functions. (go32exe_temp_stub, go32exe_temp_stub_size): New static globals. (COFF_WRITE_CONTENTS, GO32EXE_DEFAULT_STUB_SIZE): Define. (create_go32_stub): Remove check for 2k size limit. Read stub from go32exe_temp_stub if present. (go32_stubbed_coff_bfd_copy_private_bfd_data): Allocate and copy variable-length stub. (go32_check_format): Read stub to go32exe_temp_stub, set origin, return go32exe_cleanup. (adjust_filehdr_in_post, adjust_filehdr_out_pre) (adjust_filehdr_out_post, adjust_scnhdr_in_post) (adjust_scnhdr_out_pre, adjust_scnhdr_out_post) (adjust_aux_in_post, adjust_aux_out_pre, adjust_aux_out_post): Remove functions and their associated #defines. * coffcode.h (coff_mkobject_hook): Remove stub copying code. * libcoff-in.h: (struct coff_tdata): New field stub_size. Rename field go32stub to stub. * libcoff.h: Regenerate. * coff-stgo32.c (go32_check_format): Rename to... (go32exe_check_format): ...this. (go32_stubbed_coff_bfd_copy_private_bfd_data): Rename to... (go32exe_copy_private_bfd_data): ...this. (stub_bytes): Rename to... (go32exe_default_stub): ...this. (create_go32_stub): Rename to... (go32exe_create_stub): ...this. * coff-stgo32.c (go32exe_copy_private_bfd_data): Avoid realloc when possible. include * coff/go32exe.h: Remove file. * coff/internal.h (struct internal_filehdr): Remove field go32stub. Remove flag F_GO32STUB.
2020-04-02Automatic date update in version.inGDB Administrator1-1/+1
2020-04-01x86: Only allow S + A relocations against absolute symbolH.J. Lu5-31/+260
Since value of non-preemptible absolute symbol (SHN_ABS) won't change, only relocations, which can be resolved as absolute value + addend, and GOTPCREL relocations, where absolute value + addend is stored in the GOT slot, against non-preemptible absolute symbol are allowed in PIE and shared library. Also convert load relocation to R_386_32, R_X86_64_32S or R_X86_64_32 for relocation against non-preemptible absolute symbol. Don't convert to R_X86_64_32S nor R_X86_64_32 for non-preemptible absolute symbol if they overflow. bfd/ PR ld/25749 PR ld/25754 * elf32-i386.c (elf_i386_convert_load_reloc): Convert load relocation to R_386_32 for relocation against non-preemptible absolute symbol. (elf_i386_check_relocs): Call _bfd_elf_x86_valid_reloc_p. Don't allocate dynamic relocation for non-preemptible absolute symbol. (elf_i386_relocate_section): Pass sec to GENERATE_DYNAMIC_RELOCATION_P. * elf64-x86-64.c (R_X86_64_converted_reloc_bit): Moved. (elf_x86_64_convert_load_reloc): Covert load relocation to R_X86_64_32S or R_X86_64_32 for relocation against non-preemptible absolute symbol. Don't convert to R_X86_64_32S nor R_X86_64_32 for non-preemptible absolute symbol if they overflow. (elf_x86_64_check_relocs): Call _bfd_elf_x86_valid_reloc_p. Set tls_type for GOT slot to GOT_ABS for non-preemptible absolute symbol. Don't allocate dynamic relocation for non-preemptible absolute symbol. (elf_x86_64_relocate_section): Don't generate relative relocation for GOTPCREL relocations aganst local absolute symbol. Pass sec to GENERATE_DYNAMIC_RELOCATION_P. * elfxx-x86.c (elf_x86_allocate_dynrelocs): No dynamic relocation against non-preemptible absolute symbol. (_bfd_elf_x86_valid_reloc_p): New function. (_bfd_x86_elf_size_dynamic_sections): No dynamic relocation for GOT_ABS GOT slot. * elfxx-x86.h (GENERATE_DYNAMIC_RELOCATION_P): Add an SEC argument. Don't generate dynamic relocation against non-preemptible absolute symbol. (ABS_SYMBOL_P): New. (GENERATE_RELATIVE_RELOC_P): Don't generate relative relocation against non-preemptible absolute symbol. (GOT_ABS): New. (R_X86_64_converted_reloc_bit): New. Moved from elf64-x86-64.c. (_bfd_elf_x86_valid_reloc_p): New. ld/ PR ld/25749 PR ld/25754 * testsuite/ld-elf/linux-x86.exp: Run ld/25749 tests. * testsuite/ld-elf/pr25749-1.c: New file. * testsuite/ld-elf/pr25749-1a.c: Likewise. * testsuite/ld-elf/pr25749-1b.c: Likewise. * testsuite/ld-elf/pr25749-1b.err: Likewise. * testsuite/ld-elf/pr25749-1c.c: Likewise. * testsuite/ld-elf/pr25749-1d.c: Likewise. * testsuite/ld-elf/pr25749-2.c: Likewise. * testsuite/ld-elf/pr25749-2a.s: Likewise. * testsuite/ld-elf/pr25749-2b.s: Likewise. * testsuite/ld-elf/pr25749.rd: Likewise. * testsuite/ld-elf/pr25754-1a.c: Likewise. * testsuite/ld-elf/pr25754-1b.s: Likewise. * testsuite/ld-elf/pr25754-2a.c: Likewise. * testsuite/ld-elf/pr25754-2b.err: Likewise. * testsuite/ld-elf/pr25754-2b.s: Likewise. * testsuite/ld-elf/pr25754-3a.c: Likewise. * testsuite/ld-elf/pr25754-3b.s: Likewise. * testsuite/ld-elf/pr25754-4a.c: Likewise. * testsuite/ld-elf/pr25754-4b.s: Likewise. * testsuite/ld-elf/pr25754-4c.s: Likewise. * testsuite/ld-elf/pr25754-5a.c: Likewise. * testsuite/ld-elf/pr25754-5b.s: Likewise. * testsuite/ld-elf/pr25754-5c.s: Likewise. * testsuite/ld-elf/pr25754-6a.c: Likewise. * testsuite/ld-elf/pr25754-6b.s: Likewise. * testsuite/ld-x86-64/pr19609-6a.d: Don't expect linker error.
2020-04-01Arm: Fix LSB of GOT for Thumb2 only PLT.Tamar Christina2-0/+12
When you have a Thumb only PLT then the address in the GOT for PLT0 needs to have the Thumb bit set since the instruction used in PLTn to get there is `ldr.w pc` which is an inter-working instruction: the PLT sequence in question is 00000120 <foo@plt>: 120: f240 0c98 movw ip, #152 ; 0x98 124: f2c0 0c01 movt ip, #1 128: 44fc add ip, pc 12a: f8dc f000 ldr.w pc, [ip] 12e: e7fc b.n 12a <foo@plt+0xa> Disassembly of section .text: 00000130 <bar>: 130: b580 push {r7, lr} 132: af00 add r7, sp, #0 134: f7ff fff4 bl 120 <foo@plt> and previously the linker would generate Hex dump of section '.got': ... 0x000101b8 40010100 00000000 00000000 10010000 @............... Which would make it jump and transition out of thumb mode and crash since you only have thumb mode on such cores. Now it correctly generates Hex dump of section '.got': ... 0x000101b8 40010100 00000000 00000000 11010000 @............... Thanks to Amol for testing patch and to rgujju for reporting it. bfd/ChangeLog: PR ld/16017 * elf32-arm.c (elf32_arm_populate_plt_entry): Set LSB of the PLT0 address in the GOT if in thumb only mode. ld/ChangeLog: PR ld/16017 * testsuite/ld-arm/arm-elf.exp (thumb-plt-got): New. * testsuite/ld-arm/thumb-plt-got.d: New test.
2020-04-01Arm: Fix thumb2 PLT branch offsets.Tamar Christina2-2/+6
When I previously changed these offsets I had incorrectly used an offset of -2 for this Thumb2 PLT. Unfortunately because we had no tests for this PLT I had missed that the result was incorrect. This patch fixes the offset to PC .-4 so that it correctly addresses the previous instruction and adds a test for this PLT stub. bfd/ChangeLog: * elf32-arm.c (elf32_thumb2_plt_entry): Fix PC-rel offset. ld/ChangeLog: * testsuite/ld-arm/arm-elf.exp (thumb-plt): New. * testsuite/ld-arm/thumb-plt.d: New test. * testsuite/ld-arm/thumb-plt.s: New test.
2020-04-01mmo.c: Fix ld testsuite regression "objcopy executable (pr25662)".Hans-Peter Nilsson2-1/+10
* mmo.c (mmo_scan): Create .text section only when needed, not from the start. For the test-case at hand, the .data section is created and output first by the linker, but the mmo input-reader mmo_scan always creates a .text section. Since sections are output in the order in which they're created, it's output first, breaking the assumption that obcopy without options (or with -p) creates output identical to its input. The point of creating it at the top of mmo_scan is a trivial default assignment for the current section variable "sec". Instead we now defer the default, creating it only when needed and sec is NULL.
2020-04-01Automatic date update in version.inGDB Administrator1-1/+1
2020-03-31alpha-coff: unitialised readAlan Modra2-1/+6
* coff-alpha.c (alpha_ecoff_get_elt_at_filepos): Correct bfd_bread return value check.
2020-03-31alpha-vms: sanity checks for image_writeAlan Modra2-25/+52
* vms-alpha.c (image_write): Check bounds for sections without contents too. Error on non-zero write to section without contents. (_bfd_vms_slurp_etir): Check return of image_write* functions.
2020-03-31tekhex: Uninitialised readAlan Modra2-1/+5
* tekhex.c (pass_over): Check is_eof before reading buffer.
2020-03-31Automatic date update in version.inGDB Administrator1-1/+1
2020-03-30Fix objcopy's --preserve-dates command line option so that it will work with ↵Nick Clifton4-4/+18
PE format files. PR binutils/pr25662 bfd * libcoff-in.h (struct pe_tdata): Rename the insert_timestamp field to timestamp and make it an integer. * libcoff.h: Regenerate. * peXXigen.c (_bfd_XXi_only_swap_filehdr_out): Test the timestamp field in the pe_data structure rather than the insert_timestamp field. binutils* objcopy.c (copy_object): When copying PE format files set the timestamp field in the pe_data structure if the preserve_dates flag is set. * testsuite/binutils-all/objcopy.exp (objcopy_test) Use --preserve-dates in place of the -p option, in order to make its effect more obvious. ld * emultempl/pe.em (after_open): Replace initialisation of the insert_timestamp field in the pe_data structure with an initialisation of the timestamp field. * emultemp/pep.em: Likewise. * pe-dll.c (fill_edata): Use the timestamp field in the pe_data structure instead of the insert_timestamp field.
2020-03-30Automatic date update in version.inGDB Administrator1-1/+1
2020-03-30PR25745, powerpc64-ld overflows string buffer in --stats modeAlan Modra2-36/+46
PR 25745 * elf64-ppc.c (ppc64_elf_build_stubs): Use asprintf to form statistics message.
2020-03-29Automatic date update in version.inGDB Administrator1-1/+1
2020-03-28Automatic date update in version.inGDB Administrator1-1/+1
2020-03-27Automatic date update in version.inGDB Administrator1-1/+1
2020-03-26Revert earlier delta adding bfd_coff_get_internal_extra_pe_aouthdr() function.Nick Clifton4-19/+7
* cofflink.c (bfd_coff_get_internal_extra_pe_aouthdr): Delete. * libbfd-in.h (bfd_coff_get_internal_extra_pe_aouthdr): Remove prototype. * libbfd.h: Regenerate.
2020-03-26Re: i386msdos uninitialised readAlan Modra2-1/+5
Another fix. * i386msdos.c (msdos_object_p): Catch -1 return from bfd_bread.
2020-03-26alpha-vms: Sanity check ETIR__C_CTL_DFLOC indexAlan Modra2-9/+23
I doubt anyone will want to create more than 16M debug location entries. If there is no bound the object format allows for 32-bit indices and of course fuzzers find that and attempt allocation of up to a 16G byte array. The patch also fixes potential integer overflows in calculating the array size. * vms-alpha.c (dst_define_location): Limit size of dst_ptr_offsets array. (_bfd_vms_slurp_object_records): Rename "err" to "ok".