Trying to work with newlib's libc.a

Likely, Grant Grant.Likely@gdcanada.com
Fri Mar 14 18:16:00 GMT 2003


Dan, are you running from ROM or RAM on your target?  Also, what are you
using for crt0.S?  If you're using a custom crt0.S, are you be able to send
it to me?  I'm still having trouble with my target.  I'm running from ROM,
and I can get the board to work, but my newlib initialization is still
buggered.

Thanks,
g.

-----Original Message-----
From: Dan Fowell [mailto:dfowell@intelligentline.com]
Sent: Thursday, March 13, 2003 3:00 PM
To: CrossGCC (E-mail)
Cc: 'Likely, Grant'
Subject: RE: Trying to work with newlib's libc.a


Hey Grant,

Everything links in beautifully now!  I just added the .got2 and .fixup
sections, and then made sure to specify that the size of my DATA section
should include the .got2 and .fixup sections as well as the .data and .sdata
sections.

I've never seen a .eh_frame section though.  I never tried linking in
libnosys.a either.  I just wrote some empty system I/O functions and link in
the normal libc file.  In case it helps anyone, here is my rom link file, no
guarantees though.  I'll attach the c file for the system stubs as well.  If
any one wants the startup file I use (with the needed rom/ram copy) let me
know.

Thanks for the specification documents,
Dan



rom.lnk file:
--------------------------------------------------------------------

MEMORY
{
    reset :  org = 0x100,       len = 4         /*Is only 1 32-bit word /
instruction */
    vect :   org = 0x500,       len = 255

    rom :    org = 0x010000,    len = 0x7ffff
    ram :    org = 0x3FA000,    len = 0x5E00
    stack :  org = 0x3FFE00,    len = 0x200
}

SECTIONS
{
    .reset :
    {
        __reset_start = .;
        *(.reset);
        __reset_end = .;
    } > reset

    .vect :
    {
        __vect_start = .;
        *(.vect);
        __vect_end = .;
    } > vect

    .text : { *(.text) *(.rodata) *(.rdata) *(.init) *(.fini) *(.sec1) }  >
rom
    .data : { *(.data) } > ram AT > rom
    .got2 : AT(ADDR(.text)+SIZEOF(.text)+SIZEOF(.data)) { *(.got2) } > ram
    .fixup : AT(ADDR(.text)+SIZEOF(.text)+SIZEOF(.data)+SIZEOF(.got2)) {
*(.fixup) } > ram
    .sdata :
AT(ADDR(.text)+SIZEOF(.text)+SIZEOF(.data)+SIZEOF(.got2)+SIZEOF(.fixup)) {
*(.sdata) *(.sdata2) } > ram
    .bss ALIGN (4) : { *(.bss) *(.sbss) } > ram
    _end =.;
}

stack = 0x3FFE00;
stack_size = 0x200;

__SP_END    = stack;
__DATA_ROM_START  = ADDR(.text)+SIZEOF(.text);
__DATA_RAM_START    = ADDR(.data);
__DATA_RAM_SIZE     = SIZEOF(.data) + SIZEOF(.got2) + SIZEOF(.fixup) +
SIZEOF(.sdata);
__DATA_RAM_END      = __DATA_RAM_START + __DATA_RAM_SIZE;
__BSS_START = ADDR(.bss);
__BSS_SIZE  = SIZEOF(.bss);
__BSS_END   = __BSS_START + __BSS_SIZE;
__STARTUP_STACK = stack + stack_size;
--------------------------------------------------------------------




libc system function call stubs:
--------------------------------------------------------------------
#include <sys/stat.h>
#include <errno.h>

#undef errno
extern int errno;


int isatty(int file)
{
   return 1;
}

caddr_t sbrk(int incr)
{
  extern char _end;            /* Defined by the linker */
  static char *heap_end;
  char *prev_heap_end;

  if (heap_end == 0) {
    heap_end = &_end;
  }
  prev_heap_end = heap_end;
  heap_end += incr;
  return (caddr_t) prev_heap_end;
}


int write(int file, char *ptr, int len){
    int todo;

    for (todo = 0; todo < len; todo++) {
        //writechar(*ptr++);
    }
    return len;
}


int close(int file){
  return -1;
}


int fstat(int file, struct stat *st) {
st->st_mode = S_IFCHR;
return 0;
}

//Set position in a file.  Minimal implementation:
int lseek(int file, int ptr, int dir)
{
   return 0;
}

//Read from a file.  Minimal implementation:
int read(int file, char *ptr, int len)
{
   return 0;
}
--------------------------------------------------------------------




-----Original Message-----
From: crossgcc-owner@sources.redhat.com
[mailto:crossgcc-owner@sources.redhat.com]On Behalf Of Likely, Grant
Sent: Thursday, March 13, 2003 1:13 PM
To: 'crossgcc@sources.redhat.com'
Cc: 'dfowell@intelligentine.com'
Subject: Re: Trying to work with newlib's libc.a


Dan;

Did you ever get a solution for your mpc5xx link problem?

I've been having similar difficulties, and I came across the "PowerPC EABI"
and "SysV ABI PPC Suppliment" specification documents.  These two docs cover
most of the PPC sections.  I found them at:

ftp://sources.redhat.com/pub/binutils/ppc-docs

Anyway, the .got section is the Global Offset Table, and I think it is save
to put it into ROM.  I don't know what the .fixup section is.  I'm also
getting a .eh_frame section in my link, and I don't know what to do with it.
Have you made any progress?

You should be able to get rid of the io routines by linking in newlibs
libnosys.a.

Cheers,
g.

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com



More information about the crossgcc mailing list