aboutsummaryrefslogtreecommitdiff
path: root/csu
diff options
context:
space:
mode:
Diffstat (limited to 'csu')
-rw-r--r--csu/Makefile57
-rw-r--r--csu/munch-tmpl.c38
-rw-r--r--csu/munch.awk11
-rw-r--r--csu/set-init.c23
-rw-r--r--csu/version.c73
5 files changed, 197 insertions, 5 deletions
diff --git a/csu/Makefile b/csu/Makefile
index da17b2c..6d804f4 100644
--- a/csu/Makefile
+++ b/csu/Makefile
@@ -27,7 +27,7 @@
subdir := csu
-routines = init-first libc-start
+routines = init-first libc-start $(libc-init) sysdep version
csu-dummies = $(filter-out $(start-installed-name),crt1.o Mcrt1.o)
extra-objs = start.o gmon-start.o \
$(start-installed-name) g$(start-installed-name) \
@@ -36,17 +36,35 @@ omit-deps = $(patsubst %.o,%,$(start-installed-name) g$(start-installed-name) \
$(csu-dummies))
install-lib = $(start-installed-name) g$(start-installed-name) \
$(csu-dummies)
-distribute = initfini.c gmon-start.c start.c defs.awk abi-note.S init.c
+distribute = initfini.c gmon-start.c start.c defs.awk munch.awk \
+ abi-note.S init.c
+generated = version-info.h
+before-compile = $(objpfx)version-info.h
all: # Make this the default target; it will be defined in Rules.
include ../Makeconfig
-ifeq ($(elf),yes)
-before-compile = $(objpfx)abi-tag.h
+ifeq (yes,$(elf))
+before-compile += $(objpfx)abi-tag.h
generated += abi-tag.h
endif
+ifeq (yes,$(gnu-ld))
+libc-init = set-init
+else
+libc-init = munch-init
+$(objpfx)munch-init.c: munch.awk munch-tmpl.c $(+subdir_inits)
+ $(AWK) -f $< subdirs='$(+init_subdirs)' $(word 2,$^) > $@-t
+ mv -f $@-t $@
+generated += munch-init.c
+
+# All initialization source files.
++subdir_inits := $(wildcard $(foreach dir,$(subdirs),$(dir)/init-$(dir).c))
+# All subdirectories containing initialization source files.
++init_subdirs := $(patsubst %/,%,$(dir $(+subdir_inits)))
+endif
+
ifeq ($(have-initfini),yes)
CPPFLAGS += -DHAVE_INITFINI
@@ -130,11 +148,12 @@ $(addprefix $(objpfx),$(filter-out $(start-installed-name),$(csu-dummies))):
$(COMPILE.c) $(@:.o=.c) $(OUTPUT_OPTION)
rm -f $(@:.o=.c)
+# These headers are used by the startup code.
/ := $$/# bite me.
$(objpfx)abi-tag.h: $(..)abi-tags
$(make-target-directory)
rm -f $@.new
- sed 's/#.*$//;/^[ ]*$$/d' $< | while read conf tag; do \
+ sed 's/#.*$//;/^[ ]*$/d' $< | while read conf tag; do \
test `expr '$(config-machine)-$(config-vendor)-$(config-os)' \
: "$$conf"` != 0 || continue; \
echo "$$tag" | sed > $@.new \
@@ -142,3 +161,31 @@ $(objpfx)abi-tag.h: $(..)abi-tags
done
if test -r $@.new; then mv -f $@.new $@; \
else echo >&2 'This configuration not matched in $<'; exit 1; fi
+
+all-Banner-files = $(wildcard $(addsuffix /Banner, \
+ $(addprefix $(..), $(subdirs))))
+$(objpfx)version-info.h: $(common-objpfx)config.make $(all-Banner-files)
+ $(make-target-directory)
+ (case $(config-os) in \
+ linux*) version=`(echo -e "#include <linux/version.h>\nUTS_RELEASE"\
+ | $(CC) -E -P - | \
+ sed -e 's/"\([^"]*\)".*/\1/p' -e d) 2>/dev/null`;\
+ if [ -z "$$version" ]; then \
+ if [ -r /proc/version ]; then \
+ version=`sed 's/.*version \([^ ]*\) .*/>>\1<</' \
+ < /proc/version`; \
+ else \
+ version=`uname -r`; \
+ fi; \
+ fi; \
+ echo -n "\"Compiled on a Linux $$version system "; \
+ echo "on `date +%Y-%m-%d`.\\n\"" ;; \
+ *) ;; \
+ esac; \
+ files="$(all-Banner-files)"; \
+ if test -n "$$files"; then \
+ echo "\"Available extensions:"; \
+ sed -e '/^#/d' -e 's/^[[:space:]]*/ /' $$files; \
+ echo "\""; \
+ fi) > $@T
+ mv -f $@T $@
diff --git a/csu/munch-tmpl.c b/csu/munch-tmpl.c
new file mode 100644
index 0000000..c24eb89
--- /dev/null
+++ b/csu/munch-tmpl.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <stdlib.h>
+
+
+EXTERNS
+
+void
+__libc_init (int argc, char **argv, char **envp)
+{
+ CALLS
+
+#ifdef HAVE_INITFINI
+ {
+ /* These functions are defined in crti.o to run the .init and .fini
+ sections, which are used for initializers and finalizers. */
+ extern void _init __P ((void)), _fini __P ((void));
+ atexit (&_fini); /* Arrange for _fini to run at exit. */
+ _init ();
+ }
+#endif
+}
diff --git a/csu/munch.awk b/csu/munch.awk
new file mode 100644
index 0000000..1ed6868
--- /dev/null
+++ b/csu/munch.awk
@@ -0,0 +1,11 @@
+BEGIN { special = 0 }
+
+/EXTERNS/ { ndirs = split(subdirs, dirs)
+ for (i = 1; i <= ndirs; ++i)
+ printf "extern void __init_%s __P ((int argc, char **argv, char **envp));\n", dirs[i]
+ special = 1 }
+/CALLS/ { ndirs = split(subdirs, dirs)
+ for (i = 1; i <= ndirs; ++i) printf " __init_%s (argc, argv, envp);\n", dirs[i]
+ special = 1 }
+
+{ if (special == 0) print $0; special = 0 }
diff --git a/csu/set-init.c b/csu/set-init.c
new file mode 100644
index 0000000..4aea847
--- /dev/null
+++ b/csu/set-init.c
@@ -0,0 +1,23 @@
+/* Copyright (C) 1991, 1992, 1994, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <stdlib.h>
+#include <set-hooks.h>
+
+DEFINE_HOOK_RUNNER (__libc_subinit, __libc_init,
+ (int argc, char **argv, char **envp), (argc, argv, envp))
diff --git a/csu/version.c b/csu/version.c
new file mode 100644
index 0000000..2285c75
--- /dev/null
+++ b/csu/version.c
@@ -0,0 +1,73 @@
+/* Copyright (C) 1991,92,93,94,95,96,97,98 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include "version.h"
+#include <gnu/libc-version.h>
+
+static const char __libc_release[] = RELEASE;
+static const char __libc_version[] = VERSION;
+
+static const char banner[] =
+"GNU C Library "RELEASE" release version "VERSION", by Roland McGrath et al.\n\
+Copyright (C) 1992, 93, 94, 95, 96, 97, 98 Free Software Foundation, Inc.\n\
+This is free software; see the source for copying conditions.\n\
+There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n\
+PARTICULAR PURPOSE.\n\
+Compiled by GNU CC version "__VERSION__".\n"
+#include "version-info.h"
+"Report bugs using the `glibcbug' script to <bugs@gnu.org>.\n";
+
+#include <unistd.h>
+
+void
+__libc_print_version (void)
+{
+ __write (STDOUT_FILENO, banner, sizeof banner - 1);
+}
+
+const char *
+__gnu_get_libc_release (void)
+{
+ return __libc_release;
+}
+weak_alias (__gnu_get_libc_release, gnu_get_libc_release)
+
+const char *
+__gnu_get_libc_version (void)
+{
+ return __libc_version;
+}
+weak_alias (__gnu_get_libc_version, gnu_get_libc_version)
+
+#ifdef HAVE_ELF
+/* This function is the entry point for the shared object.
+ Running the library as a program will get here. */
+
+void
+__libc_main (void)
+{
+ __libc_print_version ();
+ _exit (0);
+}
+#endif
+
+/*
+ Local Variables:
+ version-control: never
+ End:
+*/