arm-linux-gnueabi compiler options

拥有回忆 提交于 2019-12-05 21:40:36

push doesn't necessarily tell you it is in thumb mode, in fact ARM's new assembly syntax called unified assembly language which means in most of the cases you can compile same code to arm or thumb-2 instruction sets.

Other problem is that, you are compiling in -O0 mode which adds some extra instructions for easy of debugability. Try -O2 and you should get the instruction flow you want.

gcc with -v switch as in arm-linux-gnueabi-gcc -v should show you how it is built, which also tells you the overall default options it uses when compiling your source code.

One last thing, targeted assembly sequence you mentioned uses ATPCS register naming scheme (check objdump doc for information), it uses a1 instead of r0 for example. You can also get this by setting disassembler-options in objdump with -M switch. Like below;

$ arm-linux-gnueabihf-gcc -c -O2 -o test test.c
$ arm-linux-gnueabihf-objdump -M reg-names-special-atpcs -d test

test:     file format elf32-littlearm


Disassembly of section .text.startup:

00000000 <main>:
   0:   f64f 70ff   movw    a1, #65535  ; 0xffff
   4:   f2c0 0001   movt    a1, #1
   8:   4770        bx  LR
   a:   bf00        nop

Another option is to get assembly output from gcc itself by using -S switch. Like below;

$ arm-linux-gnueabihf-gcc -S test.c

then you should get a new file called test.s in the same folder. However I don't know if there is an option for you to set the register naming.

I believe the default is Thumb mode:

arm-linux-gnueabi-gcc -S -mthumb test.c

The full ARM instructions can be generated using the -marm flag:

arm-linux-gnueabi-gcc -S -marm test.c
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!