Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(541)

Unified Diff: lib/Transforms/NaCl/FlattenGlobals.cpp

Issue 1694663002: PNaCl dynamic linking: Fix handling of local relocations with addends (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/Transforms/NaCl/convert-to-pso.ll » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/Transforms/NaCl/FlattenGlobals.cpp
diff --git a/lib/Transforms/NaCl/FlattenGlobals.cpp b/lib/Transforms/NaCl/FlattenGlobals.cpp
index 9b90cb2d4d911cf4835c6ede1b59c965c9df9654..3633be8c363f2fc58f90d80f0db27721116a004c 100644
--- a/lib/Transforms/NaCl/FlattenGlobals.cpp
+++ b/lib/Transforms/NaCl/FlattenGlobals.cpp
@@ -350,13 +350,16 @@ static void ExpandConstant(const DataLayout *DL, Constant *Val,
*ResultOffset = 0;
} else if (ConstantInt *CI = dyn_cast<ConstantInt>(Val)) {
*ResultGlobal = NULL;
- *ResultOffset = CI->getZExtValue();
+ *ResultOffset = CI->getSExtValue();
} else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Val)) {
ExpandConstant(DL, CE->getOperand(0), ResultGlobal, ResultOffset);
if (CE->getOpcode() == Instruction::GetElementPtr) {
SmallVector<Value *, 8> Indexes(CE->op_begin() + 1, CE->op_end());
*ResultOffset += DL->getIndexedOffset(CE->getOperand(0)->getType(),
Indexes);
+ } else if (CE->getOpcode() == Instruction::Add &&
+ isa<ConstantInt>(CE->getOperand(1))) {
+ *ResultOffset += cast<ConstantInt>(CE->getOperand(1))->getSExtValue();
} else if (CE->getOpcode() == Instruction::BitCast ||
CE->getOpcode() == Instruction::IntToPtr) {
// Nothing more to do.
« no previous file with comments | « no previous file | test/Transforms/NaCl/convert-to-pso.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698