gcc, arm, and thumbs mode
Anton Kozlov
akozlov at azul.com
Fri May 27 13:27:58 UTC 2022
Hi Thomas,
On 5/27/22 16:12, Thomas Stüfe wrote:
> P.S. I found one possible solution for my particular problem was to add
> `.type function` to the static assembler routine. That caused gcc to use
> the correct jump instruction (blx instead of bl). But I am not sure this is
> the best solution, maybe best would be to just use the same mode for all
> hotspot compilation units.
AFAIR, that .type %function directive is a correct way to write asm
code. At least this is what gcc generates for the C code [1]. I'm not
sure how the annotation in the assembly code affects the caller code,
may be link time optimization? But if adding the directive resolves the
issue, I vote for it.
(I expect arm-none crosscompiler to produce similar results compared to
arm-linux target)
Thanks,
Anton
$ echo "int main() { return 0; }" | arm-none-eabi-gcc -mthumb -S -x c - -o -
.cpu arm7tdmi
.arch armv4t
.fpu softvfp
.eabi_attribute 20, 1
.eabi_attribute 21, 1
.eabi_attribute 23, 3
.eabi_attribute 24, 1
.eabi_attribute 25, 1
.eabi_attribute 26, 1
.eabi_attribute 30, 6
.eabi_attribute 34, 0
.eabi_attribute 18, 4
.file "<stdin>"
.text
.align 1
.global main
.syntax unified
.code 16
.thumb_func
.type main, %function
main:
@ Function supports interworking.
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 1, uses_anonymous_args = 0
push {r7, lr}
add r7, sp, #0
movs r3, #0
movs r0, r3
mov sp, r7
@ sp needed
pop {r7}
pop {r1}
bx r1
.size main, .-main
.ident "GCC: (Arch Repository) 12.1.0"
More information about the build-dev
mailing list