Files
clang-p2996/lld/test/ELF/linkerscript/define.test
Hafiz Abid Qadeer 1f166edeb4 [lld][linkerscript] Fix handling of DEFINED.
Current implementation did not check that symbols is actually defined. Only checked for presence.  GNU ld documentation says,

"Return 1 if symbol is in the linker global symbol table and is defined before the statement using DEFINED in the script, otherwise return 0."

https://sourceware.org/binutils/docs/ld/Builtin-Functions.html#Builtin-Functions

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D83758
2020-07-28 21:18:01 +01:00

20 lines
629 B
Plaintext

# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/define.s -o %t.o
# RUN: ld.lld -o %t --script %s %t.o
# RUN: llvm-objdump --section-headers %t | FileCheck %s
EXTERN(extern_defined)
SECTIONS {
. = DEFINED(defined) ? 0x11000 : .;
.foo : { *(.foo*) }
. = DEFINED(notdefined) ? 0x12000 : 0x13000;
.bar : { *(.bar*) }
. = DEFINED(extern_defined) ? 0x14000 : 0x15000;
.test : { *(.test*) }
}
# CHECK: 1 .foo 00000008 0000000000011000 DATA
# CHECK: 2 .bar 00000008 0000000000013000 DATA
# CHECK: 3 .test 00000008 0000000000015000 DATA
# CHECK: 4 .text 00000000 0000000000015008 TEXT