From 2f81c0d4bcb03808e3507105f7739ad6baf3af72 Mon Sep 17 00:00:00 2001 From: John Marino Date: Sat, 15 Oct 2011 01:38:11 +0200 Subject: [PATCH] crt1.o: provide symbol definition of __progname When the linker version script requests "local: *", the linker chokes on it because the weak __progname crt1.o symbol comes back undefined. This is a duplicate definition to the ones provided by csu, but harmless since the linker resolves it. Also cleaned up some files involving libc_private.h that should have been updated in previous changesets. --- lib/csu/i386/Makefile.csu | 3 ++- lib/csu/i386/crt1_c.c | 16 ++++++++++------ lib/libc/gen/getlogin.c | 3 +-- lib/libc/gen/setprogname.c | 3 +-- lib/libc/include/libc_private.h | 2 +- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/csu/i386/Makefile.csu b/lib/csu/i386/Makefile.csu index a36a1880ad..62f6e91e65 100644 --- a/lib/csu/i386/Makefile.csu +++ b/lib/csu/i386/Makefile.csu @@ -7,7 +7,8 @@ CLEANFILES+= crt1.o crti.o crtn.o gcrt1.o Scrt1.o \ crt1_c.o crt1_s.o gcrtl_c.o Scrt1_c.o WARNS?= 2 -CFLAGS+= -I${CSUDIR}/../common +CFLAGS+= -I${CSUDIR}/../common \ + -I${CSUDIR}/../../libc/include .PATH: ${CSUDIR} ${CSUDIR}/../common diff --git a/lib/csu/i386/crt1_c.c b/lib/csu/i386/crt1_c.c index f2462d73f1..a78ad5c9d7 100644 --- a/lib/csu/i386/crt1_c.c +++ b/lib/csu/i386/crt1_c.c @@ -32,8 +32,13 @@ #include #include #include + +#include "libc_private.h" #include "crtbrand.c" +extern int _DYNAMIC; +#pragma weak _DYNAMIC + typedef void (*fptr)(void); extern void _fini(void); @@ -47,22 +52,21 @@ extern int eprol; extern int etext; #endif -extern int _DYNAMIC; -#pragma weak _DYNAMIC - char **environ; -char *__progname = ""; +const char *__progname = ""; + void _start1(fptr, int, char *[]) __dead2; +/* The entry function, C part. */ void _start1(fptr cleanup, int argc, char *argv[]) { char **env; + const char *s; env = argv + argc + 1; environ = env; - if(argc > 0 && argv[0] != NULL) { - char *s; + if (argc > 0 && argv[0] != NULL) { __progname = argv[0]; for (s = __progname; *s != '\0'; s++) if (*s == '/') diff --git a/lib/libc/gen/getlogin.c b/lib/libc/gen/getlogin.c index 77f99a6382..04726e6ad9 100644 --- a/lib/libc/gen/getlogin.c +++ b/lib/libc/gen/getlogin.c @@ -31,7 +31,6 @@ * SUCH DAMAGE. * * $FreeBSD: src/lib/libc/gen/getlogin.c,v 1.4.2.1 2001/03/05 09:06:50 obrien Exp $ - * $DragonFly: src/lib/libc/gen/getlogin.c,v 1.4 2005/04/26 06:08:42 joerg Exp $ * * @(#)getlogin.c 8.1 (Berkeley) 6/4/93 */ @@ -47,7 +46,7 @@ #include #include "un-namespace.h" -#include +#include "libc_private.h" #define THREAD_LOCK() if (__isthreaded) _pthread_mutex_lock(&logname_mutex) #define THREAD_UNLOCK() if (__isthreaded) _pthread_mutex_unlock(&logname_mutex) diff --git a/lib/libc/gen/setprogname.c b/lib/libc/gen/setprogname.c index 5779b66d6a..7fa89330e5 100644 --- a/lib/libc/gen/setprogname.c +++ b/lib/libc/gen/setprogname.c @@ -1,12 +1,11 @@ /* * $FreeBSD: src/lib/libc/gen/setprogname.c,v 1.1.2.4 2002/02/11 01:18:35 dd Exp $ - * $DragonFly: src/lib/libc/gen/setprogname.c,v 1.2 2003/06/17 04:26:42 dillon Exp $ */ #include #include -extern const char *__progname; +#include "libc_private.h" void setprogname(const char *progname) diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h index f9c18b88d0..dcceee1afe 100644 --- a/lib/libc/include/libc_private.h +++ b/lib/libc/include/libc_private.h @@ -80,7 +80,7 @@ int _yp_check(char **); * This is a pointer in the C run-time startup code. It is used * by getprogname() and setprogname(). */ -extern const char *__progname; +const char *__progname; /* * Function to clean up streams, called from abort() and exit(). -- 2.41.0