forked from OSchip/llvm-project
Add `-z nocopyreloc` option.
This option disable creating copy relocations. ld.bfd and ld.gold have the same option. llvm-svn: 295772
This commit is contained in:
parent
5d6631d8b4
commit
f9e8034c9c
|
@ -136,6 +136,7 @@ struct Configuration {
|
|||
bool WarnMissingEntry;
|
||||
bool ZCombreloc;
|
||||
bool ZExecstack;
|
||||
bool ZNocopyreloc;
|
||||
bool ZNodelete;
|
||||
bool ZNow;
|
||||
bool ZOrigin;
|
||||
|
|
|
@ -574,6 +574,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) {
|
|||
|
||||
Config->ZCombreloc = !hasZOption(Args, "nocombreloc");
|
||||
Config->ZExecstack = hasZOption(Args, "execstack");
|
||||
Config->ZNocopyreloc = hasZOption(Args, "nocopyreloc");
|
||||
Config->ZNodelete = hasZOption(Args, "nodelete");
|
||||
Config->ZNow = hasZOption(Args, "now");
|
||||
Config->ZOrigin = hasZOption(Args, "origin");
|
||||
|
|
|
@ -543,8 +543,14 @@ static RelExpr adjustExpr(const elf::ObjectFile<ELFT> &File, SymbolBody &Body,
|
|||
if (Body.isObject()) {
|
||||
// Produce a copy relocation.
|
||||
auto *B = cast<SharedSymbol<ELFT>>(&Body);
|
||||
if (!B->NeedsCopy)
|
||||
if (!B->NeedsCopy) {
|
||||
if (Config->ZNocopyreloc)
|
||||
error(S.getLocation(RelOff) + ": unresolvable relocation " + toString(Type)
|
||||
+ " against symbol '" + toString(*B) +
|
||||
"'; recompile with -fPIC or remove '-z nocopyreloc'");
|
||||
|
||||
addCopyRelSymbol(B);
|
||||
}
|
||||
return Expr;
|
||||
}
|
||||
if (Body.isFunc()) {
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
// REQUIRES: x86
|
||||
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
|
||||
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/relocation-copy.s -o %t2.o
|
||||
// RUN: ld.lld -shared %t2.o -o %t.so
|
||||
// RUN: not ld.lld -z nocopyreloc %t.o %t.so -o %t3 2>&1 | FileCheck %s
|
||||
|
||||
// CHECK: unresolvable relocation R_X86_64_32S against symbol 'x'
|
||||
// CHECK: unresolvable relocation R_X86_64_32S against symbol 'y'
|
||||
// CHECK: unresolvable relocation R_X86_64_32S against symbol 'z'
|
||||
|
||||
.text
|
||||
.global _start
|
||||
_start:
|
||||
movl $5, x
|
||||
movl $7, y
|
||||
movl $9, z
|
||||
movl $x, %edx
|
||||
movl $y, %edx
|
||||
movl $z, %edx
|
Loading…
Reference in New Issue