forked from OSchip/llvm-project
Relax the restriction on what relocations can be in a non-alloc section.
The main thing that they can't have is relocations that require the creation of gots or plt. For now also accept R_PC. Found while linking seabios. llvm-svn: 295102
This commit is contained in:
parent
9503004089
commit
ee29e42b33
|
@ -452,7 +452,8 @@ void InputSection<ELFT>::relocateNonAlloc(uint8_t *Buf, ArrayRef<RelTy> Rels) {
|
|||
Addend += Target->getImplicitAddend(BufLoc, Type);
|
||||
|
||||
SymbolBody &Sym = this->File->getRelocTargetSym(Rel);
|
||||
if (Target->getRelExpr(Type, Sym) != R_ABS) {
|
||||
RelExpr E = Target->getRelExpr(Type, Sym);
|
||||
if (E != R_ABS && E != R_PC) {
|
||||
error(this->getLocation(Offset) + ": has non-ABS reloc");
|
||||
return;
|
||||
}
|
||||
|
@ -461,7 +462,7 @@ void InputSection<ELFT>::relocateNonAlloc(uint8_t *Buf, ArrayRef<RelTy> Rels) {
|
|||
uint64_t SymVA = 0;
|
||||
if (!Sym.isTls() || Out<ELFT>::TlsPhdr)
|
||||
SymVA = SignExtend64<sizeof(uintX_t) * 8>(
|
||||
getRelocTargetVA<ELFT>(Type, Addend, AddrLoc, Sym, R_ABS));
|
||||
getRelocTargetVA<ELFT>(Type, Addend, AddrLoc, Sym, E));
|
||||
Target->relocateOne(BufLoc, Type, SymVA);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
// REQUIRES: x86
|
||||
|
||||
// RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %s -o %t.o
|
||||
// RUN: ld.lld -shared %t.o -o %t.so
|
||||
// RUN: llvm-objdump -s %t.so | FileCheck %s
|
||||
|
||||
// CHECK: Contents of section .text:
|
||||
// CHECK-NEXT: 1000 00000000 00000000
|
||||
|
||||
// CHECK: Contents of section .bar:
|
||||
// CHECK-NEXT: 0000 00100000 fc0f0000
|
||||
|
||||
foo:
|
||||
.quad 0
|
||||
|
||||
.section .bar
|
||||
.long foo - .
|
||||
.long foo - .
|
Loading…
Reference in New Issue