0

a little project of avr, when i directly compile main.c(all other c are included in main.c), all ok.

    avr-gcc -Wall -mmcu=atmega8 -g -O1 $1 -o $1.out
    avr-objdump -dS $1.out>$1.asm

with asm, i can see all vector here.

    main.c.out:     file format elf32-avr
    Disassembly of section .text:
    00000000 <__vectors>:
   0:       1d cd           rjmp    .-1478          ; 0xfffffa3c <__eeprom_end+0xff7efa3c>
   2:       37 cd           rjmp    .-1426          ; 0xfffffa72 <__eeprom_end+0xff7efa72>

when i compile each c into obj (just add some header files, codes almost same), then link them, the result fail. of course MCU become mad.

    for i in src/*.c; do j=`basename $i`; j=obj/${j%%.c}.o; avr-gcc -c $i -o $j -mmcu=atmega8 -g -O1 -Wall; done;
    avr-ld obj/*.o -o a.out;
    avr-objdump -dS a.out >a.asm;

here is code in asm, not vector jump here, but just my rom datas.

    Disassembly of section .text:
    00000000 <tm_tone>:
           0:       00 00 e0 1d 9e 1a b5 17 62 16 ee 13 c1 11 d0 0f     ........b.......
    00000010 <tiger>:
          10:       31 32 33 31 31 32 33 31 33 34 35 30 33 34 35 30     1231123134503450

any advise? thanks. if i need special each obj file manually when use avr-ld?

eexpress
  • 155
  • 1
  • 10

1 Answers1

0

only this can be ok, after compile to obj. link use avr-gcc.

    avr-gcc -Wall -mmcu=atmega8 -g -O1 -o main.o src/main.c obj/usart.o obj/irda.o obj/everybody.o obj/audio.o
eexpress
  • 155
  • 1
  • 10