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

Unified Diff: src/IceAssemblerX86BaseImpl.h

Issue 1428443002: Enhance address mode recovery (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fixed relocation being attached to the wrong location. Created 5 years, 2 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 | src/IceInstX8632.cpp » ('j') | src/IceTargetLoweringX8632Traits.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceAssemblerX86BaseImpl.h
diff --git a/src/IceAssemblerX86BaseImpl.h b/src/IceAssemblerX86BaseImpl.h
index f06ee96007c7895493c3b83046eae66a4fbb022c..f82f367b57904e0467742f0989298707b2abb1a0 100644
--- a/src/IceAssemblerX86BaseImpl.h
+++ b/src/IceAssemblerX86BaseImpl.h
@@ -3313,14 +3313,22 @@ void AssemblerX86Base<Machine>::emitOperand(
assert(rm >= 0 && rm < 8);
const intptr_t length = operand.length_;
assert(length > 0);
+ intptr_t displacement_start = 1;
// Emit the ModRM byte updated with the given RM value.
assert((operand.encoding_[0] & 0x38) == 0);
emitUint8(operand.encoding_[0] + (rm << 3));
+ // Whenever the addressing mode is not register indirect, using esp == 0x4
+ // as the register operation indicates an SIB byte follows.
+ if (((operand.encoding_[0] & 0xc0) != 0xc0) &&
+ ((operand.encoding_[0] & 0x07) == 0x04)) {
+ emitUint8(operand.encoding_[1]);
+ displacement_start = 2;
+ }
+ // Emit the displacement and the fixup that affects it, if any.
if (operand.fixup()) {
emitFixup(operand.fixup());
}
- // Emit the rest of the encoded operand.
- for (intptr_t i = 1; i < length; i++) {
+ for (intptr_t i = displacement_start; i < length; i++) {
emitUint8(operand.encoding_[i]);
}
}
« no previous file with comments | « no previous file | src/IceInstX8632.cpp » ('j') | src/IceTargetLoweringX8632Traits.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698