xref: /llvm-project/llvm/test/tools/llvm-size/elf-sysv.test (revision 55c81d4282c5da0189711261a11537bc8a7fe85c)
1## Show that llvm-sizes works correctly on a typical ELF input for sysv
2## format. It also shows that the formatting is correct.
3
4## FIXME: The rules demonstrated by this test are not quite what GNU size
5## follows. See https://bugs.llvm.org/show_bug.cgi?id=42934.
6
7# RUN: yaml2obj %s -o %t.o
8# RUN: llvm-size --format=sysv %t.o \
9# RUN:   | FileCheck %s --match-full-lines --strict-whitespace -DFILE=%t.o --implicit-check-not={{.}}
10# RUN: llvm-size -A %t.o \
11# RUN:   | FileCheck %s --match-full-lines --strict-whitespace -DFILE=%t.o --implicit-check-not={{.}}
12
13#      CHECK:[[FILE]]  :
14# CHECK-NEXT:section               size      addr
15# CHECK-NEXT:.progbits                1   2097152
16# CHECK-NEXT:.symtab_shndx            4    524288
17# CHECK-NEXT:.hash                   64     65536
18# CHECK-NEXT:.dynamic               128     32768
19# CHECK-NEXT:.note                  256     16384
20# CHECK-NEXT:.nobits                512      8192
21# CHECK-NEXT:.shlib                2048      2048
22# CHECK-NEXT:.dynsym               4096      1024
23# CHECK-NEXT:.init_array           8192       512
24# CHECK-NEXT:.fini_array          16384       256
25# CHECK-NEXT:.preinit_array       32768       128
26# CHECK-NEXT:.group               65536        64
27# CHECK-NEXT:.relr               131072        32
28# CHECK-NEXT:.os_specific        262144        16
29# CHECK-NEXT:.proc_specific      524288         8
30# CHECK-NEXT:.user_specific     1048576         4
31# CHECK-NEXT:Total              2096069
32
33!ELF
34FileHeader:
35  Class:   ELFCLASS64
36  Data:    ELFDATA2LSB
37  Type:    ET_REL
38  Machine: EM_X86_64
39Sections:
40  - Name:    .progbits
41    Type:    SHT_PROGBITS
42    ShSize:  0x1
43    Address: 0x200000
44  - Name:    .strtab
45    Type:    SHT_STRTAB
46    ShSize:  0x2
47    Address: 0x100000
48  - Name:    .symtab_shndx
49    Link:    .symtab
50    Type:    SHT_SYMTAB_SHNDX
51    ShSize:  0x4
52    Address: 0x80000
53    Entries:
54  - Name:    .symtab
55    Type:    SHT_SYMTAB
56    ## .symtab's size has to be based on .symtab_shndx's size, hence the
57    ## size not following the pattern of the other sections.
58    ShSize:  0x18
59    Address: 0x40000
60  - Name:    .rela
61    Type:    SHT_RELA
62    ShSize:  0x20
63    Address: 0x20000
64  - Name:    .hash
65    Type:    SHT_HASH
66    Content: ''
67    ShSize:  0x40
68    Address: 0x10000
69  - Name:    .dynamic
70    Type:    SHT_DYNAMIC
71    ShSize:  0x80
72    Address: 0x8000
73  - Name:    .note
74    Type:    SHT_NOTE
75    ShSize:  0x100
76    Address: 0x4000
77    Notes:   []
78  - Name:    .nobits
79    Type:    SHT_NOBITS
80    ShSize:  0x200
81    Address: 0x2000
82  - Name:    .rel
83    Type:    SHT_REL
84    ShSize:  0x400
85    Address: 0x1000
86  - Name:    .shlib
87    Type:    SHT_SHLIB
88    ShSize:  0x800
89    Address: 0x800
90  - Name:    .dynsym
91    Type:    SHT_DYNSYM
92    ShSize:  0x1000
93    Address: 0x400
94  - Name:    .init_array
95    Type:    SHT_INIT_ARRAY
96    ShSize:  0x2000
97    Address: 0x200
98  - Name:    .fini_array
99    Type:    SHT_FINI_ARRAY
100    ShSize:  0x4000
101    Address: 0x100
102  - Name:    .preinit_array
103    Type:    SHT_PREINIT_ARRAY
104    ShSize:  0x8000
105    Address: 0x80
106  - Name:    .group
107    Type:    SHT_GROUP
108    ShSize:  0x10000
109    Address: 0x40
110    Info:    0
111    Members:
112  - Name:    .relr
113    Type:    SHT_RELR
114    ShSize:  0x20000
115    Address: 0x20
116  - Name:    .os_specific
117    Type:    0x61234567
118    ShSize:  0x40000
119    Address: 0x10
120  - Name:    .proc_specific
121    Type:    0x71234567
122    ShSize:  0x80000
123    Address: 0x8
124  - Name:    .user_specific
125    Type:    0x81234567
126    ShSize:  0x100000
127    Address: 0x4
128  - Name:    .null
129    Type:    SHT_NULL
130    ShSize:  0x200000
131    Address: 0x2
132