forked from OSchip/llvm-project
[ELF] Support quoted symbols in symbol assignments
glibc/elf/tst-absolute-zero-lib.lds uses `"absolute" = 0;`
This commit is contained in:
parent
75e7d1320c
commit
e7a7ad134f
|
@ -1001,6 +1001,7 @@ SymbolAssignment *ScriptParser::readAssignment(StringRef tok) {
|
|||
}
|
||||
|
||||
SymbolAssignment *ScriptParser::readSymbolAssignment(StringRef name) {
|
||||
name = unquote(name);
|
||||
StringRef op = next();
|
||||
assert(op == "=" || op == "+=");
|
||||
Expr e = readExpr();
|
||||
|
@ -1350,7 +1351,7 @@ Expr ScriptParser::readPrimary() {
|
|||
return [=] { return alignTo(script->getDot(), e().getValue()); };
|
||||
}
|
||||
if (tok == "DEFINED") {
|
||||
StringRef name = readParenLiteral();
|
||||
StringRef name = unquote(readParenLiteral());
|
||||
return [=] {
|
||||
Symbol *b = symtab->find(name);
|
||||
return (b && b->isDefined()) ? 1 : 0;
|
||||
|
@ -1428,6 +1429,7 @@ Expr ScriptParser::readPrimary() {
|
|||
return [=] { return *val; };
|
||||
|
||||
// Tok is a symbol name.
|
||||
tok = unquote(tok);
|
||||
if (!isValidSymbolName(tok))
|
||||
setError("malformed number: " + tok);
|
||||
script->referencedSymbols.push_back(tok);
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
# REQUIRES: x86
|
||||
## Test that . and $ can be used by symbol names in expressions.
|
||||
## Test that ., $ and " can be used by symbol names in expressions.
|
||||
|
||||
# RUN: llvm-mc -filetype=obj -triple=x86_64 /dev/null -o %t.o
|
||||
# RUN: ld.lld -T %s %t.o -o /dev/null
|
||||
# RUN: ld.lld -T %s %t.o -o %t
|
||||
# RUN: llvm-readelf -s %t | FileCheck %s
|
||||
|
||||
# CHECK: Value Size Type Bind Vis Ndx Name
|
||||
# CHECK-DAG: 0000000000000000 0 NOTYPE GLOBAL DEFAULT ABS a1
|
||||
# CHECK-DAG: 0000000000000000 0 NOTYPE GLOBAL DEFAULT ABS a0
|
||||
# CHECK-DAG: 0000000000000003 0 NOTYPE GLOBAL DEFAULT ABS a2
|
||||
|
||||
a0 = DEFINED(.TOC.) ? .TOC. : 0;
|
||||
a1 = DEFINED(__global_pointer$) ? __global_pointer$ : 0;
|
||||
"a1" = DEFINED(__global_pointer$) ? __global_pointer$ : 0;
|
||||
"a2" = DEFINED("a1") ? "a1" + 3 : 0;
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=HIDDEN1 %s
|
||||
# HIDDEN1: 0000000000000001 l *ABS* 0000000000000000 .hidden newsym
|
||||
|
||||
# RUN: echo 'SECTIONS { PROVIDE_HIDDEN("newsym" = 1);}' > %t.script
|
||||
# RUN: ld.lld -o %t1 --script %t.script %t
|
||||
# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=HIDDEN1 %s
|
||||
|
||||
.global _start
|
||||
_start:
|
||||
nop
|
||||
|
|
Loading…
Reference in New Issue