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

Unified Diff: binutils/gas/config/tc-i386.c

Issue 5648005: [binutils] allow immediates in naclrest{bp,sp} (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/nacl-toolchain.git@master
Patch Set: Created 10 years 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 | binutils/opcodes/i386-opc.tbl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: binutils/gas/config/tc-i386.c
diff --git a/binutils/gas/config/tc-i386.c b/binutils/gas/config/tc-i386.c
index b728748de53d71030f8626a5c61de1c74df1ddd6..6cc6b72394015c8c26e567a5dc119dc865a17320 100644
--- a/binutils/gas/config/tc-i386.c
+++ b/binutils/gas/config/tc-i386.c
@@ -5795,7 +5795,8 @@ insert_sp_adjust_sandbox_code (offsetT insn_start_off)
static void
insert_xp_sandbox_code(unsigned int regN, unsigned int cmd_2reg,
- unsigned int cmd_imm, offsetT insn_start_off)
+ unsigned int cmd_imm, offsetT insn_start_off,
+ int gen_imm_prefix)
{
char *p;
unsigned int need_rex = !!(i.rex & (REX_B | REX_X));
@@ -5850,12 +5851,20 @@ insert_xp_sandbox_code(unsigned int regN, unsigned int cmd_2reg,
}
else
{
- p = frag_more (2);
- if (imm_size (0) == 1)
- p[0] = 0x83; // CMD imm8, %regN(ExP)
+ if (gen_imm_prefix)
+ {
+ p = frag_more (2);
+ if (imm_size (0) == 1)
+ p[0] = 0x83; // CMD imm8, %regN(ExP)
+ else
+ p[0] = 0x81; // CMD imm32, %regX(ExP)
+ p[1] = cmd_imm;
+ }
else
- p[0] = 0x81; // CMD imm32, %regX(ExP)
- p[1] = cmd_imm;
+ {
+ p = frag_more (1);
+ p[0] = cmd_imm;
+ }
output_imm (frag_now, insn_start_off);
// Second operand is regN(ExP)
i.rm.regmem = regN/*ExP*/;
@@ -5973,26 +5982,26 @@ check_prefix:
if (!strcmp(i.tm.name, "naclasp"))
/* esp add add
reg imm */
- insert_xp_sandbox_code (4, 0x01, 0xc4, insn_start_off);
+ insert_xp_sandbox_code (4, 0x01, 0xc4, insn_start_off, 1);
else if (!strcmp(i.tm.name, "naclssp"))
/* esp sub sub
reg imm */
- insert_xp_sandbox_code (4, 0x29, 0xec, insn_start_off);
+ insert_xp_sandbox_code (4, 0x29, 0xec, insn_start_off, 1);
else if (!strcmp(i.tm.name, "naclspadj"))
insert_sp_adjust_sandbox_code (insn_start_off);
else if (!strcmp(i.tm.name, "naclrestbp"))
/* ebp mov mov
reg imm */
- insert_xp_sandbox_code (5, 0x89, 0xbc, insn_start_off);
+ insert_xp_sandbox_code (5, 0x89, 0xbd, insn_start_off, 0);
else if (!strcmp(i.tm.name, "naclrestsp"))
/* esp mov mov
reg imm */
- insert_xp_sandbox_code (4, 0x89, 0xbc, insn_start_off);
+ insert_xp_sandbox_code (4, 0x89, 0xbc, insn_start_off, 0);
else if (!strcmp(i.tm.name, "naclrestsp_noflags")) {
/* esp mov mov
reg imm */
// Generate the mov from src into esp first.
- insert_xp_sandbox_code (4, 0x89, 0xbc, insn_start_off);
+ insert_xp_sandbox_code (4, 0x89, 0xbc, insn_start_off, 0);
// Now set it up to restore rsp with lea (%rsp,%r15,1), %rsp --
// overriding the add instruction that insert_xp_sandbox_code
// set up to restore rsp.
« no previous file with comments | « no previous file | binutils/opcodes/i386-opc.tbl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698