[uClibc] crt1S.S ET_DYN binary issue
Peter S. Mazinger
ps.m at gmx.net
Fri Oct 10 18:21:41 UTC 2003
Hello!
Could someone from the uClibc developers take a look at the attached diff
(diff to libc/sysdeps/linux/i386/crt0.S). The resulting file (crt1S.S)
should work instead of crt1.o.
Test may be done for a binary, if it is built with (-shared does not load
crt1.o)
gcc -shared crt1S.o interp.o <program>.o
where interp.c is:
const char __invoke_dynamic_linker__[] __attribute__ ((section (".interp"))) = "/lib/ld-uClibc.so.0";
The resulting binary is an ET_DYN binary, behaves like a library (fully
relocatable with position independency).
To build crt1S.o I used:
gcc -fPIC -DL_crt1 -D__UCLIBC_CTOR_DTOR__ -c crt1S.S
Thanks, Peter
--
Peter S. Mazinger <ps.m at gmx.net> ID: 0xA5F059F2 NIC: IXUYHSKQLI
Key fingerprint = 92A4 31E1 56BC 3D5A 2D08 BB6E C389 975E A5F0 59F2
____________________________________________________________________
Miert fizetsz az internetert? Korlatlan, ingyenes internet hozzaferes a FreeStarttol.
Probald ki most! http://www.freestart.hu
-------------- next part --------------
--- uClibc-0.9.21/libc/sysdeps/linux/i386/crt0.S Tue Mar 4 08:05:33 2003
+++ crt0S.S.1 Fri Oct 10 20:10:22 2003
@@ -74,10 +74,15 @@
pushl %ebp /* callers %ebp (frame pointer) */
movl %esp,%ebp /* mark callers stack frame as invalid */
+ call .L1
+.L1:
+ pop %edx
+ addl $_GLOBAL_OFFSET_TABLE_+[.-.L1],%edx
+
#if (defined L_crt1 || defined L_gcrt1 ) && defined __UCLIBC_CTOR_DTOR__
/* Push .init and .fini arguments to __uClibc_start_main() on the stack */
- pushl $_fini
- pushl $_init
+ pushl _fini at GOT(%edx)
+ pushl _init at GOT(%edx)
/* Push envp, argc, and argc arguments to __uClibc_start_main() on the stack */
pushl %eax /* Environment pointer */
@@ -85,17 +90,22 @@
pushl %ecx /* And the argument count */
/* Ok, now run uClibc's main() -- shouldn't return */
- call __uClibc_start_main
+ pushl .hlt at GOT(%edx)
+ pushl __uClibc_start_main at GOT(%edx)
+ ret
#else
/* Push envp, argc, and argc arguments to __uClibc_start_main() on the stack */
pushl %eax /* Environment pointer */
pushl %ebx /* Argument pointer */
pushl %ecx /* And the argument count */
- call __uClibc_main
+ pushl .hlt at GOT(%edx)
+ pushl __uClibc_main at GOT(%edx)
+ ret
#endif
/* Crash if somehow `exit' returns anyways. */
+.hlt:
hlt
.size _start,.-_start
More information about the uClibc
mailing list