mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-30 00:32:53 +00:00
Accept subtractions involving a weak symbol.
When a symbol S shows up in an expression in assembly there are two possible interpretations * The expression is referring to the value of S in this file. * The expression is referring to the value after symbol resolution. In the first case the assembler can reason about the value and try to produce a relocation. In the second case, that is only possible if the symbol cannot be preempted. Assemblers are not very consistent about which interpretation gets used. This changes MC to agree with GAS in the case of an expression of the form "Sym - WeakSym". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@258329 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e52954eb4a
commit
888824fa23
@ -655,12 +655,6 @@ void ELFObjectWriter::recordRelocation(MCAssembler &Asm,
|
||||
return;
|
||||
}
|
||||
|
||||
if (::isWeak(SymB)) {
|
||||
Ctx.reportError(Fixup.getLoc(),
|
||||
"Cannot represent a subtraction with a weak symbol");
|
||||
return;
|
||||
}
|
||||
|
||||
uint64_t SymBOffset = Layout.getSymbolOffset(SymB);
|
||||
uint64_t K = SymBOffset - FixupOffset;
|
||||
IsPCRel = true;
|
||||
|
@ -16,9 +16,6 @@
|
||||
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Cannot represent a difference across sections
|
||||
.word x_a - y_a
|
||||
|
||||
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Cannot represent a subtraction with a weak symbol
|
||||
.word a - w
|
||||
|
||||
// CHECK: <unknown>:0: error: expression could not be evaluated
|
||||
.set v1, -undef
|
||||
|
||||
|
@ -16,9 +16,6 @@
|
||||
@ CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Cannot represent a difference across sections
|
||||
.word x_a - y_a
|
||||
|
||||
@ CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Cannot represent a subtraction with a weak symbol
|
||||
.word a - w
|
||||
|
||||
@ CHECK: <unknown>:0: error: expression could not be evaluated
|
||||
.set v1, -undef
|
||||
|
||||
|
@ -63,6 +63,11 @@ pr24486:
|
||||
.code16
|
||||
call pr23771
|
||||
|
||||
.weak weak_sym
|
||||
weak_sym:
|
||||
.long pr23272-weak_sym
|
||||
|
||||
|
||||
// CHECK: Section {
|
||||
// CHECK: Name: .rela.text
|
||||
// CHECK: Relocations [
|
||||
@ -101,5 +106,6 @@ pr24486:
|
||||
// CHECK-NEXT: 0xDC R_X86_64_PLT32 foo 0x0
|
||||
// CHECK-NEXT: 0xF0 R_X86_64_32 .text 0xF0
|
||||
// CHECK-NEXT: 0xF5 R_X86_64_PC16 pr23771 0xFFFFFFFFFFFFFFFE
|
||||
// CHECK-NEXT: 0xF7 R_X86_64_PC32 pr23272 0x0
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: }
|
||||
|
Loading…
x
Reference in New Issue
Block a user