File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -1437,6 +1437,14 @@ static void sortSection(OutputSection *sec,
1437
1437
if (name == " .init" || name == " .fini" )
1438
1438
return ;
1439
1439
1440
+ // IRelative relocations that usually live in the .rel[a].dyn section should
1441
+ // be proccessed last by the dynamic loader. To achieve that we add synthetic
1442
+ // sections in the required order from the begining so that the in.relaIplt
1443
+ // section is placed last in an output section. Here we just do not apply
1444
+ // sorting for an output section which holds the in.relaIplt section.
1445
+ if (in.relaIplt ->getParent () == sec)
1446
+ return ;
1447
+
1440
1448
// Sort input sections by priority using the list provided by
1441
1449
// --symbol-ordering-file or --shuffle-sections=. This is a least significant
1442
1450
// digit radix sort. The sections may be sorted stably again by a more
Original file line number Diff line number Diff line change 77
77
// DISASM-NEXT: 201386: pushq $0x1
78
78
// DISASM-NEXT: 20138b: jmp 0x201340 <.plt>
79
79
80
+ // Test that --shuffle-sections does not affect the order of relocations and that
81
+ // we still place IRELATIVE relocations last. Check both random seed (0) and an
82
+ // arbitrary seed that was known to break the order of relocations previously (3).
83
+ // RUN: ld.lld --shuffle-sections=3 %t.so %t.o -o %tout2
84
+ // RUN: llvm-readobj --relocations %tout2 | FileCheck %s --check-prefix=SHUFFLE
85
+ // RUN: ld.lld --shuffle-sections=0 %t.so %t.o -o %tout3
86
+ // RUN: llvm-readobj --relocations %tout3 | FileCheck %s --check-prefix=SHUFFLE
87
+
88
+ // SHUFFLE: Section {{.*}} .rela.dyn {
89
+ // SHUFFLE-NEXT: R_X86_64_GLOB_DAT
90
+ // SHUFFLE-NEXT: R_X86_64_IRELATIVE
91
+ // SHUFFLE-NEXT: R_X86_64_IRELATIVE
92
+ // SHUFFLE-NEXT: }
93
+
80
94
.text
81
95
.type foo STT_GNU_IFUNC
82
96
.globl foo
You can’t perform that action at this time.
0 commit comments