Do not enable '-z separate code' by default - allow packages to choose to do it. Add fix for discarded section counting for AArcch64 DT_RELR relocs.
Resolves: RHEL-42765
This commit is contained in:
parent
52b082c2f5
commit
b2f9df48ed
@ -3271,3 +3271,167 @@ diff -rupN binutils,orig/ld/testsuite/ld-x86-64/dt-relr-1b.d binutils-2.41/ld/te
|
||||
#...
|
||||
Symbol table '.symtab' contains [0-9]+ entries:
|
||||
+Num: +Value +Size Type +Bind +Vis +Ndx Name
|
||||
diff -rup binutils.orig/bfd/elfnn-aarch64.c binutils-2.41/bfd/elfnn-aarch64.c
|
||||
--- binutils.orig/bfd/elfnn-aarch64.c 2024-06-17 16:39:30.773928699 +0100
|
||||
+++ binutils-2.41/bfd/elfnn-aarch64.c 2024-06-17 16:40:31.696076282 +0100
|
||||
@@ -9330,6 +9330,8 @@ record_relr_non_got_relocs (bfd *input_b
|
||||
return true;
|
||||
if (sec->alignment_power == 0)
|
||||
return true;
|
||||
+ if (discarded_section (sec))
|
||||
+ return true;
|
||||
sreloc = elf_section_data (sec)->sreloc;
|
||||
if (sreloc == NULL)
|
||||
return true;
|
||||
@@ -9604,8 +9606,7 @@ elfNN_aarch64_size_dynamic_sections (bfd
|
||||
for (p = (struct elf_dyn_relocs *)
|
||||
(elf_section_data (s)->local_dynrel); p != NULL; p = p->next)
|
||||
{
|
||||
- if (!bfd_is_abs_section (p->sec)
|
||||
- && bfd_is_abs_section (p->sec->output_section))
|
||||
+ if (discarded_section (p->sec))
|
||||
{
|
||||
/* Input section has been discarded, either because
|
||||
it is a copy of a linkonce section or due to
|
||||
Only in binutils-2.41/bfd: elfnn-aarch64.c.orig
|
||||
diff -rup binutils.orig/ld/testsuite/ld-aarch64/aarch64-elf.exp binutils-2.41/ld/testsuite/ld-aarch64/aarch64-elf.exp
|
||||
--- binutils.orig/ld/testsuite/ld-aarch64/aarch64-elf.exp 2024-06-17 16:39:33.555935438 +0100
|
||||
+++ binutils-2.41/ld/testsuite/ld-aarch64/aarch64-elf.exp 2024-06-17 16:40:40.933098658 +0100
|
||||
@@ -474,6 +474,8 @@ run_dump_test_lp64 "relr-got-pie"
|
||||
run_dump_test_lp64 "relr-got-shared"
|
||||
run_dump_test_lp64 "relr-text-pie"
|
||||
run_dump_test_lp64 "relr-text-shared"
|
||||
+run_dump_test_lp64 "relr-discard-pie"
|
||||
+run_dump_test_lp64 "relr-discard-shared"
|
||||
|
||||
if { ![skip_sframe_tests] } {
|
||||
run_dump_test "sframe-simple-1"
|
||||
Only in binutils-2.41/ld/testsuite/ld-aarch64: aarch64-elf.exp.orig
|
||||
Only in binutils-2.41/ld/testsuite/ld-aarch64: relr-discard-pie.d
|
||||
Only in binutils-2.41/ld/testsuite/ld-aarch64: relr-discard-shared.d
|
||||
Only in binutils-2.41/ld/testsuite/ld-aarch64: relr-discard.ld
|
||||
Only in binutils-2.41/ld/testsuite/ld-aarch64: relr-discard.s
|
||||
--- /dev/null 2024-06-17 07:14:45.537242699 +0100
|
||||
+++ binutils-2.41/ld/testsuite/ld-aarch64/relr-discard-pie.d 2024-06-17 16:40:40.934098660 +0100
|
||||
@@ -0,0 +1,18 @@
|
||||
+#source: relr-discard.s
|
||||
+#ld: -pie --no-apply-dynamic-relocs -z pack-relative-relocs -T relr-discard.ld
|
||||
+#readelf: -rW
|
||||
+
|
||||
+# Note: There are unnecessary GOT entries and *_NONE relocations
|
||||
+# for those GOT entries and discarded locations, this is bug 31850.
|
||||
+
|
||||
+Relocation section '\.rela\.dyn' at offset 0x1.* contains 4 entries:
|
||||
+ Offset Info Type Symbol's Value Symbol's Name \+ Addend
|
||||
+0000000000000000 0000000000000000 R_AARCH64_NONE 0
|
||||
+0000000000000000 0000000000000000 R_AARCH64_NONE 0
|
||||
+0000000000000000 0000000000000000 R_AARCH64_NONE 0
|
||||
+0000000000000000 0000000000000000 R_AARCH64_NONE 0
|
||||
+
|
||||
+Relocation section '\.relr\.dyn' at offset 0x1.* contains 2 entries which relocate 2 locations:
|
||||
+Index: Entry Address Symbolic Address
|
||||
+0000: 0000000000020008 0000000000020008 _GLOBAL_OFFSET_TABLE_ \+ 0x8
|
||||
+0001: 0000000000000003 0000000000020010 _GLOBAL_OFFSET_TABLE_ \+ 0x10
|
||||
--- /dev/null 2024-06-17 07:14:45.537242699 +0100
|
||||
+++ binutils-2.41/ld/testsuite/ld-aarch64/relr-discard-shared.d 2024-06-17 16:40:40.934098660 +0100
|
||||
@@ -0,0 +1,18 @@
|
||||
+#source: relr-discard.s
|
||||
+#ld: -shared --no-apply-dynamic-relocs -z pack-relative-relocs -T relr-discard.ld
|
||||
+#readelf: -rW
|
||||
+
|
||||
+# Note: There are unnecessary GOT entries and *_NONE relocations
|
||||
+# for those GOT entries and discarded locations, this is bug 31850.
|
||||
+
|
||||
+Relocation section '\.rela\.dyn' at offset 0x1.* contains 5 entries:
|
||||
+ Offset Info Type Symbol's Value Symbol's Name \+ Addend
|
||||
+0000000000000000 0000000000000000 R_AARCH64_NONE 0
|
||||
+0000000000000000 0000000000000000 R_AARCH64_NONE 0
|
||||
+0000000000000000 0000000000000000 R_AARCH64_NONE 0
|
||||
+0000000000000000 0000000000000000 R_AARCH64_NONE 0
|
||||
+0000000000020010 .* R_AARCH64_GLOB_DAT 000000000001000c sym_global \+ 0
|
||||
+
|
||||
+Relocation section '\.relr\.dyn' at offset 0x1.* contains 1 entry which relocates 1 location:
|
||||
+Index: Entry Address Symbolic Address
|
||||
+0000: 0000000000020008 0000000000020008 _GLOBAL_OFFSET_TABLE_ \+ 0x8
|
||||
--- /dev/null 2024-06-17 07:14:45.537242699 +0100
|
||||
+++ binutils-2.41/ld/testsuite/ld-aarch64/relr-discard.ld 2024-06-17 16:40:40.935098663 +0100
|
||||
@@ -0,0 +1,13 @@
|
||||
+OUTPUT_ARCH(aarch64)
|
||||
+ENTRY(_start)
|
||||
+SECTIONS
|
||||
+{
|
||||
+ /DISCARD/ : { *(.discard.*) }
|
||||
+
|
||||
+ . = 0x10000;
|
||||
+ .text : { *(.text) }
|
||||
+ . = 0x20000;
|
||||
+ .got : { *(.got) *(.got.plt)}
|
||||
+ . = 0x30000;
|
||||
+ .data : { *(.data) *(.data.*) }
|
||||
+}
|
||||
--- /dev/null 2024-06-17 07:14:45.537242699 +0100
|
||||
+++ binutils-2.41/ld/testsuite/ld-aarch64/relr-discard.s 2024-06-17 16:40:40.935098663 +0100
|
||||
@@ -0,0 +1,63 @@
|
||||
+// Test DT_RELR with references in discarded sections.
|
||||
+
|
||||
+.text
|
||||
+.p2align 3
|
||||
+.global _start
|
||||
+_start:
|
||||
+ nop
|
||||
+
|
||||
+sym_local:
|
||||
+ nop
|
||||
+
|
||||
+.global sym_hidden
|
||||
+.hidden sym_hidden
|
||||
+sym_hidden:
|
||||
+ nop
|
||||
+
|
||||
+.global sym_global
|
||||
+sym_global:
|
||||
+ nop
|
||||
+
|
||||
+.global sym_global_abs
|
||||
+.set sym_global_abs, 42
|
||||
+
|
||||
+.global sym_weak_undef
|
||||
+.weak sym_weak_undef
|
||||
+
|
||||
+.section .discard.got_local,"ax"
|
||||
+ adrp x0, :got:sym_local
|
||||
+ ldr x0, [x0, :got_lo12:sym_local]
|
||||
+
|
||||
+.section .discard.got_global,"ax"
|
||||
+ adrp x0, :got:sym_global
|
||||
+ ldr x0, [x0, :got_lo12:sym_global]
|
||||
+
|
||||
+.section .discard.local,"a"
|
||||
+.p2align 1
|
||||
+discard_local:
|
||||
+.xword sym_local
|
||||
+
|
||||
+.section .discard.hidden,"a"
|
||||
+.p2align 1
|
||||
+discard_hidden:
|
||||
+.xword sym_hidden
|
||||
+
|
||||
+.section .discard.global,"a"
|
||||
+.p2align 1
|
||||
+discard_global:
|
||||
+.xword sym_global
|
||||
+
|
||||
+.section .discard.global_abs,"a"
|
||||
+.p2align 1
|
||||
+discard_global_abs:
|
||||
+.xword sym_global_abs
|
||||
+
|
||||
+.section .discard.weak_undef,"a"
|
||||
+.p2align 1
|
||||
+discard_weak_undef:
|
||||
+.xword sym_weak_undef
|
||||
+
|
||||
+.section .discard._DYNAMIC,"a"
|
||||
+.p2align 1
|
||||
+discard_DYNAMIC:
|
||||
+.xword _DYNAMIC
|
||||
|
@ -2,7 +2,7 @@
|
||||
Summary: A GNU collection of binary utilities
|
||||
Name: binutils%{?_with_debug:-debug}
|
||||
Version: 2.41
|
||||
Release: 42%{?dist}
|
||||
Release: 43%{?dist}
|
||||
License: GPL-3.0-or-later AND (GPL-3.0-or-later WITH Bison-exception-2.2) AND (LGPL-2.0-or-later WITH GCC-exception-2.0) AND BSD-3-Clause AND GFDL-1.3-or-later AND GPL-2.0-or-later AND LGPL-2.1-or-later AND LGPL-2.0-or-later
|
||||
URL: https://sourceware.org/binutils
|
||||
|
||||
@ -78,7 +78,7 @@ URL: https://sourceware.org/binutils
|
||||
|
||||
# Enable the use of separate code and data segments for all architectures,
|
||||
# not just x86/x86_64.
|
||||
%define enable_separate_code 1
|
||||
%define enable_separate_code 0
|
||||
|
||||
#----End of Configure Options------------------------------------------------
|
||||
|
||||
@ -1383,6 +1383,10 @@ exit 0
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
%changelog
|
||||
* Mon Jun 17 2024 Nick Clifton <nickc@redhat.com> - 2.41-43
|
||||
- Do not enable '-z separate code' by default - allow packages to choose to do it.
|
||||
- Add fix for discarded section counting for AArcch64 DT_RELR relocs. (RHEL-42765)
|
||||
|
||||
* Thu Jun 13 2024 Nick Clifton <nickc@redhat.com> - 2.41-42
|
||||
- Add --rosegment option to BFD linker.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user