diff options
author | kib <kib@FreeBSD.org> | 2012-03-11 20:04:09 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2012-03-11 20:04:09 +0000 |
commit | 3a09450fbfc07fbf4db074a00361c61127b4822a (patch) | |
tree | 87fa5b72982e5d814e7f1852737adcdcb1b08fc7 /lib/csu/mips | |
parent | 95d1e3d11bebe5f0d75da30af98fbc94ee0e5233 (diff) | |
download | FreeBSD-src-3a09450fbfc07fbf4db074a00361c61127b4822a.zip FreeBSD-src-3a09450fbfc07fbf4db074a00361c61127b4822a.tar.gz |
Stop calling _init/_fini methods from crt1 for dynamic binaries. Do
call preinit, init and fini arrays methods from crt1 for static binaries.
Mark new crt1 with FreeBSD-specific ELF note.
Move some common crt1 code into new MI file ignore_init.c, to reduce
duplication. Also, conservatively adjust nearby sources for style.
Reviewed by: kan
Tested by: andrew (arm), flo (sparc64)
MFC after: 3 weeks
Diffstat (limited to 'lib/csu/mips')
-rw-r--r-- | lib/csu/mips/Makefile | 6 | ||||
-rw-r--r-- | lib/csu/mips/crt1.c | 28 |
2 files changed, 9 insertions, 25 deletions
diff --git a/lib/csu/mips/Makefile b/lib/csu/mips/Makefile index 095a9ad..1e1d1fa 100644 --- a/lib/csu/mips/Makefile +++ b/lib/csu/mips/Makefile @@ -18,21 +18,21 @@ CLEANFILES+= crt1.s gcrt1.s Scrt1.s crt1.s: crt1.c ${CC} ${CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed -i "" -e '/\.note\.ABI-tag/s/progbits/note/' ${.TARGET} + sed ${SED_FIX_NOTE} ${.TARGET} crt1.o: crt1.s ${CC} ${CFLAGS} -c -o ${.TARGET} crt1.s gcrt1.s: crt1.c ${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed -i "" -e '/\.note\.ABI-tag/s/progbits/note/' ${.TARGET} + sed ${SED_FIX_NOTE} ${.TARGET} gcrt1.o: gcrt1.s ${CC} ${CFLAGS} -c -o ${.TARGET} gcrt1.s Scrt1.s: crt1.c ${CC} ${CFLAGS} -fPIC -DPIC -S -o ${.TARGET} ${.CURDIR}/crt1.c - sed -i "" -e '/\.note\.ABI-tag/s/progbits/note/' ${.TARGET} + sed ${SED_FIX_NOTE} ${.TARGET} Scrt1.o: Scrt1.s ${CC} ${CFLAGS} -c -o ${.TARGET} Scrt1.s diff --git a/lib/csu/mips/crt1.c b/lib/csu/mips/crt1.c index 94a3046..1968f06 100644 --- a/lib/csu/mips/crt1.c +++ b/lib/csu/mips/crt1.c @@ -43,17 +43,11 @@ __FBSDID("$FreeBSD$"); #include <stdlib.h> #include "libc_private.h" #include "crtbrand.c" +#include "ignore_init.c" struct Struct_Obj_Entry; struct ps_strings; -extern int _DYNAMIC; -#pragma weak _DYNAMIC - -extern void _init(void); -extern void _fini(void); -extern int main(int, char **, char **); - #ifdef GCRT extern void _mcleanup(void); extern void monstartup(void *, void *); @@ -61,9 +55,6 @@ extern int eprol; extern int etext; #endif -char **environ; -const char *__progname = ""; - void __start(char **, void (*)(void), struct Struct_Obj_Entry *, struct ps_strings *); /* The entry function. */ @@ -81,13 +72,8 @@ __start(char **ap, argv = ap + 1; env = ap + 2 + argc; environ = env; - if (argc > 0 && argv[0] != NULL) { - const char *s; - __progname = argv[0]; - for (s = __progname; *s != '\0'; s++) - if (*s == '/') - __progname = s + 1; - } + if (argc > 0 && argv[0] != NULL) + handle_progname(argv[0]); if (&_DYNAMIC != NULL) atexit(cleanup); @@ -96,13 +82,11 @@ __start(char **ap, #ifdef GCRT atexit(_mcleanup); -#endif - atexit(_fini); -#ifdef GCRT monstartup(&eprol, &etext); #endif - _init(); - exit( main(argc, argv, env) ); + + handle_static_init(argc, argv, env); + exit(main(argc, argv, env)); } #ifdef GCRT |