[PATCH] D35651: [ELF] Align the value if needed when computing the expression

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 19 16:23:11 PDT 2017


phosek created this revision.
phosek added a project: lld.
Herald added a subscriber: emaste.

Repository:
  rL LLVM

https://reviews.llvm.org/D35651

Files:
  ELF/ScriptParser.cpp


Index: ELF/ScriptParser.cpp
===================================================================
--- ELF/ScriptParser.cpp
+++ ELF/ScriptParser.cpp
@@ -139,11 +139,13 @@
 
 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) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35651.107410.patch
Type: text/x-patch
Size: 669 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170719/6c221497/attachment.bin>


More information about the llvm-commits mailing list