seL4 / sel4runtime

A minimal runtime for seL4 applications.
Other
11 stars 29 forks source link

[ARM64] Failed to compile with error "operand 1 should be an integer register" #2

Open cee1 opened 4 years ago

cee1 commented 4 years ago
[PATCH] [ARM64] Use x29 and x30 instead of fp and lr to make GCC
 happy

GCC will abort the compilation with errors:
   "operand 1 should be an integer register ..."

See also https://bugs.webkit.org/show_bug.cgi?id=175512
---
 crt/sel4_arch/aarch64/crt0.S | 4 ++--
 crt/sel4_arch/aarch64/crti.S | 8 ++++----
 crt/sel4_arch/aarch64/crtn.S | 4 ++--
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/crt/sel4_arch/aarch64/crt0.S b/crt/sel4_arch/aarch64/crt0.S
index 3bd28b7..d265d06 100644
--- a/crt/sel4_arch/aarch64/crt0.S
+++ b/crt/sel4_arch/aarch64/crt0.S
@@ -12,8 +12,8 @@
 .section .text
 .global _start
 _start:
-   mov fp, #0
-   mov lr, #0
+   mov x29, #0
+   mov x30, #0

    mov x0, sp
    bl __sel4_start_c
diff --git a/crt/sel4_arch/aarch64/crti.S b/crt/sel4_arch/aarch64/crti.S
index 1119b90..3b85d67 100644
--- a/crt/sel4_arch/aarch64/crti.S
+++ b/crt/sel4_arch/aarch64/crti.S
@@ -12,11 +12,11 @@
 .section .init
 .global _init
 _init:
-   stp fp, lr, [sp, -16]!
-   mov fp, sp
+   stp x29, x30, [sp, -16]!
+   mov x29, sp

 .section .fini
 .global _fini
 _fini:
-   stp fp, lr, [sp, -16]!
-   mov fp, sp
+   stp x29, x30, [sp, -16]!
+   mov x29, sp
diff --git a/crt/sel4_arch/aarch64/crtn.S b/crt/sel4_arch/aarch64/crtn.S
index 734ccdc..4af13dc 100644
--- a/crt/sel4_arch/aarch64/crtn.S
+++ b/crt/sel4_arch/aarch64/crtn.S
@@ -10,9 +10,9 @@
  * @TAG(DATA61_BSD)
  */
 .section .init
-   ldp fp, lr, [sp], #16
+   ldp x29, x30, [sp], #16
    ret

 .section .fini
-   ldp fp, lr, [sp], #16
+   ldp x29, x30, [sp], #16
    ret
-- 
2.25.0
xurtis commented 4 years ago

Could you please clarify the underlying issue?

Our experience across a number of versions of GCC and clang has shown this not to be an issue in our codebase.

cee1 commented 4 years ago

It happened during the build process of "seL4 + Linux VMM":

During the compiling, GCC drops error messages, similar to webkit:#175512


Following webkit:#175512, I've made and patch and managed to build the u-boot image "capdl-loader-image-arm-tx2" and boot my TX2 board.

xurtis commented 4 years ago

I suspect that it's an issue in GCC7 that has been resolved in later versions.

The issues you linked suggested that the issue was only present in inline assembly, but you do not seem to have encountered any issues assembling the seL4 kernel itself which uses those register names in inline assembly.