[uClibc] RE: [uClibc-cvs] svn commit:trunk/uClibc/ldso/ldso:armcris i386 m68k mips powerpc sh sh64 etc...
Joakim Tjernlund
joakim.tjernlund at lumentis.se
Tue Mar 15 17:27:35 UTC 2005
> > make -C ldso
> > make[2]: Entering directory
> > `/home/pkj/241Q-new_uClibc/libs/uClibc/ldso/ldso'
> > ccache cris-gcc -Wall -Wstrict-prototypes -Wno-trigraphs
> > -fno-strict-aliasing -Os -mlinux -fpic
> > -DUCLIBC_RUNTIME_PREFIX=\"/\" -fno-builtin -nostdinc -D_LIBC
> > -I../../ldso/include -I. -I../../include -isystem
> > /usr/local/cris/lib/gcc-lib/cris-axis-elf/3.2.1/include
> > -D__SUPPORT_LD_DEBUG__ -D__SUPPORT_LD_DEBUG_EARLY__ -I../libdl -c ldso.c
> > -o ldso.o
> > cris-ld -mcrislinux -z now -Bsymbolic -shared --warn-common
> > --export-dynamic --sort-common -z combreloc --discard-locals
> > --discard-all --no-undefined -e _dl_boot -soname=ld-uClibc.so.0 \
> > -o ld-uClibc-0.9.27.so cris/resolve.o ldso.o
> > /usr/local/cris/lib/gcc-lib/cris-axis-linux-gnu/3.2.1/libgcc.a
> > cris-ld: ldso.o: relocation R_CRIS_32_GOTREL is not allowed for global
> > symbol: `_dl_boot' from .text section
> > cris-ld: final link failed: Bad value
> > make[2]: *** [ld-uClibc-0.9.27.so] Error 1
> > make[2]: Leaving directory
> > `/home/pkj/241Q-new_uClibc/libs/uClibc/ldso/ldso'
>
> hmm, don't quite understand this yet. Can you try changing _dl_boot to _dl_boot2
> in elf_machine_load_address()? Possibly add attribute_hidden or static to the
> declaration of _dl_boot2 and/or _dl_boot
Compared to glibc, uClibc has a few issuses(more about these later).
I have converted PPC, ARM and CRIS to what is a first step.
Does the following patch work on CRIS and ARM?
Index: powerpc/dl-startup.h
===================================================================
--- powerpc/dl-startup.h (revision 10009)
+++ powerpc/dl-startup.h (working copy)
@@ -6,24 +6,21 @@
* Then call the real _dl_boot function, which is now named _dl_boot2. */
asm(
" .text\n"
- " .globl _dl_boot\n"
- " .type _dl_boot, at function\n"
- "_dl_boot:\n"
+ " .globl _start\n"
+ " .type _start, at function\n"
+ "_start:\n"
" mr 3,1\n" /* Pass SP to _dl_boot2 in r3 */
" addi 1,1,-16\n" /* Make room on stack for _dl_boot2 to store LR */
" li 4,0\n"
" stw 4,0(1)\n" /* Clear Stack frame */
- " bl _dl_boot2 at local\n" /* Perform relocation */
+ " bl _dl_start at local\n" /* Perform relocation */
" addi 1,1,16\n" /* Restore SP */
" mtctr 3\n" /* Load applications entry point */
" bctr\n" /* Jump to entry point */
- " .size _dl_boot,.-_dl_boot\n"
+ " .size _start,.-_start\n"
" .previous\n"
);
-
-#define DL_BOOT(X) static void* __attribute_used__ _dl_boot2(X)
-
/*
* Get a pointer to the argv array. On many platforms this can be just
* the address if the first argument, on other platforms we need to
Index: arm/dl-startup.h
===================================================================
--- arm/dl-startup.h (revision 10009)
+++ arm/dl-startup.h (working copy)
@@ -4,25 +4,21 @@
* Copyright (C) 2000-2004 by Erik Andersen <andersen at codepoet.org>
*/
-void* _dl_boot(void);
/* Overrive the default _dl_boot function, and replace it with a bit of asm.
* Then call the real _dl_boot function, which is now named _dl_boot2. */
asm("" \
" .text\n" \
-" .globl _dl_boot\n" \
-"_dl_boot:\n" \
+" .globl _start\n" \
+"_start:\n" \
" mov r7, sp\n" \
" @ldr r0, [sp], #4\n" \
" mov r0, sp\n" \
-" bl _dl_boot2\n" \
+" bl _dl_start\n" \
" mov r6, r0\n" \
" mov r0, r7\n" \
" mov pc, r6\n" \
);
-#define DL_BOOT(X) static __attribute_used__ void* _dl_boot2 (X)
-
-
/* Get a pointer to the argv array. On many platforms this can be just
* the address if the first argument, on other platforms we need to
* do something a little more subtle here. */
Index: arm/dl-sysdep.h
===================================================================
--- arm/dl-sysdep.h (revision 10009)
+++ arm/dl-sysdep.h (working copy)
@@ -82,10 +82,10 @@
static inline Elf32_Addr __attribute__ ((unused))
elf_machine_load_address (void)
{
- extern void __dl_boot asm ("_dl_boot");
- Elf32_Addr got_addr = (Elf32_Addr) &__dl_boot;
+ extern void __dl_start asm ("_dl_start");
+ Elf32_Addr got_addr = (Elf32_Addr) &__dl_start;
Elf32_Addr pcrel_addr;
- asm ("adr %0, _dl_boot" : "=r" (pcrel_addr));
+ asm ("adr %0, _dl_start" : "=r" (pcrel_addr));
return pcrel_addr - got_addr;
}
Index: dl-startup.c
===================================================================
--- dl-startup.c (revision 10009)
+++ dl-startup.c (working copy)
@@ -109,7 +109,7 @@
NULL
auxvt[0...N] Auxiliary Vector Table elements (mixed types)
*/
-DL_BOOT(unsigned long args)
+static void * __attribute_used__ _dl_start(unsigned long args)
{
unsigned int argc;
char **argv, **envp;
Index: ldso.c
===================================================================
--- ldso.c (revision 10009)
+++ ldso.c (working copy)
@@ -128,6 +128,11 @@
if (argv[0]) {
_dl_progname = argv[0];
}
+ extern void _start(void);
+ if (_start == (void *) auxvt[AT_ENTRY].a_un.a_fcn) {
+ _dl_dprintf(2, "Standalone exection is not supported yet\n");
+ _dl_exit(1);
+ }
/* Start to build the tables of the modules that are required for
* this beast to run. We start with the basic executable, and then
Index: cris/dl-startup.h
===================================================================
--- cris/dl-startup.h (revision 10009)
+++ cris/dl-startup.h (working copy)
@@ -6,18 +6,16 @@
* can find argc, argv and auxvt (Auxillary Vector Table). */
asm("" \
" .text\n" \
-" .globl _dl_boot\n" \
-" .type _dl_boot, at function\n" \
-"_dl_boot:\n" \
+" .globl _start\n" \
+" .type _start, at function\n" \
+"_start:\n" \
" move.d $sp,$r10\n" \
" move.d $pc,$r9\n" \
-" add.d _dl_boot2 - ., $r9\n" \
+" add.d _dl_start - ., $r9\n" \
" jsr $r9\n" \
);
-#define DL_BOOT(X) static void __attribute_used__ _dl_boot2 (X)
-
/* Get a pointer to the argv array. On many platforms this can be just
* the address if the first argument, on other platforms we need to
* do something a little more subtle here. */
Index: cris/dl-sysdep.h
===================================================================
--- cris/dl-sysdep.h (revision 10009)
+++ cris/dl-sysdep.h (working copy)
@@ -105,8 +105,8 @@
{
Elf32_Addr gotaddr_diff;
- __asm__ ("sub.d [$r0+_dl_parse:GOT16],$r0,%0\n\t"
- "add.d _dl_parse:GOTOFF,%0" : "=r" (gotaddr_diff));
+ __asm__ ("sub.d [$r0+_dl_start:GOT16],$r0,%0\n\t"
+ "add.d _dl_start:GOTOFF,%0" : "=r" (gotaddr_diff));
return gotaddr_diff;
}
Index: Makefile
===================================================================
--- Makefile (revision 10009)
+++ Makefile (working copy)
@@ -73,7 +73,7 @@
all: $(LDSO_FULLNAME)
$(LDSO_FULLNAME): $(OBJS) $(DLINK_OBJS)
- $(LD) $(LDFLAGS) -e _dl_boot -soname=$(UCLIBC_LDSO) \
+ $(LD) $(LDFLAGS) -soname=$(UCLIBC_LDSO) \
-o $(LDSO_FULLNAME) $(OBJS) $(LIBGCC)
$(INSTALL) -d $(TOPDIR)lib
$(INSTALL) -m 755 $(LDSO_FULLNAME) $(TOPDIR)lib
More information about the uClibc
mailing list