為了描述方便,將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
-
ARM
+關注
關注
134文章
9165瀏覽量
369189 -
編譯器
+關注
關注
1文章
1642瀏覽量
49284 -
編譯
+關注
關注
0文章
661瀏覽量
33040 -
匯編代碼
+關注
關注
0文章
24瀏覽量
7567
原文標題:基于ARM編譯器版本5的工程遷移與適配到ARM編譯器版本6.12 后續1 - 匯編代碼處理問題
文章出處:【微信號:嵌入式那些事,微信公眾號:嵌入式那些事】歡迎添加關注!文章轉載請注明出處。
發布評論請先 登錄
相關推薦
評論