一直以来都没有搞明白交叉编译默认支持的指令集的问题,今天在网上闲逛,找到一些有用的信息。
这个gcc默认参数输出哪个指令集的代码?
gcc -v :
Reading specs from /scratchbox/compilers/cs2005q3.2-glibc-arm/gcc.specs
rename spec cpp to old_cpp
Configured
with:
/home/kl/cs2005q3-2_toolchain/gcc/glibc/work/gcc-2005q3-2/configure
--build=i386-linux --host=i386-linux --target=arm-none-linux-gnueabi
--prefix=/scratchbox/compilers/cs2005q3.2-glibc-arm
--with-headers=/scratchbox/compilers/cs2005q3.2-glibc-arm/usr/include
--enable-languages=c,c++ --enable-shared --enable-threads
--disable-checking --enable-symvers=gnu --program-prefix=arm-linux-
--with-gnu-ld --enable-__cxa_atexit --disable-libssp
--disable-libstdcxx-pch --with-cpu= --enable-interwork
Thread model: posix
如果用gcc -o hi -Os hi.c编译,输出的指令应该是arm哪个版本的指令呢?
Re: 这个gcc默认参数输出哪个指令集的代码?
这个可以在制作编译器的同时,指定目标板的cpu类型,如arm-armv4-linux等,
如果不指定,则应该由用户自行选择编译器,或者直接报错,我想指令集应该
都是比较兼容的,编译时不指定可能是使用较高版本进行编译,如果不认识的
指令则直接报错失败。像objdump的这样的反汇编工具看了一下:
arm-linux-objdump: supported architectures: arm armv2 armv2a armv3 armv3m armv4 armv4t armv5 armv5t
armv5te xscale ep9312 iwmmxt
也就是可以用
-m, --architecture=MACHINE Specify the target architecture as MACHINE来指定吧!
具体看一下别人怎么说的:
-mcpu=name
This specifies the name of the target ARM processor. GCC uses this name to
determine what kind of instructions it can emit when generating assembly code.
Permissible names are: arm2, arm250, arm3, arm6, arm60, arm600, arm610, arm620,
arm7, arm7m, arm7d, arm7dm, arm7di, arm7dmi, arm70, arm700, arm700i, arm710,
arm710c, arm7100, arm7500, arm7500fe, arm7tdmi, arm7tdmi-s, arm8, strongarm,
strongarm110, strongarm1100, arm8, arm810, arm9, arm9e, arm920, arm920t,
arm922t, arm946e-s, arm966e-s, arm968e-s, arm926ej-s, arm940t, arm9tdmi,
arm10tdmi, arm1020t, arm1026ej-s, arm10e, arm1020e, arm1022e, arm1136j-s,
arm1136jf-s, mpcore, mpcorenovfp, arm1176jz-s, arm1176jzf-s, xscale, iwmmxt,
ep9312.
-mtune=name
This option is very similar to the -mcpu= option, except that instead of speci-
fying the actual target processor type, and hence restricting which instruc-
tions can be used, it specifies that GCC should tune the performance of the
code as if the target were of the type specified in this option, but still
choosing the instructions that it will generate based on the cpu specified by a
-mcpu= option. For some ARM implementations better performance can be obtained
by using this option.
-march=name
This specifies the name of the target ARM architecture. GCC uses this name to
determine what kind of instructions it can emit when generating assembly code.
This option can be used in conjunction with or instead of the -mcpu= option.
Permissible names are: armv2, armv2a, armv3, armv3m, armv4, armv4t, armv5,
armv5t, armv5te, armv6, armv6j, iwmmxt, ep9312.
所以我们可能通过这几个选项让编译器产生指定的版本指令集 ,比如:
-march=armv4 -mtune=arm7tdmi -mcpu=armv4等,但是这儿就是没有说出默认的情况是个啥子。
以下内容自撰:
arm-none-linux-gnueabi-objdump -H 会看到很多选项信息,但以下两项比较回答了开头的疑问:
arm-none-linux-gnueabi-objdump:
supported targets: elf32-littlearm elf32-bigarm elf32-little elf32-big
srec symbolsrec tekhex binary ihex
arm-none-linux-gnueabi-objdump:
supported architectures: arm armv2 armv2a armv3 armv3m armv4 armv4t
armv5 armv5t armv5te xscale ep9312 iwmmxt iwmmxt2
也就是说这个工具可以支持的指令集和目标文件列表了。领教了。
参考GNU编译器文档:
GNU compilers:
ARM Options: