llvm/llvm/test/ExecutionEngine/JITLink/x86-64/COFF_rel32_4_reloc.test

# RUN: yaml2obj %s -o %t
# RUN: llvm-jitlink -noexec -check %s %t 
# 
# Check IMAGE_REL_AMD64_REL32_4 relocation correctly calculates the
# delta between target and next_pc despite the existance of 4 bytes immediate field.
#
# jitlink-check: decode_operand(main, 3) = func - next_pc(main)
--- !COFF
header:
  Machine:         IMAGE_FILE_MACHINE_AMD64
  Characteristics: [  ]
sections:
  - Name:            .text
    Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
    Alignment:       16
# The disassembly of main block data is:
# 0: f7 05 00 00 00 00 00 00 00 00 testl   $0, (%rip)
#         0000000000000002:  IMAGE_REL_AMD64_REL32_4      func
# a: e8 00 00 00 00                callq   0xf <main+0xf>
#         000000000000000b:  IMAGE_REL_AMD64_REL32        func
# f: c3                            retq
    SectionData:     F7050000000000000000E800000000C3C3
    Relocations:
      - VirtualAddress:  2
        SymbolName:      func
        Type:            IMAGE_REL_AMD64_REL32_4
      - VirtualAddress:  11
        SymbolName:      func
        Type:            IMAGE_REL_AMD64_REL32
  - Name:            .data
    Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
    Alignment:       4
    SectionData:     ''
  - Name:            .bss
    Characteristics: [ IMAGE_SCN_CNT_UNINITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
    Alignment:       4
    SectionData:     ''
    SizeOfRawData:   0
symbols:
  - Name:            .text
    Value:           0
    SectionNumber:   1
    SimpleType:      IMAGE_SYM_TYPE_NULL
    ComplexType:     IMAGE_SYM_DTYPE_NULL
    StorageClass:    IMAGE_SYM_CLASS_STATIC
    SectionDefinition:
      Length:          17
      NumberOfRelocations: 1
      NumberOfLinenumbers: 0
      CheckSum:        1443257137
      Number:          1
  - Name:            .data
    Value:           0
    SectionNumber:   2
    SimpleType:      IMAGE_SYM_TYPE_NULL
    ComplexType:     IMAGE_SYM_DTYPE_NULL
    StorageClass:    IMAGE_SYM_CLASS_STATIC
    SectionDefinition:
      Length:          0
      NumberOfRelocations: 0
      NumberOfLinenumbers: 0
      CheckSum:        0
      Number:          2
  - Name:            .bss
    Value:           0
    SectionNumber:   3
    SimpleType:      IMAGE_SYM_TYPE_NULL
    ComplexType:     IMAGE_SYM_DTYPE_NULL
    StorageClass:    IMAGE_SYM_CLASS_STATIC
    SectionDefinition:
      Length:          0
      NumberOfRelocations: 0
      NumberOfLinenumbers: 0
      CheckSum:        0
      Number:          3
  - Name:            main
    Value:           0
    SectionNumber:   1
    SimpleType:      IMAGE_SYM_TYPE_NULL
    ComplexType:     IMAGE_SYM_DTYPE_FUNCTION
    StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
  - Name:            func
    Value:           16
    SectionNumber:   1
    SimpleType:      IMAGE_SYM_TYPE_NULL
    ComplexType:     IMAGE_SYM_DTYPE_FUNCTION
    StorageClass:    IMAGE_SYM_CLASS_EXTERNAL