aboutsummaryrefslogtreecommitdiff
path: root/ld
AgeCommit message (Collapse)AuthorFilesLines
2021-10-25libctf, ld: handle nonrepresentable types betterNick Alcock3-0/+36
ctf_type_visit (used, among other things, by the type dumping code) was aborting when it saw a nonrepresentable type anywhere: even a single structure member with a nonrepresentable type caused an abort with ECTF_NONREPRESENTABLE. This is not useful behaviour, given that the abort comes from a type-resolution we are only doing in order to determine whether the type is a structure or union. We know nonrepresentable types can't be either, so handle that case and pass the nonrepresentable type down. (The added test verifies that the dumper now handles this case and prints nonrepresentable structure members as it already does nonrepresentable top-level types, rather than skipping the whole structure -- or, without the previous commit, skipping the whole types section.) ld/ChangeLog 2021-10-25 Nick Alcock <nick.alcock@oracle.com> * testsuite/ld-ctf/nonrepresentable-member.*: New test. libctf/ChangeLog 2021-10-25 Nick Alcock <nick.alcock@oracle.com> * ctf-types.c (ctf_type_rvisit): Handle nonrepresentable types.
2021-10-25binutils, ld: make objdump --ctf's parameter optionalNick Alcock32-31/+65
ld by default (and always, unless adjusted with a hand-rolled linker script) emits deduplicated CTF into the .ctf section. But viewing it needs you to explicitly tell objdump this: it doesn't default its argument, even though what you always end up typing is --ctf=.ctf. This is annoying, so make the argument optional. binutils/ChangeLog 2021-10-25 Nick Alcock <nick.alcock@oracle.com> * objdump.c (usage): --ctf now has an optional argument. (main): Adjust accordingly. (dump_ctf): Default it. * doc/ctf.options.texi: Adjust. ld/ChangeLog 2021-10-25 Nick Alcock <nick.alcock@oracle.com> * testsuite/ld-ctf/array.d: Change --ctf=.ctf to --ctf. * testsuite/ld-ctf/conflicting-cycle-1.B-1.d: Likewise. * testsuite/ld-ctf/conflicting-cycle-1.B-2.d: Likewise. * testsuite/ld-ctf/conflicting-cycle-1.parent.d: Likewise. * testsuite/ld-ctf/conflicting-cycle-2.A-1.d: Likewise. * testsuite/ld-ctf/conflicting-cycle-2.A-2.d: Likewise. * testsuite/ld-ctf/conflicting-cycle-2.parent.d: Likewise. * testsuite/ld-ctf/conflicting-cycle-3.C-1.d: Likewise. * testsuite/ld-ctf/conflicting-cycle-3.C-2.d: Likewise. * testsuite/ld-ctf/conflicting-cycle-3.parent.d: Likewise. * testsuite/ld-ctf/conflicting-enums.d: Likewise. * testsuite/ld-ctf/conflicting-typedefs.d: Likewise. * testsuite/ld-ctf/cross-tu-cyclic-conflicting.d: Likewise. * testsuite/ld-ctf/cross-tu-cyclic-nonconflicting.d: Likewise. * testsuite/ld-ctf/cross-tu-into-cycle.d: Likewise. * testsuite/ld-ctf/cross-tu-noncyclic.d: Likewise. * testsuite/ld-ctf/cycle-1.d: Likewise. * testsuite/ld-ctf/cycle-2.A.d: Likewise. * testsuite/ld-ctf/cycle-2.B.d: Likewise. * testsuite/ld-ctf/cycle-2.C.d: Likewise. * testsuite/ld-ctf/data-func-conflicted.d: Likewise. * testsuite/ld-ctf/diag-cttname-null.d: Likewise. * testsuite/ld-ctf/diag-cuname.d: Likewise. * testsuite/ld-ctf/diag-parlabel.d: Likewise. * testsuite/ld-ctf/enum-forward.d: Likewise. * testsuite/ld-ctf/enums.d: Likewise. * testsuite/ld-ctf/forward.d: Likewise. * testsuite/ld-ctf/function.d: Likewise. * testsuite/ld-ctf/nonrepresentable.d: Likewise. * testsuite/ld-ctf/slice.d: Likewise. * testsuite/ld-ctf/super-sub-cycles.d: Likewise.
2021-10-24LoongArch ld supportliuzhensong22-1/+1146
2021-10-22 Chenghua Xu <xuchenghua@loongson.cn> Zhensong Liu <liuzhensong@loongson.cn> Weinan Liu <liuweinan@loongson.cn> Xiaolin Tang <tangxiaolin@loongson.cn> ld/ * Makefile.am: Add LoongArch. * NEWS: Mention LoongArch support. * configure.tgt: Add LoongArch. * emulparams/elf32loongarch-defs.sh: New. * emulparams/elf32loongarch.sh: Likewise. * emulparams/elf64loongarch-defs.sh: Likewise. * emulparams/elf64loongarch.sh: Likewise. * emultempl/loongarchelf.em: Likewise. * Makefile.in: Regenerate. * po/BLD-POTFILES.in: Regenerate. ld/testsuite/ * ld-loongarch-elf/disas-jirl.d: New. * ld-loongarch-elf/disas-jirl.s: Likewise. * ld-loongarch-elf/jmp_op.d: Likewise. * ld-loongarch-elf/jmp_op.s: Likewise. * ld-loongarch-elf/ld-loongarch-elf.exp: Likewise. * ld-loongarch-elf/macro_op.d: Likewise. * ld-loongarch-elf/macro_op.s: Likewise. * ld-loongarch-elf/syscall-0.s: Likewise. * ld-loongarch-elf/syscall-1.s: Likewise. * ld-loongarch-elf/syscall.d: Likewise. * ld-srec/srec.exp: Add LoongArch. * ld-unique/pr21529.d: Likewise.
2021-10-22RISC-V: Added ld testcase for pcgp relaxation.Lewis Revill5-2/+36
Consider the the pcgp-relax-02 testcase, .text .globl _start _start: .L1: auipc a0, %pcrel_hi(data_a) .L2: auipc a1, %pcrel_hi(data_b) addi a0, a0, %pcrel_lo(.L1) addi a1, a1, %pcrel_lo(.L2) .data .word 0x0 .globl data_a data_a: .word 0x1 .section .rodata .globl data_b data_b: .word 0x2 If the first auipc is deleted, but we are still building the pcgp table (connect the high and low pcrel relocations), then there is an aliasing issue that we need some way to disambiguate which of the two symbols we are targeting. Therefore, Palmer thought of a way to use R_RISCV_DELETE to split this into two phases, so we could resolve the addresses before creating the ambiguities. This patch just add the ld testcase for the above case, in case we have changed something but break this. ld/ * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Renamed pcgp-relax to pcgp-relax-01, and added pcgp-relax-02. * testsuite/ld-riscv-elf/pcgp-relax-01.d: Renmaed from pcgp-relax. * testsuite/ld-riscv-elf/pcgp-relax-01.s: Likewise. * testsuite/ld-riscv-elf/pcgp-relax-02.d: New testcase. * testsuite/ld-riscv-elf/pcgp-relax-02.s: Likewise.
2021-10-22RISC-V: Don't separate pcgp relaxation to another relax pass.Lewis Revill7-38/+34
Commit abd20cb637008da9d32018b4b03973e119388a0a and ebdcad3fddf6ec21f6d4dcc702379a12718cf0c4 introduced additional complexity into the paths run by the RISC-V relaxation pass in order to resolve the issue of accurately keeping track of pcrel_hi and pcrel_lo pairs. The first commit split up relaxation of these relocs into a pass which occurred after other relaxations in order to prevent the situation where bytes were deleted in between a pcrel_lo/pcrel_hi pair, inhibiting our ability to find the corresponding pcrel_hi relocation from the address attached to the pcrel_lo. Since the relaxation was split into two passes the 'again' parameter could not be used to perform the entire relaxation process again and so the second commit added a way to restart ldelf_map_segments, thus starting the whole process again. Unfortunately this process could not account for the fact that we were not finished with the relaxation process so in some cases - such as the case where code would not fit in a memory region before the R_RISCV_ALIGN relocation was relaxed - sanity checks in generic code would fail. This patch fixes all three of these concerns by reverting back to a system of having only one target relax pass but updating entries in the table of pcrel_hi/pcrel_lo relocs every time any bytes are deleted. Thus we can keep track of the pairs accurately, and we can use the 'again' parameter to restart the entire target relax pass, behaving in the way that generic code expects. Unfortunately we must still have an additional pass to delay deleting AUIPC bytes to avoid ambiguity between pcrel_hi relocs stored in the table after deletion. This pass can only be run once so we may potentially miss out on relaxation opportunities but this is likely to be rare. https://sourceware.org/bugzilla/show_bug.cgi?id=28410 bfd/ * elfnn-riscv.c (riscv_elf_link_hash_table): Removed restart_relax. (riscv_elf_link_hash_table_create): Updated. (riscv_relax_delete_bytes): Moved after the riscv_update_pcgp_relocs. Update the pcgp_relocs table whenever bytes are deleted. (riscv_update_pcgp_relocs): Add function to update the section offset of pcrel_hi and pcrel_lo, and also update the symbol value of pcrel_hi. (_bfd_riscv_relax_call): Need to update the pcgp_relocs table when deleting codes. (_bfd_riscv_relax_lui): Likewise. (_bfd_riscv_relax_tls_le): Likewise. (_bfd_riscv_relax_align): Once we've handled an R_RISCV_ALIGN, we can't relax anything else, so set the sec->sec_flg0 to true. Besides, we don't need to update the pcgp_relocs table at this stage, so just pass NULL pointer as the pcgp_relocs table for riscv_relax_delete_bytes. (_bfd_riscv_relax_section): Use only one pass for all target relaxations. (_bfd_riscv_relax_delete): Likewise, we don't need to update the pcgp_relocs table at this stage, and don't need to set the `again' since restart_relax mechanism is abandoned. (bfd_elfNN_riscv_restart_relax_sections): Removed. (_bfd_riscv_relax_section): Updated. * elfxx-riscv.h (bfd_elf32_riscv_restart_relax_sections): Removed. (bfd_elf64_riscv_restart_relax_sections): Likewise. ld/ * emultempl/riscvelf.em: Revert restart_relax changes and set relax_pass to 3. * testsuite/ld-riscv-elf/align-small-region.d: New testcase. * testsuite/ld-riscv-elf/align-small-region.ld: Likewise. * testsuite/ld-riscv-elf/align-small-region.s: Likewise. * testsuite/ld-riscv-elf/restart-relax.d: Removed sine the restart_relax mechanism is abandoned. * testsuite/ld-riscv-elf/restart-relax.s: Likewise. * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.
2021-10-21-Waddress warning in ldelf.cAlan Modra1-1/+0
ldelf.c: In function 'ldelf_after_open': ldelf.c:1049:43: warning: the comparison will always evaluate as 'true' for the address of 'elf_header' will never be NULL [-Waddress] 1049 | && elf_tdata (abfd)->elf_header != NULL | ^~ In file included from ldelf.c:37: ../bfd/elf-bfd.h:1957:21: note: 'elf_header' declared here 1957 | Elf_Internal_Ehdr elf_header[1]; /* Actual data, but ref like ptr */ * ldelf.c (ldelf_after_open): Remove useless elf_header test.
2021-10-16ld: Adjust pr28158.rd for glibc 2.34H.J. Lu1-1/+1
Adjust pr28158.rd for glibc 2.34: $ readelf -W --dyn-syms tmpdir/pr28158 Symbol table '.dynsym' contains 4 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __libc_start_main@GLIBC_2.34 (2) 2: 0000000000000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__ 3: 000000000040401c 4 OBJECT GLOBAL DEFAULT 23 foo@VERS_2.0 (3) $ vs older glibc: $ readelf -W --dyn-syms tmpdir/pr28158 Symbol table '.dynsym' contains 4 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __libc_start_main@GLIBC_2.2.5 (3) 2: 0000000000000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__ 3: 000000000040401c 4 OBJECT GLOBAL DEFAULT 23 foo@VERS_2.0 (2) $ * testsuite/ld-elf/pr28158.rd: Adjusted for glibc 2.34.
2021-09-30ld: pru: Fix resource_table output section alignmentDimitar Dimitrov2-4/+8
My commit 261980de18b added alignment for the resource table symbol. But it is wrong. The Linux remoteproc driver loads and interprets the contents of the .resource_table ELF section, not of a table symbol. Without this patch, if the linker happens to output padding for symbol alignment, then the resource table contents as viewed by the kernel loader would "shift" and look corrupted. ld/ChangeLog: * scripttempl/pru.sc (.resource_table): Align the output section, not the first symbol. Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2021-09-27configure: regenerate in all projects that use libtool.m4Nick Alcock2-45/+50
(including sim/, which has no changelog.) bfd/ChangeLog 2021-09-27 Nick Alcock <nick.alcock@oracle.com> * configure: Regenerate. binutils/ChangeLog 2021-09-27 Nick Alcock <nick.alcock@oracle.com> * configure: Regenerate. gas/ChangeLog 2021-09-27 Nick Alcock <nick.alcock@oracle.com> * configure: Regenerate. gprof/ChangeLog 2021-09-27 Nick Alcock <nick.alcock@oracle.com> * configure: Regenerate. ld/ChangeLog 2021-09-27 Nick Alcock <nick.alcock@oracle.com> * configure: Regenerate. libctf/ChangeLog 2021-09-27 Nick Alcock <nick.alcock@oracle.com> * configure: Regenerate. * Makefile.in: Regenerate. opcodes/ChangeLog 2021-09-27 Nick Alcock <nick.alcock@oracle.com> * configure: Regenerate. zlib/ChangeLog 2021-09-27 Nick Alcock <nick.alcock@oracle.com> * configure: Regenerate.
2021-09-22Fix x86 "FAIL: TLS -fno-pic -shared"Alan Modra1-1/+1
Fix a typo in commit 5d0869d9872a * testsuite/ld-i386/tlsnopic.rd: Typo fix.
2021-09-21Change the linker's heuristic for computing the entry point for binaries so ↵Nick Clifton22-21/+58
that shared libraries default to an entry point of 0. * ldlang.c (lang_end): When computing the entry point, only try the start address of the entry section when creating an executable. * ld.texi (Entry point): Update description of heuristic used to choose the entry point. testsuite/ld-alpha/tlspic.rd: Update expected entry point address. testsuite/ld-arm/tls-gdesc-got.d: Likewise. testsuite/ld-i386/tlsnopic.rd: Likewise. testsuite/ld-ia64/tlspic.rd: Likewise. testsuite/ld-sparc/gotop32.rd: Likewise. testsuite/ld-sparc/gotop64.rd: Likewise. testsuite/ld-sparc/tlssunnopic32.rd: Likewise. testsuite/ld-sparc/tlssunnopic64.rd: Likewise. testsuite/ld-sparc/tlssunpic32.rd: Likewise. testsuite/ld-sparc/tlssunpic64.rd: Likewise. testsuite/ld-tic6x/shlib-1.rd: Likewise. testsuite/ld-tic6x/shlib-1b.rd: Likewise. testsuite/ld-tic6x/shlib-1r.rd: Likewise. testsuite/ld-tic6x/shlib-1rb.rd: Likewise. testsuite/ld-tic6x/shlib-noindex.rd: Likewise. testsuite/ld-x86-64/pr14207.d: Likewise. testsuite/ld-x86-64/tlsdesc.rd: Likewise. testsuite/ld-x86-64/tlspic.rd: Likewise. testsuite/ld-x86-64/tlspic2.rd: Likewise.
2021-09-20Move eelf_mipsel_haiki.c to ALL_64_EMULATION_SOURCESAlan Modra2-118/+132
--enable-targets=all on a 32-bit host results in a link failure with undefined references due to elfxx-mips.c not being compiled. This patch fixes that by putting eelf_mipsel_haiki.c in the correct EMULATION_SOURCES Makefile variable. I've also added a bunch of missing file dependencies and sorted a few things so that it's easier to verify dependencies are present. * Makfile.am: Add missing haiku dependencies, sort. (ALL_EMULATION_SOURCES): Sort. Move eelf_mipsel_haiku.c to.. (ALL_64_EMULATION_SOURCES): ..here. Sort. * Makfile.in: Regenerate.
2021-09-19elf: Don't set version info on unversioned symbolsH.J. Lu6-0/+71
Don't set version info on unversioned symbols when seeing a hidden versioned symbol after an unversioned definition and the default versioned symbol. bfd/ PR ld/28348 * elflink.c (elf_link_add_object_symbols): Don't set version info on unversioned symbols. ld/ PR ld/28348 * testsuite/ld-elf/pr28348.rd: New file. * testsuite/ld-elf/pr28348.t: Likewise. * testsuite/ld-elf/pr28348a.c: Likewise. * testsuite/ld-elf/pr28348b.c: Likewise. * testsuite/ld-elf/pr28348c.c: Likewise. * testsuite/ld-elf/shared.exp: Run PR ld/28348 tests.
2021-09-15arc: Fix got-weak linker testClaudiu Zissulescu2-3/+7
Use regular expressions to fix the got-weak linker test. ld/ * testsuite/got-weak.d: Update test. Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
2021-09-14arc: Fix potential invalid pointer access when fixing got symbols.Claudiu Zissulescu3-0/+24
When statically linking, it can arrive to an undefined weak symbol of which its value cannot be determined. However, we are having pieces of code which doesn't take this situation into account, leading to access a structure which may not be initialized. Fix this situation and add a test. bfd/ xxxx-xx-xx Cupertino Miranda <cmiranda@synopsys.com> Claudiu Zissulescu <claziss@synopsys.com> * arc-got.h (arc_static_sym_data): New structure. (get_static_sym_data): New function. (relocate_fix_got_relocs_for_got_info): Move the computation fo symbol value and section to above introduced function, and use this new function. ld/testsuite/ xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com> * ld-arc/got-weak.d: New file. * ld-arc/got-weak.s: Likewise. Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com> fix
2021-09-03ld testsuite tidyAlan Modra18-115/+95
Fixes a few issues: 1) If you use "-fsanitize=address,undefined" in CFLAGS, the Makefile attempt to trim off -fsanitize options left us with ",undefined". 2) ld_compile adds CFLAGS_FOR_TARGET itself, no need to pass it. 3) CFLAGS might be needed linking bootstrap test. * Makefile.am (CFLAGS_FOR_TARGET, CXXFLAGS_FOR_TARGET): Trim off all -fsanitize=*. * Makefile.in: Regenerate. * testsuite/ld-bootstrap/bootstrap.exp: Use CFLAGS when linking. * testsuite/ld-cdtest/cdtest.exp: Use CFLAGS_FOR_TARGET when linking. * testsuite/ld-auto-import/auto-import.exp: Don't pass CFLAGS_FOR_TARGET to ld_compile. * testsuite/ld-cygwin/exe-export.exp: Likewise. * testsuite/ld-elfvers/vers.exp: Likewise. * testsuite/ld-elfvsb/elfvsb.exp: Likewise. * testsuite/ld-elfweak/elfweak.exp: Likewise. * testsuite/ld-gc/gc.exp: Likewise. * testsuite/ld-pe/pe-compile.exp: Likewise. * testsuite/ld-pe/pe-run.exp: Likewise. * testsuite/ld-pe/pe-run2.exp: Likewise. * testsuite/ld-plugin/plugin.exp: Likewise. * testsuite/ld-shared/shared.exp: Likewise. * testsuite/ld-elfcomm/elfcomm.exp: Likewise, and don't allow nios2 testing to trash CFLAGS_FOR_TARGET. * testsuite/ld-scripts/crossref.exp: Don't pass options in CC_FOR_TARGET, do so in CFLAGS_FOR_TARGET instead. * testsuite/ld-srec/srec.exp: Likewise, and for CXX.
2021-09-03CC_FOR_TARGET et alAlan Modra31-321/+332
The top level Makefile, the ld Makefile and others, define CC_FOR_TARGET to be a compiler for the binutils target machine. This is the compiler that should be used for almost all tests with C source. There are _FOR_TARGET versions of CFLAGS, CXX, and CXXFLAGS too. This was all supposed to work with the testsuite .exp files using CC for the target compiler, and CC_FOR_HOST for the host compiler, with the makefiles passing CC=$CC_FOR_TARGET and CC_FOR_HOST=$CC to the runtest invocation. One exception to the rule of using CC_FOR_TARGET is the native-only ld bootstrap test, which uses the newly built ld to link a copy of itself. Since the files being linked were created with the host compiler, the boostrap test should use CC and CFLAGS, in case some host compiler option provides needed libraries automatically. However, bootstrap.exp used CC where it should have used CC_FOR_HOST. I set about fixing that problem, then decided that playing games in the makefiles with CC was a bad idea. Not only is it confusing, but other dejagnu code knows about CC_FOR_TARGET. See dejagnu/target.exp. So this patch gets rid of the makefile variable renaming and changes all the .exp files to use the correct _FOR_TARGET variables. CC_FOR_HOST and CFLAGS_FOR_HOST disappear. A followup patch will correct bootstrap.exp to use CFLAGS, and a number of other things I noticed. binutils/ * testsuite/lib/binutils-common.exp (run_dump_test): Use CC_FOR_TARGET and CFLAGS_FOR_TARGET rather than CC and CFLAGS. ld/ * Makefile.am (check-DEJAGNU): Don't set CC to CC_FOR_TARGET and similar. Pass variables with unchanged names. Don't set CC_FOR_HOST or CFLAGS_FOR_HOST. * Makefile.in: Regenerate. * testsuite/config/default.exp: Update default CC and similar. (compiler_supports, plug_opt): Use CC_FOR_TARGET. * testsuite/ld-cdtest/cdtest.exp: Replace all uses of CC with CC_FOR_TARGET, and similarly for CFLAGS, CXX and CXXFLAGS. * testsuite/ld-auto-import/auto-import.exp: Likewise. * testsuite/ld-cygwin/exe-export.exp: Likewise. * testsuite/ld-elf/dwarf.exp: Likewise. * testsuite/ld-elf/indirect.exp: Likewise. * testsuite/ld-elf/shared.exp: Likewise. * testsuite/ld-elfcomm/elfcomm.exp: Likewise. * testsuite/ld-elfvers/vers.exp: Likewise. * testsuite/ld-elfvsb/elfvsb.exp: Likewise. * testsuite/ld-elfweak/elfweak.exp: Likewise. * testsuite/ld-gc/gc.exp: Likewise. * testsuite/ld-ifunc/ifunc.exp: Likewise. * testsuite/ld-mn10300/mn10300.exp: Likewise. * testsuite/ld-pe/pe-compile.exp: Likewise. * testsuite/ld-pe/pe-run.exp: Likewise. * testsuite/ld-pe/pe-run2.exp: Likewise. * testsuite/ld-pie/pie.exp: Likewise. * testsuite/ld-plugin/lto.exp: Likewise. * testsuite/ld-plugin/plugin.exp: Likewise. * testsuite/ld-scripts/crossref.exp: Likewise. * testsuite/ld-selective/selective.exp: Likewise. * testsuite/ld-sh/sh.exp: Likewise. * testsuite/ld-shared/shared.exp: Likewise. * testsuite/ld-srec/srec.exp: Likewise. * testsuite/ld-undefined/undefined.exp: Likewise. * testsuite/ld-unique/unique.exp: Likewise. * testsuite/ld-x86-64/tls.exp: Likewise. * testsuite/lib/ld-lib.exp: Likewise. libctf/ * Makefile.am (check-DEJAGNU): Don't set CC to CC_FOR_TARGET. Pass CC and CC_FOR_TARGET. Don't set CC_FOR_HOST. * Makefile.in: Regenerate. * testsuite/config/default.exp: Update default CC and similar. * testsuite/lib/ctf-lib.exp (run_native_host_cmd): Use CC rather than CC_FOR_HOST. (run_lookup_test): Use CC_FOR_TARGET and CFLAGS_FOR_TARGET.
2021-09-03haiku tidyAlan Modra3-6/+12
--enable-maintainer-mode showed a number of files needing to be regenerated, and in the case of ld/Makefile.in that the file was regenerated by hand. Nothing to see here really. ld/ * Makefile.am (ALL_64_EMULATION_SOURCES): Sort haiku entry. * Makefile.in: Regenerate. * po/BLD-POTFILES.in: Regenerate. libctf/ * configure: Regenerate. zlib/ * configure: Regenerate.
2021-09-02Add support for the haiku operating system. These are the os support ↵Alexander von Gluck IV11-2/+132
patches we have been grooming and maintaining for quite a few years over on git.haiku-os.org. All of these architectures are working and most have been stable for quite some time.
2021-08-27ld: Change indirect symbol from IR to undefinedH.J. Lu7-0/+46
bfd/ PR ld/28264 * elflink.c (_bfd_elf_merge_symbol): Change indirect symbol from IR to undefined. ld/ PR ld/28264 * testsuite/ld-plugin/lto.exp: Run PR ld/28264 test. * testsuite/ld-plugin/pr28264-1.d: New file. * testsuite/ld-plugin/pr28264-2.d: Likewise. * testsuite/ld-plugin/pr28264-3.d: Likewise. * testsuite/ld-plugin/pr28264-4.d: Likewise. * testsuite/ld-plugin/pr28264.c: Likewise. * testsuite/ld-plugin/pr28264.ver: Likewise.
2021-08-24Real programmers don't configure gcc using --with-ldAlan Modra1-1/+5
* testsuite/lib/ld-lib.exp (run_host_cmd): Give a clue as to why gcc -B doesn't pick up the ld under test.
2021-08-18Another ld script backtrackAlan Modra1-0/+5
* ldgram.y (length_spec): Throw away look-ahead NAME.
2021-08-14ld script fill pattern expressionAlan Modra2-3/+27
It turns out we do need to backtrack when parsing after all. The fill_opt component in the section rule swiches to EXPRESSION and back to SCRIPT, and to find the end of an expression it is necessary to look ahead one token. * ldgram.y (section): Throw away lookahead NAME token. (overlay_section): Likewise. * testsuite/ld-elf/overlay.t: Add fill pattern on overlays. Test fill pattern before stupidly named normal sections too, and before /DISCARD/.
2021-08-13ld lexer tidy, possibly break the worldAlan Modra2-129/+140
This tidies the states in which ld lexer rules are enabled. This change will quite likely trip over issues similar to those mentioned in the new ldlex.l comments, so please test it out. * ldgram.y (wildcard_name): Remove now unnecessary components. * ldlex.l: Restrict many rules' states. Remove -l expression state rule. Comment on lookahead state madness and need for /DISCARD/ in expression state.
2021-08-13ld script lower-case absolute and sizeof_headersAlan Modra3-5/+4
I think these happened by accident, so let's see what breaks if they are removed. * ldlex.l: Remove lower case "absolute" and "sizeof_headers" in non-mri mode. * ld.texi: Remove sizeof_headers index. * testsuite/ld-mmix/mmohdr1.ld: Use SIZEOF_HEADERS.
2021-08-13tidy mri script externAlan Modra1-10/+5
MRI mode generally doesn't flip lexer states, so let's make MRI mode "extern" not do so either. * ldgram.y (extern_name_list): Don't change lex state here. (ifile_p1): Change state here on EXTERN instead.
2021-08-13Re: PR28217, Syntax error when memory region contains a hyphenAlan Modra1-10/+3
I discovered some more errors when tightening up the lexer rules. Just because we INCLUDE a file doesn't mean we've switched states. PR 28217 * ldgram.y (statement): Don't switch lexer state on INCLUDE. (mri_script_command, ifile_p1, memory_spec, section): Likewise.
2021-08-13PR28217, Syntax error when memory region contains a hyphenAlan Modra4-184/+171
The saga of commit 40726f16a8d7 continues. This attacks the problem of switching between SCRIPT and EXPRESSION state lexing by removing the need to do so for phdrs like ":text". Instead {WILDCHAR}* matching, the reason why ":text" lexed as one token, is restricted to within the braces of a section or overlay statement. The new WILD lexer state is switched at the non-optional brace tokens, so ldlex_backup is no longer needed. I've also removed the BOTH state, which doesn't seem to be needed any more. Besides rules involving error reporting, there was just one place where SCRIPT appeared without BOTH, the {WILDCHAR}* rule, three where BOTH appears without SCRIPT for tokens that only need EXPRESSION state, and two where BOTH appears alongside INPUT_LIST. (Since I'm editing the wild and filename rules, removing BOTH and adding WILD can also be seen as renaming the old BOTH state to SCRIPT and renaming the old SCRIPT state to WILD with a reduced scope.) As a followup, I'll look at removing EXPRESSION state from some lexer rules that no longer need it due to this cleanup. PR 28217 * ldgram.y (exp <ORIGIN, LENGTH>): Use paren_script_name. (section): Parse within braces of section in wild mode, and after brace back in script mode. Remove ldlex_backup call. Similarly for OVERLAY. (overlay_section): Similarly. (script_file): Replace ldlex_both with ldlex_script. * ldlex.h (ldlex_wild): Declare. (ldlex_both): Delete. * ldlex.l (BOTH): Delete. Remove state from all rules. (WILD): New state. Enable many tokens in this state. Enable filename match in SCRIPT mode. Enable WILDCHAR match in WILD state, disable in SCRIPT mode. (ldlex_wild): New function. * ldfile.c (ldfile_try_open_bfd): Replace ldlex_both call with ldlex_script.
2021-08-13ns32k configuryAlan Modra1-1/+1
Since ns32k-netbsd is as yet not removed, just marked obsolete, the target should still be accepted with --enable-obsolete. I also enabled ns32k-openbsd in ld since there doesn't seem to be a good reason why that target is not supported there but is elsewhere. bfd/ * config.bfd: Allow ns32k-netbsd. ld/ * configure.tgt: Allow ns32k-openbsd.
2021-08-11ld: Update the pass and fail strings of PR ld/28138 testH.J. Lu1-4/+4
PR ld/28138 * testsuite/ld-plugin/lto.exp: Update the pass and fail strings of PR ld/28138 test to indicate which part of the test passed and failed.
2021-08-11Deprecate a.out support for NetBSD targets.John Ericson5-458/+481
As discussed previously, a.out support is now quite deprecated, and in some cases removed, in both Binutils itself and NetBSD, so this legacy default makes little sense. `netbsdelf*` and `netbsdaout*` still work allowing the user to be explicit about there choice. Additionally, the configure script warns about the change as Nick Clifton requested. One possible concern was the status of NetBSD on NS32K, where only a.out was supported. But per [1] NetBSD has removed support, and if it were to come back, it would be with ELF. The binutils implementation is therefore marked obsolete, per the instructions in the last message. With that patch and this one applied, I have confirmed the following: --target=i686-unknown-netbsd --target=i686-unknown-netbsdelf builds completely --target=i686-unknown-netbsdaout properly fails because target is deprecated. --target=vax-unknown-netbsdaout builds completely except for gas, where the target is deprecated. [1]: https://mail-index.netbsd.org/tech-toolchain/2021/07/19/msg004025.html --- bfd/config.bfd | 43 +++++++++++++-------- bfd/configure.ac | 5 +-- binutils/testsuite/binutils-all/nm.exp | 2 +- binutils/testsuite/lib/binutils-common.exp | 7 +--- config/picflag.m4 | 4 +- gas/configure.tgt | 9 +++-- gas/testsuite/gas/arm/blx-bl-convert.d | 2 +- gas/testsuite/gas/arm/blx-local-thumb.d | 2 +- gas/testsuite/gas/sh/basic.exp | 2 +- gdb/configure.host | 34 +++++++---------- gdb/configure.tgt | 2 +- gdb/testsuite/gdb.asm/asm-source.exp | 6 +-- intl/configure | 2 +- ld/configure.tgt | 44 +++++++++++----------- ld/testsuite/ld-arm/arm-elf.exp | 4 +- ld/testsuite/ld-elf/elf.exp | 2 +- ld/testsuite/ld-elf/shared.exp | 4 +- libiberty/configure | 4 +-
2021-08-11PR28198, Support # as linker script comment markerAlan Modra1-8/+7
PR 28198 * ldlex.l: Combine rules for handling newline, whitespace and comments. Extend # comment handling to all states.
2021-08-11ldgram.y tidiesAlan Modra1-41/+55
I've been tripped up before thinking the "end" rule was the "END" token. Let's use a better name. The formatting changes are for consistency within rules, and making it a little easier to visually separate tokens from mid-rule actions. * ldgram.y (separator): Rename from "end". Update uses. (statement): Formatting. Move ';' match to beginning. (paren_script_name): Formatting. Simplify. (must_be_exp, section): Formatting.
2021-08-11Mention whitespace in script expressionsAlan Modra1-3/+5
Inside an output section statement, ld's parser can't tell whether a line .+=4; is an assignment to dot or a file named ".+=4". * ld.texi (expressions): Mention need for whitespace.
2021-08-05Re: elf: Treat undefined version as hiddenAlan Modra2-5/+5
Fix fallout in cris testsuite PR binutils/28158 * ld-cris/libdso-1c.d: Update for version display change. * ld-cris/libdso-15b.d: Likewise.
2021-08-04elf: Treat undefined version as hiddenH.J. Lu15-12/+62
Since undefined version can't be used to resolve any references without the original definition, treat it as hidden. bfd/ PR binutils/28158 * elf.c (_bfd_elf_get_symbol_version_string): Treat undefined version as hidden. ld/ PR binutils/28158 * testsuite/ld-elf/linux-x86.exp: Run PR binutils/28158 tests. * testsuite/ld-elf/pr28158-1.c: New file. * testsuite/ld-elf/pr28158-2.S: Likewise. * testsuite/ld-elf/pr28158.nd: Likewise. * testsuite/ld-elf/pr28158.rd: Likewise. * testsuite/ld-elf/pr28158.t: Likewise. * testsuite/ld-elfvers/vers2.dsym: Updated. * testsuite/ld-elfvers/vers3.dsym: Likewise. * testsuite/ld-elfvers/vers6.dsym: Likewise. * testsuite/ld-elfvers/vers19.dsym: Likewise. * testsuite/ld-elfvers/vers22.dsym: Likewise. * testsuite/ld-elfvers/vers23.dsym: Likewise. * testsuite/ld-elfvers/vers23d.dsym: Likewise. * testsuite/ld-elfvers/vers27d4.dsym: Likewise. * testsuite/ld-elfvers/vers28c.dsym: Likewise.
2021-08-04PR28155, Superfluous "the" in the man pageAlan Modra1-1/+1
PR 28155 * ld.texi (Options <runtime library name>): Correct grammar.
2021-07-28ld: Run tmpdir/pr28138 only for native buildH.J. Lu1-30/+34
* PR ld/28138 * testsuite/ld-plugin/lto.exp: Run tmpdir/pr28138 only for native build.
2021-07-28bfd: Close the file descriptor if there is no archive fdH.J. Lu9-0/+92
Close the file descriptor if there is no archive plugin file descriptor to avoid running out of file descriptors on thin archives with many archive members. bfd/ PR ld/28138 * plugin.c (bfd_plugin_close_file_descriptor): Close the file descriptor there is no archive plugin file descriptor. ld/ PR ld/28138 * testsuite/ld-plugin/lto.exp: Run ld/28138 tests. * testsuite/ld-plugin/pr28138.c: New file. * testsuite/ld-plugin/pr28138-1.c: Likewise. * testsuite/ld-plugin/pr28138-2.c: Likewise. * testsuite/ld-plugin/pr28138-3.c: Likewise. * testsuite/ld-plugin/pr28138-4.c: Likewise. * testsuite/ld-plugin/pr28138-5.c: Likewise. * testsuite/ld-plugin/pr28138-6.c: Likewise. * testsuite/ld-plugin/pr28138-7.c: Likewise.
2021-07-28ld: Report error reason when a library cannot be foundH.J. Lu1-2/+2
With "ulimit -n 20", report: ld: cannot find -lgcc: Too many open files instead of ld: cannot find -lgcc * ldfile.c (ldfile_open_file): Rport error reason when a library cannot be found.
2021-07-26Fix ld test case that assumes --enable-textrel-checkRoland McGrath2-1/+5
ld/ * testsuite/ld-x86-64/x86-64.exp (Build textrel-1): Use --warn-textrel.
2021-07-24Revert: PowerPC: Don't generate unused section symbolsAlan Modra15-23/+159
Blindly following x86 broke linux kernel builds. bfd/ * elf32-ppc.c (TARGET_KEEP_UNUSED_SECTION_SYMBOLS): Define as true. * elf64-ppc.c (TARGET_KEEP_UNUSED_SECTION_SYMBOLS): Likewise. gas/ * testsuite/gas/ppc/power4.d: Adjust for section sym change. * testsuite/gas/ppc/test1elf32.d: Likewise. * testsuite/gas/ppc/test1elf64.d: Likewise. ld/ * testsuite/ld-powerpc/tlsexe.r: Adjust for section sym change. * testsuite/ld-powerpc/tlsexe32.r: Likewise. * testsuite/ld-powerpc/tlsexe32no.r: Likewise. * testsuite/ld-powerpc/tlsexeno.r: Likewise. * testsuite/ld-powerpc/tlsexenors.r: Likewise. * testsuite/ld-powerpc/tlsexers.r: Likewise. * testsuite/ld-powerpc/tlsexetoc.r: Likewise. * testsuite/ld-powerpc/tlsexetocrs.r: Likewise. * testsuite/ld-powerpc/tlsget.d: Likewise. * testsuite/ld-powerpc/tlsget.wf: Likewise. * testsuite/ld-powerpc/tlsget2.d: Likewise. * testsuite/ld-powerpc/tlsget2.wf: Likewise. * testsuite/ld-powerpc/tlsso.r: Likewise. * testsuite/ld-powerpc/tlsso32.r: Likewise. * testsuite/ld-powerpc/tlstocso.r: Likewise.
2021-07-24Re: ld script expression parsingAlan Modra3-16/+32
Commit 40726f16a8d7 broke references to sections within ADDR(), and overlays with weird section names. * ldgram.y (paren_script_name): New rule. (exp): Use it for ALIGNOF, SIZEOF, ADDR, and LOADADDR. Similarly ensure script mode parsing for section name in SEGMENT_START. (overlay_section): Delete unnecessary ldlex_script call. Backup on a lookahead NAME parsed in expression mode. * testsuite/ld-elf/overlay.s: Add more sections. * testsuite/ld-elf/overlay.t: Test '-' in section names.
2021-07-21Allows linker scripts to set the SEC_READONLY flag.Luca Boccassi8-1/+34
* ld.texi: Document new output section type. * ldgram.y: Add new token. * ldlang.c: Handle the new flag. * ldlang.h: Add readonly_section to list of section types. * ldlex.l: Add a new identifier. * testsuite/ld-scripts/output-section-types.t: New example linker script. * testsuite/ld-scripts/output-section-types.d: Test driver. * testsyute/ld-scripts/script.exp: Run the new test.
2021-07-21Remove `netbsdpe` supportJohn Ericson2-5/+1
netbsdpe was deprecated in c2ce831330e10dab4703094491f80b6b9a5c2289. Since then, a release has passed (2.37), and it was marked obselete in 5c9cbf07f3f972ecffe13d858010b3179df17b32. Unless I am mistaken, that means we can now remove support altogether. All branches in the "active" code are remove, and the target is additionally marked as obsolete next to the other removed ones for libbfd and gdb. Per [1] from the NetBSD toolchain list, PE/COFF support was removed a decade ago. Furthermore, the sole mention of this target in the binutils commit history was in 2002. Together, I'm led to believe this target hasn't seen much attention in quite a while. [1]: https://mail-index.netbsd.org/tech-toolchain/2021/06/16/msg003996.html bfd/ * config.bfd: Remove netbsdpe entry. binutils/ * configure.ac: Remove netbsdpe entry. * testsuite/lib/binutils-common.exp (is_pecoff_format): Likewise. * configure: Regenerate. gas/ * configure.tgt: Remove netbsdpe entry. gdb/ * configure.tgt: Add netbsdpe to removed targets. ld/ * configure.tgt: Remove netbsdpe entry. * testsuite/ld-bootstrap/bootstrap.exp: Likewise.
2021-07-09ld/NEWS: Clarify -z [no]indirect-extern-accessH.J. Lu1-2/+2
-z [no]indirect-extern-access are only for x86 ELF linker.
2021-07-08elf: Limits 2 GNU_PROPERTY_1_NEEDED tests to Linux/x86H.J. Lu2-10/+2
Run property-1_needed-1b.d and property-1_needed-1c.d, which pass -z [no]indirect-extern-access to linker, only run for Linux/x86 targets. * testsuite/ld-elf/property-1_needed-1b.d: Only run for Linux/x86 targets. * testsuite/ld-elf/property-1_needed-1c.d: Likewise.
2021-07-08elf: Add GNU_PROPERTY_1_NEEDED checkH.J. Lu25-0/+907
If GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS is set on any input relocatable files: 1. Don't generate copy relocations. 2. Turn off extern_protected_data since it implies GNU_PROPERTY_NO_COPY_ON_PROTECTED. 3. Treate reference to protected symbols with indirect external access as local. 4. Set GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS on output. 5. When generating executable, clear this bit when there are non-GOT or non-PLT relocations in input relocatable files without the bit set. 6. Add -z [no]indirect-extern-access to control indirect external access. bfd/ * elf-bfd (elf_obj_tdata): Add has_indirect_extern_access. (elf_has_indirect_extern_access): New. * elf-properties.c (_bfd_elf_parse_gnu_properties): Set elf_has_indirect_extern_access and elf_has_no_copy_on_protected when seeing GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS. (elf_write_gnu_propertie): Add an argument to pass link_info. Set needed_1_p for GNU_PROPERTY_1_NEEDED in memory. (_bfd_elf_link_setup_gnu_properties): Handle GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS for -z indirect-extern-access. Set nocopyreloc to true and extern_protected_data to false for indirect external access. (_bfd_elf_convert_gnu_properties): Updated. * elf32-i386.c (elf_i386_check_relocs): Set non_got_ref_without_indirect_extern_access on legacy non-GOT or non-PLT references. * elf64-x86-64.c (elf_x86_64_check_relocs): Likewise. * elflink.c (_bfd_elf_symbol_refs_local_p): Return true for STV_PROTECTED symbols with indirect external access. * elfxx-x86.c (_bfd_x86_elf_adjust_dynamic_symbol): Clear indirect_extern_access for legacy non-GOT/non-PLT references. * elfxx-x86.h (elf_x86_link_hash_entry): Add non_got_ref_without_indirect_extern_access. include/ * bfdlink.h (bfd_link_info): Add indirect_extern_access and needed_1_p. Change nocopyreloc to int. ld/ * NEWS: Mention -z [no]indirect-extern-access * ld.texi: Document -z [no]indirect-extern-access * ldmain.c (main): Initialize link_info.indirect_extern_access to -1. * emulparams/extern_protected_data.sh: Support -z [no]indirect-extern-access. * testsuite/ld-elf/indirect-extern-access-1.rd: New file * testsuite/ld-elf/indirect-extern-access-1a.c: Likewise. * testsuite/ld-elf/indirect-extern-access-1b.c: Likewise. * testsuite/ld-elf/indirect-extern-access-2.rd: Likewise. * testsuite/ld-elf/indirect-extern-access-2a.c: Likewise. * testsuite/ld-elf/indirect-extern-access-2b.c: Likewise. * testsuite/ld-elf/indirect-extern-access-3.rd: Likewise. * testsuite/ld-elf/indirect-extern-access.S: Likewise. * testsuite/ld-elf/property-1_needed-1b.d: Likewise. * testsuite/ld-elf/property-1_needed-1c.d: Likewise. * testsuite/ld-x86-64/indirect-extern-access.rd: Likewise. * testsuite/ld-x86-64/protected-data-1.h: Likewise. * testsuite/ld-x86-64/protected-data-1a.c: Likewise. * testsuite/ld-x86-64/protected-data-1b.c: Likewise. * testsuite/ld-x86-64/protected-data-2a.S: Likewise. * testsuite/ld-x86-64/protected-data-2b.S: Likewise. * testsuite/ld-x86-64/protected-func-2a.S: Likewise. * testsuite/ld-x86-64/protected-func-2b.S: Likewise. * testsuite/ld-x86-64/protected-func-2c.c: Likewise. * testsuite/ld-elf/linux-x86.exp: Run test with GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS. * testsuite/ld-x86-64/x86-64.exp: Run tests for protected function and data with indirect external access.
2021-07-08elf: Add GNU_PROPERTY_1_NEEDEDH.J. Lu2-0/+32
Add GNU_PROPERTY_1_NEEDED: #define GNU_PROPERTY_1_NEEDED GNU_PROPERTY_UINT32_OR_LO to indicate the needed properties by the object file. Add GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS: #define GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS (1U << 0) to indicate that the object file requires canonical function pointers and cannot be used with copy relocation. binutils/ * readelf.c (decode_1_needed): New. (print_gnu_property_note): Handle GNU_PROPERTY_1_NEEDED. include/ * elf/common.h (GNU_PROPERTY_1_NEEDED): New. (GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS): Likewise. ld/ * testsuite/ld-elf/property-1_needed-1a.d: New file. * testsuite/ld-elf/property-1_needed-1.s: Likewise.
2021-07-08x86-64: Disallow PC reloc against weak undefined symbols in PIEH.J. Lu1-10/+1
Disallow PC relocations against weak undefined symbols in PIE since they can lead to non-zero address at run-time. bfd/ PR ld/21782 * elf64-x86-64.c (elf_x86_64_relocate_section): Disallow PC relocations against weak undefined symbols in PIE. ld/ PR ld/21782 * testsuite/ld-x86-64/pie3.d: Expect linker error.