|
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 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 |
| 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: |
8 | 10 |
|
9 |
| -# ERR: a.t:10: unable to move location counter (0x4104) backward (0x4070) for section 'code.unused_space' |
| 11 | +# ERR: error: a.t:14: unable to move location counter (0x4104) backward to 0x4070 for section 'code.unused_space' |
| 12 | +# ERR-NEXT: error: section '.ARM.exidx' will not fit in region 'CODE': overflowed by 148 bytes |
| 13 | +# ERR-NEXT: error: section dummy1 at 0x1000 of size 0xFFFFFFFFFFFFFF6C exceeds available address space |
| 14 | +# ERR-NEXT: error: section dummy2 at 0x2000 of size 0xFFFFFFFFFFFFFF6C exceeds available address space |
| 15 | +# ERR-NEXT: error: section code.unused_space at 0x4104 of size 0xFFFFFFFFFFFFFF6C exceeds available address space |
10 | 16 |
|
11 | 17 | ## If we merge adjacent duplicate entries, we will have enough space. Don't report
|
12 | 18 | ## a spurious error https://github.com/llvm/llvm-project/issues/66836
|
13 |
| -# RUN: ld.lld -z norelro -T a.t a.o -o a |
| 19 | +# RUN: ld.lld -z norelro -z max-page-size=4096 -T a.t a.o -o a |
14 | 20 | # RUN: llvm-readelf -S a | FileCheck %s
|
15 | 21 |
|
16 | 22 | # CHECK: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
|
17 | 23 | # 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 |
| 24 | +# CHECK-NEXT: [ 1] dummy1 NOBITS 00001000 001000 00000c 00 A 0 0 1 |
| 25 | +# CHECK-NEXT: [ 2] dummy2 NOBITS 00002000 001000 00000c 00 A 0 0 1 |
| 26 | +# CHECK-NEXT: [ 3] .text PROGBITS 00004000 001000 000054 00 AX 0 0 4 |
| 27 | +# CHECK-NEXT: [ 4] .ARM.exidx ARM_EXIDX 00004054 001054 000010 00 AL 3 0 4 |
| 28 | +# CHECK-NEXT: [ 5] code.unused_space NOBITS 00004064 001064 00000c 00 A 0 0 1 |
21 | 29 |
|
22 | 30 | #--- a.s
|
23 | 31 | .globl _start
|
|
40 | 48 |
|
41 | 49 | #--- a.t
|
42 | 50 | MEMORY {
|
| 51 | + DUMMY1 (RW) : ORIGIN = 0x1000, LENGTH = 0x70 |
| 52 | + DUMMY2 (RW) : ORIGIN = 0x2000, LENGTH = 0x70 |
43 | 53 | CODE (RX) : ORIGIN = 0x4000, LENGTH = 0x70
|
44 | 54 | }
|
45 |
| -__code_end = ORIGIN(CODE) + LENGTH(CODE); |
| 55 | +code_end = ORIGIN(CODE) + LENGTH(CODE); |
46 | 56 |
|
47 | 57 | SECTIONS {
|
| 58 | + dummy1 (NOLOAD) : { . += code_size; } > DUMMY1 |
| 59 | + dummy2 (NOLOAD) : { . += code_size; } > DUMMY2 |
48 | 60 | .text : { *(.text .text.*) } > CODE
|
49 | 61 | .ARM.exidx : { *(.ARM.exidx .ARM.exidx.*) } > CODE
|
50 |
| - __code_size = __code_end - .; |
51 |
| - code.unused_space (NOLOAD) : { . += __code_size; } > CODE |
| 62 | + code_size = code_end - .; |
| 63 | + code.unused_space (NOLOAD) : { . += code_size; } > CODE |
52 | 64 | }
|
0 commit comments