3 # Test that mimics a use case of -n to produce a kernel mapped shared-object
4 # in a non paged context. We specifically want to test:
5 # - We can allocate the headers into the first program header (via PHDRS)
6 # typically -n does not allocate headers.
7 # - The alignment of the .text section is not page aligned.
9 # RUN: echo ".text; .globl foo; foo: nop" > %t.s
10 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %t.s -o %t.o
11 # RUN: ld.lld %t.o -o %t.so --shared --hash-style=sysv --script %s
12 # RUN: llvm-readobj --program-headers %t.so | FileCheck %s
13 # RUN: ld.lld %t.o -o %t2.so --shared --hash-style=sysv -n --script %s
14 # RUN: llvm-readobj --program-headers %t2.so | FileCheck %s --check-prefix=CHECK-N
17 . = 0x0 + SIZEOF_HEADERS;
18 .hash : { *(.hash) } :text
19 .dynsym : { *(.dynsym) }
20 .dynstr : { *(.dynstr) }
23 .dynamic : { *(.dynamic) } :text :dynamic
27 text PT_LOAD FLAGS(5) FILEHDR PHDRS;
28 dynamic PT_DYNAMIC FLAGS(4);
31 # CHECK: ProgramHeaders [
32 # CHECK-NEXT: ProgramHeader {
33 # CHECK-NEXT: Type: PT_LOAD
34 # CHECK-NEXT: Offset: 0x0
35 # CHECK-NEXT: VirtualAddress: 0x0
36 # CHECK-NEXT: PhysicalAddress: 0x0
37 # CHECK-NEXT: FileSize:
38 # CHECK-NEXT: MemSize:
43 # CHECK-NEXT: Alignment: 4096
45 # CHECK-NEXT: ProgramHeader {
46 # CHECK-NEXT: Type: PT_DYNAMIC
47 # CHECK-NEXT: Offset: 0x108
48 # CHECK-NEXT: VirtualAddress: 0x108
49 # CHECK-NEXT: PhysicalAddress: 0x108
50 # CHECK-NEXT: FileSize:
51 # CHECK-NEXT: MemSize:
55 # CHECK-NEXT: Alignment: 8
59 # CHECK-N: ProgramHeaders [
60 # CHECK-N-NEXT: ProgramHeader {
61 # CHECK-N-NEXT: Type: PT_LOAD
62 # CHECK-N-NEXT: Offset: 0x0
63 # CHECK-N-NEXT: VirtualAddress: 0x0
64 # CHECK-N-NEXT: PhysicalAddress: 0x0
65 # CHECK-N-NEXT: FileSize: 360
66 # CHECK-N-NEXT: MemSize: 360
67 # CHECK-N-NEXT: Flags [
71 # CHECK-N-NEXT: Alignment: 8
73 # CHECK-N-NEXT: ProgramHeader {
74 # CHECK-N-NEXT: Type: PT_DYNAMIC
75 # CHECK-N-NEXT: Offset: 0x108
76 # CHECK-N-NEXT: VirtualAddress: 0x108
77 # CHECK-N-NEXT: PhysicalAddress: 0x108
78 # CHECK-N-NEXT: FileSize:
79 # CHECK-N-NEXT: MemSize:
80 # CHECK-N-NEXT: Flags [
83 # CHECK-N-NEXT: Alignment: 8