[lld] r278770 - [ELF] Linkerscript: support hidden symbols assignments
Petr Hosek via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 15 18:11:16 PDT 2016
Author: phosek
Date: Mon Aug 15 20:11:16 2016
New Revision: 278770
URL: http://llvm.org/viewvc/llvm-project?rev=278770&view=rev
Log:
[ELF] Linkerscript: support hidden symbols assignments
This add support for HIDDEN command which can be used to define
a symbol that will be hidden and won't be exported.
Differential Revision: https://reviews.llvm.org/D23534
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/test/ELF/linkerscript/linkerscript-symbols.s
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=278770&r1=278769&r2=278770&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Mon Aug 15 20:11:16 2016
@@ -602,7 +602,7 @@ private:
InputSectionDescription *readInputSectionRules();
unsigned readPhdrType();
SortKind readSortKind();
- SymbolAssignment *readProvide(bool Hidden);
+ SymbolAssignment *readProvideHidden(bool Provide, bool Hidden);
SymbolAssignment *readProvideOrAssignment(StringRef Tok);
Expr readAlign();
void readSort();
@@ -969,10 +969,10 @@ std::vector<uint8_t> ScriptParser::readO
return { uint8_t(V >> 24), uint8_t(V >> 16), uint8_t(V >> 8), uint8_t(V) };
}
-SymbolAssignment *ScriptParser::readProvide(bool Hidden) {
+SymbolAssignment *ScriptParser::readProvideHidden(bool Provide, bool Hidden) {
expect("(");
SymbolAssignment *Cmd = readAssignment(next());
- Cmd->Provide = true;
+ Cmd->Provide = Provide;
Cmd->Hidden = Hidden;
expect(")");
expect(";");
@@ -985,9 +985,11 @@ SymbolAssignment *ScriptParser::readProv
Cmd = readAssignment(Tok);
expect(";");
} else if (Tok == "PROVIDE") {
- Cmd = readProvide(false);
+ Cmd = readProvideHidden(true, false);
+ } else if (Tok == "HIDDEN") {
+ Cmd = readProvideHidden(false, true);
} else if (Tok == "PROVIDE_HIDDEN") {
- Cmd = readProvide(true);
+ Cmd = readProvideHidden(true, true);
}
return Cmd;
}
Modified: lld/trunk/test/ELF/linkerscript/linkerscript-symbols.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/linkerscript-symbols.s?rev=278770&r1=278769&r2=278770&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/linkerscript-symbols.s (original)
+++ lld/trunk/test/ELF/linkerscript/linkerscript-symbols.s Mon Aug 15 20:11:16 2016
@@ -35,6 +35,12 @@
# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=HIDDEN2 %s
# HIDDEN2: 0000000000000000 *ABS* 00000000 somesym
+# Hidden symbol assignment.
+# RUN: echo "SECTIONS { HIDDEN(newsym = 1);}" > %t.script
+# RUN: ld.lld -o %t1 --script %t.script %t
+# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=HIDDEN3 %s
+# HIDDEN3: 0000000000000001 *ABS* 00000000 .hidden newsym
+
.global _start
_start:
nop
More information about the llvm-commits
mailing list