Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F152513213
D37220.id112446.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
9 KB
Referenced Files
None
Subscribers
None
D37220.id112446.diff
View Options
diff --git a/lib/csu/aarch64/Makefile b/lib/csu/aarch64/Makefile
--- a/lib/csu/aarch64/Makefile
+++ b/lib/csu/aarch64/Makefile
@@ -3,7 +3,6 @@
.PATH: ${.CURDIR:H}/common
CFLAGS+= -I${.CURDIR}
-CFLAGS+= -DCRT_IRELOC_RELA
CRT1OBJS+= crt1_s.o
diff --git a/lib/csu/aarch64/crt1_c.c b/lib/csu/aarch64/crt1_c.c
--- a/lib/csu/aarch64/crt1_c.c
+++ b/lib/csu/aarch64/crt1_c.c
@@ -32,42 +32,14 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <stdlib.h>
-
#include "libc_private.h"
-#include "ignore_init.c"
-
-#ifdef GCRT
-extern void _mcleanup(void);
-extern void monstartup(void *, void *);
-extern int eprol;
-extern int etext;
-#endif
+#include "csu_common.h"
-extern long * _end;
-
-void __start(int, char **, char **, void (*)(void));
+void __start(int, char **, char **, void (*)(void)) __dead2;
/* The entry function. */
void
__start(int argc, char *argv[], char *env[], void (*cleanup)(void))
{
-
- handle_argv(argc, argv, env);
-
- if (&_DYNAMIC != NULL)
- atexit(cleanup);
- else {
- process_irelocs();
- _init_tls();
- }
-
-#ifdef GCRT
- atexit(_mcleanup);
- monstartup(&eprol, &etext);
-__asm__("eprol:");
-#endif
-
- handle_static_init(argc, argv, env);
- exit(main(argc, argv, env));
+ __libc_start1(argc, argc, env, cleanup, main);
}
diff --git a/lib/csu/amd64/Makefile b/lib/csu/amd64/Makefile
--- a/lib/csu/amd64/Makefile
+++ b/lib/csu/amd64/Makefile
@@ -3,6 +3,6 @@
.PATH: ${.CURDIR:H}/common
CFLAGS+= -I${.CURDIR}
-CFLAGS+= -fno-omit-frame-pointer -DCRT_IRELOC_RELA
+CFLAGS+= -fno-omit-frame-pointer
.include <bsd.lib.mk>
diff --git a/lib/csu/amd64/crt1_c.c b/lib/csu/amd64/crt1_c.c
--- a/lib/csu/amd64/crt1_c.c
+++ b/lib/csu/amd64/crt1_c.c
@@ -29,19 +29,10 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <stdlib.h>
-
#include "libc_private.h"
-#include "ignore_init.c"
-
-#ifdef GCRT
-extern void _mcleanup(void);
-extern void monstartup(void *, void *);
-extern int eprol;
-extern int etext;
-#endif
+#include "csu_common.h"
-void _start(char **, void (*)(void));
+void _start(char **, void (*)(void)) __dead2;
/* The entry function. */
void
@@ -54,21 +45,10 @@
argc = *(long *)(void *)ap;
argv = ap + 1;
env = ap + 2 + argc;
- handle_argv(argc, argv, env);
-
- if (&_DYNAMIC != NULL) {
- atexit(cleanup);
- } else {
- process_irelocs();
- _init_tls();
- }
-
#ifdef GCRT
- atexit(_mcleanup);
- monstartup(&eprol, &etext);
+ __libc_start1_gcrt(argc, argv, env, cleanup, main, &eprol, &etext);
__asm__("eprol:");
+#else
+ __libc_start1(argc, argv, env, cleanup, main);
#endif
-
- handle_static_init(argc, argv, env);
- exit(main(argc, argv, env));
}
diff --git a/lib/csu/common/csu_common.h b/lib/csu/common/csu_common.h
new file mode 100644
--- /dev/null
+++ b/lib/csu/common/csu_common.h
@@ -0,0 +1,41 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright 1996-1998 John D. Polstra.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This file includes both definitions and declarations, it can be
+ * included only into one compilation unit for csu objects.
+ */
+
+char **environ;
+const char *__progname = "";
+
+#ifdef GCRT
+extern int eprol;
+extern int etext;
+#endif
+
+extern int main(int, char **, char **);
diff --git a/lib/csu/i386/Makefile b/lib/csu/i386/Makefile
--- a/lib/csu/i386/Makefile
+++ b/lib/csu/i386/Makefile
@@ -3,7 +3,6 @@
.PATH: ${.CURDIR:H}/common
CFLAGS+= -I${.CURDIR}
-CFLAGS+= -DCRT_IRELOC_REL
CRT1OBJS+= crt1_s.o
diff --git a/lib/csu/i386/crt1_c.c b/lib/csu/i386/crt1_c.c
--- a/lib/csu/i386/crt1_c.c
+++ b/lib/csu/i386/crt1_c.c
@@ -29,20 +29,10 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <stdlib.h>
-
#include "libc_private.h"
-#include "ignore_init.c"
-
-extern void _start(char *, ...);
-
-#ifdef GCRT
-extern void _mcleanup(void);
-extern void monstartup(void *, void *);
-extern int eprol;
-extern int etext;
-#endif
+#include "csu_common.h"
+void _start(char *, ...);
void _start1(void (*)(void), int, char *[]) __dead2;
/* The entry function, C part. */
@@ -52,22 +42,12 @@
char **env;
env = argv + argc + 1;
- handle_argv(argc, argv, env);
- if (&_DYNAMIC != NULL) {
- atexit(cleanup);
- } else {
- process_irelocs();
- _init_tls();
- }
-
#ifdef GCRT
- atexit(_mcleanup);
- monstartup(&eprol, &etext);
+ __libc_start1_gcrt(argc, argv, env, cleanup, main, &eprol, &etext);
__asm__("eprol:");
+#else
+ __libc_start1(argc, argv, env, cleanup, main);
#endif
-
- handle_static_init(argc, argv, env);
- exit(main(argc, argv, env));
}
__asm(".hidden _start1");
diff --git a/lib/libc/Makefile b/lib/libc/Makefile
--- a/lib/libc/Makefile
+++ b/lib/libc/Makefile
@@ -93,6 +93,7 @@
NOASM=
.include "${LIBC_SRCTOP}/${LIBC_ARCH}/Makefile.inc"
+.include "${LIBC_SRCTOP}/csu/Makefile.inc"
.include "${LIBC_SRCTOP}/db/Makefile.inc"
.include "${LIBC_SRCTOP}/compat-43/Makefile.inc"
.include "${LIBC_SRCTOP}/gdtoa/Makefile.inc"
diff --git a/lib/libc/csu/Makefile.inc b/lib/libc/csu/Makefile.inc
new file mode 100644
--- /dev/null
+++ b/lib/libc/csu/Makefile.inc
@@ -0,0 +1,10 @@
+#
+
+.PATH: ${LIBC_SRCTOP}/csu
+.include "${LIBC_SRCTOP}/csu/${LIBC_ARCH}/Makefile.inc"
+
+SRCS+= \
+ ignore_init.c
+
+CFLAGS+= -I${LIBC_SRCTOP}/csu/${LIBC_ARCH}
+SYM_MAPS+=${LIBC_SRCTOP}/csu/Symbol.map
diff --git a/lib/libc/csu/Symbol.map b/lib/libc/csu/Symbol.map
new file mode 100644
--- /dev/null
+++ b/lib/libc/csu/Symbol.map
@@ -0,0 +1,4 @@
+FBSD_1.7 {
+ __libc_start1;
+ __libc_start1_gcrt;
+};
diff --git a/lib/libc/csu/aarch64/Makefile.inc b/lib/libc/csu/aarch64/Makefile.inc
new file mode 100644
--- /dev/null
+++ b/lib/libc/csu/aarch64/Makefile.inc
@@ -0,0 +1,3 @@
+#
+
+CFLAGS+= -DCRT_IRELOC_RELA
diff --git a/lib/csu/aarch64/reloc.c b/lib/libc/csu/aarch64/reloc.c
rename from lib/csu/aarch64/reloc.c
rename to lib/libc/csu/aarch64/reloc.c
diff --git a/lib/libc/csu/amd64/Makefile.inc b/lib/libc/csu/amd64/Makefile.inc
new file mode 100644
--- /dev/null
+++ b/lib/libc/csu/amd64/Makefile.inc
@@ -0,0 +1,3 @@
+#
+
+CFLAGS+= -DCRT_IRELOC_RELA
diff --git a/lib/csu/amd64/reloc.c b/lib/libc/csu/amd64/reloc.c
rename from lib/csu/amd64/reloc.c
rename to lib/libc/csu/amd64/reloc.c
diff --git a/lib/libc/csu/i386/Makefile.inc b/lib/libc/csu/i386/Makefile.inc
new file mode 100644
--- /dev/null
+++ b/lib/libc/csu/i386/Makefile.inc
@@ -0,0 +1,3 @@
+#
+
+CFLAGS+= -DCRT_IRELOC_REL
diff --git a/lib/csu/i386/reloc.c b/lib/libc/csu/i386/reloc.c
rename from lib/csu/i386/reloc.c
rename to lib/libc/csu/i386/reloc.c
diff --git a/lib/csu/common/ignore_init.c b/lib/libc/csu/ignore_init.c
rename from lib/csu/common/ignore_init.c
rename to lib/libc/csu/ignore_init.c
--- a/lib/csu/common/ignore_init.c
+++ b/lib/libc/csu/ignore_init.c
@@ -31,8 +31,8 @@
#include <sys/param.h>
#include <sys/elf.h>
#include <sys/elf_common.h>
-
-extern int main(int, char **, char **);
+#include <stdlib.h>
+#include "libc_private.h"
extern void (*__preinit_array_start[])(int, char **, char **) __hidden;
extern void (*__preinit_array_end[])(int, char **, char **) __hidden;
@@ -79,9 +79,6 @@
#error "Define platform reloc type"
#endif
-char **environ;
-const char *__progname = "";
-
static void
finalizer(void)
{
@@ -97,7 +94,7 @@
_fini();
}
-static inline void
+static void
handle_static_init(int argc, char **argv, char **env)
{
void (*fn)(int, char **, char **);
@@ -123,7 +120,9 @@
}
}
-static inline void
+extern char **environ;
+
+static void
handle_argv(int argc, char *argv[], char **env)
{
const char *s;
@@ -138,3 +137,45 @@
}
}
}
+
+void
+__libc_start1(int argc, char *argv[], char *env[], void (*cleanup)(void),
+ int (*mainX)(int, char *[], char *[]))
+{
+ handle_argv(argc, argv, env);
+
+ if (&_DYNAMIC != NULL)
+ atexit(cleanup);
+ else {
+ process_irelocs();
+ _init_tls();
+ }
+
+ handle_static_init(argc, argv, env);
+ exit(mainX(argc, argv, env));
+}
+
+/* XXXKIB _mcleanup and monstartup defs */
+extern void _mcleanup(void);
+extern void monstartup(void *, void *);
+
+void
+__libc_start1_gcrt(int argc, char *argv[], char *env[],
+ void (*cleanup)(void), int (*mainX)(int, char *[], char *[]),
+ int *eprolp, int *etextp)
+{
+ handle_argv(argc, argv, env);
+
+ if (&_DYNAMIC != NULL)
+ atexit(cleanup);
+ else {
+ process_irelocs();
+ _init_tls();
+ }
+
+ atexit(_mcleanup);
+ monstartup(eprolp, etextp);
+
+ handle_static_init(argc, argv, env);
+ exit(mainX(argc, argv, env));
+}
diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h
--- a/lib/libc/include/libc_private.h
+++ b/lib/libc/include/libc_private.h
@@ -249,6 +249,12 @@
int _yp_check(char **);
#endif
+void __libc_start1(int, char *[], char *[],
+ void (*)(void), int (*)(int, char *[], char *[])) __dead2;
+void __libc_start1_gcrt(int, char *[], char *[],
+ void (*)(void), int (*)(int, char *[], char *[]),
+ int *, int *) __dead2;
+
/*
* Initialise TLS for static programs
*/
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Apr 16, 10:40 AM (12 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31596662
Default Alt Text
D37220.id112446.diff (9 KB)
Attached To
Mode
D37220: csu: move common code to libc
Attached
Detach File
Event Timeline
Log In to Comment