[lld] r264707 - [ELF] - Error out when R_X86_64_PC32/R_X86_64_32 are used against preemptible symbol when linking shared object.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 29 01:35:45 PDT 2016
Author: grimar
Date: Tue Mar 29 03:35:42 2016
New Revision: 264707
URL: http://llvm.org/viewvc/llvm-project?rev=264707&view=rev
Log:
[ELF] - Error out when R_X86_64_PC32/R_X86_64_32 are used against preemptible symbol when linking shared object.
When R_X86_64_PC32/R_X86_64_32 relocations are
used against preemptible symbol and output is position independent,
error should be generated.
Differential revision: http://reviews.llvm.org/D18190
Added:
lld/trunk/test/ELF/x86-64-reloc-32-fpic.s
lld/trunk/test/ELF/x86-64-reloc-pc32-fpic.s
Modified:
lld/trunk/ELF/Target.cpp
lld/trunk/test/ELF/Inputs/allow-shlib-undefined.s
lld/trunk/test/ELF/Inputs/llvm33-rela-outside-group.o
lld/trunk/test/ELF/allow-shlib-undefined.s
lld/trunk/test/ELF/llvm33-rela-outside-group.s
lld/trunk/test/ELF/lto/linkonce-odr.ll
lld/trunk/test/ELF/lto/linkonce.ll
lld/trunk/test/ELF/no-undefined.s
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=264707&r1=264706&r2=264707&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Tue Mar 29 03:35:42 2016
@@ -110,6 +110,7 @@ public:
class X86_64TargetInfo final : public TargetInfo {
public:
X86_64TargetInfo();
+ uint32_t getDynRel(uint32_t Type) const override;
uint32_t getTlsGotRel(uint32_t Type) const override;
bool pointsToLocalDynamicGotEntry(uint32_t Type) const override;
bool isTlsLocalDynamicRel(uint32_t Type) const override;
@@ -758,6 +759,14 @@ bool X86_64TargetInfo::needsGot(uint32_t
return refersToGotEntry(Type) || needsPlt(Type, S);
}
+uint32_t X86_64TargetInfo::getDynRel(uint32_t Type) const {
+ if (Type == R_X86_64_PC32 || Type == R_X86_64_32)
+ if (Config->Shared)
+ error(getELFRelocationTypeName(EM_X86_64, Type) +
+ " cannot be a dynamic relocation");
+ return Type;
+}
+
uint32_t X86_64TargetInfo::getTlsGotRel(uint32_t Type) const {
// No other types of TLS relocations requiring GOT should
// reach here.
Modified: lld/trunk/test/ELF/Inputs/allow-shlib-undefined.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/Inputs/allow-shlib-undefined.s?rev=264707&r1=264706&r2=264707&view=diff
==============================================================================
--- lld/trunk/test/ELF/Inputs/allow-shlib-undefined.s (original)
+++ lld/trunk/test/ELF/Inputs/allow-shlib-undefined.s Tue Mar 29 03:35:42 2016
@@ -1,3 +1,3 @@
.globl _shared
_shared:
- call _unresolved
+ callq _unresolved at PLT
Modified: lld/trunk/test/ELF/Inputs/llvm33-rela-outside-group.o
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/Inputs/llvm33-rela-outside-group.o?rev=264707&r1=264706&r2=264707&view=diff
==============================================================================
Binary files lld/trunk/test/ELF/Inputs/llvm33-rela-outside-group.o (original) and lld/trunk/test/ELF/Inputs/llvm33-rela-outside-group.o Tue Mar 29 03:35:42 2016 differ
Modified: lld/trunk/test/ELF/allow-shlib-undefined.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/allow-shlib-undefined.s?rev=264707&r1=264706&r2=264707&view=diff
==============================================================================
--- lld/trunk/test/ELF/allow-shlib-undefined.s (original)
+++ lld/trunk/test/ELF/allow-shlib-undefined.s Tue Mar 29 03:35:42 2016
@@ -22,4 +22,4 @@
.globl _start
_start:
- call _shared
+ callq _shared at PLT
Modified: lld/trunk/test/ELF/llvm33-rela-outside-group.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/llvm33-rela-outside-group.s?rev=264707&r1=264706&r2=264707&view=diff
==============================================================================
--- lld/trunk/test/ELF/llvm33-rela-outside-group.s (original)
+++ lld/trunk/test/ELF/llvm33-rela-outside-group.s Tue Mar 29 03:35:42 2016
@@ -8,4 +8,4 @@
.section .text._Z3fooIiEvv,"axG", at progbits,_Z3fooIiEvv,comdat
_Z3fooIiEvv:
- callq bar
+ callq bar at PLT
Modified: lld/trunk/test/ELF/lto/linkonce-odr.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/linkonce-odr.ll?rev=264707&r1=264706&r2=264707&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto/linkonce-odr.ll (original)
+++ lld/trunk/test/ELF/lto/linkonce-odr.ll Tue Mar 29 03:35:42 2016
@@ -1,6 +1,6 @@
; REQUIRES: x86
; RUN: llvm-as %p/Inputs/linkonce-odr.ll -o %t1.o
-; RUN: llc %s -o %t2.o -filetype=obj
+; RUN: llc -relocation-model=pic %s -o %t2.o -filetype=obj
; RUN: ld.lld %t1.o %t2.o -o %t.so -shared -save-temps
; RUN: llvm-dis %t.so.lto.opt.bc -o - | FileCheck %s
Modified: lld/trunk/test/ELF/lto/linkonce.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/linkonce.ll?rev=264707&r1=264706&r2=264707&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto/linkonce.ll (original)
+++ lld/trunk/test/ELF/lto/linkonce.ll Tue Mar 29 03:35:42 2016
@@ -1,6 +1,6 @@
; REQUIRES: x86
; RUN: llvm-as %p/Inputs/linkonce.ll -o %t1.o
-; RUN: llc %s -o %t2.o -filetype=obj
+; RUN: llc -relocation-model=pic %s -o %t2.o -filetype=obj
; RUN: ld.lld %t1.o %t2.o -o %t.so -shared -save-temps
; RUN: llvm-dis %t.so.lto.opt.bc -o - | FileCheck %s
Modified: lld/trunk/test/ELF/no-undefined.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/no-undefined.s?rev=264707&r1=264706&r2=264707&view=diff
==============================================================================
--- lld/trunk/test/ELF/no-undefined.s (original)
+++ lld/trunk/test/ELF/no-undefined.s Tue Mar 29 03:35:42 2016
@@ -4,4 +4,4 @@
.globl _shared
_shared:
- call _unresolved
+ callq _unresolved at PLT
Added: lld/trunk/test/ELF/x86-64-reloc-32-fpic.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/x86-64-reloc-32-fpic.s?rev=264707&view=auto
==============================================================================
--- lld/trunk/test/ELF/x86-64-reloc-32-fpic.s (added)
+++ lld/trunk/test/ELF/x86-64-reloc-32-fpic.s Tue Mar 29 03:35:42 2016
@@ -0,0 +1,6 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
+# CHECK: R_X86_64_32 cannot be a dynamic relocation
+
+.long _shared
Added: lld/trunk/test/ELF/x86-64-reloc-pc32-fpic.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/x86-64-reloc-pc32-fpic.s?rev=264707&view=auto
==============================================================================
--- lld/trunk/test/ELF/x86-64-reloc-pc32-fpic.s (added)
+++ lld/trunk/test/ELF/x86-64-reloc-pc32-fpic.s Tue Mar 29 03:35:42 2016
@@ -0,0 +1,6 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
+# CHECK: R_X86_64_PC32 cannot be a dynamic relocation
+
+call _shared
More information about the llvm-commits
mailing list