Skip to content

Commit

Permalink
[ELF,test] Improve duplicate "symbol not found" error tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MaskRay committed Dec 16, 2023
1 parent 395f9ce commit 01c8af5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lld/test/ELF/linkerscript/copy-rel-symbol-value-err.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/copy-rel-symbol-value.s -o %t2.o
# RUN: ld.lld %t2.o -o %t2.so -shared
# RUN: echo "SECTIONS { . = . + SIZEOF_HEADERS; foo = bar; }" > %t.script
# RUN: not ld.lld %t.o %t2.so --script %t.script -o /dev/null 2>&1 | FileCheck %s
# RUN: not ld.lld %t.o %t2.so --script %t.script -o /dev/null 2>&1 | FileCheck %s --implicit-check-not=error:

# CHECK: symbol not found: bar
# CHECK-COUNT-2: error: {{.*}}.script:1: symbol not found: bar

.global _start
_start:
Expand Down
16 changes: 10 additions & 6 deletions lld/test/ELF/linkerscript/sections-padding.s
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@
## Invalid hex value:
# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x99XX }" > %t.script
# RUN: not ld.lld -o /dev/null --script %t.script %t 2>&1 \
# RUN: | FileCheck --check-prefix=ERR2 %s
# ERR2: malformed number: 0x99XX
# RUN: | FileCheck --check-prefix=ERR2 %s --implicit-check-not=error:
# ERR2: error: {{.*}}.script:1: malformed number: 0x99XX
# ERR2-NEXT: >>> SECTIONS { .mysec : { *(.mysec*) } =0x99XX }
# ERR2-NEXT: >>> ^
# ERR2-EMPTY:
# ERR2-NEXT: error: {{.*}}.script:1: symbol not found: 0x99XX

## Check case with space between '=' and a value:
# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } = 0x1122 }" > %t.script
Expand All @@ -58,13 +62,13 @@

## Check we report an error if expression value is larger than 32-bits.
# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =(0x11 << 32) }" > %t.script
# RUN: not ld.lld -o /dev/null --script %t.script %t 2>&1 | FileCheck --check-prefix=ERR3 %s
# ERR3: filler expression result does not fit 32-bit: 0x1100000000
# RUN: not ld.lld -o /dev/null --script %t.script %t 2>&1 | FileCheck --check-prefix=ERR3 %s --implicit-check-not=error:
# ERR3: error: {{.*}}.script:1: filler expression result does not fit 32-bit: 0x1100000000

## Check we report an error if an expression use a symbol.
# RUN: echo "SECTIONS { foo = 0x11; .mysec : { *(.mysec*) } = foo }" > %t.script
# RUN: not ld.lld -o /dev/null %t --script %t.script 2>&1 | FileCheck --check-prefix=ERR4 %s
# ERR4: symbol not found: foo
# RUN: not ld.lld -o /dev/null %t --script %t.script 2>&1 | FileCheck --check-prefix=ERR4 %s --implicit-check-not=error:
# ERR4: error: {{.*}}.script:1: symbol not found: foo

## Check we are able to parse scripts where "/DISCARD/" follows a section fill expression.
# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x1122 /DISCARD/ : { *(.text) } }" > %t.script
Expand Down
24 changes: 21 additions & 3 deletions lld/test/ELF/linkerscript/symbol-assignexpr.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,27 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o

# RUN: echo "SECTIONS { symbol2 = symbol; }" > %t2.script
# RUN: not ld.lld -o /dev/null -T %t2.script %t.o 2>&1 \
# RUN: | FileCheck -check-prefix=ERR %s
# ERR: {{.*}}.script:1: symbol not found: symbol
# RUN: not ld.lld -o /dev/null -T %t2.script %t.o -Map=%t.map 2>&1 \
# RUN: | FileCheck --check-prefix=ERR %s --implicit-check-not=error:
# RUN: FileCheck --input-file=%t.map %s --check-prefix=MAP
# RUN: not ld.lld -o /dev/null --noinhibit-exec -T %t2.script %t.o 2>&1 \
# RUN: | FileCheck --check-prefix=ERR %s --implicit-check-not=error:

# ERR-COUNT-3: {{.*}}.script:1: symbol not found: symbol

# MAP: VMA LMA Size Align Out In Symbol
# MAP-NEXT: 0 0 0 1 symbol2 = symbol
# MAP-NEXT: 0 0 1 4 .text
# MAP-NEXT: 0 0 1 4 {{.*}}.o:(.text)
# MAP-NEXT: 0 0 0 1 _start
# MAP-NEXT: 0 0 8 1 .comment
# MAP-NEXT: 0 0 8 1 <internal>:(.comment)
# MAP-NEXT: 0 0 60 8 .symtab
# MAP-NEXT: 0 0 60 8 <internal>:(.symtab)
# MAP-NEXT: 0 0 2a 1 .shstrtab
# MAP-NEXT: 0 0 2a 1 <internal>:(.shstrtab)
# MAP-NEXT: 0 0 17 1 .strtab
# MAP-NEXT: 0 0 17 1 <internal>:(.strtab)

.global _start
_start:
Expand Down

0 comments on commit 01c8af5

Please sign in to comment.