我想這是this問題的延續。 我編譯了我的中間引導加載程序庫,並驗證了它的工作原理,現在是時候針對它編寫一些應用程序代碼。如何正確鏈接符號
我能夠使用$(OBJCOPY) --wildcard --strip-symbol=main --strip-symbol="_*" $(TARGET).elf $(TARGET).syms
從引導加載程序生成的.hex
文件生成符號列表,這會給我bootloader.syms
。
我已經寫了使用一些功能在存儲庫部分測試應用程序,我編譯如下:
我通過GCC在引導加載程序使用的所有頭文件的位置/庫以及上面生成的符號文件。我已經測試過GCC按照預期來選擇頭文件。
Makefile文件調用:
Making: obj/main.o
avr-gcc -Os -std=gnu99 -Wall -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -ffunction-sections -fdata-sections -static -DF_CPU=8000000UL -DBAUD= -iquote../firmware/src/ -I. -I../firmware/src/ -MP -MD -mmcu=atmega16 -c -o obj/main.o src/main.c;
avr-gcc -Wl,-Map,app.map -Wl,--just-symbols=../firmware/bootloader.syms -T ld_script_app.x -mmcu=atmega16 obj/main.o -o app.elf
obj/main.o: In function `main':
main.c:(.text.startup.main+0x14): undefined reference to `lcd_init'
main.c:(.text.startup.main+0x8e): undefined reference to `lcd_fill'
main.c:(.text.startup.main+0x142): undefined reference to `gfx_draw_line'
collect2: error: ld returned 1 exit status
make: *** [app.elf] Error 1
我不知道,雖然是什麼導致了未定義的引用。我的印象是,他們會通過符號文件引用。