Opened 2 years ago

Closed 2 years ago

#14317 closed bug (fixed)

arm thumb code in kernel

Reported by: kallisti5 Owned by: nobody
Priority: low Milestone: Unscheduled
Component: System/Kernel Version: R1/Development
Keywords: arm thumb clang Cc:
Blocked By: Blocking:
Platform: All


While using clang to build Haiku ARM, it points out that we're using ARM thumb assembly:

/home/kallisti5/Code/haiku/src/system/kernel/arch/arm/arch_asm.S:239:16: error: constant expression expected
 str r4, [r0, #CPU_ENT_fault_handler]
/home/kallisti5/Code/haiku/src/system/kernel/arch/arm/arch_asm.S:240:16: error: constant expression expected
 str sp, [r0, #CPU_ENT_fault_handler_stack_pointer]
/home/kallisti5/Code/haiku/src/system/kernel/arch/arm/arch_asm.S:245:2: error: instruction requires: armv5t
 blx r2

I'm not sure of the intent here. It could be "working as expected" and clang is misconfigured... or clang could be pointing out a problem. My knowledge here is pretty limited.

Change History (4)

comment:1 by pulkomandy, 2 years ago

It is not necessarily thumb. ARMv5 was ARM-only. ARMv5t added the thumb instruction set, and the blx instruction, which allows to jump to a subroutine and optionally switch to or from thumb mode. On modern ARM architectures it is usual to use the blx instruction for jumping in all cases.

ARMv7 does support thumb, so this is not a problem. I suspect we forgot to pass -march and/or -mcpu in the ASMFLAGS for clang, so it is trying to compile things as plain ARMv5 or ARMv4 and rejecting any modern instructions?

comment:2 by waddlesplash, 2 years ago

We already tell Clang to use armv7a, and I think we pass the same cflags to clang when assembling; but if we don't then that will be the issue here, yes. Are we ready allowed to use the instruction outside of thumb mode?

comment:3 by pulkomandy, 2 years ago

Yes, BLX is "jump to address, and if lowest bit of address is set, also switch to thumb mode". This allows to jump seemlessly between ARM and Thumb code.

See (Table 4.7 for instruction availability)

comment:4 by waddlesplash, 2 years ago

Resolution: fixed
Status: newclosed

Fixed in hrev52208.

Note: See TracTickets for help on using tickets.