1// Verify the .fix data section conveys the right offsets and the right relocations 2// RUN: llvm-mc -filetype=obj -triple x86_64-pc-win32 %s -o - | llvm-readobj -r --expand-relocs -S --section-data - | FileCheck %s --check-prefix=READOBJ 3 4 .text 5 .section .rdata,"dr" 6 .globl g1 # @g1 7 .align 4 8g1: 9 .long 1 # 0x1 10 11 .globl g2 # @g2 12 .align 4 13g2: 14 .long 2 # 0x2 15 16 .globl g3 # @g3 17 .align 4 18g3: 19 .long 3 # 0x3 20 21 .globl g4 # @g4 22 .align 4 23g4: 24 .long 4 # 0x4 25 26 .section .fix,"dw" 27 .globl t1 # @t1 28 .align 8 29t1: 30 31 .globl t2 # @t2 32 .align 8 33t2: 34 35 .globl t3 # @t3 36 .align 8 37t3: 38 39 .globl t4 # @t4 40 .align 4 41t4: 42 .long g3-t4 43 44 .globl t5 # @t5 45 .align 4 46t5: 47 .long g3@IMGREL 48 49 .globl t6 # @t6 50 .align 16 51t6: 52 .ascii "\001\002" 53 .zero 6 54 .quad 256 # 0x100 55 .long g3-(t6+16) 56 .zero 4 57 58.long foobar - . 59 60// As an extension, we allow 64-bit label differences. They lower to 61// IMAGE_REL_AMD64_REL32 because IMAGE_REL_AMD64_REL64 does not exist. 62.quad foobar - . 63 64// READOBJ: Section { 65// READOBJ: Number: 66// READOBJ: Name: .fix (2E 66 69 78 00 00 00 00) 67// READOBJ-NEXT: VirtualSize: 0x0 68// READOBJ-NEXT: VirtualAddress: 0x0 69// READOBJ-NEXT: RawDataSize: 70// READOBJ-NEXT: PointerToRawData: 0xEC 71// READOBJ-NEXT: PointerToRelocations: 72// READOBJ-NEXT: PointerToLineNumbers: 0x0 73// READOBJ-NEXT: RelocationCount: 74// READOBJ-NEXT: LineNumberCount: 0 75// READOBJ-NEXT: Characteristics [ (0xC0500040) 76// READOBJ-NEXT: IMAGE_SCN_ALIGN_16BYTES (0x500000) 77// READOBJ-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA (0x40) 78// READOBJ-NEXT: IMAGE_SCN_MEM_READ (0x40000000) 79// READOBJ-NEXT: IMAGE_SCN_MEM_WRITE (0x80000000) 80// READOBJ-NEXT: ] 81// READOBJ-NEXT: SectionData ( 82// READOBJ-NEXT: 0000: 04000000 00000000 00000000 00000000 | 83// READOBJ-NEXT: 0010: 01020000 00000000 00010000 00000000 | 84// READOBJ-NEXT: 0020: 04000000 00000000 04000000 04000000 | 85// READOBJ-NEXT: 0030: 00000000 | 86// READOBJ-NEXT: ) 87// READOBJ-NEXT: } 88// READOBJ-NEXT: ] 89// READOBJ-NEXT: Relocations [ 90// READOBJ-NEXT: Section (5) .fix { 91// READOBJ-NEXT: Relocation { 92// READOBJ-NEXT: Offset: 0x0 93// READOBJ-NEXT: Type: IMAGE_REL_AMD64_REL32 (4) 94// READOBJ-NEXT: Symbol: g3 95// READOBJ-NEXT: SymbolIndex: 12 96// READOBJ-NEXT: } 97// READOBJ-NEXT: Relocation { 98// READOBJ-NEXT: Offset: 0x4 99// READOBJ-NEXT: Type: IMAGE_REL_AMD64_ADDR32NB (3) 100// READOBJ-NEXT: Symbol: g3 101// READOBJ-NEXT: SymbolIndex: 12 102// READOBJ-NEXT: } 103// READOBJ-NEXT: Relocation { 104// READOBJ-NEXT: Offset: 0x20 105// READOBJ-NEXT: Type: IMAGE_REL_AMD64_REL32 (4) 106// READOBJ-NEXT: Symbol: g3 107// READOBJ-NEXT: SymbolIndex: 12 108// READOBJ-NEXT: } 109// READOBJ-NEXT: Relocation { 110// READOBJ-NEXT: Offset: 0x28 111// READOBJ-NEXT: Type: IMAGE_REL_AMD64_REL32 (4) 112// READOBJ-NEXT: Symbol: foobar 113// READOBJ-NEXT: SymbolIndex: 20 114// READOBJ-NEXT: } 115// READOBJ-NEXT: Relocation { 116// READOBJ-NEXT: Offset: 0x2C 117// READOBJ-NEXT: Type: IMAGE_REL_AMD64_REL32 (4) 118// READOBJ-NEXT: Symbol: foobar 119// READOBJ-NEXT: SymbolIndex: 20 120// READOBJ-NEXT: } 121// READOBJ-NEXT: } 122// READOBJ-NEXT:] 123