Re: How to create a ROM library using GNU gcc and ld?
- From: wyse03br@xxxxxxxxxxxx
- Date: Mon, 31 Mar 2008 12:55:12 -0700 (PDT)
On Mar 31, 3:35 pm, Arlet Ottens <usene...@xxxxxxxxxx> wrote:
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
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.
Thanks for the info, it makes sense. I did something slightly
different, but the overall result seems to be the same:
% ppc-elf-gcc -g lib.c -lm -Wl,-r -DROM -o rom.out
% ppc-elf-gcc -c lib.c -o lib.o
% ppc-elf-ld lib.o rom.out -T lib.lnk -o lib.out
Just for the records, the linker script is:
SECTIONS
{
/* Selects the sections from rom_code file which should go in ROM
*/
/* This line must come before the other .text section */
.rom_code : { rom.out(.text* .rodata*) } > ROM_CODE
.bss : { *(.bss) } > RAM_CODE
.sbss : { *(.sbss) } > RAM_CODE
.rodata : { *(.rodata*) } > RAM_CODE
.got2 : { *(.got*) } > RAM_CODE
.data : { *(.data) } > RAM_CODE
.sdata : { *(.sdata*) } > RAM_CODE
/* main() and other routines go in RAM */
.text : { *(.text*) } > RAM_CODE
}
Rgds
.
- Follow-Ups:
- Re: How to create a ROM library using GNU gcc and ld?
- From: Arlet Ottens
- Re: How to create a ROM library using GNU gcc and ld?
- 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: Software's evil
- Next by Date: Re: Feasible to implement a router on a system on a chip?
- 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):