|
3 | 3 | # RUN: llvm-mc -filetype=obj -triple=armv7-linux-gnueabi a.s -o a.o
|
4 | 4 |
|
5 | 5 | ## If we don't merge adjacent duplicate entries, __code_size will be negative and
|
6 |
| -## . += __code_size will trigger a "move location counter backward" error. |
7 |
| -## LLD may report more errors further down, but there is only one "move location counter backward" error. |
8 |
| -# RUN: not ld.lld -z norelro -z max-page-size=4096 -T a.t a.o -o /dev/null --no-merge-exidx-entries 2>&1 | \ |
9 |
| -# RUN: FileCheck %s --check-prefix=ERR --implicit-check-not=error: |
10 |
| - |
11 |
| -# ERR: error: a.t:14: unable to move location counter backward for: code.unused_space |
12 |
| -# ERR-NEXT: error: a.t:9: unable to move location counter backward for: dummy1 |
13 |
| -# ERR-NEXT: error: a.t:10: unable to move location counter backward for: dummy2 |
14 |
| -# ERR-NEXT: error: a.t:14: unable to move location counter backward for: code.unused_space |
15 |
| -# ERR-NEXT: error: a.t:9: unable to move location counter backward for: dummy1 |
16 |
| -# ERR-NEXT: error: a.t:10: unable to move location counter backward for: dummy2 |
17 |
| -# ERR-NEXT: error: a.t:14: unable to move location counter backward for: code.unused_space |
18 |
| -# ERR-NEXT: error: section dummy1 at 0x1000 of size 0xFFFFFFFFFFFFFF6C exceeds available address space |
19 |
| -# ERR-NEXT: error: section dummy2 at 0x2000 of size 0xFFFFFFFFFFFFFF6C exceeds available address space |
20 |
| -# ERR-NEXT: error: section code.unused_space at 0x4104 of size 0xFFFFFFFFFFFFFF6C exceeds available address space |
| 6 | +## . += __code_size will trigger an error. |
| 7 | +# RUN: not ld.lld -z norelro -T a.t a.o -o /dev/null --no-merge-exidx-entries 2>&1 | FileCheck %s --check-prefix=ERR |
| 8 | + |
| 9 | +# ERR: a.t:10: unable to move location counter (0x4104) backward (0x4070) for section 'code.unused_space' |
21 | 10 |
|
22 | 11 | ## If we merge adjacent duplicate entries, we will have enough space. Don't report
|
23 | 12 | ## a spurious error https://github.com/llvm/llvm-project/issues/66836
|
24 |
| -# RUN: not ld.lld -z norelro -z max-page-size=4096 -T a.t a.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR2 |
| 13 | +# RUN: ld.lld -z norelro -T a.t a.o -o a |
| 14 | +# RUN: llvm-readelf -S a | FileCheck %s |
25 | 15 |
|
26 |
| -# ERR2: error: a.t:14: unable to move location counter backward for: code.unused_space |
| 16 | +# CHECK: [Nr] Name Type Address Off Size ES Flg Lk Inf Al |
| 17 | +# CHECK-NEXT: [ 0] NULL 00000000 000000 000000 00 0 0 0 |
| 18 | +# CHECK-NEXT: [ 1] .text PROGBITS 00004000 004000 000054 00 AX 0 0 4 |
| 19 | +# CHECK-NEXT: [ 2] .ARM.exidx ARM_EXIDX 00004054 004054 000010 00 AL 1 0 4 |
| 20 | +# CHECK-NEXT: [ 3] code.unused_space NOBITS 00004064 004064 00000c 00 A 0 0 1 |
27 | 21 |
|
28 | 22 | #--- a.s
|
29 | 23 | .globl _start
|
|
46 | 40 |
|
47 | 41 | #--- a.t
|
48 | 42 | MEMORY {
|
49 |
| - DUMMY1 (RW) : ORIGIN = 0x1000, LENGTH = 0x70 |
50 |
| - DUMMY2 (RW) : ORIGIN = 0x2000, LENGTH = 0x70 |
51 | 43 | CODE (RX) : ORIGIN = 0x4000, LENGTH = 0x70
|
52 | 44 | }
|
53 |
| -code_end = ORIGIN(CODE) + LENGTH(CODE); |
| 45 | +__code_end = ORIGIN(CODE) + LENGTH(CODE); |
54 | 46 |
|
55 | 47 | SECTIONS {
|
56 |
| - dummy1 (NOLOAD) : { . += code_size; } > DUMMY1 |
57 |
| - dummy2 (NOLOAD) : { . += code_size; } > DUMMY2 |
58 | 48 | .text : { *(.text .text.*) } > CODE
|
59 | 49 | .ARM.exidx : { *(.ARM.exidx .ARM.exidx.*) } > CODE
|
60 |
| - code_size = code_end - .; |
61 |
| - code.unused_space (NOLOAD) : { . += code_size; } > CODE |
| 50 | + __code_size = __code_end - .; |
| 51 | + code.unused_space (NOLOAD) : { . += __code_size; } > CODE |
62 | 52 | }
|
0 commit comments