1# REQUIRES: x86 2# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o 3 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. 7## 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;} \ 14# RUN: SECTIONS { \ 15# RUN: .text : {*(.text .text*)} :text \ 16# RUN: .foo : {*(.foo)} :foo \ 17# RUN: }" > %t.script 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 21 22# CHECK: Program Headers: 23# CHECK-NEXT: Type 24# CHECK-NEXT: LOAD 25# CHECK-NEXT: <unknown>: 0x12345678 26 27# CHECK: Section to Segment mapping: 28# CHECK-NEXT: Segment Sections... 29# CHECK-NEXT: 00 .text 30# CHECK-NEXT: 01 .foo 31 32# PHDR: Type: (0x12345678) 33# PHDR-NEXT: Offset: 0x1004 34# PHDR-NEXT: VirtualAddress 35# PHDR-NEXT: PhysicalAddress 36# PHDR-NEXT: FileSize: 4 37 38.global _start 39_start: 40 nop 41 42.section .foo 43 .align 4 44 .long 0 45