biggestsonicfan / i960-CTOOLS-with-NINDY

A repo in which i960 CTOOLS and NINDY are mirrored and a work in progress for binaries will be.
4 stars 2 forks source link

undefined reference to `_heap_base' and `_heap_end' #5

Open biggestsonicfan opened 4 years ago

biggestsonicfan commented 4 years ago
localhost$ G960BASE=~/i960-CTOOLS-with-NINDY/i386-nbsd1-ctools/ I960BASE=~/i960-CTOOLS-with-NINDY/i386-nbsd1-ctools/ ../i386-nbsd1-ctools/bin/gcc960 -o qtrom lib/qtrom_test.ld kx/kx_init.o basefile.o fp.o float.o kx/kx.a qt960/qt.a -lckb -lll -sdlkfjhsdf
/home/rob/i960-CTOOLS-with-NINDY/i386-nbsd1-ctools//lib/libll.a(_create.o): multiple definition of `__thread_ptr (.text)'
basefile.o errno.c:0: (_thread_ptr): first seen here
/home/rob/i960-CTOOLS-with-NINDY/i386-nbsd1-ctools//lib/libll.a(_create.o): multiple definition of `_thread_ptr.lf (.text)'
basefile.o errno.c:0: (_thread_ptr): first seen here
/home/rob/i960-CTOOLS-with-NINDY/i386-nbsd1-ctools//lib/crt960.o: undefined reference to `_stackbase'
/home/rob/i960-CTOOLS-with-NINDY/i386-nbsd1-ctools//lib/libll.a(brk.o): undefined reference to `_heap_base'
/home/rob/i960-CTOOLS-with-NINDY/i386-nbsd1-ctools//lib/libll.a(brk.o): undefined reference to `_heap_end'
/home/rob/i960-CTOOLS-with-NINDY/i386-nbsd1-ctools//lib/libll.a(brk.o): undefined reference to `_heap_base'
/home/rob/i960-CTOOLS-with-NINDY/i386-nbsd1-ctools//lib/libll.a(brk.o): undefined reference to `_heap_end'
/home/rob/i960-CTOOLS-with-NINDY/i386-nbsd1-ctools//bin/gld960: Can not perform relocation.
/home/rob/i960-CTOOLS-with-NINDY/i386-nbsd1-ctools//bin/gld960: Fatal error.  Output file: qtrom was not created.

From brk.c of the libll :

/*
 * This routine initializes the curbrk pointer.  This must be done
 * at run-time, not at link-time, because the value of heap_base
 * may change if Position-Independent Data (PID) is used.
 *
 * heap_base is defined in the linker-directive files (*.ld).  As
 * shipped, the .ld files define heap_base relative to the end of
 * the data section.  If you want to have an absolute area for the
 * heap, you can simply change the definition of heap_base in the .ld
 * file.  If you want an absolute heap plus PID, you must also change
 * the references to heap_base and heap_end in this module so that
 * they are not biased by g12 (g12 is the PID base register).
 */

However, in our linker-directive file there are no such definitions. An example of a definition is seen in 7-5 of the i960 Processor Software Utilities User's Guide.

/ Bounds of heap: // The heap may be placed in a separate memory region, if desired. /_heap_size = 0x20000;_heap_base = (_end + 0xf) & ~0xf;_heap_end = _heap_base + _heap_size - 1;

biggestsonicfan commented 4 years ago

I don't know if it will work properly or not, but I copied the values from cycx.ld and referenced the value stored in heapsize.s and used that to create:

_heap_size = 0x2000;
_heap_base = (_end + 0xf) & ~0xf;
_heap_end = _heap_base + _heap_size - 1;

_stackbase = (_heap_end + 0x10) & ~0x0f;

It gets past the error but unsure if this code will actually work, so leaving this open for now.

biggestsonicfan commented 4 years ago

From crtnin.s

/* set up stack pointer:
 *  The heap will begin at '_end';  its length is 'heap_size'
 *  bytes.  The stack will begin at the first 64-byte-aligned
 *  block after the heap.
 *
 *  A default value of 'heap_size' is set by linking with libnindy.a
 *  The default can be overridden by redefining this symbol at link
 *  time (with a line of the form 'heap_size=XXXX;' in the lnk960
 *  linker specification file; or one of the form
 *  "-defsym heap_size=XXXX" on the gld960 invocation line).
 */

If ldconst _end, sp /* set sp = address of end of heap */ is the end of the heap, should _heap_base really be defined as (_end + 0xf) & ~0xf;?

biggestsonicfan commented 4 years ago

Removing brk.o and ll_init.o from the libll Makefile and _LL_init(); from init_c.c of libc (for testing purposes), got rid of this error. I need to understand why those are used in those files, specifically brk.c.