__cxa_atexit and __cxa_finalize implementation
Peter S. Mazinger
ps.m at gmx.net
Fri Sep 16 01:02:28 UTC 2005
On Thu, 15 Sep 2005, Stephen Warren wrote:
Attached are my patches:
nonshared:
-adds support generally for any files to uclibc_nonshared.a
-creates the needed linker script
-it does not check for existence of files (fails if no nonshared_obj.*
file is present)
atexit:
adds atexit to nonshared lib, applies after the cxa_atexit... patch
Be aware, this will for sure kill most of the apps (all that used atexit()
) it will be an incompatible change to uClibc.
Peter
> Peter S. Mazinger wrote:
> > On Thu, 15 Sep 2005, Stephen Warren wrote:
> >
> >>Peter S. Mazinger wrote:
> >>
> >>>>>Please redo your patch as follows:
> >>>>>1. the functions that have to go into *libc_nonshared.a should be in
> >>>>>separate objects (ifdef L_* is ok, if you use the same source)
> >>>>>2. for hiding use attribute_hidden (it takes care of the case that gcc
> >>>>>does not support it, then it becomes visible)
> >>>>
> >>>>Sounds great. I'll try to work on this soon:-)
> >>
> >>Found a few minutes during a build. Attached is the latest patch.
> >>
> >>Item 1 on your list was already in place - libc/stdlib/atexit.o wants to
> >>go in the new .a file. (This comes from libc/stdlib/atexit.c with
> >>L_atexit defined). Everything else built from that .c file can go in
> >>"libc.so"
> >
> > should atexit.o go also into libc.so or only into nonshared.a?
> > (if libc uses it itself, then it should also go into libc.so)
>
> grep says libc.so doesn't use atexit internally, except for possibly
> some stuff in these files
>
> libc/sysdeps/linux/m68k/crt0.S
> libc/sysdeps/linux/h8300/crt0.S
> libc/sysdeps/linux/nios/crt0.c (same stuff, but commented)
>
> For example (from 68k):
>
> /*
> * this was needed for gcc/g++-builds, atexit was not getting included
> * for some stupid reason, this gets us a compiler
> */
> empty_func:
> rts
> #if defined(__HAVE_ELF__)
> .weak atexit
> atexit = empty_func
> #else
> .set atexit,empty_func
> #endif
>
> I have no idea what this does or why!
>
--
Peter S. Mazinger <ps dot m at gmx dot net> ID: 0xA5F059F2
Key fingerprint = 92A4 31E1 56BC 3D5A 2D08 BB6E C389 975E A5F0 59F2
-------------- next part --------------
--- uClibc-0.9.28/libc/Makefile.mps 2005-09-15 18:20:20 +0200
+++ uClibc-0.9.28/libc/Makefile 2005-09-15 21:18:47 +0200
@@ -87,8 +87,15 @@
$(INSTALL) -d $(TOPDIR)lib
$(RM) $(TOPDIR)lib/$(SHARED_FULLNAME)
$(INSTALL) -m 644 $(SHARED_FULLNAME) $(TOPDIR)lib
- $(LN) -sf $(SHARED_FULLNAME) $(TOPDIR)lib/libc.so
$(LN) -sf $(SHARED_FULLNAME) $(TOPDIR)lib/$(SHARED_MAJORNAME)
+ $(AR) $(ARFLAGS) $(TOPDIR)lib/$(NONSHARED_LIBNAME) `cat nonshared_obj.*`
+ $(RANLIB) $(TOPDIR)lib/$(NONSHARED_LIBNAME)
+ echo "/* GNU ld script" > $(TOPDIR)lib/libc.so
+ echo " * Use the shared library, but some functions are only in" >> $(TOPDIR)lib/libc.so
+ echo " * the static library, so try that secondarily. */" >> $(TOPDIR)lib/libc.so
+ #OUT_FORMAT:=$(shell $(LD) --verbose | grep OUTPUT_FORMAT | awk -F '"' '{print $2}')
+ #echo "OUTPUT_FORMAT($(OUT_FORMAT))" >> $(TOPDIR)lib/libc.so
+ echo "GROUP ( $(TOPDIR)lib/$(SHARED_MAJORNAME) $(TOPDIR)lib/$(NONSHARED_LIBNAME) )" >> $(TOPDIR)lib/libc.so
halfclean:
@$(RM) $(LIBNAME) shared_$(LIBNAME) uClibc_config.h
--- uClibc-0.9.28/Makefile.mps 2005-09-15 18:49:09 +0200
+++ uClibc-0.9.28/Makefile 2005-09-15 21:19:10 +0200
@@ -230,6 +230,10 @@
$(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)$$i.$(MAJOR_VERSION) \
$(PREFIX)$(DEVEL_PREFIX)lib/$$i; \
done;
+ $(RM) $(PREFIX)$(DEVEL_PREFIX)lib/libc.so
+ sed -e '/^GROUP/d' $(TOPDIR)lib/libc.so > $(PREFIX)$(DEVEL_PREFIX)lib/libc.so
+ echo "GROUP ( $(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME) $(DEVEL_PREFIX)lib/$(NONSHARED_LIBNAME) )" >> \
+ $(PREFIX)$(DEVEL_PREFIX)lib/libc.so
ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
$(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)libthread_db.so.1 \
$(PREFIX)$(DEVEL_PREFIX)lib/libthread_db.so
--- uClibc-0.9.28/Rules.mak.mps 2005-09-15 21:04:26 +0200
+++ uClibc-0.9.28/Rules.mak 2005-09-15 21:05:31 +0200
@@ -70,6 +70,7 @@
SHARED_FULLNAME:=libuClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
SHARED_MAJORNAME:=libc.so.$(MAJOR_VERSION)
UCLIBC_LDSO:=ld-uClibc.so.$(MAJOR_VERSION)
+NONSHARED_LIBNAME:=uclibc_nonshared.a
LIBNAME:=libc.a
LIBC:=$(TOPDIR)libc/$(LIBNAME)
-------------- next part --------------
--- uClibc-0.9.28/libc/stdlib/Makefile.mps 2005-09-16 02:05:40 +0200
+++ uClibc-0.9.28/libc/stdlib/Makefile 2005-09-16 02:05:08 +0200
@@ -79,7 +79,7 @@
# wcstod wcstof wcstold
MSRC2 = atexit.c
-MOBJ2 = atexit.o on_exit.o __cxa_atexit.o __cxa_finalize.o __exit_handler.o exit.o
+MOBJ2 = on_exit.o __cxa_atexit.o __cxa_finalize.o __exit_handler.o exit.o
CSRC = \
abort.c getenv.c mkdtemp.c mktemp.c realpath.c mkstemp.c mkstemp64.c \
@@ -95,13 +95,20 @@
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 +125,7 @@
$(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
More information about the uClibc
mailing list