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

Unified Diff: src/tools/tls_edit/tls_edit.c

Issue 1536713003: [MIPS] Make $t8 point to the address of TLS pointers (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client@master
Patch Set: Move EditMipsCode() below EditArmCode(). Created 4 years, 11 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 | « SConstruct ('k') | src/trusted/service_runtime/arch/mips/nacl_syscall.S » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/tools/tls_edit/tls_edit.c
diff --git a/src/tools/tls_edit/tls_edit.c b/src/tools/tls_edit/tls_edit.c
index 3df73aa8918a05aeb65529dcd15a549310c76358..9e6e7e7a1c7eb4439aa17bef29b3760009e43427 100644
--- a/src/tools/tls_edit/tls_edit.c
+++ b/src/tools/tls_edit/tls_edit.c
@@ -66,6 +66,23 @@ static void EditArmCode(void *code, size_t code_length) {
}
}
+static void EditMipsCode(void *code, size_t code_length) {
+ Elf32_Word *const words = code;
+ Elf32_Word *const end = (void *) ((uint8_t *) code + code_length);
+ Elf32_Word *insn;
+
+ for (insn = words; insn < end; ++insn) {
+ if ((*insn & 0xFFE0FFFF) == 0x8f000000) {
+ /*
+ * This is 'lw $REG, 0($t8)'.
+ * Turn it into 'lw $REG, 4($t8)'.
+ */
+ *insn |= 4;
+ ++g_changes;
+ }
+ }
+}
+
static Bool ConsiderOneInsn(const uint8_t *insn_begin, const uint8_t *insn_end,
uint32_t validation_info, void *data) {
UNREFERENCED_PARAMETER(data);
@@ -189,10 +206,7 @@ static Bool EditTLSCode(const char *infile, uint32_t code_addr,
}
return TRUE;
case EM_MIPS:
- if (g_verbose) {
- printf("%s: MIPS ELF detected, no instructions changed\n",
- infile);
- }
+ EditMipsCode(g_code_start, code_length);
return TRUE;
default:
fprintf(stderr, "%s: Unsupported e_machine %d\n",
« no previous file with comments | « SConstruct ('k') | src/trusted/service_runtime/arch/mips/nacl_syscall.S » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698