LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 26705 - lld-linked libc++.so, libc++abi.so has undefined _GLOBAL_OFFSET_TABLE_ symbol
Summary: lld-linked libc++.so, libc++abi.so has undefined _GLOBAL_OFFSET_TABLE_ symbol
Status: RESOLVED FIXED
Alias: None
Product: lld
Classification: Unclassified
Component: All Bugs (show other bugs)
Version: unspecified
Hardware: PC FreeBSD
: P normal
Assignee: Unassigned LLVM Bugs
URL: http://reviews.llvm.org/D18166
Keywords:
Depends on:
Blocks: 23214
  Show dependency tree
 
Reported: 2016-02-22 19:29 PST by emaste
Modified: 2016-03-15 19:39 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description emaste 2016-02-22 19:29:29 PST
linked with lld:

% nm build-lld-selfhost2/lib/libc++abi.so | grep 'GLOBAL_OFFSET'
                 U _GLOBAL_OFFSET_TABLE_

with gnu ld:

% nm build-nodebug/lib/libc++abi.so | grep 'GLOBAL_OFFSET'      
00000000002592e0 a _GLOBAL_OFFSET_TABLE_

and link failures are observed in 'check-libcxxabi'

/usr/bin/ld: /tank/emaste/src/llvm/build-lld-selfhost2/projects/libcxxabi/test/Output/catch_pointer_reference.pass.cpp.exe: hidden symbol `_GLOBAL_OFFSET_TABLE_' in /usr/lib/crt1.o is referenced by DSO
/usr/bin/ld: final link failed: Nonrepresentable section on output
CC: error: linker command failed with exit code 1 (use -v to see invocation)
Comment 1 Davide Italiano 2016-03-04 15:39:34 PST
I'm working on a (proper) fix, in the meanwhile you can workaround using the following:

Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp      (revision 262736)
+++ ELF/Writer.cpp      (working copy)
@@ -1021,6 +1021,12 @@
   if (isOutputDynamic())
     Symtab.addSynthetic("_DYNAMIC", *Out<ELFT>::Dynamic, 0, STV_HIDDEN);
 
+  // If the ouput contains a GotPlt section, add
+  // _GLOBAL_OFFSET_TABLE_ to the symbol table.
+  if (Config->Shared && Out<ELFT>::GotPlt)
+    Symtab.addSynthetic("_GLOBAL_OFFSET_TABLE_", *Out<ELFT>::GotPlt,
+      Out<ELFT>::GotPlt->getSize(), STV_HIDDEN);
+
   // Define __rel[a]_iplt_{start,end} symbols if needed.
   addRelIpltSymbols();
Comment 2 emaste 2016-03-15 19:39:32 PDT
Committed as r263594 http://reviews.llvm.org/rL263594