xref: /llvm-project/llvm/test/tools/llvm-readobj/XCOFF/loader-section-symbol.test (revision 3034632a2708f3b79aa30f895dc42f35569c3647)
1## Test the --loader-section-symbols option.
2
3# RUN: yaml2obj --docnum=1 -DSYMNUM=2 %s -o %t_xcoff32.o
4# RUN: yaml2obj --docnum=1 -DSYMNUM=4 %s -o %t_xcoff32_invalid.o
5# RUN: yaml2obj --docnum=2 %s -o %t_xcoff64.o
6
7# RUN: llvm-readobj --loader-section-symbols %t_xcoff32.o |\
8# RUN:   FileCheck %s --check-prefixes=CHECK32
9# RUN: llvm-readobj --loader-section-symbols --no-demangle %t_xcoff32.o |\
10# RUN:   FileCheck %s --check-prefixes=CHECK32
11# RUN: llvm-readobj --loader-section-symbols --demangle %t_xcoff32.o |\
12# RUN:   FileCheck %s --check-prefixes=CHECK32
13# RUN: llvm-readobj --loader-section-symbols %t_xcoff32_invalid.o 2>&1 |\
14# RUN:   FileCheck -DFILE=%t_xcoff32_invalid.o %s --check-prefixes=CHECK32,WARN
15# RUN: llvm-readobj --loader-section-symbols %t_xcoff64.o |\
16# RUN:   FileCheck %s --check-prefixes=CHECK64,NODEMAN64
17# RUN: llvm-readobj --loader-section-symbols --no-demangle %t_xcoff64.o |\
18# RUN:   FileCheck %s --check-prefixes=CHECK64,NODEMAN64
19# RUN: llvm-readobj --loader-section-symbols --demangle %t_xcoff64.o |\
20# RUN:   FileCheck %s --check-prefixes=CHECK64,DEMAN64
21
22--- !XCOFF
23FileHeader:
24  MagicNumber:       0x1DF
25Sections:
26  - Name:            .loader
27    Flags:           [ STYP_LOADER ]
28    SectionData:     "000000010000000[[SYMNUM]]000000050000016D00000001000000A40000000c000000506d79696e74766172200002800002110500000000000000000000000000000002200002840002110a0000000000000000000a66756e63305f5f467600"
29##                    ^-------                                                           -Version=1
30##                            ^----------------                                                   -NumberOfSymbolEntries=SYMNUM
31##                                             ^-------                                           -NumberOfRelocationEntries=5
32##                                                     ^-------                                   -LengthOfImportFileIDStringTable=365
33##                                                             ^-------                           -NumberOfImportFileIDs=1
34##                                                                     ^-------                   -OffsetToImportFileIDs=0xA4
35##                                                                             ^-------           -LengthOfStringTable=12
36##                                                                                     ^-------   -OffsetToStringTable=0x050
37##                                                                                             ^---------------         SymbolName=myintvar
38##                                                                                                             ^------- Value=0x20000280
39##                                                                                                                     ^---  sectionNumber = 2
40##                                                                                                                         ^- SymbolType=0x11
41##                                                                                                                           ^- StorageClass=0x05
42##                                                                                                                             ^-------   ImportFileID=0
43##                                                                                                                                     ^-------ParameterCheckType=0
44##                                                                                                                                             ^-------SymbolZero=0
45##                                                                                                                                                     ^-------OffsetToSymTbl=2
46##                                                                                                                                                             ^------- Value=20000284
47##                                                                                                                                                                     ^---  sectionNumber = 2
48##                                                                                                                                                                         ^- SymbolType=0x11
49##                                                                                                                                                                           ^- StorageClass=0x0a
50##                                                                                                                                                                              ^-------   ImportFileID=0
51##                                                                                                                                                                                      ^-------ParameterCheckType=0
52##                                                                                                                                                                                              ^StringTable
53
54--- !XCOFF
55FileHeader:
56  MagicNumber:       0x1F7
57Sections:
58  - Name:            .loader
59    Flags:           [ STYP_LOADER ]
60    SectionData:     "0000000200000002000000050000016D000000010000001200000000000000D000000000000000680000000000000038000000000000008000000001100003000000000200021105000000000000000000000001100003080000000d0002110a000000000000000000096d79696e7476617200000a5f5a3566756e6330760000"
61##                    ^-------                                                           -Version=2
62##                            ^-------                                                   -NumberOfSymbolEntries=2
63##                                    ^-------                                           -NumberOfRelocationEntries=5
64##                                            ^-------                                   -LengthOfImportFileIDStringTable=365
65##                                                    ^-------                           -NumberOfImportFileIDs=1
66##                                                            ^-------                   --LengthOfStringTable=0x12
67##                                                                    ^---------------   -OffsetToImportFileIDs=0xD0
68##                                                                                    ^---------------   -OffsetToStringTable=0x68
69##                                                                                                    ^---------------  -OffsetToSymbolTable=0x38
70##                                                                                                                    ^---------------   -OffsetToRelocationEntries=0x80
71##                                                                                                                                    ^---------------         Value=0x0000000110000300
72##                                                                                                                                                    ^------- OffsetToStringTbl=2
73##                                                                                                                                                            ^---  sectionNumber = 2
74##                                                                                                                                                                ^- SymbolType=0x11
75##                                                                                                                                                                  ^- StorageClass=0x05
76##                                                                                                                                                                    ^-------   ImportFileID=0
77##                                                                                                                                                                            ^-------ParameterCheckType=0
78##                                                                                                                                                                                    ^--------------- Value=0x0000000110000308
79##                                                                                                                                                                                                    ^------- OffsetToStringTbl= 0x0d
80##                                                                                                                                                                                                            ^---  sectionNumber = 2
81##                                                                                                                                                                                                                ^- SymbolType=0x11
82##                                                                                                                                                                                                                  ^- StorageClass=0x0a
83##                                                                                                                                                                                                                    ^-------   ImportFileID=0
84##                                                                                                                                                                                                                            ^-------ParameterCheckType=0
85##                                                                                                                                                                                                                                    ^StringTable
86
87# CHECK32:      Loader Section {
88# CHECK32-NEXT:     Loader Section Symbols {
89# CHECK32-NEXT:       Symbol {
90# CHECK32-NEXT:         Name: myintvar
91# CHECK32-NEXT:         Virtual Address: 0x20000280
92# CHECK32-NEXT:         SectionNum: 2
93# CHECK32-NEXT:         SymbolType: 0x11
94# CHECK32-NEXT:         StorageClass: C_EXTDEF (0x5)
95# CHECK32-NEXT:         ImportFileID: 0x0
96# CHECK32-NEXT:         ParameterTypeCheck: 0
97# CHECK32-NEXT:       }
98# CHECK32-NEXT:       Symbol {
99# CHECK32-NEXT:         Name: func0__Fv
100# CHECK32-NEXT:         Virtual Address: 0x20000284
101# CHECK32-NEXT:         SectionNum: 2
102# CHECK32-NEXT:         SymbolType: 0x11
103# CHECK32-NEXT:         StorageClass: C_STRTAG (0xA)
104# CHECK32-NEXT:         ImportFileID: 0x0
105# CHECK32-NEXT:         ParameterTypeCheck: 0
106# CHECK32-NEXT:       }
107# WARN:          warning: '[[FILE]]': The end of the file was unexpectedly encountered
108# CHECK32-NEXT:     }
109# CHECK32-NEXT: }
110
111# CHECK64:      Loader Section {
112# CHECK64-NEXT:     Loader Section Symbols {
113# CHECK64-NEXT:       Symbol {
114# CHECK64-NEXT:         Name: myintvar
115# CHECK64-NEXT:         Virtual Address: 0x110000300
116# CHECK64-NEXT:         SectionNum: 2
117# CHECK64-NEXT:         SymbolType: 0x11
118# CHECK64-NEXT:         StorageClass: C_EXTDEF (0x5)
119# CHECK64-NEXT:         ImportFileID: 0x0
120# CHECK64-NEXT:         ParameterTypeCheck: 0
121# CHECK64-NEXT:       }
122# CHECK64-NEXT:       Symbol {
123# NODEMAN64-NEXT:       Name: _Z5func0v
124# DEMAN64-NEXT:         Name: func0()
125# CHECK64-NEXT:         Virtual Address: 0x110000308
126# CHECK64-NEXT:         SectionNum: 2
127# CHECK64-NEXT:         SymbolType: 0x11
128# CHECK64-NEXT:         StorageClass: C_STRTAG (0xA)
129# CHECK64-NEXT:         ImportFileID: 0x0
130# CHECK64-NEXT:         ParameterTypeCheck: 0
131# CHECK64-NEXT:       }
132# CHECK64-NEXT:     }
133# CHECK64-NEXT: }
134