Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 34412fc

Browse files
author
George Rimar
committed
[ELF] - Make __start_/__stop_<section_name> symbols STV_PROTECTED
There are no reasons for them to be STV_DEFAULT, recently bfd did the same change. Differential revision: https://reviews.llvm.org/D44566 git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@327983 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 07bab16 commit 34412fc

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

ELF/Writer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1629,8 +1629,8 @@ void Writer<ELFT>::addStartStopSymbols(OutputSection *Sec) {
16291629
StringRef S = Sec->Name;
16301630
if (!isValidCIdentifier(S))
16311631
return;
1632-
addOptionalRegular(Saver.save("__start_" + S), Sec, 0, STV_DEFAULT);
1633-
addOptionalRegular(Saver.save("__stop_" + S), Sec, -1, STV_DEFAULT);
1632+
addOptionalRegular(Saver.save("__start_" + S), Sec, 0, STV_PROTECTED);
1633+
addOptionalRegular(Saver.save("__stop_" + S), Sec, -1, STV_PROTECTED);
16341634
}
16351635

16361636
static bool needsPtLoad(OutputSection *Sec) {

test/ELF/startstop-shared.s

+17-5
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,30 @@
1111
.quad __start_bar
1212
.section bar,"a"
1313

14-
// Test that we are able to hide the symbol.
15-
// CHECK: R_X86_64_RELATIVE - 0x[[ADDR:.*]]
14+
// CHECK: Relocations [
15+
// CHECK-NEXT: Section {{.*}} .rela.dyn {
16+
// CHECK-NEXT: R_X86_64_RELATIVE
17+
// CHECK-NEXT: R_X86_64_RELATIVE
18+
// CHECK-NEXT: }
19+
// CHECK-NEXT: ]
1620

17-
// By default the symbol is visible and we need a dynamic reloc.
18-
// CHECK: R_X86_64_64 __start_foo 0x0
21+
// Test that we are able to hide the symbol.
22+
// By default the symbol is protected.
1923

2024
// CHECK: Name: __start_bar
21-
// CHECK-NEXT: Value: 0x[[ADDR]]
25+
// CHECK-NEXT: Value:
2226
// CHECK-NEXT: Size:
2327
// CHECK-NEXT: Binding: Local
28+
// CHECK-NEXT: Type: None
29+
// CHECK-NEXT: Other [
30+
// CHECK-NEXT: STV_HIDDEN
31+
// CHECK-NEXT: ]
2432

2533
// CHECK: Name: __start_foo
2634
// CHECK-NEXT: Value:
2735
// CHECK-NEXT: Size:
2836
// CHECK-NEXT: Binding: Global
37+
// CHECK-NEXT: Type: None
38+
// CHECK-NEXT: Other [
39+
// CHECK-NEXT: STV_PROTECTED
40+
// CHECK-NEXT: ]

test/ELF/startstop.s

+7-8
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@
1919
// DISASM: 1013: 90 nop
2020
// DISASM: 1014: 90 nop
2121

22-
2322
// SYMBOL: Relocations [
2423
// SYMBOL-NEXT: Section ({{.*}}) .rela.dyn {
25-
// SYMBOL-NEXT: 0x2010 R_X86_64_64 __stop_zed1 0x0
26-
// SYMBOL-NEXT: 0x2018 R_X86_64_64 __stop_zed1 0x1
27-
// SYMBOL-NEXT: 0x2000 R_X86_64_64 __stop_zed2 0x0
28-
// SYMBOL-NEXT: 0x2008 R_X86_64_64 __stop_zed2 0x1
24+
// SYMBOL-NEXT: R_X86_64_RELATIVE
25+
// SYMBOL-NEXT: R_X86_64_RELATIVE
26+
// SYMBOL-NEXT: R_X86_64_RELATIVE
27+
// SYMBOL-NEXT: R_X86_64_RELATIVE
2928
// SYMBOL-NEXT: }
3029
// SYMBOL-NEXT: ]
3130

@@ -45,20 +44,20 @@
4544
// SYMBOL: Symbol {
4645
// SYMBOL: Name: __stop_foo
4746
// SYMBOL: Value: 0x1012
48-
// STMBOL: STV_HIDDEN
47+
// SYMBOL: STV_HIDDEN
4948
// SYMBOL: Section: foo
5049
// SYMBOL: }
5150

5251
// SYMBOL: Symbol {
5352
// SYMBOL: Name: __stop_zed1
5453
// SYMBOL: Value: 0x2010
55-
// STMBOL: Other: 0
54+
// SYMBOL: STV_PROTECTED
5655
// SYMBOL: Section: zed1
5756
// SYMBOL: }
5857
// SYMBOL: Symbol {
5958
// SYMBOL: Name: __stop_zed2
6059
// SYMBOL: Value: 0x2020
61-
// STMBOL: Other: 0
60+
// SYMBOL: STV_PROTECTED
6261
// SYMBOL: Section: zed2
6362
// SYMBOL: }
6463

0 commit comments

Comments
 (0)