armasm编译汇编代码链接失败的问题分析

为了描述方便,将arm compiler 5简称为ac5,将arm compiler 6.12简称ac6.12。
在公众号中回复arm编译器升级文档可以获取ac5升级到ac6.12的arm官方文档。
1、armasm编译汇编代码,链接失败的问题
这里新开一篇博文,专门讲讲针对arm格式的汇编代码,使用ac6.12应该如何处理。下述内容大多来自文档《migration_and_compatibility_guide_100068_0612_00_en.pdf》文档的 3.3 command-line options for preprocessing assembly source code。
我在我自己的工程中遇到过使用ac6.12编译汇编代码成功,但是链接会失败。提示内容大致是:xxx.scf error: l6236e: no section matches selector - no section to be first/last.对于这个问题,我起初以为是分散加载文件(*.scf)有问题,看了半天的分散加载文件内容,也没发现分散加载文件有问题。于是我转换方向,使用命令去手动编译startup_lpc55s69_cm33_core0.s,然后再手动链接,发现还是提示xxx.scf error: l6236e: no section matches selector - no section to be first/last.错误。
于是我再次查阅arm官方的升级与适配手册《migration_and_compatibility_guide_100068_0612_00_en.pdf》,发现armasm使用--cpreproc和--cpreproc_opts选项编译汇编代码时,输入源代码的后缀名是.s(大写)。然而我的工程的arm格式的汇编代码文件的后缀名均为小写,导致了armasm处理出错。下面是文档中3.3 command-line options for preprocessing assembly source code对--cpreproc和--cpreproc_opts的描述:
if you are using armasm to assemble source code that requires the use of the preprocessor, you must use both the --cpreproc and --cpreproc_opts options together. also:
• as a minimum, you must include the armclang options --target and either -mcpu or -march in --cpreproc_opts.
• the input assembly source must have an upper-case extension .s.
其中第2点,对汇编源文件后缀名为大写.s作了一个说明吧。
为了处理汇编源文件后缀是小写.s的情况,文档的下面也提供了一个操作的说明吧:
if you have existing source files, which require preprocessing,and that have the lower-case extension .s, then to avoidhaving to rename the files:
1.perform the preprocessing step separately using thearmclang -x assembler-with-cpp option.
2.assemble the preprocessed file without usingthe --cpreproc and --cpreproc_opts options.
上面这段英文的内容给出了汇编源代码文件后缀是小写.s,但是又不想修改源代码后缀的方法,首先使用armclang (带编译选项-x assembler-with-cpp)去预处理*.s汇编代码,生成一个过程*.s文件,接着再使用armasm(不带编译选项--cpreproc和--cpreproc_opts)去编译这个过程*.s文件。这里提供一个例子如下:
(1).armclang --target=arm-arm-none-eabi -mcpu=cortex-m33 -x assembler-with-cpp -e test.s -o test_preproc.s;
(2).armasm --cpu=cortex-m33 --fpu=fpv5-sp test_preproc.s;
2、总结
arm compiler 6.12对于arm格式的汇编处理,这里总结下吧,分两种情况:
(1).如果arm格式汇编代码源文件的后缀名是大写的.s,那么直接使用armasm 带编译选项--cpreproc和--cpreproc_opts进行编译即可,例如:
armasm --cpu=cortex-m33 --cpreproc --cpreproc_opts=--target=arm-arm-none-eabi,-mcpu=cortex-m33 startup_lpc55s69_cm33_core0.s
(2).如果arm格式汇编代码源文件的后缀名是小写的.s,这里就需要特殊处理了,有两种方法:
a.将arm格式汇编代码源文件的后缀名改为大写.s,然后按照步骤(1)进行处理即可。
b.首先使用armclang (带编译选项-x assembler-with-cpp)去预处理*.s汇编代码,生成一个过程*.s文件,接着再使用armasm(不带编译选项--cpreproc和--cpreproc_opts)去编译这个过程*.s文件。这里提供一个例子如下:
1).armclang --target=arm-arm-none-eabi -mcpu=cortex-m33 -x assembler-with-cpp -e test.s -o test_preproc.s
2).armasm --cpu=cortex-m33 --fpu=fpv5-sp test_preproc.s


STM32中断优先级谁更高 主要根据两个方面来判断
苹果公司的太阳能装机容量领先于其他企业
是德科技支持灵活定制调制的信号生成软件加快5G开发与测试速度
8项相关照明推荐性国家标准将于明年2月1日实施
蚂蚁集团针对互联网存款用户进行下线处理
armasm编译汇编代码链接失败的问题分析
简单了解ADI的位置编码器信号链解决方案
谈谈企业为什么要对UPS进行预防性维护
电视盒子哪款好?【师兄测评】分享最受欢迎电视盒子推荐
Agilent推出ADS 2010支持IBIS-AMI 模型
拜拜英伟达 特斯拉正试图为自动驾驶汽车制造首款电脑芯片
英飞凌面向安全关键型汽车应用推出双传感器封装器件
焊缝跟踪有哪些方法和技巧
用于实时机器学习的流式传输优先基础架构
人脸感知是人工智能界最早探索的领域之一
从400G的部署经验看800G数据中心的升级
如何解刨看LED路灯
解决星闪芯片BS25 1.0.T20.12版本开发工具默认SDK无法编译的问题
电流互感器开路防范措施
魅族推送Flyme 8内测版更新 暂取消mBack长按息屏功能