summaryrefslogtreecommitdiff
path: root/ld
AgeCommit message (Collapse)Author
2022-07-22i386: Don't allow GOTOFF relocation against IFUNC symbol for PIClinaro-local/ci/tcwg_kernel/llvm-release-arm-stable-defconfiglinaro-local/ci/tcwg_kernel/llvm-release-arm-stable-allyesconfiglinaro-local/ci/tcwg_kernel/llvm-release-arm-stable-allnoconfiglinaro-local/ci/tcwg_kernel/llvm-release-arm-stable-allmodconfiglinaro-local/ci/tcwg_kernel/llvm-release-arm-norov-defconfiglinaro-local/ci/tcwg_kernel/llvm-release-arm-norov-allyesconfiglinaro-local/ci/tcwg_kernel/llvm-release-arm-norov-allnoconfiglinaro-local/ci/tcwg_kernel/llvm-release-arm-norov-allmodconfiglinaro-local/ci/tcwg_kernel/llvm-release-arm-next-defconfiglinaro-local/ci/tcwg_kernel/llvm-release-arm-next-allyesconfiglinaro-local/ci/tcwg_kernel/llvm-release-arm-next-allnoconfiglinaro-local/ci/tcwg_kernel/llvm-release-arm-next-allmodconfiglinaro-local/ci/tcwg_kernel/llvm-release-arm-mainline-defconfiglinaro-local/ci/tcwg_kernel/llvm-release-arm-mainline-allyesconfiglinaro-local/ci/tcwg_kernel/llvm-release-arm-mainline-allnoconfiglinaro-local/ci/tcwg_kernel/llvm-release-arm-mainline-allmodconfiglinaro-local/ci/tcwg_kernel/llvm-release-arm-lts-defconfiglinaro-local/ci/tcwg_kernel/llvm-release-arm-lts-allyesconfiglinaro-local/ci/tcwg_kernel/llvm-release-arm-lts-allnoconfiglinaro-local/ci/tcwg_kernel/llvm-release-arm-lts-allmodconfiglinaro-local/ci/tcwg_kernel/llvm-release-aarch64-stable-defconfiglinaro-local/ci/tcwg_kernel/llvm-release-aarch64-stable-allyesconfiglinaro-local/ci/tcwg_kernel/llvm-release-aarch64-stable-allnoconfiglinaro-local/ci/tcwg_kernel/llvm-release-aarch64-stable-allmodconfiglinaro-local/ci/tcwg_kernel/llvm-release-aarch64-norov-defconfiglinaro-local/ci/tcwg_kernel/llvm-release-aarch64-norov-allyesconfiglinaro-local/ci/tcwg_kernel/llvm-release-aarch64-norov-allnoconfiglinaro-local/ci/tcwg_kernel/llvm-release-aarch64-norov-allmodconfiglinaro-local/ci/tcwg_kernel/llvm-release-aarch64-next-defconfiglinaro-local/ci/tcwg_kernel/llvm-release-aarch64-next-allyesconfiglinaro-local/ci/tcwg_kernel/llvm-release-aarch64-next-allnoconfiglinaro-local/ci/tcwg_kernel/llvm-release-aarch64-next-allmodconfiglinaro-local/ci/tcwg_kernel/llvm-release-aarch64-mainline-defconfiglinaro-local/ci/tcwg_kernel/llvm-release-aarch64-mainline-allyesconfiglinaro-local/ci/tcwg_kernel/llvm-release-aarch64-mainline-allnoconfiglinaro-local/ci/tcwg_kernel/llvm-release-aarch64-mainline-allmodconfiglinaro-local/ci/tcwg_kernel/llvm-release-aarch64-lts-defconfiglinaro-local/ci/tcwg_kernel/llvm-release-aarch64-lts-allyesconfiglinaro-local/ci/tcwg_kernel/llvm-release-aarch64-lts-allnoconfiglinaro-local/ci/tcwg_kernel/llvm-release-aarch64-lts-allmodconfiglinaro-local/ci/tcwg_kernel/gnu-release-arm-stable-defconfiglinaro-local/ci/tcwg_kernel/gnu-release-arm-stable-allyesconfiglinaro-local/ci/tcwg_kernel/gnu-release-arm-stable-allnoconfiglinaro-local/ci/tcwg_kernel/gnu-release-arm-stable-allmodconfiglinaro-local/ci/tcwg_kernel/gnu-release-arm-norov-defconfiglinaro-local/ci/tcwg_kernel/gnu-release-arm-norov-allyesconfiglinaro-local/ci/tcwg_kernel/gnu-release-arm-norov-allnoconfiglinaro-local/ci/tcwg_kernel/gnu-release-arm-norov-allmodconfiglinaro-local/ci/tcwg_kernel/gnu-release-arm-next-defconfiglinaro-local/ci/tcwg_kernel/gnu-release-arm-next-allyesconfiglinaro-local/ci/tcwg_kernel/gnu-release-arm-next-allnoconfiglinaro-local/ci/tcwg_kernel/gnu-release-arm-next-allmodconfiglinaro-local/ci/tcwg_kernel/gnu-release-arm-mainline-defconfiglinaro-local/ci/tcwg_kernel/gnu-release-arm-mainline-allyesconfiglinaro-local/ci/tcwg_kernel/gnu-release-arm-mainline-allnoconfiglinaro-local/ci/tcwg_kernel/gnu-release-arm-mainline-allmodconfiglinaro-local/ci/tcwg_kernel/gnu-release-arm-lts-defconfiglinaro-local/ci/tcwg_kernel/gnu-release-arm-lts-allyesconfiglinaro-local/ci/tcwg_kernel/gnu-release-arm-lts-allnoconfiglinaro-local/ci/tcwg_kernel/gnu-release-arm-lts-allmodconfiglinaro-local/ci/tcwg_kernel/gnu-release-aarch64-stable-defconfiglinaro-local/ci/tcwg_kernel/gnu-release-aarch64-stable-allyesconfiglinaro-local/ci/tcwg_kernel/gnu-release-aarch64-stable-allnoconfiglinaro-local/ci/tcwg_kernel/gnu-release-aarch64-stable-allmodconfiglinaro-local/ci/tcwg_kernel/gnu-release-aarch64-norov-defconfiglinaro-local/ci/tcwg_kernel/gnu-release-aarch64-norov-allyesconfiglinaro-local/ci/tcwg_kernel/gnu-release-aarch64-norov-allnoconfiglinaro-local/ci/tcwg_kernel/gnu-release-aarch64-norov-allmodconfiglinaro-local/ci/tcwg_kernel/gnu-release-aarch64-next-defconfiglinaro-local/ci/tcwg_kernel/gnu-release-aarch64-next-allyesconfiglinaro-local/ci/tcwg_kernel/gnu-release-aarch64-next-allnoconfiglinaro-local/ci/tcwg_kernel/gnu-release-aarch64-next-allmodconfiglinaro-local/ci/tcwg_kernel/gnu-release-aarch64-mainline-defconfiglinaro-local/ci/tcwg_kernel/gnu-release-aarch64-mainline-allyesconfiglinaro-local/ci/tcwg_kernel/gnu-release-aarch64-mainline-allnoconfiglinaro-local/ci/tcwg_kernel/gnu-release-aarch64-mainline-allmodconfiglinaro-local/ci/tcwg_kernel/gnu-release-aarch64-lts-defconfiglinaro-local/ci/tcwg_kernel/gnu-release-aarch64-lts-allyesconfiglinaro-local/ci/tcwg_kernel/gnu-release-aarch64-lts-allnoconfiglinaro-local/ci/tcwg_kernel/gnu-release-aarch64-lts-allmodconfiglinaro-local/ci/tcwg_bmk_llvm_tx1/llvm-release-aarch64-spec2k6-O3_LTOlinaro-local/ci/tcwg_bmk_llvm_tx1/llvm-release-aarch64-spec2k6-O3linaro-local/ci/tcwg_bmk_llvm_tx1/llvm-release-aarch64-spec2k6-O2_LTOlinaro-local/ci/tcwg_bmk_llvm_tx1/llvm-release-aarch64-spec2k6-O2linaro-local/ci/tcwg_bmk_llvm_tk1/llvm-release-arm-spec2k6-O3_LTOlinaro-local/ci/tcwg_bmk_llvm_tk1/llvm-release-arm-spec2k6-O3linaro-local/ci/tcwg_bmk_llvm_sq/llvm-release-aarch64-spec2k6-Oslinaro-local/ci/tcwg_bmk_llvm_apm/llvm-release-arm-spec2k6-Oz_LTOlinaro-local/ci/tcwg_bmk_llvm_apm/llvm-release-arm-spec2k6-Ozlinaro-local/ci/tcwg_bmk_llvm_apm/llvm-release-arm-spec2k6-Os_LTOlinaro-local/ci/tcwg_bmk_llvm_apm/llvm-release-arm-spec2k6-Oslinaro-local/ci/tcwg_bmk_llvm_apm/llvm-release-aarch64-spec2k6-Ozlinaro-local/ci/tcwg_bmk_llvm_apm/llvm-release-aarch64-spec2k6-Os_LTOlinaro-local/ci/tcwg_bmk_gnu_tx1/gnu-release-aarch64-spec2k6-O3_LTOlinaro-local/ci/tcwg_bmk_gnu_tx1/gnu-release-aarch64-spec2k6-O3linaro-local/ci/tcwg_bmk_gnu_tx1/gnu-release-aarch64-spec2k6-O2_LTOlinaro-local/ci/tcwg_bmk_gnu_tx1/gnu-release-aarch64-spec2k6-O2linaro-local/ci/tcwg_bmk_gnu_tk1/gnu-release-arm-spec2k6-O3_LTOlinaro-local/ci/tcwg_bmk_gnu_tk1/gnu-release-arm-spec2k6-O3linaro-local/ci/tcwg_bmk_gnu_tk1/gnu-release-arm-spec2k6-O2_LTOlinaro-local/ci/tcwg_bmk_gnu_tk1/gnu-release-arm-spec2k6-O2linaro-local/ci/tcwg_bmk_gnu_sq/gnu-release-aarch64-spec2k6-Oslinaro-local/ci/tcwg_bmk_gnu_eabi_stm32/gnu_eabi-release-arm_eabi-coremark-Oslinaro-local/ci/tcwg_bmk_gnu_eabi_stm32/gnu_eabi-release-arm_eabi-coremark-O3_LTOlinaro-local/ci/tcwg_bmk_gnu_eabi_stm32/gnu_eabi-release-arm_eabi-coremark-O3linaro-local/ci/tcwg_bmk_gnu_apm/gnu-release-arm-spec2k6-Os_LTOlinaro-local/ci/tcwg_bmk_gnu_apm/gnu-release-arm-spec2k6-Oslinaro-local/ci/tcwg_bmk_gnu_apm/gnu-release-aarch64-spec2k6-OsH.J. Lu
We can't use the PLT entry as the function address for PIC since the PIC register may not be set up properly for indirect call. bfd/ PR ld/27998 * elf32-i386.c (elf_i386_relocate_section): Don't allow GOTOFF relocation against IFUNC symbol for PIC. ld/ PR ld/27998 * testsuite/ld-i386/pr27998a.d: Replace -shared with -e bar. * testsuite/ld-i386/pr27998b.d: Expect a linker error. * testsuite/ld-ifunc/ifunc-2-i386-now.d: Updated. * testsuite/ld-ifunc/ifunc-2-local-i386-now.d: Likewise. * testsuite/ld-ifunc/ifunc-2-i386.s: Replace @GOTOFF with @GOT. * testsuite/ld-ifunc/ifunc-2-local-i386.s: Likewise. (cherry picked from commit 8f29211c3f0a6335c17e0a90396c146facf6dba4)
2022-07-19x86: Properly check invalid relocation against protected symbollinaro-local/ci/tcwg_bmk_llvm_apm/llvm-release-aarch64-spec2k6-OsH.J. Lu
Only check invalid relocation against protected symbol defined in shared object. bfd/ PR ld/29377 * elf32-i386.c (elf_i386_scan_relocs): Only check invalid relocation against protected symbol defined in shared object. * elf64-x86-64.c (elf_x86_64_scan_relocs): Likewise. ld/ PR ld/29377 * testsuite/ld-elf/linux-x86.exp: Run PR ld/29377 tests. * testsuite/ld-elf/pr29377a.c: New file. * testsuite/ld-elf/pr29377b.c: Likewise. (cherry picked from commit bd0736124c20950ac353f01e5029b7cb5d8a7010) ld: Pass -nostdlib to compiler with -r Pass -nostdlib to compiler with -r to avoid unnecessary .o file and libraries. PR ld/29377 * testsuite/ld-elf/linux-x86.exp: Pass -nostdlib with -r. (cherry picked from commit 76e4fa70e79ee959c0e11eaacd4cf863291b1ddb)
2022-05-31x86: Properly handle IFUNC function pointer referenceH.J. Lu
Update commit 68c4956b1401de70173848a6bdf620cb42fa9358 Author: H.J. Lu <hjl.tools@gmail.com> Date: Tue Apr 26 09:08:54 2022 -0700 x86: Properly handle function pointer reference to properly handle IFUNC function pointer reference. Since IFUNC symbol value is only known at run-time, set pointer_equality_needed for IFUNC function pointer reference in PDE so that it will be resolved to its PLT entry directly. bfd/ PR ld/29216 * elf32-i386.c (elf_i386_scan_relocs): Set pointer_equality_needed for IFUNC function pointer reference in PDE. * elf64-x86-64.c (elf_x86_64_scan_relocs): Likewise. ld/ PR ld/29216 * testsuite/ld-ifunc/ifunc.exp: Run PR ld/29216 test. * testsuite/ld-ifunc/pr29216.c: New file. (cherry picked from commit 98a1627f19ca125476d5d58d9999c7a8d381f403)
2022-05-09Adjust ld ctf test for 32-bit targetsAlan Modra
powerpc-linux, and I suspect other 32-bit targets, report "aligned at 0x4" for this test. * testsuite/ld-ctf/nonrepresentable.d: Accept any alignment. (cherry picked from commit db120fb808dc24538e89b851d6dda1890aad5a1f)
2022-04-28x86: Properly handle function pointer referenceH.J. Lu
Update commit ebb191adac4ab45498dec0bfaac62f0a33537ba4 Author: H.J. Lu <hjl.tools@gmail.com> Date: Wed Feb 9 15:51:22 2022 -0800 x86: Disallow invalid relocation against protected symbol to allow function pointer reference and make sure that PLT entry isn't used for function reference due to function pointer reference. bfd/ PR ld/29087 * elf32-i386.c (elf_i386_scan_relocs): Don't set pointer_equality_needed nor check non-canonical reference for function pointer reference. * elf64-x86-64.c (elf_x86_64_scan_relocs): Likewise. ld/ PR ld/29087 * testsuite/ld-x86-64/x86-64.exp: Run PR ld/29087 tests. * testsuite/ld-x86-64/protected-func-3.c: New file. (cherry picked from commit 68c4956b1401de70173848a6bdf620cb42fa9358)
2022-03-24libctf, ld: diagnose corrupted CTF header cth_strlenNick Alcock
The last section in a CTF dict is the string table, at an offset represented by the cth_stroff header field. Its length is recorded in the next field, cth_strlen, and the two added together are taken as the size of the CTF dict. Upon opening a dict, we check that none of the header offsets exceed this size, and we check when uncompressing a compressed dict that the result of the uncompression is the same length: but CTF dicts need not be compressed, and short ones are not. Uncompressed dicts just use the ctf_size without checking it. This field is thankfully almost unused: it is mostly used when reserializing a dict, which can't be done to dicts read off disk since they're read-only. However, when opening an uncompressed foreign-endian dict we have to copy it out of the mmaped region it is stored in so we can endian- swap it, and we use ctf_size when doing that. When the cth_strlen is corrupt, this can overrun. Fix this by checking the ctf_size in all uncompressed cases, just as we already do in the compressed case. Add a new test. This came to light because various corrupted-CTF raw-asm tests had an incorrect cth_strlen: fix all of them so they produce the expected error again. libctf/ PR libctf/28933 * ctf-open.c (ctf_bufopen_internal): Always check uncompressed CTF dict sizes against the section size in case the cth_strlen is corrupt. ld/ PR libctf/28933 * testsuite/ld-ctf/diag-strlen-invalid.*: New test, derived from diag-cttname-invalid.s. * testsuite/ld-ctf/diag-cttname-invalid.s: Fix incorrect cth_strlen. * testsuite/ld-ctf/diag-cttname-null.s: Likewise. * testsuite/ld-ctf/diag-cuname.s: Likewise. * testsuite/ld-ctf/diag-parlabel.s: Likewise. * testsuite/ld-ctf/diag-parname.s: Likewise.
2022-02-17Updated Serbian translations for the bfd, gold, ld and opcodes directoriesNick Clifton
2022-02-16ld: Keep indirect symbol from IR if referenced from shared objectH.J. Lu
Don't change indirect symbol defined in IR to undefined if it is referenced from shared object. bfd/ PR ld/28879 * elflink.c (_bfd_elf_merge_symbol): Don't change indirect symbol defined in IR to undefined if it is referenced from shared object. ld/ PR ld/28879 * testsuite/ld-plugin/lto.exp: Run PR ld/28879 tests. * testsuite/ld-plugin/pr28879a.cc: New file. * testsuite/ld-plugin/pr28879b.cc: Likewise. (cherry picked from commit 20ea3acc727f3be6322dfbd881e506873535231d)
2022-02-15i386: Update I386_NEED_DYNAMIC_RELOC_TYPE_P for DT_TEXTRELH.J. Lu
Update I386_NEED_DYNAMIC_RELOC_TYPE_P to allow R_386_TLS_IE for relocation in read-only section. bfd/ PR ld/28894 * elfxx-x86.h (I386_NEED_DYNAMIC_RELOC_TYPE_P): Allow R_386_TLS_IE. ld/ PR ld/28894 * testsuite/ld-i386/i386.exp: Run pr28894. * testsuite/ld-i386/pr28894.d: New file. * testsuite/ld-i386/pr28894.s: Likewise. (cherry picked from commit 3319ba7a8d6a42ba071d691789bc184632399331)
2022-02-11x86: Disallow invalid relocation against protected symbolH.J. Lu
I am checking this into master and will backport it to 2.38 branch. H.J ---- On x86, GCC 12 supports -mno-direct-extern-access to enable canonical reference to protected function and disable copy relocation. With -mno-direct-extern-access, the canonical protected function symbols must be accessed via canonical reference and the protected data symbols in shared libraries are non-copyable. Under glibc 2.35, non-canonical reference to the canonical protected function will get the run-time error: ./y: internal_f: ./libfoo.so: non-canonical reference to canonical protected function and copy relocations against the non-copyable protected symbols will get the run-time error: ./x: internal_i: ./libfoo.so: copy relocation against non-copyable protected symbol Update x86 linker to disallow non-canonical reference to the canonical protected function: ld: plt.o: non-canonical reference to canonical protected function `internal_f' in libfoo.so ld: failed to set dynamic section sizes: bad value and copy relocation against the non-copyable protected symbol: ld: main.o: copy relocation against non-copyable protected symbol `internal_i' in libfoo.so at link-time. bfd/ PR ld/28875 * elf-properties.c (_bfd_elf_parse_gnu_properties): Don't skip shared libraries for GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS. * elf32-i386.c (elf_i386_scan_relocs): Disallow non-canonical reference to canonical protected function. * elf64-x86-64.c (elf_x86_64_scan_relocs): Likewise. * elfxx-x86.c (elf_x86_allocate_dynrelocs): Don't allow copy relocation against non-copyable protected symbol. ld/ PR ld/28875 * testsuite/ld-i386/i386.exp: Check non-canonical reference to canonical protected function and check copy relocation against non-copyable protected symbol. * testsuite/ld-i386/pr21997-1.err: New file. * testsuite/ld-i386/pr28875.err: Likewise. * testsuite/ld-i386/pr28875a.c: Likewise. * testsuite/ld-i386/pr28875b.c: Likewise. * testsuite/ld-x86-64/pr21997-1a.err: Updated. * testsuite/ld-x86-64/pr21997-1b.err: Likewise. * testsuite/ld-x86-64/pr28875-data.err: New file. * testsuite/ld-x86-64/pr28875-func.err: Likewise. * testsuite/ld-x86-64/x86-64.exp: Check non-canonical reference to canonical protected function and check copy relocation against non-copyable protected symbol. (cherry picked from commit ebb191adac4ab45498dec0bfaac62f0a33537ba4)
2022-02-09This is the 2.38 GNU Binutils releaseNick Clifton
2022-02-08RISC-V: Stop reporting warnings for mismatched extension versionsPalmer Dabbelt
The extension version checking logic is really just too complicated to encode into the linker, trying to do so causes more harm than good. This removes the checks and the associated tests, leaving the logic to keep the largest version of each extension linked into the target. bfd/ * elfnn-riscv.c (riscv_version_mismatch): Rename to riscv_update_subset_version, and stop reporting warnings on version mismatches. (riscv_merge_std_ext): Adjust calls to riscv_version_mismatch. (riscv_merge_multi_letter_ext): Likewise. ld/ * testsuite/ld-riscv-elf/attr-merge-arch-failed-01.d: Remove * testsuite/ld-riscv-elf/attr-merge-arch-failed-01a.s: Likewise * testsuite/ld-riscv-elf/attr-merge-arch-failed-01b.s: Likewise * testsuite/ld-riscv-elf/attr-merge-arch-failed-02.d: Likewise * testsuite/ld-riscv-elf/attr-merge-arch-failed-02a.s: Likewise * testsuite/ld-riscv-elf/attr-merge-arch-failed-02b.s: Likewise * testsuite/ld-riscv-elf/attr-merge-arch-failed-02c.s: Likewise * testsuite/ld-riscv-elf/attr-merge-arch-failed-02d.s: Likewise * testsuite/ld-riscv-elf/attr-merge-user-ext-01.d: New test. * testsuite/ld-riscv-elf/attr-merge-user-ext-rv32i21_m2p0.s: Likewise. * testsuite/ld-riscv-elf/attr-merge-user-ext-rv32i21_m2p1.s: Likewise. * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Remove obselete attr-merge-arch-failed-{01,02}, replace with attr-merge-user-ext-01. Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
2022-02-07i386: Allow GOT32 relocations against ABS symbolsH.J. Lu
GOT32 relocations are allowed since absolute value + addend is stored in the GOT slot. Tested on glibc 2.35 build with GCC 11.2 and -Os. bfd/ PR ld/28870 * elfxx-x86.c (_bfd_elf_x86_valid_reloc_p): Also allow GOT32 relocations. ld/ PR ld/28870 * testsuite/ld-i386/i386.exp: Run pr28870. * testsuite/ld-i386/pr28870.d: New file. * testsuite/ld-i386/pr28870.s: Likewise. (cherry picked from commit 30a954525f4e53a9cd50a1a8a6f201c7cf6595c7)
2022-02-07Revert "elf: Remove the 1-page gap before the RELRO segment"Alan Modra
This reverts commit 2f83249c13d86065b4c7cdb198ea871017b4bba1. PR ld/28743 * ldlang.c (lang_size_relro_segment_1): Revert 2022-01-10 changes. * testsuite/ld-i386/pr20830.d: Likewise. * testsuite/ld-s390/gotreloc_64-relro-1.dd: Likewise. * testsuite/ld-x86-64/pr14207.d: Likewise. * testsuite/ld-x86-64/pr18176.d: Likewise. * testsuite/ld-x86-64/pr20830a-now.d: Likewise. * testsuite/ld-x86-64/pr20830a.d: Likewise. * testsuite/ld-x86-64/pr20830b-now.d: Likewise. * testsuite/ld-x86-64/pr20830b.d: Likewise. * testsuite/ld-x86-64/pr21038a-now.d: Likewise. * testsuite/ld-x86-64/pr21038a.d: Likewise. * testsuite/ld-x86-64/pr21038b-now.d: Likewise. * testsuite/ld-x86-64/pr21038c-now.d: Likewise. * testsuite/ld-x86-64/pr21038c.d: Likewise.
2022-02-07Revert "ld: Rewrite lang_size_relro_segment_1"Alan Modra
This reverts commit 8b7c6a1fbab5b0efc6abb50cdb24aef3954ac018. PR ld/28743 PR ld/28819 * ldlang.c (lang_size_relro_segment_1): Revert 2022-01-14 change. testsuite/ld-x86-64/pr28743-1.d: Likewise. testsuite/ld-x86-64/pr28743-1.s: Likewise. testsuite/ld-x86-64/x86-64.exp: Likewise.
2022-02-05PR28827 testcaseAlan Modra
This testcase triggers a stub sizing error with the patches applied for PR28743 (commit 2f83249c13d8 and c804c6f98d34). PR 28827 * testsuite/ld-powerpc/pr28827-1.s, * testsuite/ld-powerpc/pr28827-1.d: New test. * testsuite/ld-powerpc/powerpc.exp: Run it. (cherry picked from commit 9810db10f726f47c8e878ca4b0b4b4f5e9c16a5d) (cherry picked from commit 0acf434a23768449cbb4b3732355f3f2febecaee)
2022-02-05Enable "size" as a dumpprog in ldAlan Modra
binutils/ * testsuite/lib/binutils-common.exp (run_dump_test): Reference global SIZE and SIZEFLAGS. ld/ * testsuite/config/default.exp: Define SIZE and SIZEFLAGS. (cherry picked from commit cd8adbf3017272877c7e196e2e326f888f207bd9)
2022-02-05PowerPC64 treatment of absolute symbolsAlan Modra
Supporting -static-pie on PowerPC64 requires the linker to properly treat SHN_ABS symbols for cases like glibc's _nl_current_LC_CTYPE_used absolute symbol. I've been slow to fix the linker on powerpc because there is some chance that this will break some shared libraries or PIEs. bfd/ * elf64-ppc.c (ppc64_elf_check_relocs): Consolidate local sym handling code. Don't count dyn relocs against non-dynamic absolute symbols. (dec_dynrel_count): Adjust to suit. (ppc64_elf_edit_toc): Don't remove entries for absolute symbols when pic. (allocate_got): Don't allocate space for got relocs against non-dynamic absolute syms. (ppc64_elf_layout_multitoc): Likewise. (got_and_plt_relr): Likewise. (ppc64_elf_size_dynamic_sections): Likewise for local got. (got_and_plt_relr_for_local_syms): Likewise. (ppc64_elf_size_stubs): Don't allocate space for relr either. (ppc64_elf_relocate_section): Don't write relocs against non-dynamic absolute symbols. Don't optimise got and toc code sequences loading absolute symbol entries. ld/ * testsuite/ld-powerpc/abs-reloc.s, * testsuite/ld-powerpc/abs-static.d, * testsuite/ld-powerpc/abs-static.r, * testsuite/ld-powerpc/abs-pie.d, * testsuite/ld-powerpc/abs-pie.r, * testsuite/ld-powerpc/abs-shared.d, * testsuite/ld-powerpc/abs-shared.r, * testsuite/ld-powerpc/abs-pie-relr.d, * testsuite/ld-powerpc/abs-pie-relr.r, * testsuite/ld-powerpc/abs-shared-relr.d, * testsuite/ld-powerpc/abs-shared-relr.r: New tests. * testsuite/ld-powerpc/powerpc.exp: Run them. (cherry picked from commit 3a3a4c1fe4ccb1914d29fbf8f5930d55aacec78f)
2022-02-05PR28827, assertion building LLVM 9 on powerpc64le-linux-gnuAlan Modra
The assertion is this one in ppc_build_one_stub BFD_ASSERT (stub_entry->stub_offset >= stub_entry->group->stub_sec->size); It is checking that a stub doesn't overwrite the tail of a previous stub, so not something trivial. Normally, stub sizing iterates until no stubs are added, detected by no change in stub section size. Iteration also continues if no stubs are added but one or more stubs increases in size, which also can be detected by a change in stub section size. But there is a pathological case where stub section sizing decreases one iteration then increases the next. To handle that situation, stub sizing also stops at more than STUB_SHRINK_ITER (20) iterations when calculated stub section size is smaller. The previous larger size is kept for the actual layout (so that building the stubs, which behaves like another iteration of stub sizing, will see the stub section sizes shrink). The problem with that stopping condition is that it assumes that stub sizing is only affected by addresses external to the stub sections, which isn't always true. This patch fixes that by also keeping larger individual stub_offset addresses past STUB_SHRINK_ITER. It also catches a further pathological case where one stub shrinks and another expands in such a way that no stub section size change is seen. PR 28827 * elf64-ppc.c (struct ppc_link_hash_table): Add stub_changed. (STUB_SHRINK_ITER): Move earlier in file. (ppc_size_one_stub): Detect any change in stub_offset. Keep larger one if past STUB_SHRINK_ITER. (ppc64_elf_size_stubs): Iterate on stub_changed too. (cherry picked from commit 0441f94fba61998b4bd18487aacf70a672df099c) Re: PR28827, assertion building LLVM 9 on powerpc64le-linux-gnu The previous patch wasn't quite correct. The size and padding depends on offset used in the current iteration, and if we're fudging the offset past STUB_SHRINK_ITER then we'd better use that offset. We can't have plt_stub_pad using stub_sec->size as the offset. PR 28827 * elf64-ppc.c (plt_stub_pad): Add stub_off param. (ppc_size_one_stub): Set up stub_offset to value used in this iteration before sizing the stub. Adjust plt_stub_pad calls. (cherry picked from commit 2405fc4016feadea33cb747d5654514f62b74ff4) Re: PR28827, assertion building LLVM 9 on powerpc64le-linux-gnu In trying to find a testcase for PR28827, I managed to hit a linker error in bfd_set_section_contents with a .branch_lt input section being too large for the output .branch_lt. bfd/ PR 28827 * elf64-ppc.c (ppc64_elf_size_stubs): Set section size to maxsize past STUB_SHRINK_ITER before laying out. Remove now unnecessary conditional setting of maxsize at start of loop. ld/ * testsuite/ld-powerpc/pr28827-2.d, * testsuite/ld-powerpc/pr28827-2.lnk, * testsuite/ld-powerpc/pr28827-2.s: New test. * testsuite/ld-powerpc/powerpc.exp: Run it. (cherry picked from commit 9ff8aa7d418bc508dbd429576b93e30ed9dc5891)
2022-02-05Update PowerPC64 symtocbase testAlan Modra
Using a symbol other than .TOC. with @tocbase is an extension to the ABI. It is never valid to use a symbol without a definition in the binary, and symbols on these expressions cannot be overridden. Make this explicit by using ".hidden" in the testcase. * testsuite/ld-powerpc/symtocbase-1.s: Align data. Make function entry symbol hidden. * testsuite/ld-powerpc/symtocbase-2.s: Likewise. * testsuite/ld-powerpc/symtocbase.d: Adjust expected output. (cherry picked from commit ef5684c2bdf4d4f9975650e3b7b8f9b0ff98abee)
2022-02-02Updated French translation for the ld/ and gold/ sub-directoriesNick Clifton
2022-01-26ld: Rewrite lang_size_relro_segment_1H.J. Lu
1. Compute the desired PT_GNU_RELRO segment base and find the maximum section alignment of sections starting from the PT_GNU_RELRO segment. 2. Find the first preceding load section. 3. Don't add the 1-page gap between the first preceding load section and the relro segment if the maximum page size >= the maximum section alignment. Align the PT_GNU_RELRO segment first. Subtract the maximum page size if therer is still a 1-page gap. PR ld/28743 PR ld/28819 * ldlang.c (lang_size_relro_segment_1): Rewrite. * testsuite/ld-x86-64/pr28743-1.d: New file. * testsuite/ld-x86-64/pr28743-1.s: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run pr28743-1. (cherry picked from commit c804c6f98d342c3d46f73d7a7ec6229d5ab1c9f3)
2022-01-24Update Bulgarian, French, Romaniam and Ukranian translation for some of the ↵Nick Clifton
sub-directories
2022-01-22Adjust default page sizes for haiku arm.Alexander von Gluck IV
* configure.tgt (arm-haiku): Fix typo. * emulparams/armelf_haiku.su (MAXPAGESIZE): Use the default value. (COMMONPAGESIZE): Likewise.
2022-01-22CHange version number to 2.37.90 and regenerate filesNick Clifton
2022-01-22Add markers for 2.38 branchNick Clifton
2022-01-21Updated Serbian translation for the ld sub-directoryNick Clifton
2022-01-21drop old unused stamp-h.in fileMike Frysinger
This was needed by ancient versions of automake, but that hasn't been the case since at least automake-1.5, so punt this from the tree.
2022-01-18lang_size_relro_segment tidyAlan Modra
This function has seen too many minimal change style edits. No functional changes in this patch. * ldlang.c (lang_size_relro_segment): Tidy.
2022-01-18PowerPC64 DT_RELRAlan Modra
PowerPC64 takes a more traditional approach to DT_RELR than x86. Count relative relocs in check_relocs, allocate space for them and output in the usual places but not doing so when enable_dt_relr. DT_RELR is sized in the existing ppc stub relaxation machinery, run via the linker's ldemul_after_allocation hook. DT_RELR is output in the same function that writes ppc stubs, run via ldemul_finish. This support should be considered experimental. bfd/ * elf64-ppc.c (struct ppc_local_dyn_relocs): Renamed from ppc_dyn_relocs. Add rel_count field. Update uses. (struct ppc_dyn_relocs): New. Replace all uses of elf_dyn_relocs. (struct ppc_link_hash_table): Add relr_alloc, relr_count and relr_addr. (ppc64_elf_copy_indirect_symbol): Merge rel_count. (ppc64_elf_check_relocs): Init rel_count for global and local syms. (dec_dynrel_count): Change r_info param to reloc pointer. Update all callers. Handle decrementing rel_count. (allocate_got): Don't allocate space for relative relocs when enable_dt_relr. (allocate_dynrelocs): Likewise. (ppc64_elf_size_dynamic_sections): Likewise. Handle srelrdyn. (ppc_build_one_stub): Don't emit relative relocs on .branch_lt. (compare_relr_address, append_relr_off): New functions. (got_and_plt_relr_for_local_syms, got_and_plt_relr): Likewise. (ppc64_elf_size_stubs): Size .relr.syn. (ppc64_elf_build_stubs): Emit .relr.dyn. (build_global_entry_stubs_and_plt): Don't output relative relocs when enable_dt_relr. (write_plt_relocs_for_local_syms): Likewise. (ppc64_elf_relocate_section): Likewise. binutils/ * testsuite/lib/binutils-common.exp (supports_dt_relr): Add powerpc64. ld/ * emulparams/elf64ppc.sh: Source dt-relr.sh. * testsuite/ld-elf/dt-relr-2b.d: Adjust for powerpc. * testsuite/ld-elf/dt-relr-2c.d: Likewise. * testsuite/ld-elf/dt-relr-2d.d: Likewise. * testsuite/ld-elf/dt-relr-2e.d: Likewise.
2022-01-18tweak __ehdr_start visibility and flags for check_relocsAlan Modra
bfd/ * elf-bfd.h (UNDEFWEAK_NO_DYNAMIC_RELOC): Test linker_def. ld/ * ldelf.c (ldelf_before_allocation): Don't force __ehdr_start local and hidden here.. * ldlang.c (lang_symbol_tweaks): ..do so here instead and set def_regular and linker_def for check_relocs. New function extracted from lang_process.
2022-01-17Update the config.guess and config.sub files from the master repository and ↵Nick Clifton
regenerate files.
2022-01-14PR28751 mbind2a / mbind2b regressions on powerpc*-linuxAlan Modra
include/ * bfdlink.h (struct bfd_link_info): Add commonpagesize_is_set. ld/ PR 28751 * emultempl/elf.em (handle_option): Set commonpagesize_is_set. * ldelf.c (ldelf_after_parse): Don't error when only one of -z max-page-size or -z common-page-size is given, correct the other value to make it sane. * testsuite/ld-elf/elf.exp (mbind2a, mbind2b): Do not pass -z max-page-size.
2022-01-13ld: Disable DT_RELR in some -z relro testsH.J. Lu
Disable DT_RELR in the following -z relro tests which don't expect DT_RELR in linker outputs. * testsuite/ld-i386/pr20830.d: Pass $NO_DT_RELR_LDFLAGS to ld. * testsuite/ld-x86-64/pr20830a-now.d: Likewise. * testsuite/ld-x86-64/pr20830a.d: Likewise. * testsuite/ld-x86-64/pr20830b-now.d: Likewise. * testsuite/ld-x86-64/pr20830b.d: Likewise. * testsuite/ld-x86-64/pr21038a-now.d: Likewise. * testsuite/ld-x86-64/pr21038a.d: Likewise. * testsuite/ld-x86-64/pr21038b-now.d: Likewise. * testsuite/ld-x86-64/pr21038c-now.d: Likewise. * testsuite/ld-x86-64/pr21038c.d: Likewise.
2022-01-13elf: Remove the 1-page gap before the RELRO segmentH.J. Lu
The existing RELRO scheme may leave a 1-page gap before the RELRO segment and align the end of the RELRO segment to the page size: [18] .eh_frame PROGBITS 408fa0 008fa0 005e80 00 A 0 0 8 [19] .init_array INIT_ARRAY 410de0 00fde0 000008 08 WA 0 0 8 [20] .fini_array FINI_ARRAY 410de8 00fde8 000008 08 WA 0 0 8 [21] .dynamic DYNAMIC 410df0 00fdf0 000200 10 WA 7 0 8 [22] .got PROGBITS 410ff0 00fff0 000010 08 WA 0 0 8 [23] .got.plt PROGBITS 411000 010000 000048 08 WA 0 0 8 Instead, we can remove the 1-page gap if the maximum page size >= the maximum section alignment: [18] .eh_frame PROGBITS 408fa0 008fa0 005e80 00 A 0 0 8 [19] .init_array INIT_ARRAY 40fde0 00fde0 000008 08 WA 0 0 8 [20] .fini_array FINI_ARRAY 40fde8 00fde8 000008 08 WA 0 0 8 [21] .dynamic DYNAMIC 40fdf0 00fdf0 000200 10 WA 7 0 8 [22] .got PROGBITS 40fff0 00fff0 000010 08 WA 0 0 8 [23] .got.plt PROGBITS 410000 010000 000048 08 WA 0 0 8 Because the end of the RELRO segment is always aligned to the page size and may not be moved, the RELRO segment size may be increased: [ 3] .dynstr STRTAB 000148 000148 000001 00 A 0 0 1 [ 4] .eh_frame PROGBITS 000150 000150 000000 00 A 0 0 8 [ 5] .init_array INIT_ARRAY 200150 000150 000010 08 WA 0 0 1 [ 6] .fini_array FINI_ARRAY 200160 000160 000010 08 WA 0 0 1 [ 7] .jcr PROGBITS 200170 000170 000008 00 WA 0 0 1 [ 8] .data.rel.ro PROGBITS 200180 000180 000020 00 WA 0 0 16 [ 9] .dynamic DYNAMIC 2001a0 0001a0 0001c0 10 WA 3 0 8 [10] .got PROGBITS 200360 000360 0002a8 00 WA 0 0 8 [11] .bss NOBITS 201000 000608 000840 00 WA 0 0 1 vs the old section layout: [ 3] .dynstr STRTAB 000148 000148 000001 00 A 0 0 1 [ 4] .eh_frame PROGBITS 000150 000150 000000 00 A 0 0 8 [ 5] .init_array INIT_ARRAY 200b48 000b48 000010 08 WA 0 0 1 [ 6] .fini_array FINI_ARRAY 200b58 000b58 000010 08 WA 0 0 1 [ 7] .jcr PROGBITS 200b68 000b68 000008 00 WA 0 0 1 [ 8] .data.rel.ro PROGBITS 200b70 000b70 000020 00 WA 0 0 16 [ 9] .dynamic DYNAMIC 200b90 000b90 0001c0 10 WA 3 0 8 [10] .got PROGBITS 200d50 000d50 0002a8 00 WA 0 0 8 [11] .bss NOBITS 201000 000ff8 000840 00 WA 0 0 1 But there is no 1-page gap. PR ld/28743 * ldlang.c (lang_size_relro_segment_1): Remove the 1-page gap before the RELRO segment if the maximum page size >= the maximum section alignment. * testsuite/ld-i386/pr20830.d: Adjusted. * testsuite/ld-s390/gotreloc_64-relro-1.dd: Likewise. * testsuite/ld-x86-64/pr14207.d: Likewise. * testsuite/ld-x86-64/pr18176.d: Likewise. * testsuite/ld-x86-64/pr20830a-now.d: Likewise. * testsuite/ld-x86-64/pr20830a.d: Likewise. * testsuite/ld-x86-64/pr20830b-now.d: Likewise. * testsuite/ld-x86-64/pr20830b.d: Likewise. * testsuite/ld-x86-64/pr21038a-now.d: Likewise. * testsuite/ld-x86-64/pr21038a.d: Likewise. * testsuite/ld-x86-64/pr21038b-now.d: Likewise. * testsuite/ld-x86-64/pr21038c-now.d: Likewise. * testsuite/ld-x86-64/pr21038c.d: Likewise.
2022-01-13dt-relr.exp --no-as-neededAlan Modra
Otherwise the very simple test may not be linked with libc.so at all, and thus correctly have no version reference added. Causing failure of the dt-relr-glibc-1b.so test. * testsuite/ld-elf/dt-relr.exp: Link with --no-as-needed.
2022-01-13Correct .relr.dyn nocombreloc scriptAlan Modra
* scripttempl/elf.sc (.relr.dyn): Don't depend on $COMBRELOC.
2022-01-13testsuite supports_dt_relrAlan Modra
Tidy, and fix "FAIL: Build dt-relr-glibc-1b.so" on all non-x86 linux targets. binutils/ * binutils-common.exp (supports_dt_relr): New proc. ld/ * testsuite/config/default.exp (DT_RELR_LDFLAGS, NO_DT_RELR_LDFLAGS), (DT_RELR_CC_LDFLAGS, NO_DT_RELR_CC_LDFLAGS): Use supports_dt_relr. * testsuite/ld-elf/dt-relr.exp: Don't run unless supports_dt_relr. * testsuite/ld-elf/dt-relr-1a.d: Likewise. * testsuite/ld-elf/dt-relr-1b.d: Likewise. * testsuite/ld-elf/dt-relr-1c.d: Likewise. * testsuite/ld-elf/dt-relr-2a.d: Likewise. * testsuite/ld-elf/dt-relr-2b.d: Likewise. * testsuite/ld-elf/dt-relr-2c.d: Likewise. * testsuite/ld-elf/dt-relr-2d.d: Likewise. * testsuite/ld-elf/dt-relr-2e.d: Likewise. * testsuite/ld-elf/dt-relr-2f.d: Likewise. * testsuite/ld-elf/dt-relr-2g.d: Likewise. * testsuite/ld-elf/dt-relr-2h.d: Likewise. * testsuite/ld-elf/dt-relr-3a.d: Likewise. * testsuite/ld-elf/dt-relr-3b.d: Likewise.
2022-01-13Don't use C++ comments in assemblyAlan Modra
It might seem to work, but only if '/' is a start of comment char. * testsuite/ld-elf/dt-relr-1.s: Use # for comment. * testsuite/ld-elf/dt-relr-2.s: Likewise. * testsuite/ld-elf/dt-relr-3.s: Likewise.
2022-01-12ld: Add glibc dependency for DT_RELRH.J. Lu
When DT_RELR is enabled, to avoid random run-time crash with older glibc binaries without DT_RELR support, add a GLIBC_ABI_DT_RELR symbol version, which is provided by glibc with DT_RELR support, dependency on the shared C library if it provides a GLIBC_2.XX symbol version. bfd/ * elflink.c (elf_link_add_dt_relr_dependency): New function. (bfd_elf_size_dynamic_sections): Call elf_link_add_dt_relr_dependency if DT_RELR is enabled. ld/ * ld.texi: Mention GLIBC_ABI_DT_RELR in -z pack-relative-relocs entry. * testsuite/ld-elf/dt-relr-glibc-1.c: New file. * testsuite/ld-elf/dt-relr-glibc-1a.rd: Likewise. * testsuite/ld-elf/dt-relr-glibc-1b.rd: Likewise. * testsuite/ld-elf/dt-relr.exp: Likewise.
2022-01-12ld: Add simple DT_RELR testsH.J. Lu
* testsuite/ld-elf/dt-relr-1.s: New file. * testsuite/ld-elf/dt-relr-1a.d: Likewise. * testsuite/ld-elf/dt-relr-1b.d: Likewise. * testsuite/ld-elf/dt-relr-1c.d: Likewise. * testsuite/ld-elf/dt-relr-2.s: Likewise. * testsuite/ld-elf/dt-relr-2a.d: Likewise. * testsuite/ld-elf/dt-relr-2b.d: Likewise. * testsuite/ld-elf/dt-relr-2c.d: Likewise. * testsuite/ld-elf/dt-relr-2d.d: Likewise. * testsuite/ld-elf/dt-relr-2e.d: Likewise. * testsuite/ld-elf/dt-relr-2f.d: Likewise. * testsuite/ld-elf/dt-relr-2g.d: Likewise. * testsuite/ld-elf/dt-relr-2h.d: Likewise. * testsuite/ld-elf/dt-relr-3.s: Likewise. * testsuite/ld-elf/dt-relr-3a.d: Likewise. * testsuite/ld-elf/dt-relr-3b.d: Likewise. * testsuite/ld-i386/dt-relr-1.s: Likewise. * testsuite/ld-i386/dt-relr-1a.d: Likewise. * testsuite/ld-i386/dt-relr-1b.d: Likewise. * testsuite/ld-x86-64/dt-relr-1a-x32.d: Likewise. * testsuite/ld-x86-64/dt-relr-1a.d: Likewise. * testsuite/ld-x86-64/dt-relr-1b-x32.d: Likewise. * testsuite/ld-x86-64/dt-relr-1b.d: Likewise. * testsuite/ld-x86-64/dt-relr-1.s: Likewise. * testsuite/ld-i386/i386.exp: Run dt-relr-1a and dt-relr-1b. * testsuite/ld-x86-64/x86-64.exp: Run dt-relr-1a, dt-relr-1a-x32 dt-relr-1b and dt-relr-1b-x32.
2022-01-12elf: Support DT_RELR in linker testsH.J. Lu
Allow eabling and disabling DT_RELR in linker tests. Disable DT_RELR in linker tests which don't expect DT_RELR in linker outputs. binutils/ * testsuite/lib/binutils-common.exp (run_dump_test): Make DT_RELR_LDFLAGS and NO_DT_RELR_LDFLAGS global. ld/ * testsuite/config/default.exp (DT_RELR_LDFLAGS): New. (DT_RELR_CC_LDFLAGS): Likewise. (NO_DT_RELR_LDFLAGS): Likewise. (NO_DT_RELR_CC_LDFLAGS): Likewise. * testsuite/ld-elf/shared.exp: Pass $NO_DT_RELR_LDFLAGS to linker for some tests. * testsuite/ld-i386/export-class.exp: Likewise. * testsuite/ld-i386/i386.exp: Likewise. * testsuite/ld-i386/ibt-plt-2a.d: Pass $NO_DT_RELR_LDFLAGS to linker. * testsuite/ld-i386/ibt-plt-3a.d: Likewise. * testsuite/ld-i386/ibt-plt-3c.d: Likewise. * testsuite/ld-i386/pr26869.d: Likewise. * testsuite/ld-i386/report-reloc-1.d: Likewise. * testsuite/ld-ifunc/ifunc-2-i386-now.d: Likewise. * testsuite/ld-ifunc/ifunc-2-local-i386-now.d: Likewise. * testsuite/ld-ifunc/ifunc-2-local-x86-64-now.d: Likewise. * testsuite/ld-ifunc/ifunc-2-x86-64-now.d: Likewise. * testsuite/ld-ifunc/pr17154-x86-64.d: Likewise. * testsuite/ld-x86-64/bnd-branch-1-now.d: Likewise. * testsuite/ld-x86-64/bnd-ifunc-1-now.d: Likewise. * testsuite/ld-x86-64/bnd-ifunc-2-now.d: Likewise. * testsuite/ld-x86-64/bnd-ifunc-2.d: Likewise. * testsuite/ld-x86-64/bnd-plt-1-now.d: Likewise. * testsuite/ld-x86-64/bnd-plt-1.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2a-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-2a.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3a-x32.d: Likewise. * testsuite/ld-x86-64/ibt-plt-3a.d: Likewise. * testsuite/ld-x86-64/ilp32-4.d: Likewise. * testsuite/ld-x86-64/load1c.d: Likewise. * testsuite/ld-x86-64/load1d.d: Likewise. * testsuite/ld-x86-64/pr13082-2b.d: Likewise. * testsuite/ld-x86-64/pr14207.d: Likewise. * testsuite/ld-x86-64/pr18176.d: Likewise. * testsuite/ld-x86-64/pr19162.d: Likewise. * testsuite/ld-x86-64/pr19636-2d.d: Likewise. * testsuite/ld-x86-64/pr19636-2l.d: Likewise. * testsuite/ld-x86-64/pr20253-1d.d: Likewise. * testsuite/ld-x86-64/pr20253-1f.d: Likewise. * testsuite/ld-x86-64/pr20253-1j.d: Likewise. * testsuite/ld-x86-64/pr20253-1l.d: Likewise. * testsuite/ld-x86-64/report-reloc-1-x32.d: Likewise. * testsuite/ld-x86-64/report-reloc-1.d: Likewise. * testsuite/ld-x86-64/export-class.exp (x86_64_export_class_test): Pass $NO_DT_RELR_LDFLAGS to linker. * testsuite/ld-x86-64/x86-64.exp: Pass $NO_DT_RELR_LDFLAGS to linker for some tests.
2022-01-12ld: Initial DT_RELR supportH.J. Lu
Add a -z pack-relative-relocs option to enable DT_RELR and create a relr.dyn section for DT_RELR. DT_RELR is implemented with the linker relaxation infrastructure, but it doesn't require the --relax option enabled. -z pack-relative-relocs implies -z combreloc. -z nocombreloc implies -z nopack-relative-relocs. -z pack-relative-relocs is chosen over the similar option in lld, --pack-dyn-relocs=relr, to implement a glibc binary lockout mechanism with a special glibc version symbol, to avoid random crashes of DT_RELR binaries with the existing glibc binaries. bfd/ * elf-bfd.h (elf_link_hash_table): Add srelrdyn. * elflink.c (_bfd_elf_link_create_dynamic_sections): Create a .relr.dyn section for DT_RELR. include/ * bfdlink.h (bfd_link_info): Add enable_dt_relr. ld/ * News: Mention -z pack-relative-relocs and -z nopack-relative-relocs. * ld.texi: Document -z pack-relative-relocs and -z nopack-relative-relocs. * ldelf.c (ldelf_after_parse): Disable DT_RELR if not building PIE nor shared library. Add 3 spare dynamic tags for DT_RELR, DT_RELRSZ and DT_RELRENT. * ldlang.c (lang_relax_sections): Also enable relaxation if DT_RELR is enabled. * emulparams/elf32_x86_64.sh: Source dt-relr.sh. * emulparams/elf_i386.sh: Likewise. * emulparams/elf_x86_64.sh: Likewise. * emulparams/dt-relr.sh: New file. * scripttempl/elf.sc: Support .relr.dyn.
2022-01-12elf: Pass need_layout to _bfd_elf_map_sections_to_segmentsH.J. Lu
On some targets, the DT_RELR section size can be computed only after all symbols addresses can be determined. Update ldelf_map_segments to pass need_layout to _bfd_elf_map_sections_to_segments which will size DT_RELR section and set need_layout to true if the DT_RELR section size is changed. bfd/ * elf-bfd.h (_bfd_elf_map_sections_to_segments): Add a bool pointer argument. * elf.c (_bfd_elf_map_sections_to_segments): Add a bool pointer argument to indicate if section layout needs update. (assign_file_positions_for_load_sections): Pass NULL to _bfd_elf_map_sections_to_segments. * elflink.c (_bfd_elf_strip_zero_sized_dynamic_sections): Pass NULL to _bfd_elf_map_sections_to_segments. ld/ * ldelfgen.c (ldelf_map_segments): Pass &need_layout to _bfd_elf_map_sections_to_segments.
2022-01-12ld: add hidden and internal visibility support for XCOFFClément Chigot
This patch adds a primary support for hidden and internal visibility in GNU linker for XCOFF format. The protected visibility isn't yet supported. PR 22085 bfd/ChangeLog: * xcofflink.c (xcoff_dynamic_definition_p): Add hidden and internal visibility support. (xcoff_link_add_symbols): Likewise. (xcoff_auto_export_p): Likewise. (bfd_xcoff_export_symbol): Likewise. (xcoff_link_input_bfd): Likewise. ld/ChangeLog: * testsuite/ld-vsb/main.c: Adapt for XCOFF. * testsuite/ld-vsb/sh1.c: Likewse. * testsuite/ld-vsb/vsb.exp: Likewise. * testsuite/ld-vsb/visibility-1-xcoff-32.d: New test. * testsuite/ld-vsb/visibility-1-xcoff-64.d: New test. * testsuite/ld-vsb/visibility-2-xcoff-32.d: New test. * testsuite/ld-vsb/visibility-2-xcoff-64.d: New test. * testsuite/ld-vsb/xcoffvsb.dat: New test.
2022-01-12ld/testsuite: prepare ld-elfvsb to support XCOFFClément Chigot
A following patch will add visibility support in ld for XCOFF. Thus, ld-elfvsb is renamed ld-vsb and a suffix is added to files targeting only ELF format. ld/ChangeLog: * testsuite/ld-elfvsb: rename as ld-vsb. * testsuite/ld-elfvsb/hidden0.d: move to ld-vsb and rename with suffix -elf.d. * testsuite/ld-elfvsb/hidden1.d: Likewise. * testsuite/ld-elfvsb/hidden2.d: Likewise. * testsuite/ld-elfvsb/internal0.d: Likewise. * testsuite/ld-elfvsb/internal1.d: Likewise. * testsuite/ld-elfvsb/protected0.d: Likewise. * testsuite/ld-elfvsb/protected1.d: Likewise.
2022-01-12gas: add visibility support for XCOFFClément Chigot
XCOFF assembly defines the visibility using an additional argument on several pseudo-ops: .globl, .weak, .extern and .comm. This implies that .globl and .weak syntax is different than the usual GNU syntax. But we want to provide compatibility with AIX assembler, especially because GCC is generating the visibility using this XCOFF syntax. PR 22085 bfd/ChangeLog: * coffcode.h (coff_write_object_contents): Change XCOFF header vstamp field to 2. * coffgen.c (coff_print_symbol): Increase the size for n_type. gas/ChangeLog: * config/tc-ppc.c (ppc_xcoff_get_visibility): New function. (ppc_globl): New function. (ppc_weak): New function. (ppc_comm): Add visibility field support. (ppc_extern): Likewise. * testsuite/gas/all/cofftag.d: Adjust to new n_type size providing by objdump. * testsuite/gas/ppc/test1xcoff32.d: Likewise. * testsuite/gas/ppc/aix.exp: Add new tests. * testsuite/gas/ppc/xcoff-visibility-1-32.d: New test. * testsuite/gas/ppc/xcoff-visibility-1-64.d: New test. * testsuite/gas/ppc/xcoff-visibility-1.s: New test. include/ChangeLog: * coff/internal.h (SYM_V_INTERNAL, SYM_V_HIDDEN, SYM_V_PROTECTED, SYM_V_EXPORTED, SYM_V_MASK): New defines. * coff/xcoff.h (struct xcoff_link_hash_entry): Add visibility field. ld/ChangeLog: * testsuite/ld-pe/pr19803.d: Adjust to new n_type size providing by objdump.
2022-01-12Set SEC_ELF_REVERSE_COPY earlierAlan Modra
For the sake of DT_RELR. bfd/ * elflink.c (elf_link_input_bfd): Don't set SEC_ELF_REVERSE_COPY here. Move sanity checks to reverse copying code. ld/ * ldlang.c (lang_add_section): Set SEC_ELF_REVERSE_COPY for .ctors/.dtors in .init_array/.fini_array.
2022-01-11Fix multiple problems with DLL generation.Martin Storsj
ld * pe-dll.c (make_head): Prefix the symbol name with the dll name. (make_tail, make_one, make_singleton_name_thunk): Likewise. (make_import_fixup_entry, make_runtime_pseudo_reloc): Likewise. (pe_create_runtime_relocator_reference): Likewise. (pe_dll_generate_implib): Set dll_symname_len. (pe_process_import_defs): Likewise. binutils * dlltool.c (main): If a prefix has not been provided, attempt to use a deterministic one based upon the dll name.
2022-01-10XCOFF: add support for TLS relocations on hidden symbolsClément Chigot
This patch adds support for TLS relocation targeting C_HIDEXT symbols. In gas, TLS relocations, except R_TLSM and R_TLMSL, must keep the value of their target symbol. In ld, it simply ensures that internal TLS symbols are added to the linker hash table for xcoff_reloc_type_tls. It also improves the tests made by both. bfd/ChangeLog: * coff-rs6000.c (xcoff_howto_table): Fix name of R_TLSML. (xcoff_reloc_type_tls): Replace the error when h is NULL by an assert. (xcoff_complain_overflow_unsigned_func): Adjust comments. * coff64-rs6000.c (xcoff64_howto_table): Fix name of R_TLSML. * xcofflink.c (xcoff_link_add_symbols_to_hash_table): New function. (xcoff_link_add_symbols): Add C_HIDEXT TLS symbols to the linker hash table. gas/ChangeLog: * config/tc-ppc.c (md_apply_fix): Enable support for TLS relocation over internal symbols. * testsuite/gas/ppc/aix.exp: Replace xcoff-tlms by xcoff-tls. * testsuite/gas/ppc/xcoff-tlsm-32.d: Removed. * testsuite/gas/ppc/xcoff-tlsm-64.d: Removed. * testsuite/gas/ppc/xcoff-tlsm.s: Removed. * testsuite/gas/ppc/xcoff-tls-32.d: New test. * testsuite/gas/ppc/xcoff-tls-64.d: New test. * testsuite/gas/ppc/xcoff-tls.s: New test. ld/ChangeLog: * testsuite/ld-powerpc/aix52.exp: Improve aix-tls-reloc test. * testsuite/ld-powerpc/aix-tls-reloc.s: Likewise. * testsuite/ld-powerpc/aix-tls-reloc-32.d: Removed. * testsuite/ld-powerpc/aix-tls-reloc-64.d: Removed. * testsuite/ld-powerpc/aix-tls-reloc-32.dd: New test. * testsuite/ld-powerpc/aix-tls-reloc-32.dt: New test. * testsuite/ld-powerpc/aix-tls-reloc-64.dd: New test. * testsuite/ld-powerpc/aix-tls-reloc-64.dt: New test.