[PATCH] D13888: [RuntimeDyld] Ignore ST_FILE symbols when constructing GlobalSymbolTable

Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 21 13:24:14 PDT 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL250942: [RuntimeDyld] Ignore ST_FILE symbols when constructing GlobalSymbolTable (authored by kfischer).

Changed prior to commit:
  http://reviews.llvm.org/D13888?vs=37860&id=38042#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13888

Files:
  llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
  llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/ELF_STT_FILE.s
  llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/Inputs/ELF_STT_FILE_FILE.s
  llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/Inputs/ELF_STT_FILE_GLOBAL.s

Index: llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/Inputs/ELF_STT_FILE_GLOBAL.s
===================================================================
--- llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/Inputs/ELF_STT_FILE_GLOBAL.s
+++ llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/Inputs/ELF_STT_FILE_GLOBAL.s
@@ -0,0 +1,2 @@
+.global foo.c
+foo.c:
Index: llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/Inputs/ELF_STT_FILE_FILE.s
===================================================================
--- llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/Inputs/ELF_STT_FILE_FILE.s
+++ llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/Inputs/ELF_STT_FILE_FILE.s
@@ -0,0 +1,3 @@
+.file "foo.c"
+.global bar.c
+bar.c:
Index: llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/ELF_STT_FILE.s
===================================================================
--- llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/ELF_STT_FILE.s
+++ llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/ELF_STT_FILE.s
@@ -0,0 +1,14 @@
+# RUN: llvm-mc -triple=x86_64-pc-linux -relocation-model=pic -filetype=obj -o %T/test_ELF_STT_FILE_FILE_x86-64.o %p/Inputs/ELF_STT_FILE_FILE.s
+# RUN: llvm-mc -triple=x86_64-pc-linux -relocation-model=pic -filetype=obj -o %T/test_ELF_STT_FILE_GLOBAL_x86-64.o %p/Inputs/ELF_STT_FILE_GLOBAL.s
+# RUN: llvm-mc -triple=x86_64-pc-linux -relocation-model=pic -filetype=obj -o %T/test_ELF_STT_FILE_x86-64.o %s
+# RUN: llvm-rtdyld -triple=x86_64-pc-linux -verify %T/test_ELF_STT_FILE_GLOBAL_x86-64.o %T/test_ELF_STT_FILE_FILE_x86-64.o %T/test_ELF_STT_FILE_x86-64.o
+
+# Test that RTDyldELF ignores STT_FILE symbols, and in particular does
+# crash if we are relocating against a symbol that happens to have the
+# same name as an STT_FILE symbol.
+
+_main:
+    movq    foo.c at GOTPCREL(%rip), %rax
+    movq    bar.c at GOTPCREL(%rip), %rax
+    movq    $0, %rax
+    retq
Index: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
===================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
@@ -179,7 +179,8 @@
       if (Flags & SymbolRef::SF_Exported)
         RTDyldSymFlags |= JITSymbolFlags::Exported;
 
-      if (Flags & SymbolRef::SF_Absolute) {
+      if (Flags & SymbolRef::SF_Absolute &&
+          SymType != object::SymbolRef::ST_File) {
         auto Addr = I->getAddress();
         Check(Addr.getError());
         uint64_t SectOffset = *Addr;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13888.38042.patch
Type: text/x-patch
Size: 2495 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151021/f0768c98/attachment-0001.bin>


More information about the llvm-commits mailing list