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 <bbruce@ucdavis.edu>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Gabe Black
2020-03-27 01:05:35 -07:00
parent 53b6e21c63
commit 049aaf41f5

View File

@@ -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