mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-19 00:14:20 +00:00
Fix relative relocations. This is sufficient for running the rust testsuite with
MC :-) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129923 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
64d3d12f37
commit
1ac7fe0f4d
@ -656,8 +656,13 @@ void WinCOFFObjectWriter::RecordRelocation(const MCAssembler &Asm,
|
|||||||
const MCSymbol *B = &Target.getSymB()->getSymbol();
|
const MCSymbol *B = &Target.getSymB()->getSymbol();
|
||||||
MCSymbolData &B_SD = Asm.getSymbolData(*B);
|
MCSymbolData &B_SD = Asm.getSymbolData(*B);
|
||||||
|
|
||||||
FixedValue = Layout.getSymbolOffset(&A_SD) - Layout.getSymbolOffset(&B_SD);
|
// Offset of the symbol in the section
|
||||||
|
int64_t a = Layout.getSymbolOffset(&B_SD);
|
||||||
|
|
||||||
|
// Ofeset of the relocation in the section
|
||||||
|
int64_t b = Layout.getFragmentOffset(Fragment) + Fixup.getOffset();
|
||||||
|
|
||||||
|
FixedValue = b - a;
|
||||||
// In the case where we have SymbA and SymB, we just need to store the delta
|
// In the case where we have SymbA and SymB, we just need to store the delta
|
||||||
// between the two symbols. Update FixedValue to account for the delta, and
|
// between the two symbols. Update FixedValue to account for the delta, and
|
||||||
// skip recording the relocation.
|
// skip recording the relocation.
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
.type 32;
|
.type 32;
|
||||||
.endef
|
.endef
|
||||||
.text
|
.text
|
||||||
|
.long 0
|
||||||
.globl _foobar
|
.globl _foobar
|
||||||
.align 16, 0x90
|
.align 16, 0x90
|
||||||
_foobar: # @foobar
|
_foobar: # @foobar
|
||||||
@ -15,13 +16,30 @@ _foobar: # @foobar
|
|||||||
.globl _rust_crate # @rust_crate
|
.globl _rust_crate # @rust_crate
|
||||||
.align 4
|
.align 4
|
||||||
_rust_crate:
|
_rust_crate:
|
||||||
|
.long 0
|
||||||
|
.long _foobar
|
||||||
|
.long _foobar-_rust_crate
|
||||||
.long _foobar-_rust_crate
|
.long _foobar-_rust_crate
|
||||||
|
|
||||||
|
// CHECK: Name = .data
|
||||||
// CHECK: Relocations = [
|
// CHECK: SectionData =
|
||||||
|
// CHECK-NEXT: 00 00 00 00 00 00 00 00 - 1C 00 00 00 20 00 00 00 |............ ...|
|
||||||
|
// CHECK: Relocations = [
|
||||||
// CHECK-NEXT: 0 = {
|
// CHECK-NEXT: 0 = {
|
||||||
// CHECK-NEXT: VirtualAddress = 0x0
|
// CHECK-NEXT: VirtualAddress = 0x4
|
||||||
// CHECK-NEXT: SymbolTableIndex =
|
// CHECK-NEXT: SymbolTableIndex =
|
||||||
|
// CHECK-NEXT: Type = IMAGE_REL_I386_DIR32 (6)
|
||||||
|
// CHECK-NEXT: SymbolName = _foobar
|
||||||
|
// CHECK-NEXT: }
|
||||||
|
// CHECK-NEXT: 1 = {
|
||||||
|
// CHECK-NEXT: VirtualAddress = 0x8
|
||||||
|
// CHECK-NEXT: SymbolTableIndex = 0
|
||||||
|
// CHECK-NEXT: Type = IMAGE_REL_I386_REL32 (20)
|
||||||
|
// CHECK-NEXT: SymbolName = .text
|
||||||
|
// CHECK-NEXT: }
|
||||||
|
// CHECK-NEXT: 2 = {
|
||||||
|
// CHECK-NEXT: VirtualAddress = 0xC
|
||||||
|
// CHECK-NEXT: SymbolTableIndex = 0
|
||||||
// CHECK-NEXT: Type = IMAGE_REL_I386_REL32 (20)
|
// CHECK-NEXT: Type = IMAGE_REL_I386_REL32 (20)
|
||||||
// CHECK-NEXT: SymbolName = .text
|
// CHECK-NEXT: SymbolName = .text
|
||||||
// CHECK-NEXT: }
|
// CHECK-NEXT: }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user