xref: /llvm-project/llvm/test/tools/llvm-objcopy/ELF/parent-loop-check.test (revision a7a447be0fa934505f0c423fb97b91a68c1cc715)
1# This test has a subtle purpose. Because of the specifics of the layout
2# algorithm if we're not careful cycles can occur when we resolve the order
3# that we should layout segments in. In this test we're making sure that the
4# PT_LOAD segment won't set the PT_NOTE segment as the first to be laid out
5# while the PT_NOTE segment sets the PT_LOAD load to be the first to be laid
6# out. This problem becomes visible if the layout of the file changes due to
7# the removal of a section. We use -O binary here because removing a section
8# in this way won't cause the location of the PT_LOAD segment to change if we
9# don't.
10
11# RUN: yaml2obj %s -o %t
12# RUN: llvm-objcopy -R .note -O binary %t %t2
13# RUN: od -Ax -t x1 %t2 | FileCheck %s
14
15!ELF
16FileHeader:
17  Class:           ELFCLASS64
18  Data:            ELFDATA2LSB
19  Type:            ET_EXEC
20  Machine:         EM_X86_64
21Sections:
22  - Name:            .note
23    Type:            SHT_PROGBITS
24    Flags:           [ SHF_ALLOC ]
25    Address:         0x1000
26    AddressAlign:    0x1000
27    Content:         "32323232"
28    Size:            32
29  - Name:            .rodata
30    Flags:           [ SHF_ALLOC ]
31    Type:            SHT_PROGBITS
32    Address:         0x1020
33    Size:            4064
34    Content:         "DEADBEEF"
35ProgramHeaders:
36  - Type:     PT_LOAD
37    Flags:    [ PF_R ]
38    VAddr:    0x1000
39    FirstSec: .note
40    LastSec:  .rodata
41  - Type:     PT_NOTE
42    Flags:    [ PF_R ]
43    VAddr:    0x1000
44    FirstSec: .note
45    LastSec:  .note
46
47# CHECK: 000000 de ad be ef
48