[PATCH] D26599: [ELF] - Do not create absolute __ehdr_start symbol for relocatable output.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 14 01:55:50 PST 2016


grimar created this revision.
grimar added reviewers: ruiu, rafael.
grimar added a subscriber: llvm-commits.

We should not create absolute symbols when doing relocatable link.
This one continues job started by https://reviews.llvm.org/D26545.


https://reviews.llvm.org/D26599

Files:
  ELF/Writer.cpp
  test/ELF/ehdr_start.s


Index: test/ELF/ehdr_start.s
===================================================================
--- test/ELF/ehdr_start.s
+++ test/ELF/ehdr_start.s
@@ -9,3 +9,8 @@
 .global _start, __ehdr_start
 _start:
   .quad __ehdr_start
+
+# RUN: ld.lld -r %t.o -o %t.r
+# RUN: llvm-objdump -t %t.r | FileCheck %s --check-prefix=RELOCATABLE
+
+# RELOCATABLE: 0000000000000000 *UND* 00000000 __ehdr_start
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -649,7 +649,8 @@
   if (ScriptConfig->HasSections)
     return;
 
-  ElfSym<ELFT>::EhdrStart = Symtab<ELFT>::X->addIgnored("__ehdr_start");
+  if (!Config->Relocatable)
+    ElfSym<ELFT>::EhdrStart = Symtab<ELFT>::X->addIgnored("__ehdr_start");
 
   auto Define = [this](StringRef S, DefinedRegular<ELFT> *&Sym1,
                        DefinedRegular<ELFT> *&Sym2) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26599.77776.patch
Type: text/x-patch
Size: 892 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161114/305ebcdb/attachment.bin>


More information about the llvm-commits mailing list