Skip to content

Commit 45423a4

Browse files
committed
improve test
1 parent b12993b commit 45423a4

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

lld/ELF/LinkerScript.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ void LinkerScript::setDot(Expr e, const Twine &loc, bool inSec) {
175175
if (val < dot && inSec) {
176176
backwardDotErr =
177177
(loc + ": unable to move location counter (0x" + Twine::utohexstr(dot) +
178-
") backward (0x" + Twine::utohexstr(val) + ") for section '" +
178+
") backward to 0x" + Twine::utohexstr(val) + " for section '" +
179179
state->outSec->name + "'")
180180
.str();
181181
}

lld/test/ELF/linkerscript/locationcountererr-arm-exidx.test

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,29 @@
33
# RUN: llvm-mc -filetype=obj -triple=armv7-linux-gnueabi a.s -o a.o
44

55
## 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:
810

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
1016

1117
## If we merge adjacent duplicate entries, we will have enough space. Don't report
1218
## 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
1420
# RUN: llvm-readelf -S a | FileCheck %s
1521

1622
# CHECK: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
1723
# 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
2129

2230
#--- a.s
2331
.globl _start
@@ -40,13 +48,17 @@ f\@:
4048

4149
#--- a.t
4250
MEMORY {
51+
DUMMY1 (RW) : ORIGIN = 0x1000, LENGTH = 0x70
52+
DUMMY2 (RW) : ORIGIN = 0x2000, LENGTH = 0x70
4353
CODE (RX) : ORIGIN = 0x4000, LENGTH = 0x70
4454
}
45-
__code_end = ORIGIN(CODE) + LENGTH(CODE);
55+
code_end = ORIGIN(CODE) + LENGTH(CODE);
4656

4757
SECTIONS {
58+
dummy1 (NOLOAD) : { . += code_size; } > DUMMY1
59+
dummy2 (NOLOAD) : { . += code_size; } > DUMMY2
4860
.text : { *(.text .text.*) } > CODE
4961
.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
5264
}

lld/test/ELF/linkerscript/locationcountererr.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# REQUIRES: x86
22
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux /dev/null -o %t
33
# RUN: not ld.lld %t --script %s -o /dev/null 2>&1 | FileCheck %s
4-
# CHECK: {{.*}}.test:8: unable to move location counter (0x2000) backward (0x10) for section '.text'
4+
# CHECK: {{.*}}.test:8: unable to move location counter (0x2000) backward to 0x10 for section '.text'
55

66
SECTIONS {
77
.text 0x2000 : {

0 commit comments

Comments
 (0)