File: elf-disassemble-symbolize-operands.yaml

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (151 lines) | stat: -rw-r--r-- 5,154 bytes parent folder | download | duplicates (4)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# RUN: rm -rf %t
# RUN: %split-file %s %t

# RUN: yaml2obj %t/zero-secaddr.yml -o %t/zero-secaddr
# RUN: llvm-objdump %t/zero-secaddr -d --symbolize-operands\
# RUN:  --no-show-raw-insn --no-leading-addr | FileCheck %s

# RUN: yaml2obj %t/nonzero-secaddr.yml -o %t/nonzero-secaddr
# RUN: llvm-objdump %t/nonzero-secaddr -d --symbolize-operands\
# RUN:  --no-show-raw-insn --no-leading-addr | FileCheck %s

## Expect to find the branch labels.
# CHECK: <break_cond_is_arg>:
# CHECK:     s_branch L1
# CHECK: <L0>:
# CHECK:     s_cbranch_execz L2
# CHECK: <L1>:
# CHECK:     s_branch L0
# CHECKL <L2>:

# I created this YAML starting with this LLVM IR:
#
#   define void @break_cond_is_arg(i32 %arg, i1 %breakcond) {
#   entry:
#     br label %loop
#   loop:
#     %tmp23phi = phi i32 [ %tmp23, %endif ], [ 0, %entry ]
#     %tmp23 = add nuw i32 %tmp23phi, 1
#     %tmp27 = icmp ult i32 %arg, %tmp23
#     br i1 %tmp27, label %then, label %endif
#   then:                                             ; preds = %bb
#     call void @llvm.amdgcn.raw.buffer.store.f32(float undef, <4 x i32> undef, i32 0, i32 undef, i32 0)
#     br label %endif
#   endif:                                             ; preds = %bb28, %bb
#     br i1 %breakcond, label %loop, label %loopexit
#   loopexit:
#     ret void
#   }
#
#   declare void @llvm.amdgcn.raw.buffer.store.f32(float, <4 x i32>, i32, i32, i32 immarg) #0
#
#   attributes #0 = { nounwind writeonly }
#
# I compiled it to a relocatable ELF:
#
#   llc -march=amdgcn -mcpu=gfx1030 llvm/a.ll -filetype=obj -o a.elf
#
# then converted it to YAML:
#
#   obj2yaml a.elf
#
# then manually removed the BB0_1 etc local symbols.
#
# Note that there are two copies of the file:
#   - One as a relocatable object file (zero section addresses)
#   - One as a shared object file (non-zero section addresses)

#--- zero-secaddr.yml
--- !ELF
FileHeader:
  Class:           ELFCLASS64
  Data:            ELFDATA2LSB
  Type:            ET_REL
  Machine:         EM_AMDGPU
  Flags:           [ EF_AMDGPU_MACH_AMDGCN_GFX1030 ]
Sections:
  - Name:            .text
    Type:            SHT_PROGBITS
    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
    AddressAlign:    0x4
    Content:         00008CBF0000FDBB81020236810385BE800384BE8102847D6AC10689040082BF7E077E88058105817E047E8A080088BF0500887D7E060787070404886A3C87BEF7FF88BF000070E000000104F4FF82BF7E047E880000FDBB1E2080BE
  - Name:            .AMDGPU.config
    Type:            SHT_PROGBITS
    AddressAlign:    0x1
    Content:         48B80000000000004CB800000000000060B800000000000004000000000000000800000000000000
  - Name:            .note.GNU-stack
    Type:            SHT_PROGBITS
    AddressAlign:    0x1
  - Name:            .note
    Type:            SHT_NOTE
    AddressAlign:    0x4
    Notes:
      - Name:            AMD
        Desc:            616D6467636E2D756E6B6E6F776E2D6C696E75782D676E752D67667831303330
        Type:            NT_FREEBSD_PROCSTAT_GROUPS
  - Type:            SectionHeaderTable
    Sections:
      - Name:            .strtab
      - Name:            .shstrtab
      - Name:            .text
      - Name:            .AMDGPU.config
      - Name:            .note.GNU-stack
      - Name:            .note
      - Name:            .symtab
Symbols:
  - Name:            break_cond_is_arg
    Type:            STT_FUNC
    Section:         .text
    Binding:         STB_GLOBAL
    Size:            0x5C
...

#--- nonzero-secaddr.yml
--- !ELF
FileHeader:
  Class:           ELFCLASS64
  Data:            ELFDATA2LSB
  Type:            ET_DYN
  Machine:         EM_AMDGPU
  Flags:           [ EF_AMDGPU_MACH_AMDGCN_GFX1030 ]
Sections:
  - Name:            .text
    Type:            SHT_PROGBITS
    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
    Address:         0x1000
    AddressAlign:    0x4
    Content:         00008CBF0000FDBB81020236810385BE800384BE8102847D6AC10689040082BF7E077E88058105817E047E8A080088BF0500887D7E060787070404886A3C87BEF7FF88BF000070E000000104F4FF82BF7E047E880000FDBB1E2080BE
  - Name:            .AMDGPU.config
    Type:            SHT_PROGBITS
    Address:         0x2000
    AddressAlign:    0x1
    Content:         48B80000000000004CB800000000000060B800000000000004000000000000000800000000000000
  - Name:            .note.GNU-stack
    Type:            SHT_PROGBITS
    Address:         0x3000
    AddressAlign:    0x1
  - Name:            .note
    Type:            SHT_NOTE
    Address:         0x4000
    AddressAlign:    0x4
    Notes:
      - Name:            AMD
        Desc:            616D6467636E2D756E6B6E6F776E2D6C696E75782D676E752D67667831303330
        Type:            NT_FREEBSD_PROCSTAT_GROUPS
  - Type:            SectionHeaderTable
    Sections:
      - Name:            .strtab
      - Name:            .shstrtab
      - Name:            .text
      - Name:            .AMDGPU.config
      - Name:            .note.GNU-stack
      - Name:            .note
      - Name:            .symtab
Symbols:
  - Name:            break_cond_is_arg
    Type:            STT_FUNC
    Section:         .text
    Binding:         STB_GLOBAL
    Size:            0x5C
    Value:           0x1000
...