diff options
Diffstat (limited to 'libc')
25 files changed, 306 insertions, 189 deletions
diff --git a/libc/stdlib/Makefile b/libc/stdlib/Makefile index 210a2eeba..49d739703 100644 --- a/libc/stdlib/Makefile +++ b/libc/stdlib/Makefile @@ -79,7 +79,10 @@ endif # wcstod wcstof wcstold MSRC2 = atexit.c -MOBJ2 = atexit.o on_exit.o __exit_handler.o exit.o +MOBJ2 = on_exit.o __cxa_atexit.o __cxa_finalize.o __exit_handler.o exit.o +ifeq ($(COMPAT_ATEXIT),y) +MOBJ2 += old_atexit.o +endif CSRC = \ abort.c getenv.c mkdtemp.c mktemp.c realpath.c mkstemp.c mkstemp64.c \ @@ -95,13 +98,20 @@ COBJS=$(patsubst %.c,%.o, $(CSRC)) OBJS=$(MOBJ) $(MOBJx) $(MOBJ1) $(MOBJ1x) $(MOBJ2) $(COBJS) +NONSHARED_OBJS=atexit.o + OBJ_LIST=../obj.stdlib -all: $(OBJ_LIST) subdirs +NONSHARED_OBJ_LIST=../nonshared_obj.stdlib + +all: $(OBJ_LIST) $(NONSHARED_OBJ_LIST) subdirs $(OBJ_LIST): $(OBJS) echo $(patsubst %, stdlib/%, $(OBJS)) > $(OBJ_LIST) +$(NONSHARED_OBJ_LIST): $(NONSHARED_OBJS) + echo $(patsubst %, stdlib/%, $(NONSHARED_OBJS)) > $(NONSHARED_OBJ_LIST) + $(MOBJ): $(MSRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(STRIPTOOL) -x -R .note -R .comment $*.o @@ -118,7 +128,7 @@ $(MOBJ1x): $(MSRC1) $(CC) $(CFLAGS) -DL_$* -D__UCLIBC_DO_XLOCALE $< -c -o $*.o $(STRIPTOOL) -x -R .note -R .comment $*.o -$(MOBJ2): $(MSRC2) +$(MOBJ2) atexit.o: $(MSRC2) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(STRIPTOOL) -x -R .note -R .comment $*.o diff --git a/libc/stdlib/atexit.c b/libc/stdlib/atexit.c index 1962c1b63..e9710b038 100644 --- a/libc/stdlib/atexit.c +++ b/libc/stdlib/atexit.c @@ -32,6 +32,9 @@ * August 2002 Erik Andersen * Added locking so atexit and friends can be thread safe * + * August 2005 Stephen Warren + * Added __cxa_atexit and __cxa_finalize support + * */ #define _GNU_SOURCE @@ -39,7 +42,7 @@ #include <unistd.h> #include <stdlib.h> #include <errno.h> - +#include <atomic.h> #ifdef __UCLIBC_HAS_THREADS__ #include <pthread.h> @@ -54,9 +57,12 @@ extern pthread_mutex_t mylock; typedef void (*aefuncp) (void); /* atexit function pointer */ typedef void (*oefuncp) (int, void *); /* on_exit function pointer */ +typedef void (*cxaefuncp) (void *); /* __cxa_atexit function pointer */ typedef enum { - ef_atexit, - ef_on_exit + ef_free, + ef_in_use, + ef_on_exit, + ef_cxa_atexit } ef_type; /* exit function types */ /* this is in the L_exit object */ @@ -67,13 +73,21 @@ extern int __exit_slots; extern int __exit_count; extern void __exit_handler(int); struct exit_function { - ef_type type; /* ef_atexit or ef_on_exit */ + /* + * 'type' should be of type of the 'enum ef_type' above but since we + * need this element in an atomic operation we have to use 'long int'. + */ + long int type; /* enum ef_type */ union { - aefuncp atexit; - struct { - oefuncp func; - void *arg; - } on_exit; + struct { + oefuncp func; + void *arg; + } on_exit; + struct { + cxaefuncp func; + void *arg; + void* dso_handle; + } cxa_atexit; } funcs; }; #ifdef __UCLIBC_DYNAMIC_ATEXIT__ @@ -81,46 +95,37 @@ extern struct exit_function *__exit_function_table; #else extern struct exit_function __exit_function_table[__UCLIBC_MAX_ATEXIT]; #endif +extern struct exit_function *__new_exitfn (void); -#ifdef L_atexit - /* +/* this is in the L___cxa_atexit object */ +extern int __cxa_atexit (cxaefuncp, void *arg, void *dso_handle); + + +/* remove old_atexit after 0.9.29 */ +#if defined(L_atexit) || defined(L_old_atexit) +extern void *__dso_handle __attribute__ ((__weak__)); + +/* * register a function to be called at normal program termination * (the registered function takes no arguments) - */ -int atexit(aefuncp func) -{ - struct exit_function *efp; - - LOCK; - if (func) { -#ifdef __UCLIBC_DYNAMIC_ATEXIT__ - /* If we are out of function table slots, make some more */ - if (__exit_slots < __exit_count+1) { - efp=realloc(__exit_function_table, - (__exit_slots+20)*sizeof(struct exit_function)); - if (efp==NULL) { - UNLOCK; - __set_errno(ENOMEM); - return -1; - } - __exit_function_table = efp; - __exit_slots+=20; - } + */ +#ifdef L_atexit +int attribute_hidden atexit(aefuncp func) #else - if (__exit_count >= __UCLIBC_MAX_ATEXIT) { - UNLOCK; - __set_errno(ENOMEM); - return -1; - } +int old_atexit(aefuncp func) #endif - __exit_cleanup = __exit_handler; /* enable cleanup */ - efp = &__exit_function_table[__exit_count++]; - efp->type = ef_atexit; - efp->funcs.atexit = func; - } - UNLOCK; - return 0; +{ + /* + * glibc casts aefuncp to cxaefuncp. + * This seems dodgy, but I guess callling a function with more + * parameters than it needs will work everywhere? + */ + return __cxa_atexit((cxaefuncp)func, NULL, + &__dso_handle == NULL ? NULL : __dso_handle); } +#ifndef L_atexit +weak_alias(old_atexit,atexit); +#endif #endif #ifdef L_on_exit @@ -133,41 +138,92 @@ int atexit(aefuncp func) int on_exit(oefuncp func, void *arg) { struct exit_function *efp; + + if (func == NULL) { + return 0; + } - LOCK; - if (func) { -#ifdef __UCLIBC_DYNAMIC_ATEXIT__ - /* If we are out of function table slots, make some more */ - if (__exit_slots < __exit_count+1) { - efp=realloc(__exit_function_table, - (__exit_slots+20)*sizeof(struct exit_function)); - if (efp==NULL) { - UNLOCK; - __set_errno(ENOMEM); - return -1; - } - __exit_function_table=efp; - __exit_slots+=20; - } -#else - if (__exit_count >= __UCLIBC_MAX_ATEXIT) { - UNLOCK; - __set_errno(ENOMEM); - return -1; - } + efp = __new_exitfn(); + if (efp == NULL) { + return -1; + } + + efp->funcs.on_exit.func = func; + efp->funcs.on_exit.arg = arg; + /* assign last for thread safety, since we're now unlocked */ + efp->type = ef_on_exit; + + return 0; +} #endif - __exit_cleanup = __exit_handler; /* enable cleanup */ - efp = &__exit_function_table[__exit_count++]; - efp->type = ef_on_exit; - efp->funcs.on_exit.func = func; - efp->funcs.on_exit.arg = arg; +#ifdef L___cxa_atexit +extern int __cxa_atexit (cxaefuncp func, void *arg, void *dso_handle) +{ + struct exit_function *efp; + + if (func == NULL) { + return 0; } - UNLOCK; + + efp = __new_exitfn(); + if (efp == NULL) { + return -1; + } + + efp->funcs.cxa_atexit.func = func; + efp->funcs.cxa_atexit.arg = arg; + efp->funcs.cxa_atexit.dso_handle = dso_handle; + /* assign last for thread safety, since we're now unlocked */ + efp->type = ef_cxa_atexit; + return 0; } #endif +#ifdef L___cxa_finalize +/* + * If D is non-NULL, call all functions registered with `__cxa_atexit' + * with the same dso handle. Otherwise, if D is NULL, call all of the + * registered handlers. + */ +void __cxa_finalize (void *dso_handle) +{ + struct exit_function *efp; + int exit_count_snapshot = __exit_count; + + /* In reverse order */ + while (exit_count_snapshot) { + efp = &__exit_function_table[--exit_count_snapshot]; + + /* + * We check dso_handle match before we verify the type of the union entry. + * However, the atomic_exchange will validate that we were really "allowed" + * to read dso_handle... + */ + if ((dso_handle == NULL || dso_handle == efp->funcs.cxa_atexit.dso_handle) + /* We don't want to run this cleanup more than once. */ + && !atomic_compare_and_exchange_bool_acq(&efp->type, ef_free, ef_cxa_atexit) + ) { + /* glibc passes status (0) too, but that's not in the prototype */ + (*efp->funcs.cxa_atexit.func)(efp->funcs.cxa_atexit.arg); + } + } + +#if 0 /* haven't looked into this yet... */ + /* + * Remove the registered fork handlers. We do not have to + * unregister anything if the program is going to terminate anyway. + */ +#ifdef UNREGISTER_ATFORK + if (d != NULL) { + UNREGISTER_ATFORK (d); + } +#endif +#endif +} +#endif + #ifdef L___exit_handler int __exit_count = 0; /* Number of registered exit functions */ #ifdef __UCLIBC_DYNAMIC_ATEXIT__ @@ -177,6 +233,45 @@ int __exit_slots = 0; /* Size of __exit_function_table */ struct exit_function __exit_function_table[__UCLIBC_MAX_ATEXIT]; #endif +/* + * Find and return a new exit_function pointer, for atexit, + * onexit and __cxa_atexit to initialize + */ +struct exit_function *__new_exitfn(void) +{ + struct exit_function *efp; + + LOCK; + +#ifdef __UCLIBC_DYNAMIC_ATEXIT__ + /* If we are out of function table slots, make some more */ + if (__exit_slots < __exit_count+1) { + efp=realloc(__exit_function_table, + (__exit_slots+20)*sizeof(struct exit_function)); + if (efp == NULL) { + UNLOCK; + __set_errno(ENOMEM); + return 0; + } + __exit_function_table = efp; + __exit_slots += 20; + } +#else + if (__exit_count >= __UCLIBC_MAX_ATEXIT) { + UNLOCK; + __set_errno(ENOMEM); + return 0; + } +#endif + + __exit_cleanup = __exit_handler; /* enable cleanup */ + efp = &__exit_function_table[__exit_count++]; + efp->type = ef_in_use; + + UNLOCK; + + return efp; +} /* * Handle the work of executing the registered exit functions @@ -196,11 +291,12 @@ void __exit_handler(int status) (efp->funcs.on_exit.func) (status, efp->funcs.on_exit.arg); } break; - case ef_atexit: - if (efp->funcs.atexit) { - (efp->funcs.atexit) (); - } - break; + case ef_cxa_atexit: + if (efp->funcs.cxa_atexit.func) { + /* glibc passes status too, but that's not in the prototype */ + (efp->funcs.cxa_atexit.func) (efp->funcs.cxa_atexit.arg); + } + break; } } #ifdef __UCLIBC_DYNAMIC_ATEXIT__ diff --git a/libc/sysdeps/linux/alpha/Makefile b/libc/sysdeps/linux/alpha/Makefile index ffb075b1a..cee893a3b 100644 --- a/libc/sysdeps/linux/alpha/Makefile +++ b/libc/sysdeps/linux/alpha/Makefile @@ -32,10 +32,6 @@ COBJS=$(patsubst %.c,%.o, $(CSRC)) OBJS=$(SOBJS) $(COBJS) -ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y) -COBJS += $(PTDIR)sysdeps/$(TARGET_ARCH)/libc-tls.o -endif - OBJ_LIST=../../../obj.sysdeps.$(TARGET_ARCH) all: $(OBJ_LIST) @@ -59,14 +55,14 @@ $(COBJS): %.o : %.c ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y) crti.o: crti.S - $(CC) $(ASFLAGS) -c crti.S -o crti.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crti.S -o crti.o $(TOPDIR)lib/crti.o: crti.o $(INSTALL) -d $(TOPDIR)lib/ cp crti.o $(TOPDIR)lib/ crtn.o: crtn.S - $(CC) $(ASFLAGS) -c crtn.S -o crtn.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crtn.S -o crtn.o $(TOPDIR)lib/crtn.o: crtn.o $(INSTALL) -d $(TOPDIR)lib/ @@ -80,14 +76,8 @@ $(TOPDIR)lib/crtn.o: $(AR) $(ARFLAGS) $(TOPDIR)lib/crtn.o endif -ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y) -$(PTDIR)sysdeps/$(TARGET_ARCH)/libc-tls.o: - $(MAKE) -C $(PTDIR)sysdeps/$(TARGET_ARCH) libc-tls.o -endif - headers: $(LN) -fs ../libc/sysdeps/linux/alpha/fpu_control.h $(TOPDIR)/include/ clean: - $(RM) *.[oa] *~ core - $(RM) bits/sysnum.h + $(RM) *.o *~ core diff --git a/libc/sysdeps/linux/arm/Makefile b/libc/sysdeps/linux/arm/Makefile index 65df75338..19701e1d9 100644 --- a/libc/sysdeps/linux/arm/Makefile +++ b/libc/sysdeps/linux/arm/Makefile @@ -60,14 +60,14 @@ $(COBJS): %.o : %.c ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y) crti.o: crti.S - $(CC) $(ASFLAGS) -c crti.S -o crti.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crti.S -o crti.o $(TOPDIR)lib/crti.o: crti.o $(INSTALL) -d $(TOPDIR)lib/ cp crti.o $(TOPDIR)lib/ crtn.o: crtn.S - $(CC) $(ASFLAGS) -c crtn.S -o crtn.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crtn.S -o crtn.o $(TOPDIR)lib/crtn.o: crtn.o $(INSTALL) -d $(TOPDIR)lib/ @@ -85,5 +85,4 @@ headers: $(LN) -fs ../libc/sysdeps/linux/arm/fpu_control.h $(TOPDIR)/include/ clean: - $(RM) *.[oa] *~ core - $(RM) bits/sysnum.h + $(RM) *.o *~ core diff --git a/libc/sysdeps/linux/arm/crt1.S b/libc/sysdeps/linux/arm/crt1.S index 82e1c8c42..987c52936 100644 --- a/libc/sysdeps/linux/arm/crt1.S +++ b/libc/sysdeps/linux/arm/crt1.S @@ -75,9 +75,18 @@ ARM register quick reference: pc r15 program counter */ - .text - .globl _start - .type _start,#function +#include <features.h> + +.text + .globl _start + .type _start,%function + .type _init,%function + .type _fini,%function +#ifndef __UCLIBC_CTOR_DTOR__ + .weak _init + .weak _fini +#endif + _start: /* Clear the frame pointer and link register since this is the outermost frame. */ mov fp, #0 @@ -132,14 +141,6 @@ _start: .word _fini(GOT) .word _init(GOT) .word main(GOT) -#else -# ifdef __UCLIBC_CTOR_DTOR__ - .type _init,%function - .type _fini,%function -# else - .weak _fini - .weak _init -# endif #endif /* Define a symbol for the first piece of initialized data. */ diff --git a/libc/sysdeps/linux/bfin/Makefile b/libc/sysdeps/linux/bfin/Makefile index 8fb05118e..b43209106 100644 --- a/libc/sysdeps/linux/bfin/Makefile +++ b/libc/sysdeps/linux/bfin/Makefile @@ -55,14 +55,14 @@ $(COBJS): %.o : %.c ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y) crti.o: crti.S - $(CC) $(ASFLAGS) -c crti.S -o crti.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crti.S -o crti.o $(TOPDIR)lib/crti.o: crti.o $(INSTALL) -d $(TOPDIR)lib/ cp crti.o $(TOPDIR)lib/ crtn.o: crtn.S - $(CC) $(ASFLAGS) -c crtn.S -o crtn.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crtn.S -o crtn.o $(TOPDIR)lib/crtn.o: crtn.o $(INSTALL) -d $(TOPDIR)lib/ @@ -79,6 +79,4 @@ endif headers: clean: - $(RM) *.[oa] *~ core - $(RM) bits/sysnum.h - $(RM) $(TOPDIR)lib/crt0.o + $(RM) *.o *~ core diff --git a/libc/sysdeps/linux/common/Makefile b/libc/sysdeps/linux/common/Makefile index 84b29ac53..87791724a 100644 --- a/libc/sysdeps/linux/common/Makefile +++ b/libc/sysdeps/linux/common/Makefile @@ -25,21 +25,31 @@ ifeq ($(strip $(EXCLUDE_BRK)),y) SRCS := $(filter-out sbrk.c,$(SRCS)) endif +SRCS := $(filter-out ssp-local.c,$(SRCS)) ifneq ($(strip $(UCLIBC_HAS_SSP)),y) SRCS := $(filter-out ssp.c,$(SRCS)) +NONSHARED_OBJ_LIST= +else +NONSHARED_OBJ_LIST=../../../nonshared_obj.sysdeps.common endif ssp.o: CFLAGS += $(SSP_DISABLE_FLAGS) +ssp-local.o: CFLAGS += $(SSP_DISABLE_FLAGS) OBJS = $(patsubst %.c,%.o, $(SRCS)) +NONSHARED_OBJS = ssp-local.o + OBJ_LIST=../../../obj.sysdeps.common -all: $(OBJ_LIST) +all: $(OBJ_LIST) $(NONSHARED_OBJ_LIST) $(OBJ_LIST): $(OBJS) echo $(patsubst %, sysdeps/linux/common/%, $(OBJS)) > $(OBJ_LIST) -$(OBJS): %.o : %.c +$(NONSHARED_OBJ_LIST): $(NONSHARED_OBJS) + echo $(patsubst %, sysdeps/linux/common/%, $(NONSHARED_OBJS)) > $(NONSHARED_OBJ_LIST) + +$(OBJS) $(NONSHARED_OBJS): %.o : %.c $(CC) $(CFLAGS) -c $< -o $@ $(STRIPTOOL) -x -R .note -R .comment $*.o @@ -47,4 +57,4 @@ headers: $(LN) -fs ../libc/sysdeps/linux/common/fpu_control.h $(TOPDIR)/include/ clean: - $(RM) *.[oa] *~ core + $(RM) *.o *~ core diff --git a/libc/sysdeps/linux/common/ssp.c b/libc/sysdeps/linux/common/ssp.c index 899910c96..7791a0104 100644 --- a/libc/sysdeps/linux/common/ssp.c +++ b/libc/sysdeps/linux/common/ssp.c @@ -61,12 +61,43 @@ void __attribute__ ((noreturn)) __stack_smash_handler(char func[], int damaged _ void __attribute__ ((noreturn)) __stack_smash_handler(char func[], int damaged) { extern char *__progname; - const char message[] = ": stack smashing attack in function "; + static const char message[] = ": stack smashing attack in function "; block_signals(); ssp_write(STDERR_FILENO, __progname, message, func); + /* The loop is added only to keep gcc happy. */ + while(1) + terminate(); +} + +void __attribute__ ((noreturn)) __stack_chk_fail(void) +{ + extern char *__progname; + static const char msg1[] = "stack smashing detected: "; + static const char msg3[] = " terminated"; + + block_signals(); + + ssp_write(STDERR_FILENO, msg1, __progname, msg3); + + /* The loop is added only to keep gcc happy. */ + while(1) + terminate(); +} + +void __attribute__ ((noreturn)) __chk_fail(void) +{ + extern char *__progname; + static const char msg1[] = "buffer overflow detected: "; + static const char msg3[] = " terminated"; + + block_signals(); + + ssp_write(STDERR_FILENO, msg1, __progname, msg3); + + /* The loop is added only to keep gcc happy. */ while(1) terminate(); } diff --git a/libc/sysdeps/linux/cris/Makefile b/libc/sysdeps/linux/cris/Makefile index f69db2503..9063ff7cf 100644 --- a/libc/sysdeps/linux/cris/Makefile +++ b/libc/sysdeps/linux/cris/Makefile @@ -57,14 +57,14 @@ $(COBJS): %.o : %.c ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y) crti.o: crti.S - $(CC) $(ASFLAGS) -c crti.S -o crti.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crti.S -o crti.o $(TOPDIR)lib/crti.o: crti.o $(INSTALL) -d $(TOPDIR)lib/ cp crti.o $(TOPDIR)lib/ crtn.o: crtn.S - $(CC) $(ASFLAGS) -c crtn.S -o crtn.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crtn.S -o crtn.o $(TOPDIR)lib/crtn.o: crtn.o $(INSTALL) -d $(TOPDIR)lib/ @@ -81,4 +81,4 @@ endif headers: clean: - $(RM) *.[oa] *~ core + $(RM) *.o *~ core diff --git a/libc/sysdeps/linux/e1/Makefile b/libc/sysdeps/linux/e1/Makefile index 60d6ec026..e02888ac4 100644 --- a/libc/sysdeps/linux/e1/Makefile +++ b/libc/sysdeps/linux/e1/Makefile @@ -60,14 +60,14 @@ $(COBJS): %.o : %.c ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y) crti.o: crti.S - $(CC) $(ASFLAGS) -c crti.S -o crti.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crti.S -o crti.o $(TOPDIR)lib/crti.o: crti.o $(INSTALL) -d $(TOPDIR)lib/ cp crti.o $(TOPDIR)lib/ crtn.o: crtn.S - $(CC) $(ASFLAGS) -c crtn.S -o crtn.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crtn.S -o crtn.o $(TOPDIR)lib/crtn.o: crtn.o $(INSTALL) -d $(TOPDIR)lib/ @@ -84,8 +84,4 @@ endif headers: clean: - $(RM) *.[oa] *~ core - $(RM) bits/sysnum.h -ifneq ($(strip $(HAVE_ELF)),y) - $(RM) $(TOPDIR)/include/float.h -endif + $(RM) *.o *~ core diff --git a/libc/sysdeps/linux/frv/Makefile b/libc/sysdeps/linux/frv/Makefile index dbf78d1c6..bfb127af4 100644 --- a/libc/sysdeps/linux/frv/Makefile +++ b/libc/sysdeps/linux/frv/Makefile @@ -60,7 +60,7 @@ Scrtreloc.o: crtreloc.c $(CC) $(CFLAGS) $(PIEFLAG) -c $< -o $@ $(CTOR_TARGETS): %.o : %.S - $(CC) $(ASFLAGS) -c $< -o $@ + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c $< -o $@ $(STRIPTOOL) -x -R .note -R .comment $*.o $(SOBJS): %.o : %.S @@ -75,6 +75,5 @@ headers: $(LN) -fs ../libc/sysdeps/linux/frv/link.h $(TOPDIR)/include/ clean: - $(RM) *.[oa] *~ core - $(RM) bits/sysnum.h + $(RM) *.o *~ core $(RM) $(TOPDIR)/include/link.h diff --git a/libc/sysdeps/linux/h8300/Makefile b/libc/sysdeps/linux/h8300/Makefile index b5d337427..5403feb01 100644 --- a/libc/sysdeps/linux/h8300/Makefile +++ b/libc/sysdeps/linux/h8300/Makefile @@ -60,14 +60,14 @@ $(COBJS): %.o : %.c ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y) crti.o: crti.S - $(CC) $(ASFLAGS) -c crti.S -o crti.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crti.S -o crti.o $(TOPDIR)lib/crti.o: crti.o $(INSTALL) -d $(TOPDIR)lib/ cp crti.o $(TOPDIR)lib/ crtn.o: crtn.S - $(CC) $(ASFLAGS) -c crtn.S -o crtn.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crtn.S -o crtn.o $(TOPDIR)lib/crtn.o: crtn.o $(INSTALL) -d $(TOPDIR)lib/ @@ -84,4 +84,4 @@ endif headers: clean: - $(RM) *.[oa] *~ core + $(RM) *.o *~ core diff --git a/libc/sysdeps/linux/i386/Makefile b/libc/sysdeps/linux/i386/Makefile index bde820b2b..e1795e0e5 100644 --- a/libc/sysdeps/linux/i386/Makefile +++ b/libc/sysdeps/linux/i386/Makefile @@ -60,14 +60,14 @@ $(COBJS): %.o : %.c ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y) crti.o: crti.S - $(CC) $(ASFLAGS) -c crti.S -o crti.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crti.S -o crti.o $(TOPDIR)lib/crti.o: crti.o $(INSTALL) -d $(TOPDIR)lib/ cp crti.o $(TOPDIR)lib/ crtn.o: crtn.S - $(CC) $(ASFLAGS) -c crtn.S -o crtn.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crtn.S -o crtn.o $(TOPDIR)lib/crtn.o: crtn.o $(INSTALL) -d $(TOPDIR)lib/ @@ -85,6 +85,4 @@ headers: $(LN) -fs ../libc/sysdeps/linux/i386/fpu_control.h $(TOPDIR)include/ clean: - $(RM) *.[oa] *~ core - $(RM) bits/sysnum.h - $(RM) $(TOPDIR)include/fpu_control.h + $(RM) *.o *~ core diff --git a/libc/sysdeps/linux/i960/Makefile b/libc/sysdeps/linux/i960/Makefile index 2701e9985..b4997b9db 100644 --- a/libc/sysdeps/linux/i960/Makefile +++ b/libc/sysdeps/linux/i960/Makefile @@ -57,14 +57,14 @@ $(COBJS): %.o : %.c ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y) crti.o: crti.S - $(CC) $(ASFLAGS) -c crti.S -o crti.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crti.S -o crti.o $(TOPDIR)lib/crti.o: crti.o $(INSTALL) -d $(TOPDIR)lib/ cp crti.o $(TOPDIR)lib/ crtn.o: crtn.S - $(CC) $(ASFLAGS) -c crtn.S -o crtn.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crtn.S -o crtn.o $(TOPDIR)lib/crtn.o: crtn.o $(INSTALL) -d $(TOPDIR)lib/ @@ -81,5 +81,4 @@ endif headers: clean: - $(RM) *.[oa] *~ core - $(RM) bits/sysnum.h + $(RM) *.o *~ core diff --git a/libc/sysdeps/linux/m68k/Makefile b/libc/sysdeps/linux/m68k/Makefile index 7e595229f..00ad88e6c 100644 --- a/libc/sysdeps/linux/m68k/Makefile +++ b/libc/sysdeps/linux/m68k/Makefile @@ -65,14 +65,14 @@ $(COBJS): %.o : %.c ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y) crti.o: crti.S - $(CC) $(ASFLAGS) -c crti.S -o crti.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crti.S -o crti.o $(TOPDIR)lib/crti.o: crti.o $(INSTALL) -d $(TOPDIR)lib/ cp crti.o $(TOPDIR)lib/ crtn.o: crtn.S - $(CC) $(ASFLAGS) -c crtn.S -o crtn.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crtn.S -o crtn.o $(TOPDIR)lib/crtn.o: crtn.o $(INSTALL) -d $(TOPDIR)lib/ @@ -95,8 +95,7 @@ endif $(LN) -fs ../libc/sysdeps/linux/m68k/fpu_control.h $(TOPDIR)/include/ clean: - $(RM) *.[oa] *~ core - $(RM) bits/sysnum.h + $(RM) *.o *~ core ifneq ($(strip $(HAVE_ELF)),y) $(RM) $(TOPDIR)/include/float.h endif diff --git a/libc/sysdeps/linux/microblaze/Makefile b/libc/sysdeps/linux/microblaze/Makefile index 269d53eb6..01b91ef71 100644 --- a/libc/sysdeps/linux/microblaze/Makefile +++ b/libc/sysdeps/linux/microblaze/Makefile @@ -63,14 +63,14 @@ $(COBJS): %.o : %.c ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y) crti.o: crti.S - $(CC) $(ASFLAGS) -c crti.S -o crti.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crti.S -o crti.o $(TOPDIR)lib/crti.o: crti.o $(INSTALL) -d $(TOPDIR)lib/ cp crti.o $(TOPDIR)lib/ crtn.o: crtn.S - $(CC) $(ASFLAGS) -c crtn.S -o crtn.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crtn.S -o crtn.o $(TOPDIR)lib/crtn.o: crtn.o $(INSTALL) -d $(TOPDIR)lib/ @@ -87,5 +87,4 @@ endif headers: clean: - $(RM) *.[oa] *~ core - $(RM) bits/sysnum.h + $(RM) *.o *~ core diff --git a/libc/sysdeps/linux/mips/crt1.S b/libc/sysdeps/linux/mips/crt1.S index d0769e88a..35dc8c42e 100644 --- a/libc/sysdeps/linux/mips/crt1.S +++ b/libc/sysdeps/linux/mips/crt1.S @@ -37,7 +37,7 @@ #include <sys/regdef.h> - +#include <features.h> /* This is the canonical entry point, usually the first thing in the text @@ -70,10 +70,14 @@ */ .text - .globl __start - .type __start,@function - .type _init,@function - .type _fini,@function + .globl __start + .type __start,@function + .type _init,@function + .type _fini,@function +#ifndef __UCLIBC_CTOR_DTOR__ + .weak _init + .weak _fini +#endif .type main,@function .type __uClibc_main,@function diff --git a/libc/sysdeps/linux/nios/Makefile b/libc/sysdeps/linux/nios/Makefile index cdfd9a204..b2b622329 100644 --- a/libc/sysdeps/linux/nios/Makefile +++ b/libc/sysdeps/linux/nios/Makefile @@ -54,14 +54,14 @@ $(COBJS): %.o : %.c ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y) crti.o: crti.S - $(CC) $(ASFLAGS) -c crti.S -o crti.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crti.S -o crti.o $(TOPDIR)lib/crti.o: crti.o $(INSTALL) -d $(TOPDIR)lib/ cp crti.o $(TOPDIR)lib/ crtn.o: crtn.S - $(CC) $(ASFLAGS) -c crtn.S -o crtn.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crtn.S -o crtn.o $(TOPDIR)lib/crtn.o: crtn.o $(INSTALL) -d $(TOPDIR)lib/ @@ -79,6 +79,4 @@ headers: $(LN) -fs ../libc/sysdeps/linux/nios/fpu_control.h $(TOPDIR)/include/ clean: - $(RM) *.[oa] *~ core - $(RM) bits/sysnum.h - $(RM) $(TOPDIR)/include/fpu_control.h + $(RM) *.o *~ core diff --git a/libc/sysdeps/linux/nios2/Makefile b/libc/sysdeps/linux/nios2/Makefile index 7cb737e36..0292328f4 100644 --- a/libc/sysdeps/linux/nios2/Makefile +++ b/libc/sysdeps/linux/nios2/Makefile @@ -54,14 +54,14 @@ $(COBJS): %.o : %.c ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y) crti.o: crti.S - $(CC) $(ASFLAGS) -c crti.S -o crti.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crti.S -o crti.o $(TOPDIR)lib/crti.o: crti.o $(INSTALL) -d $(TOPDIR)lib/ cp crti.o $(TOPDIR)lib/ crtn.o: crtn.S - $(CC) $(ASFLAGS) -c crtn.S -o crtn.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crtn.S -o crtn.o $(TOPDIR)lib/crtn.o: crtn.o $(INSTALL) -d $(TOPDIR)lib/ @@ -79,6 +79,4 @@ headers: $(LN) -fs ../libc/sysdeps/linux/nios2/fpu_control.h $(TOPDIR)/include/ clean: - $(RM) *.[oa] *~ core - $(RM) bits/sysnum.h - $(RM) $(TOPDIR)/include/fpu_control.h + $(RM) *.o *~ core diff --git a/libc/sysdeps/linux/powerpc/Makefile b/libc/sysdeps/linux/powerpc/Makefile index 4c345c00f..e0d5dcdd2 100644 --- a/libc/sysdeps/linux/powerpc/Makefile +++ b/libc/sysdeps/linux/powerpc/Makefile @@ -61,14 +61,14 @@ $(COBJS): %.o : %.c ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y) crti.o: crti.S - $(CC) $(ASFLAGS) -c crti.S -o crti.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crti.S -o crti.o $(TOPDIR)lib/crti.o: crti.o $(INSTALL) -d $(TOPDIR)lib/ cp crti.o $(TOPDIR)lib/ crtn.o: crtn.S - $(CC) $(ASFLAGS) -c crtn.S -o crtn.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crtn.S -o crtn.o $(TOPDIR)lib/crtn.o: crtn.o $(INSTALL) -d $(TOPDIR)lib/ @@ -86,5 +86,4 @@ headers: $(LN) -fs ../libc/sysdeps/linux/powerpc/fpu_control.h $(TOPDIR)/include/ clean: - $(RM) *.[oa] *~ core - $(RM) bits/sysnum.h + $(RM) *.o *~ core diff --git a/libc/sysdeps/linux/sh/Makefile b/libc/sysdeps/linux/sh/Makefile index f224acdbf..d986850ba 100644 --- a/libc/sysdeps/linux/sh/Makefile +++ b/libc/sysdeps/linux/sh/Makefile @@ -60,14 +60,14 @@ $(COBJS): %.o : %.c ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y) crti.o: crti.S - $(CC) $(ASFLAGS) -c crti.S -o crti.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crti.S -o crti.o $(TOPDIR)lib/crti.o: crti.o $(INSTALL) -d $(TOPDIR)lib/ cp crti.o $(TOPDIR)lib/ crtn.o: crtn.S - $(CC) $(ASFLAGS) -c crtn.S -o crtn.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crtn.S -o crtn.o $(TOPDIR)lib/crtn.o: crtn.o $(INSTALL) -d $(TOPDIR)lib/ @@ -85,6 +85,4 @@ headers: $(LN) -fs ../libc/sysdeps/linux/sh/fpu_control.h $(TOPDIR)/include/ clean: - $(RM) *.[oa] *~ core - $(RM) bits/sysnum.h - $(RM) gmon-start.S + $(RM) *.o *~ core diff --git a/libc/sysdeps/linux/sh64/Makefile b/libc/sysdeps/linux/sh64/Makefile index 3b5e8e9d0..af49f5f1c 100644 --- a/libc/sysdeps/linux/sh64/Makefile +++ b/libc/sysdeps/linux/sh64/Makefile @@ -60,14 +60,14 @@ $(COBJS): %.o : %.c ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y) crti.o: crti.S - $(CC) $(ASFLAGS) -c crti.S -o crti.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crti.S -o crti.o $(TOPDIR)lib/crti.o: crti.o $(INSTALL) -d $(TOPDIR)lib/ cp crti.o $(TOPDIR)lib/ crtn.o: crtn.S - $(CC) $(ASFLAGS) -c crtn.S -o crtn.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crtn.S -o crtn.o $(TOPDIR)lib/crtn.o: crtn.o $(INSTALL) -d $(TOPDIR)lib/ @@ -84,5 +84,4 @@ endif headers: clean: - $(RM) *.[oa] *~ core - $(RM) bits/sysnum.h + $(RM) *.o *~ core diff --git a/libc/sysdeps/linux/sparc/Makefile b/libc/sysdeps/linux/sparc/Makefile index 8a2549cb2..de2fe0a4e 100644 --- a/libc/sysdeps/linux/sparc/Makefile +++ b/libc/sysdeps/linux/sparc/Makefile @@ -55,14 +55,14 @@ $(COBJS): %.o : %.c ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y) crti.o: crti.S - $(CC) $(ASFLAGS) -c crti.S -o crti.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crti.S -o crti.o $(TOPDIR)lib/crti.o: crti.o $(INSTALL) -d $(TOPDIR)lib/ cp crti.o $(TOPDIR)lib/ crtn.o: crtn.S - $(CC) $(ASFLAGS) -c crtn.S -o crtn.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crtn.S -o crtn.o $(TOPDIR)lib/crtn.o: crtn.o $(INSTALL) -d $(TOPDIR)lib/ @@ -80,5 +80,4 @@ headers: $(LN) -fs ../libc/sysdeps/linux/sparc/fpu_control.h $(TOPDIR)/include/ clean: - $(RM) *.[oa] *~ core - $(RM) bits/sysnum.h + $(RM) *.o *~ core diff --git a/libc/sysdeps/linux/v850/Makefile b/libc/sysdeps/linux/v850/Makefile index e54925096..d20bc89c6 100644 --- a/libc/sysdeps/linux/v850/Makefile +++ b/libc/sysdeps/linux/v850/Makefile @@ -60,14 +60,14 @@ $(COBJS): %.o : %.c ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y) crti.o: crti.S - $(CC) $(ASFLAGS) -c crti.S -o crti.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crti.S -o crti.o $(TOPDIR)lib/crti.o: crti.o $(INSTALL) -d $(TOPDIR)lib/ cp crti.o $(TOPDIR)lib/ crtn.o: crtn.S - $(CC) $(ASFLAGS) -c crtn.S -o crtn.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crtn.S -o crtn.o $(TOPDIR)lib/crtn.o: crtn.o $(INSTALL) -d $(TOPDIR)lib/ @@ -84,5 +84,4 @@ endif headers: clean: - $(RM) *.[oa] *~ core - $(RM) bits/sysnum.h + $(RM) *.o *~ core diff --git a/libc/sysdeps/linux/x86_64/Makefile b/libc/sysdeps/linux/x86_64/Makefile index 3c48d9e0b..c38204e4d 100644 --- a/libc/sysdeps/linux/x86_64/Makefile +++ b/libc/sysdeps/linux/x86_64/Makefile @@ -59,14 +59,14 @@ $(COBJS): %.o : %.c ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y) crti.o: crti.S - $(CC) $(ASFLAGS) -c crti.S -o crti.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crti.S -o crti.o $(TOPDIR)lib/crti.o: crti.o $(INSTALL) -d $(TOPDIR)lib/ cp crti.o $(TOPDIR)lib/ crtn.o: crtn.S - $(CC) $(ASFLAGS) -c crtn.S -o crtn.o + $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crtn.S -o crtn.o $(TOPDIR)lib/crtn.o: crtn.o $(INSTALL) -d $(TOPDIR)lib/ @@ -84,6 +84,4 @@ headers: $(LN) -fs ../libc/sysdeps/linux/x86_64/fpu_control.h $(TOPDIR)/include/ clean: - $(RM) *.[oa] *~ core - $(RM) bits/sysnum.h - $(RM) gmon-start.S + $(RM) *.o *~ core |