summaryrefslogtreecommitdiffstats
path: root/lld/ELF/ScriptParser.cpp
diff options
context:
space:
mode:
authorPetr Hosek <phosek@chromium.org>2017-07-20 23:11:47 +0000
committerPetr Hosek <phosek@chromium.org>2017-07-20 23:11:47 +0000
commit039fb8c2967efffacaf2150748fcad9dbe99ab4d (patch)
tree0f91b4cdaf53300c4e4d2ab227fb15c7680720a5 /lld/ELF/ScriptParser.cpp
parentb4c351dfd1d07ca7aa3f8e1c9fa25588d95b8638 (diff)
downloadbcm5719-llvm-039fb8c2967efffacaf2150748fcad9dbe99ab4d.tar.gz
bcm5719-llvm-039fb8c2967efffacaf2150748fcad9dbe99ab4d.zip
[ELF] Align the value if needed when computing the expression
Also add the test cases for the addition and subtraction both for the relative and absolute case. Differential Revision: https://reviews.llvm.org/D35346 llvm-svn: 308692
Diffstat (limited to 'lld/ELF/ScriptParser.cpp')
-rw-r--r--lld/ELF/ScriptParser.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp
index 531c61e6cb4..29570c80d2f 100644
--- a/lld/ELF/ScriptParser.cpp
+++ b/lld/ELF/ScriptParser.cpp
@@ -139,11 +139,13 @@ static void moveAbsRight(ExprValue &A, ExprValue &B) {
static ExprValue add(ExprValue A, ExprValue B) {
moveAbsRight(A, B);
- return {A.Sec, A.ForceAbsolute, A.Val + B.getValue(), A.Loc};
+ uint64_t Val = alignTo(A.Val, A.Alignment) + B.getValue();
+ return {A.Sec, A.ForceAbsolute, Val, A.Loc};
}
static ExprValue sub(ExprValue A, ExprValue B) {
- return {A.Sec, A.Val - B.getValue(), A.Loc};
+ uint64_t Val = alignTo(A.Val, A.Alignment) - B.getValue();
+ return {A.Sec, Val, A.Loc};
}
static ExprValue mul(ExprValue A, ExprValue B) {
OpenPOWER on IntegriCloud