简体   繁体   中英

How to compile ARM32 only binary (no thumb)

Is there a GCC configuration which will produce an executable only containing ARM32 code? I know the -marm switch tells the compiler not to produce Thumb code, but it applies only to the user code of the program, while initialization routines (eg _start , frame_dummy , ...) still contain Thumb instructions. I am using the Linaro cross compiler tool-chain ( arm-linux-gnueabihf- ) on a Linux x86-64 system.

EDIT :

While recompiling the tool-chain I found the (probable) solution myself. The initialization routines encoded as Thumb are part of glibc and can be found in the object files crt1.o , crti.o and crtbegin.o . I haven't tried recompiling it, but there may be a configuration value which forces the whole libc to be encoded as ARM32.

Is there a GCC configuration which will produce an executable only containing ARM32 code? I know the -marm switch ...

Your main problem is that that code (eg _start ) is not produced by the compiler but it is already present pre-compiled (as thumb code).

If you want to have these functions to be non-thumb code you'll have to "replace" the existing files (thumb) by your own ones (non-thumb).

(You don't have to overwrite the existing files but you can instruct the linker to search for these files in a different directory.)

If you don't find pre-built non-thumb files you'll have to create them yourself (what may be a lot of work).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM