[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Link Eorror in Combining C and assembly source files
From: |
Dean Ferreyra |
Subject: |
Re: [avr-gcc-list] Link Eorror in Combining C and assembly source files |
Date: |
Fri, 05 Sep 2008 01:03:16 -0700 |
User-agent: |
Thunderbird 2.0.0.16 (Windows/20080708) |
Shilin Yu wrote:
> I have tried by it doesn't work either.
Yes, I was wrong about the underscore, sorry.
> I seems like that WinAVR uses the GNU Assembler(GAS), not the AVR Assembler
Sorry, I don't know what you mean.
Can you share the actual command lines you're using to compile and
assemble the files? My new guess is that when you are assembling the
file, avr-gcc is also trying to link.
One quick test I tried was to make two files, a.c:
volatile unsigned char sched_mode;
int main(void)
{
return 0;
}
and b.S:
.extern sched_mode
LDS R18, sched_mode
and then I compiled them separately and then linked them like so:
$ avr-gcc -mmcu=atmega128 -c a.c
$ avr-gcc -mmcu=atmega128 -c b.S
$ avr-gcc -mmcu=atmega128 -o a.out a.o b.o
$ ls -l a.out
-rwxr-xr-x 1 dean None 2674 Sep 5 00:59 a.out*
Can you try something along those lines?
On the other hand, without the -c, the second command will generate an
error, something like:
$ avr-gcc -mmcu=atmega128 b.S
.../crtm128.o:(.init9+0x0): undefined reference to `main'
.../ccJeooXf.o:(.text+0x2): undefined reference to `sched_mode'
Dean
>
> 2008/9/5 Dean Ferreyra <address@hidden <mailto:address@hidden>>
>
> Try using _sched_mode in your assembly code instead. If I remember
> correctly, the C compiler automatically prefixes symbols with an
> underscore.
>
> Dean
>
> Shilin Yu wrote:
> > I met an link error when build a project with .c and .S files
> >
> > the c file like this:
> > ...
> > volatile unsigned char sched_mode;
> > ...
> >
> >
> > the assembly file like this:
> > .extern sched_mode
> > ...
> > LDS R18, sched_mode
> > ...
> >
> >
> > when I build the project. the link error about the assembly
> file output:
> >
> > (.text+0x32): undefined reference to `sched_mode'
> >
> >
> > Any reply is welcome! Thanks!
> >
> > --
> > Sincerely yours,
> > Shilin Yu
> >
>
>
>
>
> --
> Sincerely yours,
> Shilin Yu
Re: [avr-gcc-list] Link Eorror in Combining C and assembly source files, Joerg Wunsch, 2008/09/07