summaryrefslogtreecommitdiffstats
path: root/lld/ELF/LinkerScript.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lld/ELF/LinkerScript.cpp')
-rw-r--r--lld/ELF/LinkerScript.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 1b240f46ae9..0febb253149 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -756,6 +756,10 @@ template <class ELFT> uint64_t LinkerScript<ELFT>::getSymbolValue(StringRef S) {
return 0;
}
+template <class ELFT> bool LinkerScript<ELFT>::isDefined(StringRef S) {
+ return Symtab<ELFT>::X->find(S) != nullptr;
+}
+
// Returns indices of ELF headers containing specific section, identified
// by Name. Each index is a zero based number of ELF header listed within
// PHDRS {} script block.
@@ -1490,6 +1494,14 @@ Expr ScriptParser::readPrimary() {
expect(")");
return [=](uint64_t Dot) { return getConstant(Tok); };
}
+ if (Tok == "DEFINED") {
+ expect("(");
+ StringRef Tok = next();
+ expect(")");
+ return [=](uint64_t Dot) {
+ return ScriptBase->isDefined(Tok) ? 1 : 0;
+ };
+ }
if (Tok == "SEGMENT_START") {
expect("(");
next();
OpenPOWER on IntegriCloud