[lld] r310168 - [lld] Allow rel iplt symbols with dynamic symbol table

Shoaib Meenai via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 4 22:01:07 PDT 2017


Author: smeenai
Date: Fri Aug  4 22:01:07 2017
New Revision: 310168

URL: http://llvm.org/viewvc/llvm-project?rev=310168&view=rev
Log:
[lld] Allow rel iplt symbols with dynamic symbol table

Emit these symbols as long as we're building in a static configuration,
even if we're emitting a dynamic symbol table. This is consistent with
both bfd and gold.

Ordinarily, the combination of -static and -export-dynamic wouldn't make
much sense. Unfortunately, cmake versions prior to 3.4 forcefully
injected -rdynamic [1], so it seems worthwhile to support.

[1] https://cmake.org/cmake/help/v3.4/policy/CMP0065.html

Differential Revision: https://reviews.llvm.org/D36350

Added:
    lld/trunk/test/ELF/gnu-ifunc-dynsym.s
Modified:
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=310168&r1=310167&r2=310168&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Fri Aug  4 22:01:07 2017
@@ -774,7 +774,7 @@ addOptionalRegular(StringRef Name, Secti
 // need these symbols, since IRELATIVE relocs are resolved through GOT
 // and PLT. For details, see http://www.airs.com/blog/archives/403.
 template <class ELFT> void Writer<ELFT>::addRelIpltSymbols() {
-  if (InX::DynSymTab)
+  if (!Config->Static)
     return;
   StringRef S = Config->IsRela ? "__rela_iplt_start" : "__rel_iplt_start";
   addOptionalRegular<ELFT>(S, In<ELFT>::RelaIplt, 0, STV_HIDDEN, STB_WEAK);

Added: lld/trunk/test/ELF/gnu-ifunc-dynsym.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/gnu-ifunc-dynsym.s?rev=310168&view=auto
==============================================================================
--- lld/trunk/test/ELF/gnu-ifunc-dynsym.s (added)
+++ lld/trunk/test/ELF/gnu-ifunc-dynsym.s Fri Aug  4 22:01:07 2017
@@ -0,0 +1,19 @@
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+// RUN: ld.lld -static -export-dynamic %t.o -o %tout
+// RUN: llvm-nm -U %tout | FileCheck %s
+// REQUIRES: x86
+
+// CHECK: __rela_iplt_end
+// CHECK: __rela_iplt_start
+
+.text
+.type foo STT_GNU_IFUNC
+.globl foo
+foo:
+ ret
+
+.globl _start
+_start:
+ call foo
+ movl $__rela_iplt_start,%edx
+ movl $__rela_iplt_end,%edx




More information about the llvm-commits mailing list