summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/Driver.cpp8
-rw-r--r--lld/test/ELF/global_offset_table_shared.s6
2 files changed, 10 insertions, 4 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index b7cf7a3374b..0c0e31ec714 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -343,14 +343,15 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) {
Config->Rela = ELFT::Is64Bits;
- if (!Config->Shared && !Config->Relocatable) {
+ if (Config->Entry.empty() && !Config->Shared && !Config->Relocatable &&
+ Config->EMachine != EM_AMDGPU)
// Add entry symbol.
//
// There is no entry symbol for AMDGPU binaries, so skip adding one to avoid
// having and undefined symbol.
- if (Config->Entry.empty() && Config->EMachine != EM_AMDGPU)
- Config->Entry = (Config->EMachine == EM_MIPS) ? "__start" : "_start";
+ Config->Entry = Config->EMachine == EM_MIPS ? "__start" : "_start";
+ if (!Config->Relocatable)
// In the assembly for 32 bit x86 the _GLOBAL_OFFSET_TABLE_ symbol
// is magical and is used to produce a R_386_GOTPC relocation.
// The R_386_GOTPC relocation value doesn't actually depend on the
@@ -364,7 +365,6 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) {
// Given that the symbol is effectively unused, we just create a dummy
// hidden one to avoid the undefined symbol error.
Symtab.addIgnored("_GLOBAL_OFFSET_TABLE_");
- }
if (!Config->Entry.empty()) {
// Set either EntryAddr (if S is a number) or EntrySym (otherwise).
diff --git a/lld/test/ELF/global_offset_table_shared.s b/lld/test/ELF/global_offset_table_shared.s
new file mode 100644
index 00000000000..299c178f7e2
--- /dev/null
+++ b/lld/test/ELF/global_offset_table_shared.s
@@ -0,0 +1,6 @@
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
+// RUN: ld.lld -shared %t -o %t2
+// RUN: llvm-readobj -t %t2 | Filecheck %s
+.long _GLOBAL_OFFSET_TABLE_
+
+// CHECK-NOT: Name: _GLOBAL_OFFSET_TABLE_
OpenPOWER on IntegriCloud