[PATCH] D18166: Add _GLOBAL_OFFSET_TABLE_ symbol to shared libraries

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 14 17:15:46 PDT 2016


davide created this revision.
davide added reviewers: emaste, rafael.
davide added a subscriber: llvm-commits.
Herald added a subscriber: emaste.

This fixes libcxxabi bootstrap on FreeBSD for me. Ed, can you please confirm? Thanks.

http://reviews.llvm.org/D18166

Files:
  ELF/Driver.cpp

Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -342,14 +342,15 @@

   Config->Rela = ELFT::Is64Bits;

-  if (!Config->Shared && !Config->Relocatable) {
+  if (!Config->Shared && !Config->Relocatable && Config->Entry.empty() &&
+      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
@@ -363,7 +364,6 @@
     // 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).


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18166.50680.patch
Type: text/x-patch
Size: 1274 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160315/7be252d2/attachment.bin>


More information about the llvm-commits mailing list