llvm.org GIT mirror llvm / 1ac7fe0
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 Rafael Espindola 9 years ago
2 changed file(s) with 28 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
655655 const MCSymbol *B = &Target.getSymB()->getSymbol();
656656 MCSymbolData &B_SD = Asm.getSymbolData(*B);
657657
658 FixedValue = Layout.getSymbolOffset(&A_SD) - Layout.getSymbolOffset(&B_SD);
659
658 // Offset of the symbol in the section
659 int64_t a = Layout.getSymbolOffset(&B_SD);
660
661 // Ofeset of the relocation in the section
662 int64_t b = Layout.getFragmentOffset(Fragment) + Fixup.getOffset();
663
664 FixedValue = b - a;
660665 // In the case where we have SymbA and SymB, we just need to store the delta
661666 // between the two symbols. Update FixedValue to account for the delta, and
662667 // skip recording the relocation.
44 .type 32;
55 .endef
66 .text
7 .long 0
78 .globl _foobar
89 .align 16, 0x90
910 _foobar: # @foobar
1415 .globl _rust_crate # @rust_crate
1516 .align 4
1617 _rust_crate:
18 .long 0
19 .long _foobar
20 .long _foobar-_rust_crate
1721 .long _foobar-_rust_crate
1822
19
20 // CHECK: Relocations = [
23 // CHECK: Name = .data
24 // CHECK: SectionData =
25 // CHECK-NEXT: 00 00 00 00 00 00 00 00 - 1C 00 00 00 20 00 00 00 |............ ...|
26 // CHECK: Relocations = [
2127 // CHECK-NEXT: 0 = {
22 // CHECK-NEXT: VirtualAddress = 0x0
28 // CHECK-NEXT: VirtualAddress = 0x4
2329 // CHECK-NEXT: SymbolTableIndex =
30 // CHECK-NEXT: Type = IMAGE_REL_I386_DIR32 (6)
31 // CHECK-NEXT: SymbolName = _foobar
32 // CHECK-NEXT: }
33 // CHECK-NEXT: 1 = {
34 // CHECK-NEXT: VirtualAddress = 0x8
35 // CHECK-NEXT: SymbolTableIndex = 0
36 // CHECK-NEXT: Type = IMAGE_REL_I386_REL32 (20)
37 // CHECK-NEXT: SymbolName = .text
38 // CHECK-NEXT: }
39 // CHECK-NEXT: 2 = {
40 // CHECK-NEXT: VirtualAddress = 0xC
41 // CHECK-NEXT: SymbolTableIndex = 0
2442 // CHECK-NEXT: Type = IMAGE_REL_I386_REL32 (20)
2543 // CHECK-NEXT: SymbolName = .text
2644 // CHECK-NEXT: }