aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
2023-04-06Automatic date update in version.inGDB Administrator1-1/+1
2023-04-05Automatic date update in version.inGDB Administrator1-1/+1
2023-04-04bfd+ld: when / whether to generate .c filesJan Beulich2-2/+2
Having been irritated by seeing bfd/elf{32,64}-aarch64.c to be re- generated in x86-only builds, I came across 769a27ade588 ("Re: bfd BLD-POTFILES.in dependencies"). I think this went slightly too far, as outside of maintainer mode dependencies will cause the subset of files to be (re-)generated which are actually needed for the build. Generating them all is only needed when wanting to update certain files under bfd/po/, i.e. in maintainer mode. In the course of looking around in an attempt to try to understand how things are meant to work, I further noticed that ld has got things slightly wrong too: BLD-POTFILES.in depending on $(BLD_POTFILES) isn't quite right (the output doesn't change when any of the enumerated files changes; it's the mere presence which matters); like in bfd it looks like we would better extend BUILT_SOURCES accordingly. Furthermore it became apparent that ld fails to enumerate the .c files generated from the .l and .y ones. While in their absence it was benign whether translatable strings in the source files were actually marked as such, this now becomes relevant. Mark respective strings at the same time, but skipping ones which look to be of interest for debugging purposes only (e.g. such used by printf() enclosed in #ifdef TRACE).
2023-04-04Automatic date update in version.inGDB Administrator1-1/+1
2023-04-03Automatic date update in version.inGDB Administrator1-1/+1
2023-04-03asan: heap buffer overflow printing ecoff debug info file nameAlan Modra4-35/+34
A case of a string section ending with an unterminated string. Fix it by allocating one more byte and making it zero. Also make functions reading the data return void* so that casts are not needed. * ecoff.c (READ): Delete type param. Allocate one extra byte to terminate string sections with a NUL. Adjust invocation. * elfxx-mips.c (READ): Likewise. * libbfd-in.h (_bfd_alloc_and_read): Return a void*. (_bfd_malloc_and_read): Likewise. * libbfd.h: Regenerate.
2023-04-02Automatic date update in version.inGDB Administrator1-1/+1
2023-04-01Automatic date update in version.inGDB Administrator1-1/+1
2023-03-31lto: Don't add indirect symbols for versioned aliases in IRH.J. Lu1-1/+8
Linker adds indirect symbols for versioned symbol aliases, which are created by ".symver foo, foo@FOO", by checking symbol type, value and section so that references to foo will be replaced by references to foo@FOO if foo and foo@FOO have the same symbol type, value and section. But in IR, since all symbols of the same type have the same value and section, we can't tell if a symbol is an alias of another symbol by their types, values and sections. We shouldn't add indirect symbols for versioned symbol aliases in IR. bfd/ PR ld/30281 * elflink.c (elf_link_add_object_symbols): Don't add indirect symbols for ".symver foo, foo@FOO" aliases in IR. ld/ PR ld/30281 * testsuite/ld-plugin/lto.exp: Add PR ld/30281 test. * testsuite/ld-plugin/pr30281.t: New file. * testsuite/ld-plugin/pr30281.c: Likewise.
2023-03-31Arm64/ELF: accept relocations against STN_UNDEFJan Beulich1-1/+5
While only a secondary issue there, the testcase of PR gas/27212 exposes an oversight in relocation handling: Just like e.g. Arm32, which has a similar comment and a similar check, relocations against STN_UNDEF have to be permitted to satisfy the ELF spec.
2023-03-31Automatic date update in version.inGDB Administrator1-1/+1
2023-03-30Fix an illegal memory access when an accessing a zer0-lengthverdef table.Nick Clifton2-0/+11
PR 30285 * elf.c (_bfd_elf_slurp_version_tables): Fail if no version definitions are allocated.
2023-03-30Setting sh_link for SHT_REL/SHT_RELAAlan Modra1-14/+16
It's wrong to have an alloc reloc section trying to use a non-alloc symbol table. * elf.c (assign_section_numbers <SHT_REL, SHT_RELA>): Correct comment. Always set sh_link to .dynsym for alloc reloc sections and to .symtab for non-alloc.
2023-03-30Fix memory leak in bfd_get_debug_link_info_1Alan Modra2-13/+9
* opncls.c (bfd_get_alt_debug_link_info): Don't bother freeing after bfd_malloc_and_get_section failure. (get_build_id): Likewise. (bfd_get_debug_link_info_1): Likewise. Free section contents when crc not present. * section.c (bfd_malloc_and_get_section): Document that the buffer is NULL on error return.
2023-03-30Automatic date update in version.inGDB Administrator1-1/+1
2023-03-30RISC-V: PR28789, Reject R_RISCV_PCREL relocations with ABS symbol in PIC/PIE.Palmer Dabbelt1-0/+41
The non-preemptible SHN_ABS symbol with a pc-relative relocation should be disallowed when generating shared object (pic and pie). Generally, the following cases, which refer to pr25749, will cause a symbol be non-preemptible, * -pie, or -shared with -symbolic * STV_HIDDEN, STV_INTERNAL, STV_PROTECTED * Have dynamic symbol table, but without the symbol * VER_NDX_LOCAL However, PCREL_HI20/LO12 relocs are always bind locally when generating shared object, so not only the non-preemptible absolute symbol need to be disallowed, all absolute symbol references need but except that they are defined in linker script. If we also disallow the absolute symbol in linker script, then the glibc-linux toolchain build failed, so regard them as pc-relative symbols, just like what x86 did. Maybe we should add this check for all pc-relative relocations, rather than just handle in R_RISCV_PCREL relocs. Ideally, since the value of SHN_ABS symbol is a constant, only S - A relocations should be allowed in the shared object, so only BFD_RELOC_8/16/32/64 are allowed, which means R_RISCV_32/R_RISCV_64. bfd/ PR 28789 * elfnn-riscv.c (riscv_elf_check_relocs): The absolute symbol cannot be referneced with pc-relative relocation when generating shared object. ld/ PR 28789 * ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated. * ld/testsuite/ld-riscv-elf/pcrel-reloc*: New testcases.
2023-03-30RISC-V: Clarify link behaviors of R_RISCV_32/64 relocations with ABS symbol.Nelson Chu1-8/+53
There are two improvements, which are all referenced to aarch64, * R_RISCV_32 with non ABS symbol cannot be used under RV64 when making shard objects. * Don't need dynamic relocation for R_RISCV_32/64 under RV32/RV64 when making shared objects, if the referenced symbol is local ABS symbol. However, considering this link, https://github.com/riscv-non-isa/riscv-elf-psabi-doc/issues/341 Seems like we should makes all R_RISCV_32/64 relocs with ABS symbol that don't need any dynamic relocations when making the shared objects. But anyway, I just sync the current behavior as aarch64 ld, in case there are any unexpected behaviors happen. Passed the gcc/binutils regressions in riscv-gnu-toolchain. bfd/ * elfnn-riscv.c (riscv_elf_check_relocs): Only allow R_RISCV_32 with ABS symbol under RV64. (riscv_elf_relocate_section): R_RISCV_32/64 with local ABS symbol under RV32/RV64 doesn't need any dynamic relocation when making shared objects. I just make the implementations similar to other targets, so that will be more easy to mainatain. ld/ * testsuite/ld-riscv-elf/data-reloc*: New testcases. * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Added new data-reloc* testcases, and need to make ifunc-seperate* testcases work for rv32. * testsuite/ld-riscv-elf/ifunc-seperate-caller-nonplt.s: Likewise. * testsuite/ld-riscv-elf/ifunc-seperate-caller-plt.s: Likewise.
2023-03-30RISC-V: Extract the ld code which are too complicated, and may be reused.Nelson Chu1-74/+82
These types of codes are different for each target, I am not sure what are the best for RISC-V, so extract them out may be more easy to compare what's the difference. bfd/ * elfnn-riscv.c (RISCV_NEED_DYNAMIC_RELOC): New defined. Extracted from riscv_elf_check_relocs, to see if dynamic reloc is needed for the specific relocation. (RISCV_GENERATE_DYNAMIC_RELOC): New defined. Extracted from riscv_elf_relocate_section, to see if R_RISCV_32/64 need to generate dynamic relocation. (RISCV_COPY_INPUT_RELOC): New defined. Extracted from riscv_elf_relocate_section, to see if R_RISCV_32/64 need to copy itslef tp output file. (RISCV_RESOLVED_LOCALLY): New defined. Extracted from riscv_elf_relocate_section, to see if R_RISCV_GOT_HI20 can be resolved locally.
2023-03-29Sanity check section size in bfd_init_section_compress_statusAlan Modra1-1/+2
This function doesn't just initialise for compression, it actually compresses. This patch sanity checks section size before allocating buffers for the uncompressed contents. * compress.c (bfd_init_section_compress_status): Sanity check section size.
2023-03-29Re: Fix an aout memory leakAlan Modra1-2/+3
We have way too much duplicated code in bfd. Apply dd3a3d0af9f6 and 920581c57e08 to pdp11.c. * pdp11.c (bfd_free_cached_info): Free line_buf. Return true if tdata.aout_data is NULL.
2023-03-29Automatic date update in version.inGDB Administrator1-1/+1
2023-03-28ubsan: elfnn-aarch64.c:4595:19: runtime error: load of value 190Alan Modra1-8/+3
which is not a valid value for type '_Bool' * elfnn-aarch64.c (stub_hash_newfunc): Clear all fields past root.
2023-03-28Automatic date update in version.inGDB Administrator1-1/+1
2023-03-27Remove coff_pointerize_aux table_end paramAlan Modra1-9/+4
I'm fairly certain the table_end checks are redundant now. This patch reverts commit 334d4ced42d3. * coffgen.c (coff_pointerize_aux): Remove table_end parameter. (coff_get_normalized_symtab): Adjust to suit.
2023-03-27Use stdint types in coff internal_auxentAlan Modra9-95/+93
long is a poor choice of type to store 32-bit values read from objects files by H_GET_32. H_GET_32 doesn't sign extend so tests like that in gdb/coffread.c for "negative" values won't work if long is larger than 32 bits. If long is 32-bit then code needs to be careful to not accidentally index negative array elements. (I'd rather see a segfault on an unmapped 4G array index than silently reading bogus data.) long is also a poor choice for x_sect.s_scnlen, which might have 64-bit values. It's better to use unsigned exact width types to avoid surprises. I decided to change the field names too, which makes most of this patch simply renaming. Besides that there are a few places where casts are no longer needed, and where printf format strings or tests need adjusting. include/ * coff/internal.h (union internal_auxent): Use unsigned stdint types. Rename l fields to u32 and u64 as appropriate. bfd/ * coff-bfd.c, * coff-rs6000.c, * coff64-rs6000.c, * coffcode.h, * coffgen.c, * cofflink.c, * coffswap.h, * peXXigen.c, * xcofflink.c: Adjust to suit internal_auxent changes. binutils/ * rdcoff.c: Adjust to suit internal_auxent changes. gas/ * config/obj-coff.h, * config/tc-ppc.c: Adjust to suit internal_auxent changes. gdb/ * coffread.c, * xcoffread.c: Adjust to suit internal_auxent changes. ld/ * pe-dll.c: Adjust to suit internal_auxent changes.
2023-03-27Set proper union selector tagAlan Modra1-9/+18
* coff-bfd.c (bfd_coff_get_auxent): After converting sym pointer to an index, reset the union tag.
2023-03-27coffgrok access of u.auxent.x_sym.x_tagndx.pAlan Modra2-30/+30
u.auxent.x_sym.x_tagndx is a union. The p field is only valid when fix_tag is set. This patch fixes code in coffgrok.c that accessed the field without first checking fix_tag, and removes a whole lot of code validating bogus pointers to prevent segfaults (which no longer happen, I checked the referenced PR 17512 testcases). The patch also documents this in the fix_tag comment, makes is_sym a bitfield, and sorts the selecter fields a little. bfd/ * coffcode.h (combined_entry_type): Make is_sym a bitfield. Sort and comment on union selectors. * libcoff.h: Regenerate. binutils/ * coffgrok.c (do_type): Make aux a combined_entry_type. Test fix_tag before accessing u.auxent.x_sym.x_tagndx.p. Remove now unnecessary pointer bounds checking.
2023-03-27Duplicate DW_AT_call_file leakAlan Modra1-2/+5
When given two or more DW_AT_call_file for a given function we currently leak the concat memory. * dwarf2.c (scan_unit_for_symbols): Don't leak on duplicate DW_AT_call_file.
2023-03-27XCOFF sanity checkAlan Modra1-1/+2
* coffcode.h (coff_pointerize_aux_hook): Sanity check x_csect.x_scnlen against raw_syment_count.
2023-03-27Automatic date update in version.inGDB Administrator1-1/+1
2023-03-26Automatic date update in version.inGDB Administrator1-1/+1
2023-03-25Automatic date update in version.inGDB Administrator1-1/+1
2023-03-24Tidy string_ptr incrementAlan Modra1-2/+2
* peicode.h (pe_ILF_make_a_symbol): Use sprintf output to increment string_ptr to end of new string.
2023-03-24Tidy dwarf1 cached section contentsAlan Modra5-1/+22
* dwarf1.c (_bfd_dwarf1_cleanup_debug_info): New function. * libbfd-in.h (_bfd_dwarf1_cleanup_debug_info): Declare. * elf.c (_bfd_elf_close_and_cleanup): Call it. * elf-bfd.h (struct elf_obj_tdata): Make dwarf1_find_line_info a void*. * libbfd.h: Regenerate.
2023-03-24Automatic date update in version.inGDB Administrator1-1/+1
2023-03-23bfd: aarch64: Optimize BTI stubs PR30076Szabolcs Nagy1-4/+32
Don't insert a second stub if the target is already compatible with an indirect branch.
2023-03-23bfd: aarch64: Fix stubs that may break BTI PR30076Szabolcs Nagy1-15/+160
Insert two stubs in a BTI enabled binary when fixing long calls: The first is near the call site and uses an indirect jump like before, but it targets the second stub that is near the call target site and uses a direct jump. This is needed when a single stub breaks BTI compatibility. The stub layout is kept fixed between sizing and building the stubs, so the location of the second stub is known at build time, this may introduce padding between stubs when those are relaxed. Stub layout with BTI disabled is unchanged.
2023-03-23bfd: aarch64: Refactor stub sizing codeSzabolcs Nagy1-273/+279
elfNN_aarch64_size_stubs has grown big, so factor out the call stub related code before adding new logic there.
2023-03-23Automatic date update in version.inGDB Administrator1-1/+1
2023-03-22coff_get_normalized_symtab bfd_releaseAlan Modra1-4/+1
We can't free "internal" on errors, since bfd_coff_swap_sym_in may call bfd_alloc. For example, _bfd_XXi_swap_sym_in may even create new sections, which use bfd_alloc'd memory. If "internal" is freed, all more recently bfd_alloc'd memory is also freed. * coffgen.c (coff_get_normalized_symtab): Don't bfd_release on error.
2023-03-22Automatic date update in version.inGDB Administrator1-1/+1
2023-03-22Sanity check coff-sh and coff-mcore sym string offsetAlan Modra2-2/+13
* coff-mcore.c (coff_mcore_relocate_section): Sanity check sym string offset when setting up name for use by error messages. * coff-sh.c (sh_relocate_section): Likewise.
2023-03-22PR17910 sym string offset checkAlan Modra2-4/+2
As far as I can see the only place that sets obj_coff_strings without setting obj_coff_strings_len is pe_ILF_build_a_bfd. Fix that and we can simplify the sym string offset check. This is just a tidy. pe_ILF_build_a_bfd doesn't create bad symbols and _bfd_coff_read_string_table will always result in non-zero obj_coff_strings_len when obj_coff_strings is non-NULL. PR 17910 * coffgen.c (_bfd_coff_internal_syment_name): Always sanity check sym string offset. * peicode.h (pe_ILF_build_a_bfd): Set obj_coff_strings_len.
2023-03-22PE fake section for C_SECTION symsAlan Modra1-12/+2
It's an odd thing to have objdump -x show a different section table to objdump -h, but that can happen if swapping in symbols leads to creating sections. Setting SEC_LINKER_CREATED stops the display of these sections, so that you get shown what is in the object file. * peXXigen.c (_bfd_XXi_swap_sym_in): Set SEC_LINKER_CREATED on fake section created for C_SECTION syms. Don't zero asection fields that are already zero.
2023-03-22XCOFF: use bfd_coff_close_and_cleanupAlan Modra2-3/+3
Free memory on closing bfds. The COFF close_and_cleanup does more work than _bfd_generic_close_and_cleanup (defined as _bfd_archive_close_and_cleanup). * coff-rs6000.c (_bfd_xcoff_close_and_cleanup): Define as _bfd_coff_close_and_cleanup. * coff64-rs6000.c (rs6000_xcoff64_vec, rs6000_xcoff64_aix_vec): Use _bfd_coff_close_and_cleanup.
2023-03-21Automatic date update in version.inGDB Administrator1-1/+1
2023-03-20Reloc howto access broken for BPFCupertino Miranda1-1/+4
Forgot to change the logic to access the reloc howto from bpf_elf_relocate_section. Problem was introduced in previous BPF commit.
2023-03-20Automatic date update in version.inGDB Administrator1-1/+1
2023-03-19Enable vector register visibility in core file for AIX binutilsAditya Vidyadhar Kamath2-1/+36
This patch will enable vector register visibility when AIX FOLKS do core file analysis.
2023-03-19XCOFF archive sanity checkAlan Modra1-4/+10
XCOFF archive elements are in a linked list. Add a little more sanity checking. This of course doesn't stop the fuzzers finding a way to make a loop, but this check is cheap. * coff-rs6000.c (_bfd_xcoff_openr_next_archived_file): Sanity check that next element isn't pointing back to the header.