linux 汇编 `.eabi_attribute',-mfloat-abi=softfp的问题,指定fpu为neon

测试使用的C语言程序源码如下,程序源码文件是arm-c-disassemble.c:

int sum(int a, int b)

{

return a + b;

}

int sub(int a, int b)

{

return a - b;

}

1、编译但是不汇编,查看产生的汇编源码程序源码:

arm-linux-androideabi-gcc -S -o arm-c-disassemble-fp.s arm-c-disassemble.c

查看产生的汇编语言程序源码arm-c-disassemble-fp.s:

.arch armv5te

.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, 2

.eabi_attribute 30, 6

.eabi_attribute 34, 0

.eabi_attribute 18, 4

.file   "arm-c-disassemble.c"

.text

.align  2

.global sum

.type   sum, %function

sum:

@ args = 0, pretend = 0, frame = 8

@ frame_needed = 1, uses_anonymous_args = 0

@ link register save eliminated.

str     fp, [sp, #-4]!

add     fp, sp, #0

sub     sp, sp, #12

str     r0, [fp, #-8]

str     r1, [fp, #-12]

ldr     r2, [fp, #-8]

ldr     r3, [fp, #-12]

add     r3, r2, r3

mov     r0, r3

sub     sp, fp, #0

@ sp needed

ldr     fp, [sp], #4

bx      lr

.size   sum, .-sum

.align  2

.global sub

.type   sub, %function

sub:

@ args = 0, pretend = 0, frame = 8

@ frame_needed = 1, uses_anonymous_args = 0

@ link register save eliminated.

str     fp, [sp, #-4]!

add     fp, sp, #0

sub     sp, sp, #12

str     r0, [fp, #-8]

str     r1, [fp, #-12]

ldr     r2, [fp, #-8]

ldr     r3, [fp, #-12]

rsb     r3, r3, r2

mov     r0, r3

sub     sp, fp, #0

@ sp needed

ldr     fp, [sp], #4

bx      lr

.size   sub, .-sub

.ident  "GCC: (GNU) 4.8"

.section        .note.GNU-stack,"",%progbits

默认编译的arch是armv5te,默认的fpu是softvfp;

2、Cortex-A9是armv7-a的arch,因此需要在编译时指定arch:

arm-linux-androideabi-gcc -S -march=armv7-a -o arm-c-disassemble-fp.s arm-c-disassemble.c

查看编译后产生的汇编语言程序源码:

.arch armv7-a

.fpu softvfp

.eabi_attribute 20, 1

...

此时arch是armv7-a;

3、在(2)的基础上,此时fpu是softvfp,Cortex-A9中支持neon,在编译时增加-mfpu=neon指定fpu:

arm-linux-androideabi-gcc -S -march=armv7-a -mfpu=neon -o arm-c-disassemble-fp.s arm-c-disassemble.c

查看编译后产生的汇编语言程序源码:

.arch armv7-a

.fpu softvfp

.eabi_attribute 20, 1

...

奇怪的是,此时.fpu依然是softvfp,而不是我们指定的neon,为什么呢?

经过网络搜索,需要指定“-mfloat-abi=name”,mfloat-abi的作用参考gcc文档中的说明,

mfloat-abi取值有三个“soft”,“softfp”,“hard”,此处指定mfloat-abi为“softfp”,然后编译:

arm-linux-androideabi-gcc -S -march=armv7-a -mfloat-abi=softfp -mfpu=neon -o arm-c-disassemble-fp.s arm-c-disassemble.c

查看编译后产生的汇编语言程序源码:

.arch armv7-a

.eabi_attribute 27, 3

.fpu neon

.eabi_attribute 20, 1

...

此时fpu成为了我们指定的neon;

4、在(3)的基础上,还可以继续指定CPU相关的一些更详细的信息,例如-mcpu=name的值,指定具体的CPU型号:

arm-linux-androideabi-gcc -S -mcpu=cortex-a9 -march=armv7-a -mfloat-abi=softfp -mfpu=neon -o arm-c-disassemble-fp.s arm-c-disassemble.c

指定具体的CPU型号为Cortex-A9,查看编译后产生的汇编语言程序源码:

.cpu cortex-a9

.eabi_attribute 27, 3

.fpu neon

.eabi_attribute 20, 1

...

此时.arch变成了.cpu,指定具体的CPU型号;

此时编译的完整的汇编语言程序源码:

.cpu cortex-a9

.eabi_attribute 27, 3

.fpu neon

.eabi_attribute 20, 1

.eabi_attribute 21, 1

.eabi_attribute 23, 3

.eabi_attribute 24, 1

.eabi_attribute 25, 1

.eabi_attribute 26, 2

.eabi_attribute 30, 6

.eabi_attribute 34, 1

.eabi_attribute 18, 4

.file   "arm-c-disassemble.c"

.text

.align  2

.global sum

.type   sum, %function

sum:

@ args = 0, pretend = 0, frame = 8

@ frame_needed = 1, uses_anonymous_args = 0

@ link register save eliminated.

str     fp, [sp, #-4]!

add     fp, sp, #0

sub     sp, sp, #12

str     r0, [fp, #-8]

str     r1, [fp, #-12]

ldr     r2, [fp, #-8]

ldr     r3, [fp, #-12]

add     r3, r2, r3

mov     r0, r3

sub     sp, fp, #0

@ sp needed

ldr     fp, [sp], #4

bx      lr

.size   sum, .-sum

.align  2

.global sub

.type   sub, %function

sub:         @ args = 0, pretend = 0, frame = 8         @ frame_needed = 1, uses_anonymous_args = 0         @ link register save eliminated.         str     fp, [sp, #-4]!         add     fp, sp, #0         sub     sp, sp, #12         str     r0, [fp, #-8]         str     r1, [fp, #-12]         ldr     r2, [fp, #-8]         ldr     r3, [fp, #-12]         rsb     r3, r3, r2         mov     r0, r3         sub     sp, fp, #0         @ sp needed         ldr     fp, [sp], #4         bx      lr         .size   sub, .-sub         .ident  "GCC: (GNU) 4.8"         .section        .note.GNU-stack,"",%progbits

arm-none-eabi-gcc -o "SENSOR_CB.elf" @"objects.list" -mcpu=cortex-m3 -T"C:\Users\WangBingqian\Desktop\SC10L151Cube\trunk\NO_FOTA_VERSION\STM32L151CBTXA_FLASH.ld" --specs=nosys.specs -Wl,-Map="SENSOR_CB.map" -Wl,--gc-sections -static --specs=nano.specs -mfloat-abi=soft -mthumb -Wl,--start-group -lc -lm -Wl,--end-group Core/Src/rs485.o: In function `get_sample_data_max_min_value': rs485.c:(.text.get_sample_data_max_min_value+0x0): multiple definition of `get_sample_data_max_min_value' Core/Src/lora_wan.o:lora_wan.c:(.text.get_sample_data_max_min_value+0x0): first defined here Core/Src/rs485.o: In function `computeMvScale': rs485.c:(.text.computeMvScale+0x0): multiple definition of `computeMvScale' Core/Src/lora_wan.o:lora_wan.c:(.text.computeMvScale+0x0): first defined here Core/Src/rs485.o: In function `computeMvScale_f': rs485.c:(.text.computeMvScale_f+0x0): multiple definition of `computeMvScale_f' Core/Src/lora_wan.o:lora_wan.c:(.text.computeMvScale_f+0x0): first defined here Core/Src/rs485.o: In function `generate_frag_data': rs485.c:(.text.generate_frag_data+0x0): multiple definition of `generate_frag_data' Core/Src/lora_wan.o:lora_wan.c:(.text.generate_frag_data+0x0): first defined here Core/Src/rs485.o:(.bss.frag_num+0x0): multiple definition of `frag_num' Core/Src/lora_wan.o:(.bss.frag_num+0x0): first defined here collect2.exe: error: ld returned 1 exit status make: *** [makefile:50: SENSOR_CB.elf] Error 1 "make -j4 all" terminated with exit code 2. Build might be incomplete.是什么错误
06-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值