reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
## Show that references in disassembly are labelled with the correct symbol.
# RUN: yaml2obj %s --docnum=1 -o %t
# RUN: llvm-objdump %t -d | FileCheck %s --check-prefix=EXEC

# EXEC: Disassembly of section .text1:
# EXEC:     4000: e8 00 00 00 00                callq   0 <third>
# EXEC: Disassembly of section .text2:
# EXEC:     4005: e8 12 34 56 78                callq   2018915346 <fourth+0x78563412>

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_EXEC
  Machine: EM_X86_64
Sections:
  - Name:    .text1
    Type:    SHT_PROGBITS
    Address: 0x4000
    Flags:   [SHF_ALLOC, SHF_EXECINSTR]
    Content: 'e800000000' # Case 1: Referencing an address with a symbol.
  - Name:    .text2
    Type:    SHT_PROGBITS
    Flags:   [SHF_ALLOC, SHF_EXECINSTR]
    Address: 0x4005
    Content: 'e812345678' # Case 2: Referencing an address without a symbol.
  - Name:    .text3
    Type:    SHT_PROGBITS
    Flags:   [SHF_ALLOC, SHF_EXECINSTR]
    Address: 0x400A
Symbols:
  - Name:    first
    Section: .text1
    Value:   0x4000
  - Name:    second
    Section: .text1
    Value:   0x4005
  - Name:    third
    Section: .text2
    Value:   0x4005
  - Name:    fourth
    Section: .text3
    Value:   0x400A

# RUN: yaml2obj %s --docnum=2 -o %t.o
# RUN: llvm-objdump %t.o -d | FileCheck %s --check-prefix=REL

# REL:      Disassembly of section .text1:
# REL-EMPTY:
# REL-NEXT: 0000000000000000 .text1:
# REL-NEXT:        0: e8 00 00 00 00                callq   0 <.text1+0x5>
# REL-EMPTY:
# REL-NEXT: Disassembly of section .text2:
# REL-EMPTY:
# REL-NEXT: 0000000000000000 .text2:
# REL-NEXT:        0: e8 00 00 00 00                callq   0 <sym2>
# REL-EMPTY:
# REL-NEXT: Disassembly of section .text3:
# REL-EMPTY:
# REL-NEXT: 0000000000000000 .text3:
# REL-NEXT:        0: e8 00 00 00 00                callq   0 <.text3+0x5>

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_REL
  Machine: EM_X86_64
Sections:
  - Name:    .text1
    Type:    SHT_PROGBITS
    Flags:   [SHF_ALLOC, SHF_EXECINSTR]
    Content: 'e800000000' # Case 1: Instruction is patched by a relocation.
  - Name:    .rela.text1
    Type:    SHT_RELA
    Info:    .text1
    Relocations:
      - Offset: 1
        Type:   R_X86_64_PC32
        Symbol: sym3
  - Name:    .text2
    Type:    SHT_PROGBITS
    Flags:   [SHF_ALLOC, SHF_EXECINSTR]
    Content: 'e800000000' # Case 2: Referencing an address with a matching symbol in that section.
  - Name:    .text3
    Type:    SHT_PROGBITS
    Flags:   [SHF_ALLOC, SHF_EXECINSTR]
    Content: 'e800000000' # Case 3: Referencing an address without a matching symbol in that section.
  - Name:    .other
    Type:    SHT_PROGBITS
Symbols:
  # Shouldn't be picked, despite matching value, as not in right section.
  - Name:    sym1
    Section: .other
    Value:   5
  # Symbol in correct section, with right value should be picked for disassembly of .text2.
  - Name:    sym2
    Section: .text2
    Value:   5
  # Symbol referenced by relocation could be picked for disassembly of .text1, but isn't.
  - Name:    sym3