From 01c8af573961c54f0d922c3f3acffa880a0a459c Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sat, 16 Dec 2023 13:12:17 -0800 Subject: [PATCH] [ELF,test] Improve duplicate "symbol not found" error tests --- .../ELF/linkerscript/copy-rel-symbol-value-err.s | 4 ++-- lld/test/ELF/linkerscript/sections-padding.s | 16 +++++++++------ lld/test/ELF/linkerscript/symbol-assignexpr.s | 24 +++++++++++++++++++--- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/lld/test/ELF/linkerscript/copy-rel-symbol-value-err.s b/lld/test/ELF/linkerscript/copy-rel-symbol-value-err.s index cd5262b142f5..70ca582affc4 100644 --- a/lld/test/ELF/linkerscript/copy-rel-symbol-value-err.s +++ b/lld/test/ELF/linkerscript/copy-rel-symbol-value-err.s @@ -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: diff --git a/lld/test/ELF/linkerscript/sections-padding.s b/lld/test/ELF/linkerscript/sections-padding.s index 4d147d79c63e..5b5767498b09 100644 --- a/lld/test/ELF/linkerscript/sections-padding.s +++ b/lld/test/ELF/linkerscript/sections-padding.s @@ -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 @@ -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 diff --git a/lld/test/ELF/linkerscript/symbol-assignexpr.s b/lld/test/ELF/linkerscript/symbol-assignexpr.s index ed6d746b3e2d..7f1d9b702d05 100644 --- a/lld/test/ELF/linkerscript/symbol-assignexpr.s +++ b/lld/test/ELF/linkerscript/symbol-assignexpr.s @@ -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 :(.comment) +# MAP-NEXT: 0 0 60 8 .symtab +# MAP-NEXT: 0 0 60 8 :(.symtab) +# MAP-NEXT: 0 0 2a 1 .shstrtab +# MAP-NEXT: 0 0 2a 1 :(.shstrtab) +# MAP-NEXT: 0 0 17 1 .strtab +# MAP-NEXT: 0 0 17 1 :(.strtab) .global _start _start: -- 2.11.4.GIT