 |
|
| Computers Forum Index » Computer Architecture - Embedded » embedded gcc linker issue--trying to build for m68000... |
|
Page 1 of 1 |
|
| Author |
Message |
| Jim... |
Posted: Tue Nov 03, 2009 12:24 am |
|
|
|
Guest
|
Hi,
I'm using the free Code Sourcery Lite gcc for m68k for a home project
that involves a micro with 68000 cpu core. I added -lgcc to the
linker flags to resolve an issue with __divsi3. However, now I get
the following linker error:
c:/program files/codesourcery/sourcery g++ lite/bin/../lib/gcc/m68k-
elf/4.2.1/../../../../m68k-elf/bin/ld.exe: m68k:isa-a:nodiv
architecture of input file `c:/program files/codesourcery/sourcery g++
lite/bin/../lib/gcc/m68k-elf/4.2.1\libgcc.a(_divsi3.o)' is
incompatible with m68k:68000 output
My ccompiler flags are:
CFLAGS =-m68000 $(INCLUDES)
CFLAGS += -fno-exceptions
CFLAGS += -Wall -Wa,-m68000
CFLAGS += -ggdb
My linker flags are:
LFLAGS = $(CFLAGS) -Wl,-Map,$(basename $ at (no spam) ).map,--cref
LFLAGS += -nostdlib
LFLAGS += -nostartfiles
LFLAGS += -nodefaultlibs
LFLAGS += -lgcc
CodeSourcery is "for" Coldfire which (I think) has a richer
instruction set than the 68000 cpu I have. If this is true and that
lib is built with that instruction set, it wouldn't be compatible with
my object code. I think this is what the error is saying. I have an
old Linux box with v2.2 Linux on it, so I COULD build my own cross
compiler for WinXP, or I could try the cygwin deal and build it on
WinXP, but let's face it, either would be a real pain. Does anyone
have any better ideas?
Thanks much,
Jim |
|
|
| Back to top |
|
|
|
| Didi... |
Posted: Tue Nov 03, 2009 5:50 am |
|
|
|
Guest
|
|
| Back to top |
|
|
|
| DJ Delorie... |
Posted: Tue Nov 03, 2009 6:15 am |
|
|
|
Guest
|
You can get the sources for libgcc and rebuild it with the
target-specific options you need, giving you an optimized (and
appropriate) libgcc.a. You already have the right compiler for it  |
|
|
| Back to top |
|
|
|
| Jim... |
Posted: Wed Nov 04, 2009 11:58 pm |
|
|
|
Guest
|
First, I'd like to thank everyone for their input! Second, I'd like
to answer some of the questions so no one feels left out:
- The target cpu is truly a 68000 core (the old Dragonball EZ328).
Now, to avoid the "why": it's a Palm pda which has a display and
formfactor that I need and it's cheap.
- I'm using my own OS on the embedded system (no Linux).
- Now that I think about it, I upgraded my Linux box to 2.4, so I'm
not that "ancient" . I have a 2.6 one at work. I want to do my
development work in MS Windows, but I could build libgcc on Linux, if
I have to).
- I read the GettingStarted guide and I looked at all the libgcc.a
files: all seem to be ColdFire based .
- I'm coding mostly from scratch. However, I'm using a modified GDB
stub from David Williams.
- The only two languages I'll consider using for embedded projects are
C and C++ (plus the little bit of necessary assembly). It's what I'm
really familiar with.
- I don't really care if the object code is COFF or ELF. The
executable has to be straight binary though.
- I use gcc for linking. But I still need to explicitly say -lgcc
because of the -nodefaultlibs linker flag (I think). For the sake of
completeness, my compile and link lines are:
m68k-elf-gcc -o bin/main.o -m68000 -I. -I../shared -fno-exceptions -
Wall -Wa,-m68000 -ggdb -c main.c
m68k-elf-gcc -Wl,-T,RadioTest.ldi bin/MyStartup.o bin/main.o bin/
Timer.o -o bin/RadioTest.elf -m68000 -I. -I../shared -fno-exceptions -
Wall -Wa,-m68000 -ggdb -Wl,-Map,bin/RadioTest.map,--cref -nostdlib -
nostartfiles -nodefaultlibs -lgcc
So, I think the general consensus is I only get ColdFire micro support
with CodeSourcery and I agree with this. I can understand why
CodeSourcery may want to ignore older cores. However, don't they
still make micros with that (68000 based) core? I might email them,
but since I'm using the free version, I feel funny bothering them with
this (they do need to earn a living). Purchasing it would be a real
gamble since they do say it's a ColdFire compiler on their website
(and for home use, it's kinda a pricey gamble).
I'm gonna try two things. First, I'll look for other precompiled
binaries for MS Windows. Maybe I'll luck out. I came across one the
other day, but now can't remember for the life of me who made it--I'm
sure it'll turn up in a search.
Second, I'll see if I can build libgcc. I assume I'll get the source
to this when I download the source to gcc. David suggested I use
MinGW. I'm pretty sure I'll need "configure" and maybe autoconf &
automake. I'm not familiar with MinGW: does that package have them?
I just got an idea. PrcTools was a MS Windows compiler for that very
micro. I remember trying it, but it was a limited 16b compiler trying
to be compatible with the Palm OS. However, I might be able to use
its libgcc. The only issue is that compiler is so old it's probably
COFF based (and of course CodeSourcery is ELF). Nothing's ever
easy. :)
Well, thanks again for your help everyone. I'll post what I finally
end up with (in case anyone else needs the info).
Jim |
|
|
| Back to top |
|
|
|
| Hans-Bernhard Bröker... |
Posted: Thu Nov 05, 2009 2:16 am |
|
|
|
Guest
|
Jim wrote:
Quote: Hi,
I'm using the free Code Sourcery Lite gcc for m68k for a home project
that involves a micro with 68000 cpu core. I added -lgcc to the
linker flags to resolve an issue with __divsi3.
That should never be necessary. GCC already puts -lgcc into the linker
command line it builds, whenever that serves a useful purpose.
Quote: If this is true and that
lib is built with that instruction set, it wouldn't be compatible with
my object code. I think this is what the error is saying.
More to the point, GCC would probably have to be built with multilib
support to allow switching between incompatible variants of the same
basic CPU architecture. That would include multiple copies of libraries
such as libgcc, the Standard C++ runtime, and startup code as needed,
and the gcc driver program would automatically pick those needed for the
chosen architecture.
For whatever reasons, your GCC apparently wasn't built that way. Maybe
you need to pick a different package. Or, who knows, you may even have
to bite the bullet and build your own GCC tool chain. |
|
|
| Back to top |
|
|
|
| David Brown... |
Posted: Thu Nov 05, 2009 2:36 am |
|
|
|
Guest
|
Hans-Bernhard Bröker wrote:
Quote: Jim wrote:
Hi,
I'm using the free Code Sourcery Lite gcc for m68k for a home project
that involves a micro with 68000 cpu core. I added -lgcc to the
linker flags to resolve an issue with __divsi3.
That should never be necessary. GCC already puts -lgcc into the linker
command line it builds, whenever that serves a useful purpose.
If this is true and that
lib is built with that instruction set, it wouldn't be compatible with
my object code. I think this is what the error is saying.
More to the point, GCC would probably have to be built with multilib
support to allow switching between incompatible variants of the same
basic CPU architecture. That would include multiple copies of libraries
such as libgcc, the Standard C++ runtime, and startup code as needed,
and the gcc driver program would automatically pick those needed for the
chosen architecture.
For whatever reasons, your GCC apparently wasn't built that way. Maybe
you need to pick a different package. Or, who knows, you may even have
to bite the bullet and build your own GCC tool chain.
CodeSourcery gcc (for the ColdFire, anyway - I don't know about other
targets) /is/ built with multilib. It's just that they don't supply
pre-built libraries for all the architectures supported by the compiler
- pure 68000 is so old that it's rarely used. Mind you, other devices
such as the 68332 are still very much in use, and there are no pre-built
libraries for the CPU32 core either - the downloadable binaries (in the
"lite" version anyway) only include ColdFire libraries. |
|
|
| Back to top |
|
|
|
| 42Bastian Schick... |
Posted: Thu Nov 05, 2009 6:15 am |
|
|
|
Guest
|
On Wed, 4 Nov 2009 15:58:50 -0800 (PST), Jim <adirondackmtn at (no spam) yahoo.com>
wrote:
Quote: First, I'd like to thank everyone for their input! Second, I'd like
to answer some of the questions so no one feels left out:
- The target cpu is truly a 68000 core (the old Dragonball EZ328).
Now, to avoid the "why": it's a Palm pda which has a display and
formfactor that I need and it's cheap.
Funny, have such lying around and waiting for a project :-)
Quote: Second, I'll see if I can build libgcc. I assume I'll get the source
to this when I download the source to gcc.
Why not just add the needed functions to your project ?
I mean, LD will complain about missing __???? and you just pull the
source and that's it.
I wouldn't bother building libgcc.a
Quote: Well, thanks again for your help everyone. I'll post what I finally
end up with (in case anyone else needs the info).
Yes, please do so.
--
42Bastian
Do not email to bastian42 at (no spam) yahoo.com, it's a spam-only account
Use <same-name> at (no spam) monlynx.de instead ! |
|
|
| Back to top |
|
|
|
| Jim... |
Posted: Tue Nov 17, 2009 12:16 am |
|
|
|
Guest
|
On Nov 4, 6:58 pm, Jim <adirondack... at (no spam) yahoo.com> wrote:
Quote: First, I'd like to thank everyone for their input! Second, I'd like
to answer some of the questions so no one feels left out:
- The target cpu is truly a 68000 core (the old Dragonball EZ328).
Now, to avoid the "why": it's a Palm pda which has a display and
formfactor that I need and it's cheap.
- I'm using my own OS on the embedded system (no Linux).
...text deleted for brevity...
So, I think the general consensus is I only get ColdFire micro support
with CodeSourcery and I agree with this. I can understand why
CodeSourcery may want to ignore older cores. However, don't they
still make micros with that (68000 based) core? I might email them,
but since I'm using the free version, I feel funny bothering them with
this (they do need to earn a living). Purchasing it would be a real
gamble since they do say it's a ColdFire compiler on their website
(and for home use, it's kinda a pricey gamble).
I'm gonna try two things. First, I'll look for other precompiled
binaries for MS Windows. Maybe I'll luck out. I came across one the
other day, but now can't remember for the life of me who made it--I'm
sure it'll turn up in a search.
Second, I'll see if I can buildlibgcc. I assume I'll get the source
to this when I download the source to gcc. David suggested I use
MinGW. I'm pretty sure I'll need "configure" and maybe autoconf &
automake. I'm not familiar with MinGW: does that package have them?
I just got an idea. PrcTools was a MS Windows compiler for that very
micro. I remember trying it, but it was a limited 16b compiler trying
to be compatible with the Palm OS. However, I might be able to use
itslibgcc. The only issue is that compiler is so old it's probably
COFF based (and of course CodeSourcery is ELF). Nothing's ever
easy. :)
Well, thanks again for your help everyone. I'll post what I finally
end up with (in case anyone else needs the info).
Jim
Problem solved. I looked at the libc files and they were pretty
simple. I think there was only one macro definition I had to figure
out. But, then I realized my next step would be to build newlib and
that wasn't gonna be that simple.
I looked at a bunch of pre-built stuff (thanks again everyone for the
links--I may compare the Aztec C output to gcc someday). I decided I
really wanted GNU because I know the debugger works with Eclipse.
By the way, the other pre-built gcc I was thinking of was www.ronetix.it.
It had everything I needed, but, unfortunately, there was a flaw with
it (either the binary wasn't produced correctly or gdb didn't load it
correctly--I didn't look into it further). One other by ASH WARE was
too old (2.95 and coff based--I wasn't sure an elf type gdb would
handle it). The Macgregor (sp?) didn't run (I need a cygwin dll).
So, I ended up building gcc and newlib using mingw/msys like David
suggested. I was intrigued by the idea. I'm still gonna use
CodeSourcery's gcc though (I figure they ran some of the gcc tests).
I'll just link to the libc, libgcc, etc. produced by me (so far tests
show it's ok). It wasn't TOO bad building the libs. There were some
tricks to get things to build right--I spent some time doing
searches. I think the biggest thing to remember is that many tools
want you to do these three things:
(1) create a folder outside of the source tree to hold intermediate
files.
(2) run configure and build from the folder created in (1)
(3) Use a RELATIVE path when running configure in (2). You can get
weird compile errors otherwise. Unfortunately many docs have scripts
that use the full path (including the one at mingw). Maybe this used
to work for older gcc.
One last thing: gcc needs to build mpfr and gmp. It turns out for
the 4.2.1 and 4.4.2 releases I did, all you have to do it place the
source in the gcc folder (omit the -version part of the folder name).
I'm sure there's other ways to do it as well.
Well, thanks again everyone for all of your input! It was fun (for me
anyways)!!
Jim |
|
|
| Back to top |
|
|
|
|
|
All times are GMT
The time now is Fri Dec 11, 2009 2:20 pm
|
|