]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/elf/X86_64/alignoffset.test
Vendor import of lld trunk r233088:
[FreeBSD/FreeBSD.git] / test / elf / X86_64 / alignoffset.test
1 # Checks that segments are aligned as per ELF spec. The segment virtual address
2 # modulo page alignment should be equal to offset modulo page alignment.
3
4 # Build executable
5 # RUN: yaml2obj -format=elf -docnum 1 %s -o %t.o
6 # RUN: lld -flavor gnu -target x86_64 %t.o -o %t.exe -static \
7 # RUN: --no-align-segments --rosegment --noinhibit-exec
8 # RUN: llvm-readobj -program-headers %t.exe | FileCheck %s
9 #
10 #CHECK:    Offset: 0x15C
11 #CHECK:    VirtualAddress: 0x40015C
12 #CHECK:    PhysicalAddress: 0x40015C
13 #
14 #
15 #const int a = 0;
16 #int main() {
17 #  foo();
18 #  return 0;
19 #}
20 #
21 #int foo() { return 0; }
22
23 # object
24 ---
25 FileHeader:
26   Class:           ELFCLASS64
27   Data:            ELFDATA2LSB
28   OSABI:           ELFOSABI_GNU
29   Type:            ET_REL
30   Machine:         EM_X86_64
31 Sections:
32   - Name:            .text
33     Type:            SHT_PROGBITS
34     Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
35     AddressAlign:    0x0000000000000010
36     Content:         554889E54883EC10C745FC00000000E81C000000B9000000008945F889C84883C4105DC36666662E0F1F840000000000554889E5B8000000005DC3
37   - Name:            .data
38     Type:            SHT_PROGBITS
39     Flags:           [ SHF_WRITE, SHF_ALLOC ]
40     AddressAlign:    0x0000000000000004
41     Content:         ''
42   - Name:            .bss
43     Type:            SHT_NOBITS
44     Flags:           [ SHF_WRITE, SHF_ALLOC ]
45     AddressAlign:    0x0000000000000004
46     Content:         ''
47   - Name:            .rodata
48     Type:            SHT_PROGBITS
49     Flags:           [ SHF_ALLOC ]
50     AddressAlign:    0x0000000000000004
51     Content:         '00000000'
52   - Name:            .comment
53     Type:            SHT_PROGBITS
54     Flags:           [ SHF_MERGE, SHF_STRINGS ]
55     AddressAlign:    0x0000000000000001
56     Content:         005562756E747520636C616E672076657273696F6E20332E352E302D73766E3231373330342D317E6578703120286272616E636865732F72656C656173655F33352920286261736564206F6E204C4C564D20332E352E302900
57   - Name:            .note.GNU-stack
58     Type:            SHT_PROGBITS
59     AddressAlign:    0x0000000000000001
60     Content:         ''
61   - Name:            .eh_frame
62     Type:            SHT_PROGBITS
63     Flags:           [ SHF_ALLOC ]
64     AddressAlign:    0x0000000000000008
65     Content:         1400000000000000037A5200017810011B0C070890010000180000001C000000000000002400000000410E108602430D060000001800000038000000000000000B00000000410E108602430D06000000
66   - Name:            .rela.eh_frame
67     Type:            SHT_RELA
68     Link:            .symtab
69     AddressAlign:    0x0000000000000008
70     Info:            .eh_frame
71     Relocations:
72       - Offset:          0x0000000000000020
73         Symbol:          .text
74         Type:            R_X86_64_PC32
75         Addend:          0
76       - Offset:          0x000000000000003C
77         Symbol:          .text
78         Type:            R_X86_64_PC32
79         Addend:          48
80 Symbols:
81   Local:
82     - Name:            1.c
83       Type:            STT_FILE
84     - Name:            .text
85       Type:            STT_SECTION
86       Section:         .text
87     - Name:            .data
88       Type:            STT_SECTION
89       Section:         .data
90     - Name:            .bss
91       Type:            STT_SECTION
92       Section:         .bss
93     - Name:            .rodata
94       Type:            STT_SECTION
95       Section:         .rodata
96     - Name:            .comment
97       Type:            STT_SECTION
98       Section:         .comment
99     - Name:            .note.GNU-stack
100       Type:            STT_SECTION
101       Section:         .note.GNU-stack
102     - Name:            .eh_frame
103       Type:            STT_SECTION
104       Section:         .eh_frame
105   Global:
106     - Name:            a
107       Type:            STT_OBJECT
108       Section:         .rodata
109       Size:            0x0000000000000004
110     - Name:            foo
111       Type:            STT_FUNC
112       Section:         .text
113       Value:           0x0000000000000030
114       Size:            0x000000000000000B
115     - Name:            main
116       Type:            STT_FUNC
117       Section:         .text
118       Size:            0x0000000000000024
119 ...