[PATCH] D22664: [ELF/Linkerscript] Define an absolute if we find an undefined during symbol assignment

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 22 11:16:55 PDT 2016


davide updated this revision to Diff 65107.

https://reviews.llvm.org/D22664

Files:
  ELF/LinkerScript.cpp
  test/ELF/linkerscript-undef.s

Index: test/ELF/linkerscript-undef.s
===================================================================
--- /dev/null
+++ test/ELF/linkerscript-undef.s
@@ -0,0 +1,11 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+
+# RUN: echo "SECTIONS { patatino = 0x1234; }" > %t.script
+# RUN: ld.lld -o %t1 --script %t.script %t
+# RUN: llvm-objdump -t %t1 | FileCheck %s
+# CHECK: 0000000000001234         *ABS*    00000000 patatino
+
+.global _start
+_start:
+  call patatino
Index: ELF/LinkerScript.cpp
===================================================================
--- ELF/LinkerScript.cpp
+++ ELF/LinkerScript.cpp
@@ -533,7 +533,8 @@
     if (!Cmd || Cmd->Name == ".")
       continue;
 
-    if (Symtab<ELFT>::X->find(Cmd->Name) == nullptr)
+    SymbolBody *B = Symtab<ELFT>::X->find(Cmd->Name);
+    if (B == nullptr || B->isUndefined())
       Symtab<ELFT>::X->addAbsolute(Cmd->Name,
                                    Cmd->Hidden ? STV_HIDDEN : STV_DEFAULT);
     else


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22664.65107.patch
Type: text/x-patch
Size: 1015 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160722/bddace7b/attachment.bin>


More information about the llvm-commits mailing list