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

Unified Diff: tests/common/register_set.h

Issue 546043004: NonSFI mode: Make tests/common/register_set.h PIC-friendly. (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client.git@master
Patch Set: nacl-ize arm code. Created 6 years, 3 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/common/register_set.h
diff --git a/tests/common/register_set.h b/tests/common/register_set.h
index 5bb747d174b1c8fa1d02e322504c2c2d95fbf7ee..a6133804e7202abe9b6df0158bcee0753be54217 100644
--- a/tests/common/register_set.h
+++ b/tests/common/register_set.h
@@ -240,7 +240,7 @@ extern const uint8_t kX86FlagBits[5];
#def_func ":\n" \
/* Push most of "struct NaClSignalContext" in reverse order. */ \
"push $0\n" /* Leave space for flags */ \
- "push $" #def_func "\n" /* Fill out prog_ctr with known value */ \
+ "push $0 \n" /* Leave space for prog_ctr */ \
"push %edi\n" \
"push %esi\n" \
"push %ebp\n" \
@@ -252,6 +252,12 @@ extern const uint8_t kX86FlagBits[5];
/* Save flags. */ \
SAVE_X86_FLAGS_INTO_REG("%eax") \
"movl %eax, 0x24(%esp)\n" \
+ /* Obtain def_func from GOT to fill progg_ctr with known value. */ \
+ "call 0f\n" \
+ "0: popl %eax\n" \
+ "1: addl $_GLOBAL_OFFSET_TABLE_ + (1b - 0b), %eax\n" \
+ "movl " #def_func "@GOT(%eax), %eax\n" \
+ "movl %eax, 0x20(%esp)\n" \
/* Adjust saved %esp value to account for preceding pushes. */ \
"addl $5 * 4, 0x10(%esp)\n" \
/* Save argument to callee_func() temporarily. */ \
@@ -335,8 +341,20 @@ extern const uint8_t kX86FlagBits[5];
/* Save the rest of struct NaClSignalContext */ \
"push {r0-r8}\n" \
/* Now save a correct prog_ctr value */ \
- "adr r0, " #def_func "\n" \
- "str r0, [sp, #0x3c]\n" \
+ "ldr r2, 11f\n" \
+ "1:\n" \
+ "add r2, pc, r2\n" /* obtain GLOBAL_OFFSET_TABLE */ \
+ "ldr r3, 12f\n" \
+ "add r2, r2, r3\n" \
+ "bic r2, r2, #0xc0000000\n" /* SFI constraint */ \
+ "ldr r3, [r2]\n" /* obtain def_func */ \
+ "str r3, [sp, #0x3c]\n" \
+ "b 2f\n" /* leave some space for PC-relative data. */ \
+ "11:\n" \
+ ".word _GLOBAL_OFFSET_TABLE_-(1b + 8)\n" \
Junichi Uekawa 2014/09/15 03:43:08 hmmm, pnacl-clang claims it doesn't know ".word "
Junichi Uekawa 2014/09/15 12:36:51 changing to .long made this pass, but clang-3.4 do
+ "12:\n" \
+ ".word " #def_func "(GOT)\n" \
+ "2:\n" \
/* Save CPSR (flags) register, a.k.a. APSR for user mode */ \
"mrs r0, apsr\n" \
"str r0, [sp, #0x40]\n" \
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698