|
1 | 1 | # REQUIRES: x86
|
2 |
| -# RUN: echo 'nop; .section .small, "a"; .long 0; .section .big, "a"; .quad 1;' \ |
3 |
| -# RUN: | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %t.o |
4 |
| -# RUN: ld.lld %t.o --script %s -o %t |
| 2 | +# RUN: rm -rf %t && split-file %s %t && cd %t |
| 3 | +# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o |
| 4 | +# RUN: ld.lld a.o -T a.t -o a |
5 | 5 |
|
6 |
| -SECTIONS { |
7 |
| - OVERLAY 0x1000 : AT ( 0x4000 ) { |
8 |
| - .out.big { *(.big) } |
9 |
| - .out.small { *(.small) } |
10 |
| - } |
11 |
| -} |
12 |
| - |
13 |
| -## Here we check that can handle OVERLAY which will produce sections |
| 6 | +## Here we check that can handle OVERLAY which will produce sections |
14 | 7 | ## .out.big and .out.small with the same starting VAs, but different LMAs.
|
15 | 8 | ## Section .big is larger than .small, we check that placing of section
|
16 | 9 | ## .text does not cause overlapping error and that
|
17 | 10 | ## .text's VA is 0x1000 + max(sizeof(.out.big), sizeof(.out.small)).
|
18 | 11 |
|
19 |
| -# RUN: llvm-readelf --sections -l %t | FileCheck %s |
| 12 | +# RUN: llvm-readelf --sections -l a | FileCheck %s |
20 | 13 |
|
21 |
| -# CHECK: Section Headers: |
22 |
| -# CHECK: Name Type Address Off Size |
23 |
| -# CHECK: .out.big PROGBITS 0000000000001000 001000 000008 |
24 |
| -# CHECK: .out.small PROGBITS 0000000000001000 002000 000004 |
25 |
| -# CHECK: .text PROGBITS 0000000000001008 002008 000001 |
| 14 | +# CHECK: Name Type Address Off Size |
| 15 | +# CHECK: .big1 PROGBITS 0000000000001000 001000 000008 |
| 16 | +# CHECK-NEXT: .small1 PROGBITS 0000000000001000 002000 000004 |
| 17 | +# CHECK-NEXT: .small2 PROGBITS 0000000000001008 002008 000004 |
| 18 | +# CHECK-NEXT: .big2 PROGBITS 0000000000001008 003008 000008 |
| 19 | +# CHECK-NEXT: .small3 PROGBITS 0000000000001010 003010 000004 |
| 20 | +# CHECK-NEXT: .big3 PROGBITS 0000000000001014 003014 000008 |
| 21 | +# CHECK-NEXT: .text PROGBITS 0000000000001024 003024 000001 |
26 | 22 |
|
27 | 23 | # CHECK: Program Headers:
|
28 | 24 | # CHECK: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
|
29 |
| -# CHECK-NEXT: LOAD 0x001000 0x0000000000001000 0x0000000000004000 0x000008 0x000008 R 0x1000 |
30 |
| -# CHECK-NEXT: LOAD 0x002000 0x0000000000001000 0x0000000000004008 0x000004 0x000004 R 0x1000 |
31 |
| -# CHECK-NEXT: LOAD 0x002008 0x0000000000001008 0x0000000000004010 0x000001 0x000001 R E 0x1000 |
| 25 | +# CHECK-NEXT: LOAD 0x001000 0x0000000000001000 0x0000000000001000 0x000008 0x000008 R 0x1000 |
| 26 | +# CHECK-NEXT: LOAD 0x002000 0x0000000000001000 0x0000000000001008 0x000004 0x000004 R 0x1000 |
| 27 | +# CHECK-NEXT: LOAD 0x002008 0x0000000000001008 0x0000000000002008 0x000004 0x000004 R 0x1000 |
| 28 | +# CHECK-NEXT: LOAD 0x003008 0x0000000000001008 0x000000000000200c 0x000008 0x000008 R 0x1000 |
| 29 | +## FIXME Fix p_paddr when the first section in an overlay is empty and discarded. |
| 30 | +# CHECK-NEXT: LOAD 0x003010 0x0000000000001010 0x0000000000000000 0x000004 0x000004 R 0x1000 |
| 31 | +# CHECK-NEXT: LOAD 0x003014 0x0000000000001014 0x0000000000000004 0x000008 0x000008 R 0x1000 |
| 32 | +# CHECK-NEXT: LOAD 0x003024 0x0000000000001024 0x0000000000000014 0x000001 0x000001 R E 0x1000 |
| 33 | + |
| 34 | +# RUN: not ld.lld a.o -T err1.t 2>&1 | FileCheck %s --check-prefix=ERR1 --match-full-lines --strict-whitespace |
| 35 | +# ERR1:{{.*}}error: err1.t:3: { expected, but got 0x3000 |
| 36 | +# ERR1-NEXT:>>> .out.aaa 0x3000 : { *(.aaa) } |
| 37 | +# ERR1-NEXT:>>> ^ |
| 38 | + |
| 39 | +# RUN: not ld.lld a.o -T err2.t 2>&1 | FileCheck %s --check-prefix=ERR2 --match-full-lines --strict-whitespace |
| 40 | +# ERR2:{{.*}}error: err2.t:{{.*}}: { expected, but got AX |
| 41 | +# ERR2-NEXT:>>> .out.aaa { *(.aaa) } > AX AT>FLASH |
| 42 | +# ERR2-NEXT:>>> ^ |
| 43 | + |
| 44 | +#--- a.s |
| 45 | +.globl _start |
| 46 | +_start: |
| 47 | + nop |
| 48 | + |
| 49 | +.section .small1, "a"; .long 0 |
| 50 | +.section .big1, "a"; .quad 1 |
| 51 | + |
| 52 | +.section .small2, "a"; .long 0 |
| 53 | +.section .big2, "a"; .quad 1 |
| 54 | + |
| 55 | +.section .small3, "a"; .long 0 |
| 56 | +.section .big3, "a"; .quad 1 |
| 57 | + |
| 58 | +#--- a.t |
| 59 | +SECTIONS { |
| 60 | + OVERLAY 0x1000 : AT( 0x1000 ) { |
| 61 | + .big1 { *(.big1) } |
| 62 | + .small1 { *(.small1) } |
| 63 | + } |
| 64 | + OVERLAY 0x1008 : AT (0x2008) { |
| 65 | + .small2 { *(.small2) } |
| 66 | + .big2 { *(.big2) } |
| 67 | + } |
| 68 | + OVERLAY . : AT (0x2014) { |
| 69 | + .empty3 { *(.empty3) } |
| 70 | + .small3 { *(.small3) } |
| 71 | + .big3 { *(.big3) } |
| 72 | + } |
| 73 | + .text : { *(.text) } |
| 74 | +} |
| 75 | + |
| 76 | +#--- err1.t |
| 77 | +SECTIONS { |
| 78 | + OVERLAY 0x1000 : AT ( 0x2000 ) { |
| 79 | + .out.aaa 0x3000 : { *(.aaa) } |
| 80 | + } |
| 81 | +} |
| 82 | + |
| 83 | +#--- err2.t |
| 84 | +MEMORY { |
| 85 | + AX (ax) : ORIGIN = 0x3000, LENGTH = 0x4000 |
| 86 | +} |
| 87 | +SECTIONS { |
| 88 | + OVERLAY 0x1000 : AT ( 0x2000 ) { |
| 89 | + .out.aaa { *(.aaa) } > AX AT>FLASH |
| 90 | + } |
| 91 | +} |
0 commit comments