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