Index: lld/trunk/ELF/Writer.cpp =================================================================== --- lld/trunk/ELF/Writer.cpp +++ lld/trunk/ELF/Writer.cpp @@ -1629,8 +1629,8 @@ StringRef S = Sec->Name; if (!isValidCIdentifier(S)) return; - addOptionalRegular(Saver.save("__start_" + S), Sec, 0, STV_DEFAULT); - addOptionalRegular(Saver.save("__stop_" + S), Sec, -1, STV_DEFAULT); + addOptionalRegular(Saver.save("__start_" + S), Sec, 0, STV_PROTECTED); + addOptionalRegular(Saver.save("__stop_" + S), Sec, -1, STV_PROTECTED); } static bool needsPtLoad(OutputSection *Sec) { Index: lld/trunk/test/ELF/startstop-shared.s =================================================================== --- lld/trunk/test/ELF/startstop-shared.s +++ lld/trunk/test/ELF/startstop-shared.s @@ -11,18 +11,30 @@ .quad __start_bar .section bar,"a" -// Test that we are able to hide the symbol. -// CHECK: R_X86_64_RELATIVE - 0x[[ADDR:.*]] +// CHECK: Relocations [ +// CHECK-NEXT: Section {{.*}} .rela.dyn { +// CHECK-NEXT: R_X86_64_RELATIVE +// CHECK-NEXT: R_X86_64_RELATIVE +// CHECK-NEXT: } +// CHECK-NEXT: ] -// By default the symbol is visible and we need a dynamic reloc. -// CHECK: R_X86_64_64 __start_foo 0x0 +// Test that we are able to hide the symbol. +// By default the symbol is protected. // CHECK: Name: __start_bar -// CHECK-NEXT: Value: 0x[[ADDR]] +// CHECK-NEXT: Value: // CHECK-NEXT: Size: // CHECK-NEXT: Binding: Local +// CHECK-NEXT: Type: None +// CHECK-NEXT: Other [ +// CHECK-NEXT: STV_HIDDEN +// CHECK-NEXT: ] // CHECK: Name: __start_foo // CHECK-NEXT: Value: // CHECK-NEXT: Size: // CHECK-NEXT: Binding: Global +// CHECK-NEXT: Type: None +// CHECK-NEXT: Other [ +// CHECK-NEXT: STV_PROTECTED +// CHECK-NEXT: ] Index: lld/trunk/test/ELF/startstop.s =================================================================== --- lld/trunk/test/ELF/startstop.s +++ lld/trunk/test/ELF/startstop.s @@ -19,13 +19,12 @@ // DISASM: 1013: 90 nop // DISASM: 1014: 90 nop - // SYMBOL: Relocations [ // SYMBOL-NEXT: Section ({{.*}}) .rela.dyn { -// SYMBOL-NEXT: 0x2010 R_X86_64_64 __stop_zed1 0x0 -// SYMBOL-NEXT: 0x2018 R_X86_64_64 __stop_zed1 0x1 -// SYMBOL-NEXT: 0x2000 R_X86_64_64 __stop_zed2 0x0 -// SYMBOL-NEXT: 0x2008 R_X86_64_64 __stop_zed2 0x1 +// SYMBOL-NEXT: R_X86_64_RELATIVE +// SYMBOL-NEXT: R_X86_64_RELATIVE +// SYMBOL-NEXT: R_X86_64_RELATIVE +// SYMBOL-NEXT: R_X86_64_RELATIVE // SYMBOL-NEXT: } // SYMBOL-NEXT: ] @@ -45,20 +44,20 @@ // SYMBOL: Symbol { // SYMBOL: Name: __stop_foo // SYMBOL: Value: 0x1012 -// STMBOL: STV_HIDDEN +// SYMBOL: STV_HIDDEN // SYMBOL: Section: foo // SYMBOL: } // SYMBOL: Symbol { // SYMBOL: Name: __stop_zed1 // SYMBOL: Value: 0x2010 -// STMBOL: Other: 0 +// SYMBOL: STV_PROTECTED // SYMBOL: Section: zed1 // SYMBOL: } // SYMBOL: Symbol { // SYMBOL: Name: __stop_zed2 // SYMBOL: Value: 0x2020 -// STMBOL: Other: 0 +// SYMBOL: STV_PROTECTED // SYMBOL: Section: zed2 // SYMBOL: }