2 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
4 ################################################################################
5 ## Test that non-alloc section .foo can be assigned to a segment. Check that
6 ## the values of the offset and file size of this segment's PHDR are correct.
8 ## This functionality allows non-alloc metadata, which is not required at
9 ## run-time, to be added to a custom segment in a file. This metadata may be
10 ## read/edited by tools/loader using the values of the offset and file size from
11 ## the custom segment's PHDR. This is particularly important if section headers
12 ## have been stripped.
13 # RUN: echo "PHDRS {text PT_LOAD; foo 0x12345678;} \
15 # RUN: .text : {*(.text .text*)} :text \
16 # RUN: .foo : {*(.foo)} :foo \
18 # RUN: ld.lld -o %t --script %t.script %t.o
19 # RUN: llvm-readelf -S -l %t | FileCheck %s
20 # RUN: llvm-readobj -l %t | FileCheck --check-prefix=PHDR %s
22 # CHECK: Program Headers:
25 # CHECK-NEXT: <unknown>: 0x12345678
27 # CHECK: Section to Segment mapping:
28 # CHECK-NEXT: Segment Sections...
29 # CHECK-NEXT: 00 .text
32 # PHDR: Type: Unknown (0x12345678)
33 # PHDR-NEXT: Offset: 0x1004
34 # PHDR-NEXT: VirtualAddress
35 # PHDR-NEXT: PhysicalAddress
36 # PHDR-NEXT: FileSize: 4