mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-11 13:37:07 +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". llvm-svn: 258329
This commit is contained in:
parent
3635b71b45
commit
a193e28818
@ -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…
Reference in New Issue
Block a user