summaryrefslogtreecommitdiffstats
path: root/llvm/test/tools/llvm-readobj/ELF/gnu-sections.test
blob: 532ca22d3195b5c237cb893be7f6acd721a8c896 (plain)
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
## In this test case we check how we print section and flag descriptions for different targets.

## EM_386 is a target that does not have any processor and OS specific flags,
## we use it to show how the default flag key is printed.

# RUN: yaml2obj --docnum=1 %s -o %t-i386.o
# RUN: llvm-readelf -S %t-i386.o | FileCheck %s --check-prefix=ELF32 --strict-whitespace --match-full-lines

#       ELF32:There are 8 section headers, starting at offset 0x90:
# ELF32-EMPTY:
# ELF32-NEXT:Section Headers:
# ELF32-NEXT:  [Nr] Name              Type            Address  Off    Size   ES Flg Lk Inf Al
# ELF32-NEXT:  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
# ELF32-NEXT:  [ 1] .text             PROGBITS        00000000 000034 000001 00  AX  0   0  4
# ELF32-NEXT:  [ 2] .rel.text         REL             00000000 000038 000000 08      5   1  4
# ELF32-NEXT:  [ 3] .data             PROGBITS        00000000 000038 000000 00  WA  0   0  4
# ELF32-NEXT:  [ 4] .bss              NOBITS          00000000 000038 000000 00  WA  0   0  4
# ELF32-NEXT:  [ 5] .symtab           SYMTAB          00000000 000038 000020 10      6   2  8
# ELF32-NEXT:  [ 6] .strtab           STRTAB          00000000 000058 000007 00      0   0  1
# ELF32-NEXT:  [ 7] .shstrtab         STRTAB          00000000 00005f 000030 00      0   0  1
# ELF32-NEXT:Key to Flags:
# ELF32-NEXT:  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
# ELF32-NEXT:  L (link order), O (extra OS processing required), G (group), T (TLS),
# ELF32-NEXT:  C (compressed), x (unknown), o (OS specific), E (exclude),
# ELF32-NEXT:  p (processor specific)

--- !ELF
FileHeader:
  Class:   ELFCLASS32
  Data:    ELFDATA2LSB
  OSABI:   ELFOSABI_GNU
  Type:    ET_REL
  Machine: EM_386
Sections:
  - Name:         .text
    Type:         SHT_PROGBITS
    Flags:        [ SHF_ALLOC, SHF_EXECINSTR ]
    AddressAlign: 0x0000000000000004
    Content:      00
  - Name:         .rel.text
    Type:         SHT_REL
    Link:         .symtab
    AddressAlign: 0x0000000000000004
    EntSize:      0x0000000000000008
    Info:         .text
    Relocations:
  - Name:         .data
    Type:         SHT_PROGBITS
    Flags:        [ SHF_WRITE, SHF_ALLOC ]
    AddressAlign: 0x0000000000000004
    Content:      ''
  - Name:         .bss
    Type:         SHT_NOBITS
    Flags:        [ SHF_WRITE, SHF_ALLOC ]
    AddressAlign: 0x0000000000000004
Symbols:
  - Name:         .text
    Type:         STT_SECTION
    Section:      .text

## For an EM_X86_64 target we print "l" for the SHF_X86_64_LARGE section flag.
## Check we mention it in the flag key.

# RUN: yaml2obj --docnum=2 %s -o %t-x64.o
# RUN: llvm-readelf -S %t-x64.o | FileCheck %s --check-prefix=ELF64 --strict-whitespace --match-full-lines

## Check that --wide is the same as -W and ignored and also
## that --section is the same as -S.
# RUN: llvm-readobj --wide --sections %t-x64.o --elf-output-style=GNU \
# RUN:   | FileCheck %s --check-prefix=ELF64
# RUN: llvm-readobj -W --sections %t-x64.o --elf-output-style=GNU \
# RUN:   | FileCheck %s --check-prefix=ELF64
# RUN: llvm-readelf -W -S %t-x64.o | FileCheck %s --check-prefix=ELF64

#       ELF64:There are 8 section headers, starting at offset 0xb0:
# ELF64-EMPTY:
# ELF64-NEXT:Section Headers:
# ELF64-NEXT:  [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
# ELF64-NEXT:  [ 0]                   NULL            0000000000000000 000000 000000 00      0   0  0
# ELF64-NEXT:  [ 1] .text             PROGBITS        0000000000000000 000040 000001 00  AX  0   0  4
# ELF64-NEXT:  [ 2] .rela.text        RELA            0000000000000000 000048 000000 18      5   1  8
# ELF64-NEXT:  [ 3] .data             PROGBITS        0000000000000000 000048 000000 00  WA  0   0  4
# ELF64-NEXT:  [ 4] .bss              NOBITS          0000000000000000 000048 000000 00  WA  0   0  4
# ELF64-NEXT:  [ 5] .symtab           SYMTAB          0000000000000000 000048 000030 18      6   2  8
# ELF64-NEXT:  [ 6] .strtab           STRTAB          0000000000000000 000078 000007 00      0   0  1
# ELF64-NEXT:  [ 7] .shstrtab         STRTAB          0000000000000000 00007f 000031 00      0   0  1
# ELF64-NEXT:Key to Flags:
# ELF64-NEXT:  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
# ELF64-NEXT:  L (link order), O (extra OS processing required), G (group), T (TLS),
# ELF64-NEXT:  C (compressed), x (unknown), o (OS specific), E (exclude),
# ELF64-NEXT:  l (large), p (processor specific)

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  OSABI:   ELFOSABI_GNU
  Type:    ET_REL
  Machine: EM_X86_64
Sections:
  - Name:         .text
    Type:         SHT_PROGBITS
    Flags:        [ SHF_ALLOC, SHF_EXECINSTR ]
    AddressAlign: 0x0000000000000004
    Content:      00
  - Name:         .rela.text
    Type:         SHT_RELA
    Link:         .symtab
    AddressAlign: 0x0000000000000008
    EntSize:      0x0000000000000018
    Info:         .text
    Relocations:
  - Name:         .data
    Type:         SHT_PROGBITS
    Flags:        [ SHF_WRITE, SHF_ALLOC ]
    AddressAlign: 0x0000000000000004
    Content:      ''
  - Name:         .bss
    Type:         SHT_NOBITS
    Flags:        [ SHF_WRITE, SHF_ALLOC ]
    AddressAlign: 0x0000000000000004
Symbols:
  - Name:    .text
    Type:    STT_SECTION
    Section: .text

## For an EM_ARM target we print "y" for the SHF_ARM_PURECODE section flag.
## Check we mention it in the flag key.

# RUN: yaml2obj --docnum=3 %s -o %t-arm.o
# RUN: llvm-readelf -S %t-arm.o | FileCheck %s --check-prefix=ARM --strict-whitespace --match-full-lines

#      ARM:Key to Flags:
# ARM-NEXT:  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
# ARM-NEXT:  L (link order), O (extra OS processing required), G (group), T (TLS),
# ARM-NEXT:  C (compressed), x (unknown), o (OS specific), E (exclude),
# ARM-NEXT:  y (purecode), p (processor specific)

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_REL
  Machine: EM_ARM
Sections: []
OpenPOWER on IntegriCloud