summaryrefslogtreecommitdiff
path: root/sysdeps/aarch64/sysdep.h
diff options
context:
space:
mode:
authorWang Boshi <wangboshi@huawei.com>2017-09-15 17:53:23 +0100
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2017-09-18 18:15:47 +0100
commit6cd380dd366d728da9f579eeb9f7f4c47f48e474 (patch)
treea6c1ac8110060c1bc059697def0bc5b2cb9e66b7 /sysdeps/aarch64/sysdep.h
parent1c6d89e9a40302430d5986a09c7cf7594b93143c (diff)
downloadglibc-6cd380dd366d728da9f579eeb9f7f4c47f48e474.tar.gz
AArch64: use movz/movk instead of literal pools in start.S
eXecute-Only Memory (XOM) is a protection mechanism against some ROP attacks. XOM sets the code as executable and unreadable, so the access to any data, like literal pools, in the code section causes the fault with XOM. The compiler can disable literal pools for C source files, but not for assembly files, so I use movz/movk instead of literal pools in start.S for XOM. I add MOVL macro with movz/movk instructions like movl pseudo-instruction in armasm, and use the macro instead of literal pools. * sysdeps/aarch64/start.S: Use MOVL instead of literal pools. * sysdeps/aarch64/sysdep.h (MOVL): Add MOVL macro.
Diffstat (limited to 'sysdeps/aarch64/sysdep.h')
-rw-r--r--sysdeps/aarch64/sysdep.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/sysdeps/aarch64/sysdep.h b/sysdeps/aarch64/sysdep.h
index a749a707ec..aba18de4d7 100644
--- a/sysdeps/aarch64/sysdep.h
+++ b/sysdeps/aarch64/sysdep.h
@@ -137,6 +137,20 @@
ldr PTR_REG (T), [x##T, #:got_lo12:EXPR]; \
OP PTR_REG (R), [x##T];
+/* Load an immediate into R.
+ Note R is a register number and not a register name. */
+#ifdef __LP64__
+# define MOVL(R, NAME) \
+ movz PTR_REG (R), #:abs_g3:NAME; \
+ movk PTR_REG (R), #:abs_g2_nc:NAME; \
+ movk PTR_REG (R), #:abs_g1_nc:NAME; \
+ movk PTR_REG (R), #:abs_g0_nc:NAME;
+#else
+# define MOVL(R, NAME) \
+ movz PTR_REG (R), #:abs_g1:NAME; \
+ movk PTR_REG (R), #:abs_g0_nc:NAME;
+#endif
+
/* Since C identifiers are not normally prefixed with an underscore
on this system, the asm identifier `syscall_error' intrudes on the
C name space. Make sure we use an innocuous name. */