Re: How to create a ROM library using GNU gcc and ld?



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.
.



Relevant Pages

  • Re: Bug in ROM 2.14 regarding Port 2
    ... any newly defined mappings, and then recompiled/assemble any ... One does NOT have source code for many programs and libraries ... the fact is that binary programs are exchanged ... able to accidentally crash a calculator flashed with this new ROM ...
    (comp.sys.hp48)
  • Re: Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24
    ... >>> You're going to recompile all the libraries with every job?!? ... >>> You find some calls to strcpythat reference ROM for the ... >>> second argument and some that reference RAM. ... I agree and therefore standard library functions will not suffice. ...
    (comp.arch.embedded)
  • Re: TopSecret program [49 series]
    ... "free" Equation libraries is released or each time a new ROM is ... It came built into each 49G+ rom, ... Yours is also tied to a specific calculator, ...
    (comp.sys.hp48)
  • Re: Relative Speeds for Programming Languages on HP49g+/50g
    ... There are many built-in libraries in ROM; ... along with other user variables, ...
    (comp.sys.hp48)
  • Re: Access Extable from C?
    ... address pointing to ROM. ... I was thinking the same routine should be able to compile symbolics ... believe the two libraries mentioned above also contain all information ... algebraic command was stored in a library with its own additional ...
    (comp.sys.hp48)