[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
Sat Jul 23 15:16:41 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL276536: [ELF/Linkerscript] Define an absolute if we find an undefined. (authored by davide).

Changed prior to commit:
  https://reviews.llvm.org/D22664?vs=65107&id=65258#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22664

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

Index: lld/trunk/test/ELF/linkerscript-undef.s
===================================================================
--- lld/trunk/test/ELF/linkerscript-undef.s
+++ lld/trunk/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: lld/trunk/ELF/LinkerScript.cpp
===================================================================
--- lld/trunk/ELF/LinkerScript.cpp
+++ lld/trunk/ELF/LinkerScript.cpp
@@ -532,7 +532,8 @@
     if (!Cmd || Cmd->Name == ".")
       continue;
 
-    if (Symtab<ELFT>::X->find(Cmd->Name) == nullptr)
+    SymbolBody *B = Symtab<ELFT>::X->find(Cmd->Name);
+    if (!B || 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.65258.patch
Type: text/x-patch
Size: 1085 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160723/821a8ffe/attachment.bin>


More information about the llvm-commits mailing list