diff options
Diffstat (limited to 'test/elf/linkerscript/symbol-definition.test')
-rw-r--r-- | test/elf/linkerscript/symbol-definition.test | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/elf/linkerscript/symbol-definition.test b/test/elf/linkerscript/symbol-definition.test new file mode 100644 index 0000000000000..fc595bbe1f105 --- /dev/null +++ b/test/elf/linkerscript/symbol-definition.test @@ -0,0 +1,54 @@ +/* +We test whether we can define symbols in a linker script and have them exported +to the output file symbol table. + +This test uses a single X86-64 input object, simple.o, created with the +following X86-64 assembly code: + +*** simple.S: + +(command line clang -c simple.S -o simple.o) + + .text + main: + mov $1, %eax + movq $1, %rdi + movq $msg, %rsi + movq $14, %rdx + syscall + ret + + .globl _start + _start: + call main + mov $60, %eax + syscall + ret + + .data + msg: .asciz "Hello, World!\n" + + +We use the following linker script for this test: +*/ + +ENTRY(_start) + +SECTIONS +{ + . = 0x500000; + .text : { *(.text) } + MYSTRING = .; + .data : { *(.data) } +} + +/* +RUN: mkdir -p %T +RUN: yaml2obj -format=elf %p/Inputs/simple.o.yaml -o=%T/simple.o + +RUN: lld -flavor gnu -target x86_64 -T %s %T/simple.o -static -o %t1 +RUN: llvm-readobj -symbols %t1 | FileCheck -check-prefix CHECKSYMS %s + +CHECKSYMS: Name: MYSTRING +CHECKSYMS-NEXT: Value: 0x501000 +*/ |