[lld][linkerscript] Fix handling of DEFINED.
authorHafiz Abid Qadeer <abidh@codesourcery.com>
Thu, 16 Jul 2020 20:40:31 +0000 (21:40 +0100)
committerHafiz Abid Qadeer <abidh@codesourcery.com>
Tue, 28 Jul 2020 20:18:01 +0000 (21:18 +0100)
commit1f166edeb47ea3584f4f6a267a9054af994af45c
tree6dbcb882d8282f226976085e41ecd4600f9345b3
parent1e027b77f056fb50e50d9f743e21eb41151c32da
[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
lld/ELF/ScriptParser.cpp
lld/test/ELF/linkerscript/Inputs/define.s
lld/test/ELF/linkerscript/define.test