diff options
author | markm <markm@FreeBSD.org> | 2002-03-29 22:43:43 +0000 |
---|---|---|
committer | markm <markm@FreeBSD.org> | 2002-03-29 22:43:43 +0000 |
commit | 76fe441a7bf75d73962641b785f158b5cc9dc7f8 (patch) | |
tree | 4e267e060bfb6d96f46ab0d79c49b277402c0dd0 /lib/csu | |
parent | 6085f75ded37ec415ded7d6373ecd09bcb088ac4 (diff) | |
download | FreeBSD-src-76fe441a7bf75d73962641b785f158b5cc9dc7f8.zip FreeBSD-src-76fe441a7bf75d73962641b785f158b5cc9dc7f8.tar.gz |
Do not use __progname directly (except in [gs]etprogname(3)).
Also, make an internal _getprogname() that is used only inside
libc. For libc, getprogname(3) is a weak symbol in case a
function of the same name is defined in userland.
Diffstat (limited to 'lib/csu')
-rw-r--r-- | lib/csu/alpha/Makefile | 3 | ||||
-rw-r--r-- | lib/csu/alpha/crt1.c | 5 | ||||
-rw-r--r-- | lib/csu/amd64/Makefile | 3 | ||||
-rw-r--r-- | lib/csu/amd64/crt1.c | 5 | ||||
-rw-r--r-- | lib/csu/i386-elf/Makefile | 3 | ||||
-rw-r--r-- | lib/csu/i386-elf/crt1.c | 5 | ||||
-rw-r--r-- | lib/csu/i386/Makefile | 3 | ||||
-rw-r--r-- | lib/csu/i386/crt0.c | 12 | ||||
-rw-r--r-- | lib/csu/ia64/Makefile | 3 | ||||
-rw-r--r-- | lib/csu/ia64/crt1.c | 5 | ||||
-rw-r--r-- | lib/csu/powerpc/Makefile | 3 | ||||
-rw-r--r-- | lib/csu/powerpc/crt1.c | 5 | ||||
-rw-r--r-- | lib/csu/sparc64/Makefile | 3 | ||||
-rw-r--r-- | lib/csu/sparc64/crt1.c | 5 |
14 files changed, 39 insertions, 24 deletions
diff --git a/lib/csu/alpha/Makefile b/lib/csu/alpha/Makefile index 0ee91e0..5528e4e 100644 --- a/lib/csu/alpha/Makefile +++ b/lib/csu/alpha/Makefile @@ -6,7 +6,8 @@ SRCS= crt1.c crti.S crtn.S OBJS= ${SRCS:N*.h:R:S/$/.o/g} OBJS+= gcrt1.o CFLAGS+= -Wall -Wno-unused \ - -I${.CURDIR}/../common + -I${.CURDIR}/../common \ + -I${.CURDIR}/../../libc/include NOMAN= true NOPIC= true NOPROFILE= true diff --git a/lib/csu/alpha/crt1.c b/lib/csu/alpha/crt1.c index b092c67..9a76159 100644 --- a/lib/csu/alpha/crt1.c +++ b/lib/csu/alpha/crt1.c @@ -40,6 +40,7 @@ #endif #include <stdlib.h> +#include "libc_private.h" #include "crtbrand.c" struct Struct_Obj_Entry; @@ -60,7 +61,7 @@ extern int etext; #endif char **environ; -char *__progname = ""; +const char *__progname = ""; /* The entry function. */ void @@ -72,13 +73,13 @@ _start(char **ap, int argc; char **argv; char **env; + const char *s; argc = * (long *) ap; argv = ap + 1; env = ap + 2 + argc; environ = env; if(argc > 0 && argv[0] != NULL) { - char *s; __progname = argv[0]; for (s = __progname; *s != '\0'; s++) if (*s == '/') diff --git a/lib/csu/amd64/Makefile b/lib/csu/amd64/Makefile index cb1bc63..b602a02 100644 --- a/lib/csu/amd64/Makefile +++ b/lib/csu/amd64/Makefile @@ -6,7 +6,8 @@ SRCS= crt1.c crti.S crtn.S OBJS= ${SRCS:N*.h:R:S/$/.o/g} OBJS+= gcrt1.o CFLAGS+= -elf -Wall -fkeep-inline-functions \ - -I${.CURDIR}/../common + -I${.CURDIR}/../common \ + -I${.CURDIR}/../../libc/include LDFLAGS+= -elf NOMAN= true NOPIC= true diff --git a/lib/csu/amd64/crt1.c b/lib/csu/amd64/crt1.c index 60ca5b5..5dcd90e 100644 --- a/lib/csu/amd64/crt1.c +++ b/lib/csu/amd64/crt1.c @@ -29,6 +29,7 @@ #include <stddef.h> #include <stdlib.h> +#include "libc_private.h" #include "crtbrand.c" typedef void (*fptr)(void); @@ -57,7 +58,7 @@ extern int _DYNAMIC; #endif char **environ; -char *__progname = ""; +const char *__progname = ""; void _start(char *arguments, ...) @@ -66,6 +67,7 @@ _start(char *arguments, ...) int argc; char **argv; char **env; + const char *s; rtld_cleanup = get_rtld_cleanup(); argv = &arguments; @@ -73,7 +75,6 @@ _start(char *arguments, ...) env = argv + argc + 1; environ = env; if (argc > 0 && argv[0] != NULL) { - char *s; __progname = argv[0]; for (s = __progname; *s != '\0'; s++) if (*s == '/') diff --git a/lib/csu/i386-elf/Makefile b/lib/csu/i386-elf/Makefile index cb1bc63..b602a02 100644 --- a/lib/csu/i386-elf/Makefile +++ b/lib/csu/i386-elf/Makefile @@ -6,7 +6,8 @@ SRCS= crt1.c crti.S crtn.S OBJS= ${SRCS:N*.h:R:S/$/.o/g} OBJS+= gcrt1.o CFLAGS+= -elf -Wall -fkeep-inline-functions \ - -I${.CURDIR}/../common + -I${.CURDIR}/../common \ + -I${.CURDIR}/../../libc/include LDFLAGS+= -elf NOMAN= true NOPIC= true diff --git a/lib/csu/i386-elf/crt1.c b/lib/csu/i386-elf/crt1.c index 60ca5b5..5dcd90e 100644 --- a/lib/csu/i386-elf/crt1.c +++ b/lib/csu/i386-elf/crt1.c @@ -29,6 +29,7 @@ #include <stddef.h> #include <stdlib.h> +#include "libc_private.h" #include "crtbrand.c" typedef void (*fptr)(void); @@ -57,7 +58,7 @@ extern int _DYNAMIC; #endif char **environ; -char *__progname = ""; +const char *__progname = ""; void _start(char *arguments, ...) @@ -66,6 +67,7 @@ _start(char *arguments, ...) int argc; char **argv; char **env; + const char *s; rtld_cleanup = get_rtld_cleanup(); argv = &arguments; @@ -73,7 +75,6 @@ _start(char *arguments, ...) env = argv + argc + 1; environ = env; if (argc > 0 && argv[0] != NULL) { - char *s; __progname = argv[0]; for (s = __progname; *s != '\0'; s++) if (*s == '/') diff --git a/lib/csu/i386/Makefile b/lib/csu/i386/Makefile index 02f14f2..b3be808 100644 --- a/lib/csu/i386/Makefile +++ b/lib/csu/i386/Makefile @@ -1,7 +1,8 @@ # from: @(#)Makefile 5.6 (Berkeley) 5/22/91 # $FreeBSD$ -CFLAGS+= -DLIBC_SCCS -fno-omit-frame-pointer +CFLAGS+= -DLIBC_SCCS -fno-omit-frame-pointer \ + -I${.CURDIR}/../../libc/include OBJS= crt0.o c++rt0.o gcrt0.o scrt0.o sgcrt0.o CLEANFILES= a.out crt0.o.tmp c++rt0.o.tmp gcrt0.o.tmp scrt0.o.tmp \ sgcrt0.o.tmp diff --git a/lib/csu/i386/crt0.c b/lib/csu/i386/crt0.c index e1a5551..49431d9 100644 --- a/lib/csu/i386/crt0.c +++ b/lib/csu/i386/crt0.c @@ -37,10 +37,13 @@ #ifdef DYNAMIC #include <sys/types.h> #include <sys/syscall.h> -#include <a.out.h> -#include <string.h> #include <sys/mman.h> + +#include <a.out.h> #include <link.h> +#include <string.h> + +#include "libc_private.h" /* !!! * This is gross, ld.so is a ZMAGIC a.out, but has `sizeof(hdr)' for @@ -88,8 +91,7 @@ static void __do_dynamic_link(char **argv); int _callmain(); int errno; -static char empty[1]; -char *__progname = empty; +const char *__progname = ""; char **environ; /* Globals used by dlopen() and related functions in libc */ @@ -144,6 +146,7 @@ start() register struct kframe *kfp; register char **targv; register char **argv; + register const char *s; extern void _mcleanup(); #ifdef DYNAMIC volatile caddr_t x; @@ -162,7 +165,6 @@ start() environ = targv; if (argv[0]) { - register char *s; __progname = argv[0]; for (s=__progname; *s != '\0'; s++) if (*s == '/') diff --git a/lib/csu/ia64/Makefile b/lib/csu/ia64/Makefile index 0ee91e0..5528e4e 100644 --- a/lib/csu/ia64/Makefile +++ b/lib/csu/ia64/Makefile @@ -6,7 +6,8 @@ SRCS= crt1.c crti.S crtn.S OBJS= ${SRCS:N*.h:R:S/$/.o/g} OBJS+= gcrt1.o CFLAGS+= -Wall -Wno-unused \ - -I${.CURDIR}/../common + -I${.CURDIR}/../common \ + -I${.CURDIR}/../../libc/include NOMAN= true NOPIC= true NOPROFILE= true diff --git a/lib/csu/ia64/crt1.c b/lib/csu/ia64/crt1.c index 474bad8..4320b7b 100644 --- a/lib/csu/ia64/crt1.c +++ b/lib/csu/ia64/crt1.c @@ -36,6 +36,7 @@ #endif #include <stdlib.h> +#include "libc_private.h" #include "crtbrand.c" struct Struct_Obj_Entry; @@ -56,7 +57,7 @@ extern int etext; #endif char **environ; -char *__progname = ""; +const char *__progname = ""; /* The entry function. */ void @@ -67,6 +68,7 @@ _start(char **ap, int argc; char **argv; char **env; + const char *s; /* Calculate gp */ __asm __volatile(" \ @@ -82,7 +84,6 @@ _start(char **ap, env = ap + 2 + argc; environ = env; if (argc > 0 && argv[0] != NULL) { - char *s; __progname = argv[0]; for (s = __progname; *s != '\0'; s++) if (*s == '/') diff --git a/lib/csu/powerpc/Makefile b/lib/csu/powerpc/Makefile index 65dd009..44f1f3a 100644 --- a/lib/csu/powerpc/Makefile +++ b/lib/csu/powerpc/Makefile @@ -6,7 +6,8 @@ SRCS= crt1.c crti.S crtn.S OBJS= ${SRCS:N*.h:R:S/$/.o/g} OBJS+= gcrt1.o CFLAGS+= -Wall -Wno-unused \ - -I${.CURDIR}/../common + -I${.CURDIR}/../common \ + -I${.CURDIR}/../../libc/include NOMAN= true NOPIC= true NOPROFILE= true diff --git a/lib/csu/powerpc/crt1.c b/lib/csu/powerpc/crt1.c index eb293d6..46156eb 100644 --- a/lib/csu/powerpc/crt1.c +++ b/lib/csu/powerpc/crt1.c @@ -43,6 +43,7 @@ #endif #include <stdlib.h> +#include "libc_private.h" #include "crtbrand.c" struct Struct_Obj_Entry; @@ -63,7 +64,7 @@ extern int etext; #endif char **environ; -char *__progname = ""; +const char *__progname = ""; struct ps_strings *__ps_strings; /* The entry function. @@ -80,11 +81,11 @@ _start(argc, argv, envp, obj, cleanup, ps_strings) struct ps_strings *ps_strings; /* BSD extension */ { char *namep; + const char *s; environ = envp; if (argc > 0 && argv[0] != NULL) { - char *s; __progname = argv[0]; for (s = __progname; *s != '\0'; s++) if (*s == '/') diff --git a/lib/csu/sparc64/Makefile b/lib/csu/sparc64/Makefile index 566c5d9..5985c8c 100644 --- a/lib/csu/sparc64/Makefile +++ b/lib/csu/sparc64/Makefile @@ -5,7 +5,8 @@ SRCS= crt1.c crti.S crtn.S OBJS= ${SRCS:N*.h:R:S/$/.o/g} OBJS+= gcrt1.o -CFLAGS+= -I${.CURDIR}/../common +CFLAGS+= -I${.CURDIR}/../common \ + -I${.CURDIR}/../../libc/include NOMAN= true NOPIC= true NOPROFILE= true diff --git a/lib/csu/sparc64/crt1.c b/lib/csu/sparc64/crt1.c index 0c20383..99a63c8 100644 --- a/lib/csu/sparc64/crt1.c +++ b/lib/csu/sparc64/crt1.c @@ -34,6 +34,7 @@ #endif #include <stdlib.h> +#include "libc_private.h" #include "crtbrand.c" struct Struct_Obj_Entry; @@ -55,7 +56,7 @@ extern int etext; #endif char **environ; -char *__progname = ""; +const char *__progname = ""; /* The entry function. */ /* @@ -77,6 +78,7 @@ _start(char **ap, int argc; char **argv; char **env; + const char *s; #if 0 void (*term)(void); @@ -91,7 +93,6 @@ _start(char **ap, env = ap + 2 + argc; environ = env; if (argc > 0 && argv[0] != NULL) { - char *s; __progname = argv[0]; for (s = __progname; *s != '\0'; s++) if (*s == '/') |