Cortex-M0 ARM-GCC 編譯連接選項

通過兩週的努力,使用ARM-GCC編譯出來的文件終於能夠下載到板子上跑起來了,關於編譯器的配置解釋以下:windows

編譯環境: windows+cygwin函數

使用編譯器:arm-none-eabi-gcc-4.6:https://launchpad.net/gcc-arm-embedded/4.6/2011-q4-majorui

 

編譯選項:.net

-Wall                                  打開waringget

-fsigned-char                      將char作爲signed編譯器

-fno-builtin                         不使用build in函數(glibc函數)it

-ffunction-sections              將函數放到本身的section中(連接時配合--gc-sections能夠移除沒有使用的函數)io

-fdata-sections                   將data放到本身的section中(連接時配合--gc-sections能夠移除沒有使用的data)編譯

-mcpu=cortex-m0               cpu類型cortex-m0function

-mthumb                            指定arm指令集 thumb(16bit/32bit混合指令集)

 

連接選項:

-mcpu=cortex-m0               cpu類型cortex-m0

-mthumb                            指定arm指令集 thumb(16bit/32bit混合指令集)

-nostartfiles                                                      不使用編譯器默認的ld文件和startup文件

-Wl,-Map=$(IMG_PATH)/$(IMG_MAP)                   生成指定的map文件

-Wl,--gc-sections                                              移除惟有連接的內容

-Wl,-T$(L_SCRIPT)                                            指定ld文件

 

 

出現過的問題:

編譯選項忘了使用-mcpu=cortex-m0 –mthumb,致使編譯後的文件沒法運行。

連接時gcc -Map=$(IMG_PATH)/$(IMG_MAP) --gc-sections 會直接報不能識別選項,須要使用-Wl,--gc-sections來指定是連接選項便可

 

其它的幾個命令:

elf 轉bin: arm-none-eabi-objcopy -O binary –S file.elf file.bin

分析elf size: arm-none-eabi-size file.elf

相關文章
相關標籤/搜索