diff options
author | Rui Ueyama <ruiu@google.com> | 2017-04-12 23:16:52 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2017-04-12 23:16:52 +0000 |
commit | 040af7deab290bb30b0d5c4cabae13013e50aa55 (patch) | |
tree | 820266e2032c1e4af05982fd46968445b59eeafc | |
parent | e9c9edf67b05fb7d6981a68b6f3bd51e959a8247 (diff) | |
download | bcm5719-llvm-040af7deab290bb30b0d5c4cabae13013e50aa55.tar.gz bcm5719-llvm-040af7deab290bb30b0d5c4cabae13013e50aa55.zip |
Allow expressions in MEMORY command.
Previously, we allowed only integers in this context. Now you can
write expressions there. LLD is now able to handle the following
linker, for example.
MEMORY { rom (rx) : ORIGIN = (1024 * 1024) }
llvm-svn: 300131
-rw-r--r-- | lld/ELF/ScriptParser.cpp | 7 | ||||
-rw-r--r-- | lld/test/ELF/linkerscript/memory.s | 2 |
2 files changed, 2 insertions, 7 deletions
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index 0ba00a2ae35..155b08a26ac 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -1102,12 +1102,7 @@ uint64_t ScriptParser::readMemoryAssignment(StringRef S1, StringRef S2, return 0; } expect("="); - - // TODO: Fully support constant expressions. - if (Optional<uint64_t> Val = parseInt(next())) - return *Val; - setError("nonconstant expression for " + S1); - return 0; + return readExpr()().getValue(); } // Parse the MEMORY command as specified in: diff --git a/lld/test/ELF/linkerscript/memory.s b/lld/test/ELF/linkerscript/memory.s index 1b7562aca14..774a6f92ab1 100644 --- a/lld/test/ELF/linkerscript/memory.s +++ b/lld/test/ELF/linkerscript/memory.s @@ -18,7 +18,7 @@ # RUN: echo "MEMORY { \ # RUN: ram (rwx) : ORIGIN = 0, LENGTH = 1024M \ -# RUN: rom (rx) : org = 0x80000000, len = 64M \ +# RUN: rom (rx) : org = (0x80 * 0x1000 * 0x1000), len = 64M \ # RUN: } \ # RUN: SECTIONS { \ # RUN: .text : { *(.text) } > rom \ |