我想这是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
我不知道,虽然是什么导致了未定义的引用。我的印象是,他们会通过符号文件引用。