[llvm] r250942 - [RuntimeDyld] Ignore ST_FILE symbols when constructing GlobalSymbolTable
Keno Fischer via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 21 13:22:04 PDT 2015
Author: kfischer
Date: Wed Oct 21 15:22:04 2015
New Revision: 250942
URL: http://llvm.org/viewvc/llvm-project?rev=250942&view=rev
Log:
[RuntimeDyld] Ignore ST_FILE symbols when constructing GlobalSymbolTable
Summary: ELF's STT_File symbols may overlap with regular globals in
other files, so we should ignore them here in order to avoid having
bogus entries in the symbol table that confuse us when resolving relocations.
Reviewers: lhames
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D13888
Added:
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
Modified:
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=250942&r1=250941&r2=250942&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Wed Oct 21 15:22:04 2015
@@ -179,7 +179,8 @@ RuntimeDyldImpl::loadObjectImpl(const ob
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;
Added: llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/ELF_STT_FILE.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/ELF_STT_FILE.s?rev=250942&view=auto
==============================================================================
--- llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/ELF_STT_FILE.s (added)
+++ llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/ELF_STT_FILE.s Wed Oct 21 15:22:04 2015
@@ -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
Added: llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/Inputs/ELF_STT_FILE_FILE.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/Inputs/ELF_STT_FILE_FILE.s?rev=250942&view=auto
==============================================================================
--- llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/Inputs/ELF_STT_FILE_FILE.s (added)
+++ llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/Inputs/ELF_STT_FILE_FILE.s Wed Oct 21 15:22:04 2015
@@ -0,0 +1,3 @@
+.file "foo.c"
+.global bar.c
+bar.c:
Added: llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/Inputs/ELF_STT_FILE_GLOBAL.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/Inputs/ELF_STT_FILE_GLOBAL.s?rev=250942&view=auto
==============================================================================
--- llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/Inputs/ELF_STT_FILE_GLOBAL.s (added)
+++ llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/Inputs/ELF_STT_FILE_GLOBAL.s Wed Oct 21 15:22:04 2015
@@ -0,0 +1,2 @@
+.global foo.c
+foo.c:
More information about the llvm-commits
mailing list