From 049aaf41f54be4ed6c612d1d1ac865508a67e691 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Fri, 27 Mar 2020 01:05:35 -0700 Subject: [PATCH] util: Implement PIC assembly for the aarch64. When accessing m5_mem and building PIC code, we need to get the address of m5_mem out of the global offset table, and then load the value from there. If we try to load from m5_mem directly, the assembled code has a relocation type the linker can't handle when building a shared object. Change-Id: Ieb19c3d17c37ef810559ee24b68886b18ddcc869 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/27212 Reviewed-by: Bobby R. Bruce Maintainer: Gabe Black Tested-by: kokoro --- util/m5/src/m5op_arm_A64.S | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/util/m5/src/m5op_arm_A64.S b/util/m5/src/m5op_arm_A64.S index c0224e21b..6f9f03808 100644 --- a/util/m5/src/m5op_arm_A64.S +++ b/util/m5/src/m5op_arm_A64.S @@ -44,7 +44,17 @@ .macro m5op_func, name, func .globl \name \name: - ldr x9, m5_mem + // Load the value of m5_mem into x9... +#if defined(M5OP_PIC) + // using the global offset table. + adrp x9, :got:m5_mem + ldr x9, [ x9, #:got_lo12:m5_mem ] + ldr x9, [ x9 ] +#else + // normally. + adrp x9, m5_mem + ldr x9, [ x9, #:lo12:m5_mem ] +#endif movz x10, #(\func << 8) ldr x0, [ x9, x10 ] ret -- 2.30.2