diff --git a/lld/test/ELF/dynamic-list-cpp.s b/lld/test/ELF/dynamic-list-cpp.s new file mode 100644 index 000000000000..b0efb8d16bcb --- /dev/null +++ b/lld/test/ELF/dynamic-list-cpp.s @@ -0,0 +1,18 @@ +# REQUIRES: x86 + +## Confirm both mangled and unmangled names may appear in +## the --dynamic-list file. + +# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o + +# RUN: echo '{ _Z1fv; extern "C++" { "g()"; }; };' > %t.list +# RUN: ld.lld -pie --dynamic-list %t.list %t.o -o %t +# RUN: llvm-readelf --dyn-syms %t | FileCheck %s + +# CHECK: Symbol table '.dynsym' contains 3 entries: +# CHECK: _Z1fv +# CHECK-NEXT: _Z1gv + +.globl _Z1fv, _Z1gv +_Z1fv: +_Z1gv: diff --git a/lld/test/ELF/dynamic-list-glob.s b/lld/test/ELF/dynamic-list-glob.s new file mode 100644 index 000000000000..301884756580 --- /dev/null +++ b/lld/test/ELF/dynamic-list-glob.s @@ -0,0 +1,22 @@ +# REQUIRES: x86 + +## Confirm --dynamic-list identifies symbols by entries, including wildcards. +## Entries need not match a symbol. + +# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o + +# RUN: echo '{ [fb]o?1*; };' > %t.list +# RUN: ld.lld -pie --dynamic-list %t.list %t.o -o %t +# RUN: llvm-readelf --dyn-syms %t | FileCheck %s + +# CHECK: Symbol table '.dynsym' contains 4 entries: +# CHECK: boo1 +# CHECK-NEXT: foo1 +# CHECK-NEXT: foo11 + +.globl _start, foo1, foo11, foo2, boo1 +foo1: +foo11: +foo2: +boo1: +_start: diff --git a/lld/test/ELF/dynamic-list-wildcard.s b/lld/test/ELF/dynamic-list-wildcard.s deleted file mode 100644 index 7e933cd1e272..000000000000 --- a/lld/test/ELF/dynamic-list-wildcard.s +++ /dev/null @@ -1,17 +0,0 @@ -# REQUIRES: x86 - -# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t - -# RUN: echo "{ foo1*; };" > %t.list -# RUN: ld.lld -pie --dynamic-list %t.list %t -o %t -# RUN: llvm-nm -D %t | FileCheck %s - -# CHECK: foo1 -# CHECK-NEXT: foo11 -# CHECK-NOT: {{.}} - -.globl _start, foo1, foo11, foo2 -foo1: -foo11: -foo2: -_start: diff --git a/lld/test/ELF/export-symbols.s b/lld/test/ELF/export-symbols.s new file mode 100644 index 000000000000..13612390fb67 --- /dev/null +++ b/lld/test/ELF/export-symbols.s @@ -0,0 +1,68 @@ +# REQUIRES: x86 +## Verify that the arguments --export-dynamic and --dynamic-list +## put the correct symbols in the dynamic symbol table. + +# RUN: echo "{ *; };" > %t.list + +# RUN: echo ".globl shared" > %t.s ; echo "shared = 0xDEADBEEF" >> %t.s + +# RUN: llvm-mc -filetype=obj -triple=x86_64 %t.s -o %t-shared.o +# RUN: ld.lld --shared %t-shared.o -o %t.so + +# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o +## Use --fatal-warnings to confirm no diagnostics are emitted. +# RUN: ld.lld --fatal-warnings --defsym=defsym=_start %t.so %t.o -o %t.out +# RUN: ld.lld --fatal-warnings --defsym=defsym=_start %t.so %t.o -o %texport.out --export-dynamic +# RUN: ld.lld --fatal-warnings --defsym=defsym=_start %t.so %t.o -o %tlist.out --dynamic-list %t.list + +# RUN: llvm-readelf --dyn-syms %t.out | FileCheck %s --check-prefix=NO-EXPORT +# RUN: llvm-readelf --dyn-syms %texport.out | FileCheck %s --check-prefix=EXPORT +# RUN: llvm-readelf --dyn-syms %tlist.out | FileCheck %s --check-prefix=EXPORT + +# NO-EXPORT: Symbol table '.dynsym' contains 3 entries: +# NO-EXPORT: GLOBAL DEFAULT {{.*}} shared +# NO-EXPORT-NEXT: WEAK DEFAULT {{.*}} undef_weak + +# EXPORT: Symbol table '.dynsym' contains 8 entries: +# EXPORT: GLOBAL DEFAULT {{.*}} shared +# EXPORT-NEXT: WEAK DEFAULT {{.*}} undef_weak +# EXPORT-NEXT: GLOBAL PROTECTED {{.*}} _start +# EXPORT-NEXT: GLOBAL DEFAULT ABS abs +# EXPORT-NEXT: GLOBAL DEFAULT {{.*}} common +# EXPORT-NEXT: WEAK DEFAULT {{.*}} weak_default +# EXPORT-NEXT: GLOBAL DEFAULT {{.*}} defsym + +.weak undef_weak + +.weak weak_default +weak_default: + +.weak weak_internal +.internal weak_internal +weak_internal: + +.weak weak_hidden +.internal weak_hidden +weak_hidden: + +.weak weak_protected +.internal weak_protected +weak_protected: + +.globl shared + +.local local +local: + +.comm common, 10 + +.globl abs +abs = 0xDEADBEEF + +.globl hidden +.hidden hidden +hidden: + +.globl _start +.protected _start +_start: diff --git a/lld/test/ELF/invalid-dynamic-list.test b/lld/test/ELF/invalid-dynamic-list.test index 3a2f9de6f5ce..ef2bbc74bbb0 100644 --- a/lld/test/ELF/invalid-dynamic-list.test +++ b/lld/test/ELF/invalid-dynamic-list.test @@ -1,41 +1,30 @@ -## Different "echo" commands on Windows interpret quoted strings and -## wildcards in similar but different way (On Windows, ARGV tokenization -## and wildcard expansion are not done by the shell but by each command.) -## Because of that reason, this test fails on some Windows environment. -## We can't write quoted strings that are interpreted the same way -## by all echo commands. So, we don't want to run this on Windows. - -# REQUIRES: shell - -# RUN: mkdir -p %t.dir - # RUN: echo > %tempty.list # RUN: not ld.lld --dynamic-list %tempty.list 2>&1 | FileCheck --check-prefix=EMPTY %s # EMPTY: error: {{.*}}.list:1: unexpected EOF -# RUN: echo foobar > %t1 +# RUN: echo 'foobar' > %t1 # RUN: not ld.lld --dynamic-list %t1 2>&1 | FileCheck -check-prefix=ERR1 %s # ERR1: {{.*}}:1: { expected, but got foobar -# RUN: echo "{ foobar;" > %t1 -# RUN: not ld.lld --dynamic-list %t1 2>&1 | FileCheck -check-prefix=ERR2 %s +# RUN: echo '{ foobar;' > %t2 +# RUN: not ld.lld --dynamic-list %t2 2>&1 | FileCheck -check-prefix=ERR2 %s # ERR2: {{.*}}:1: unexpected EOF ## Missing ';' before '}' -# RUN: echo "{ foobar }" > %t1 -# RUN: not ld.lld --dynamic-list %t1 2>&1 | FileCheck -check-prefix=ERR3 %s +# RUN: echo '{ foobar }' > %t3 +# RUN: not ld.lld --dynamic-list %t3 2>&1 | FileCheck -check-prefix=ERR3 %s # ERR3: {{.*}}:1: ; expected, but got } ## Missing final ';' -# RUN: echo "{ foobar; }" > %t1 -# RUN: not ld.lld --dynamic-list %t1 2>&1 | FileCheck -check-prefix=ERR4 %s +# RUN: echo '{ foobar; }' > %t4 +# RUN: not ld.lld --dynamic-list %t4 2>&1 | FileCheck -check-prefix=ERR4 %s # ERR4: {{.*}}:1: unexpected EOF -## Missing \" in foobar definition -# RUN echo "{ \"foobar; };" > %t1 -# RUN: not ld.lld --dynamic-list %t1 2>&1 | FileCheck -check-prefix=ERR5 %s -# ERR5: {{.*}}:1: unexpected EOF +## Missing " in foobar definition +# RUN: echo '{ "foobar; };' > %t5 +# RUN: not ld.lld --dynamic-list %t5 2>&1 | FileCheck -check-prefix=ERR5 %s +# ERR5: {{.*}}:1: unclosed quote -# RUN: echo "{ extern \"BOGUS\" { test }; };" > %t1 -# RUN: not ld.lld --dynamic-list %t1 2>&1 | FileCheck -check-prefix=ERR6 %s +# RUN: echo '{ extern "BOGUS" { test }; };' > %t6 +# RUN: not ld.lld --dynamic-list %t6 2>&1 | FileCheck -check-prefix=ERR6 %s # ERR6: {{.*}}:1: Unknown language