Re: How to create a ROM library using GNU gcc and ld?
- From: Tauno Voipio <tauno.voipio@xxxxxxxxxxxxx>
- Date: Mon, 31 Mar 2008 18:46:47 GMT
Arlet Ottens wrote:
wyse03br@xxxxxxxxxxxx wrote:
Hi,
On Mar 31, 2:59 am, Arlet <usene...@xxxxxxxxxx> wrote:
You could use partial linking.
Use: ld -r with your object files and libraries to generate another .o
file.
Name this .o file explicitly in your linker script to put it in the
ROM area.
If I understood correctly, compilation and linking will be done in
2 steps - first compile the ROM library functions generating an a.aux
intermediary file and second link it when compilling the non ROM
library functions (main(), for instance):
% ppc-elf-gcc -g lib.c -lm -Wl,-T lib.lnk -Wl,-r -o a.aux -DROM #-
DROM selects the ROM-based routines
% ppc-elf-gcc lib.c -Wl,-T lib_aux.lnk a.aux -o a.out
This strategy doesn't work so well, because some symbols are
introduced twice (apparently by CRT0):
/lib/gcc-lib/ppc-elf/3.3.2/crtsavres.o(.text+0x1cc): In function
`_restgpr_31_x':
: multiple definition of `_restgpr_31_x'
a.aux(.text+0x1578): first defined here
collect2: ld returned 1 exit status
Have I misundestood something? Any workaround?
Don't use gcc for the partial link.
First use gcc to convert .c file into .o file, then call ld manually to do partial link (without linker script). Something like this:
% ppc-elf-gcc -g -c lib.c -DROM # creates lib.o file
% ppc-elf-ld -g -r -o a.aux lib.o -lm # add library code
Then build the rest of your project, adding a.aux file to final link stage.
I would call it rom.o instead of a.aux, but that's a personal preference.
There are risks for problems, however.
If the library code assumes that the memory is all read/write,
it may break when the code is forced to a write-only section.
Also, you need initialization for initialized variables in
the .data section before the ROM code works. I assume that
you do not have a mechanism for setting the values for the
..data section at start.
Usually, both the application and libraries have to be compiled
so that they can be put into a ROM.
--
Tauno Voipio
tauno voipio (at) iki fi
.
- References:
- How to create a ROM library using GNU gcc and ld?
- From: wyse03br
- Re: How to create a ROM library using GNU gcc and ld?
- From: Arlet
- Re: How to create a ROM library using GNU gcc and ld?
- From: wyse03br
- Re: How to create a ROM library using GNU gcc and ld?
- From: Arlet Ottens
- How to create a ROM library using GNU gcc and ld?
- Prev by Date: Re: How to create a ROM library using GNU gcc and ld?
- Next by Date: Re: Cost of a microcontroller - is it very important?
- Previous by thread: Re: How to create a ROM library using GNU gcc and ld?
- Next by thread: Re: How to create a ROM library using GNU gcc and ld?
- Index(es):
Relevant Pages
|