[erlang-patches] hipe: fix ARM/Thumb interworking

Mikael Pettersson mikpelinux@REDACTED
Sun Jan 11 14:35:58 CET 2015


HiPE on ARM is currently severely broken if the rest of the VM is
compiled to run in Thumb mode -- calling native code quickly ends
up executing code in the wrong mode and crashing the VM.  This is
a problem on e.g. Ubuntu which configures its system GCC to generate
Thumb by default.  It can also be triggered by overriding CC or
CFLAGS when compiling the VM.

There were three issues that caused the breakage:

1. Assembly-coded functions in hipe_arm_glue.S weren't explicitly
   tagged as functions, preventing the linker from generating the
   correct mode-switching call instructions for calls from C to
   these functions.

   Fixed by tagging those symbols as functions.

2. A few BIF wrappers were so simple that they performed tailcalls
   to the C BIFs.  This fails to switch mode when C is in Thumb.

   Fixed by performing ordinary recursive calls when C is in Thumb.

3. The assembly-coded source files weren't explicitly tagged as ARM.

Tested with the HiPE testsuite on ARMv7, with the VM built as ARM
and as Thumb.  Also manually inspected the object code for the beam
executable and checked that call sites from C to HiPE's ARM runtime
code and vice versa used the correct mode-switching instructions.

Signed-off-by: Mikael Pettersson <mikpelinux@REDACTED>

Links:

git fetch git://github.com/mikpe/otp.git hipe-arm-interworking

https://github.com/mikpe/otp/compare/erlang:maint...hipe-arm-interworking
https://github.com/mikpe/otp/compare/erlang:maint...hipe-arm-interworking.patch

https://github.com/erlang/otp/pull/583



More information about the erlang-patches mailing list