llvm-project/lld/test/elf/linkerscript/symbol-definition.test

55 lines
1.0 KiB
Plaintext

/*
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
*/