1## In this test case we check how we print section and flag descriptions for different targets.
2
3## EM_386 is a target that does not have any processor and OS specific flags,
4## we use it to show how the default flag key is printed.
5
6# RUN: yaml2obj --docnum=1 %s -o %t-i386.o
7# RUN: llvm-readelf -S %t-i386.o | FileCheck %s --check-prefix=ELF32 --strict-whitespace --match-full-lines
8
9#       ELF32:There are 8 section headers, starting at offset 0x90:
10# ELF32-EMPTY:
11# ELF32-NEXT:Section Headers:
12# ELF32-NEXT:  [Nr] Name              Type            Address  Off    Size   ES Flg Lk Inf Al
13# ELF32-NEXT:  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
14# ELF32-NEXT:  [ 1] .text             PROGBITS        00000000 000034 000001 00  AX  0   0  4
15# ELF32-NEXT:  [ 2] .rel.text         REL             00000000 000038 000000 08      5   1  4
16# ELF32-NEXT:  [ 3] .data             PROGBITS        00000000 000038 000000 00  WA  0   0  4
17# ELF32-NEXT:  [ 4] .bss              NOBITS          00000000 000038 000000 00  WA  0   0  4
18# ELF32-NEXT:  [ 5] .symtab           SYMTAB          00000000 000038 000020 10      6   2  8
19# ELF32-NEXT:  [ 6] .strtab           STRTAB          00000000 000058 000007 00      0   0  1
20# ELF32-NEXT:  [ 7] .shstrtab         STRTAB          00000000 00005f 000030 00      0   0  1
21# ELF32-NEXT:Key to Flags:
22# ELF32-NEXT:  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
23# ELF32-NEXT:  L (link order), O (extra OS processing required), G (group), T (TLS),
24# ELF32-NEXT:  C (compressed), x (unknown), o (OS specific), E (exclude),
25# ELF32-NEXT:  p (processor specific)
26
27--- !ELF
28FileHeader:
29  Class:   ELFCLASS32
30  Data:    ELFDATA2LSB
31  OSABI:   ELFOSABI_GNU
32  Type:    ET_REL
33  Machine: EM_386
34Sections:
35  - Name:         .text
36    Type:         SHT_PROGBITS
37    Flags:        [ SHF_ALLOC, SHF_EXECINSTR ]
38    AddressAlign: 0x0000000000000004
39    Content:      00
40  - Name:         .rel.text
41    Type:         SHT_REL
42    Link:         .symtab
43    AddressAlign: 0x0000000000000004
44    EntSize:      0x0000000000000008
45    Info:         .text
46    Relocations:
47  - Name:         .data
48    Type:         SHT_PROGBITS
49    Flags:        [ SHF_WRITE, SHF_ALLOC ]
50    AddressAlign: 0x0000000000000004
51    Content:      ''
52  - Name:         .bss
53    Type:         SHT_NOBITS
54    Flags:        [ SHF_WRITE, SHF_ALLOC ]
55    AddressAlign: 0x0000000000000004
56Symbols:
57  - Name:         .text
58    Type:         STT_SECTION
59    Section:      .text
60
61## For an EM_X86_64 target we print "l" for the SHF_X86_64_LARGE section flag.
62## Check we mention it in the flag key.
63
64# RUN: yaml2obj --docnum=2 %s -o %t-x64.o
65# RUN: llvm-readelf -S %t-x64.o | FileCheck %s --check-prefix=ELF64 --strict-whitespace --match-full-lines
66
67## Check that --wide is the same as -W and ignored and also
68## that --section is the same as -S.
69# RUN: llvm-readobj --wide --sections %t-x64.o --elf-output-style=GNU \
70# RUN:   | FileCheck %s --check-prefix=ELF64
71# RUN: llvm-readobj -W --sections %t-x64.o --elf-output-style=GNU \
72# RUN:   | FileCheck %s --check-prefix=ELF64
73# RUN: llvm-readelf -W -S %t-x64.o | FileCheck %s --check-prefix=ELF64
74
75#       ELF64:There are 8 section headers, starting at offset 0xb0:
76# ELF64-EMPTY:
77# ELF64-NEXT:Section Headers:
78# ELF64-NEXT:  [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
79# ELF64-NEXT:  [ 0]                   NULL            0000000000000000 000000 000000 00      0   0  0
80# ELF64-NEXT:  [ 1] .text             PROGBITS        0000000000000000 000040 000001 00  AX  0   0  4
81# ELF64-NEXT:  [ 2] .rela.text        RELA            0000000000000000 000048 000000 18      5   1  8
82# ELF64-NEXT:  [ 3] .data             PROGBITS        0000000000000000 000048 000000 00  WA  0   0  4
83# ELF64-NEXT:  [ 4] .bss              NOBITS          0000000000000000 000048 000000 00  WA  0   0  4
84# ELF64-NEXT:  [ 5] .symtab           SYMTAB          0000000000000000 000048 000030 18      6   2  8
85# ELF64-NEXT:  [ 6] .strtab           STRTAB          0000000000000000 000078 000007 00      0   0  1
86# ELF64-NEXT:  [ 7] .shstrtab         STRTAB          0000000000000000 00007f 000031 00      0   0  1
87# ELF64-NEXT:Key to Flags:
88# ELF64-NEXT:  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
89# ELF64-NEXT:  L (link order), O (extra OS processing required), G (group), T (TLS),
90# ELF64-NEXT:  C (compressed), x (unknown), o (OS specific), E (exclude),
91# ELF64-NEXT:  l (large), p (processor specific)
92
93--- !ELF
94FileHeader:
95  Class:   ELFCLASS64
96  Data:    ELFDATA2LSB
97  OSABI:   ELFOSABI_GNU
98  Type:    ET_REL
99  Machine: EM_X86_64
100Sections:
101  - Name:         .text
102    Type:         SHT_PROGBITS
103    Flags:        [ SHF_ALLOC, SHF_EXECINSTR ]
104    AddressAlign: 0x0000000000000004
105    Content:      00
106  - Name:         .rela.text
107    Type:         SHT_RELA
108    Link:         .symtab
109    AddressAlign: 0x0000000000000008
110    EntSize:      0x0000000000000018
111    Info:         .text
112    Relocations:
113  - Name:         .data
114    Type:         SHT_PROGBITS
115    Flags:        [ SHF_WRITE, SHF_ALLOC ]
116    AddressAlign: 0x0000000000000004
117    Content:      ''
118  - Name:         .bss
119    Type:         SHT_NOBITS
120    Flags:        [ SHF_WRITE, SHF_ALLOC ]
121    AddressAlign: 0x0000000000000004
122Symbols:
123  - Name:    .text
124    Type:    STT_SECTION
125    Section: .text
126
127## For an EM_ARM target we print "y" for the SHF_ARM_PURECODE section flag.
128## Check we mention it in the flag key.
129
130# RUN: yaml2obj --docnum=3 %s -o %t-arm.o
131# RUN: llvm-readelf -S %t-arm.o | FileCheck %s --check-prefix=ARM --strict-whitespace --match-full-lines
132
133#      ARM:Key to Flags:
134# ARM-NEXT:  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
135# ARM-NEXT:  L (link order), O (extra OS processing required), G (group), T (TLS),
136# ARM-NEXT:  C (compressed), x (unknown), o (OS specific), E (exclude),
137# ARM-NEXT:  y (purecode), p (processor specific)
138
139--- !ELF
140FileHeader:
141  Class:   ELFCLASS64
142  Data:    ELFDATA2LSB
143  Type:    ET_REL
144  Machine: EM_ARM
145Sections: []
146