Skip to content

Commit

Permalink
crt1.o: provide symbol definition of __progname
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jrmarino committed Oct 15, 2011
1 parent 1fabed7 commit 2f81c0d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
3 changes: 2 additions & 1 deletion lib/csu/i386/Makefile.csu
Expand Up @@ -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

Expand Down
16 changes: 10 additions & 6 deletions lib/csu/i386/crt1_c.c
Expand Up @@ -32,8 +32,13 @@
#include <machine/tls.h>
#include <stddef.h>
#include <stdlib.h>

#include "libc_private.h"
#include "crtbrand.c"

extern int _DYNAMIC;
#pragma weak _DYNAMIC

typedef void (*fptr)(void);

extern void _fini(void);
Expand All @@ -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 == '/')
Expand Down
3 changes: 1 addition & 2 deletions lib/libc/gen/getlogin.c
Expand Up @@ -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
*/
Expand All @@ -47,7 +46,7 @@
#include <pthread.h>
#include "un-namespace.h"

#include <libc_private.h>
#include "libc_private.h"

#define THREAD_LOCK() if (__isthreaded) _pthread_mutex_lock(&logname_mutex)
#define THREAD_UNLOCK() if (__isthreaded) _pthread_mutex_unlock(&logname_mutex)
Expand Down
3 changes: 1 addition & 2 deletions 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 <stdlib.h>
#include <string.h>

extern const char *__progname;
#include "libc_private.h"

void
setprogname(const char *progname)
Expand Down
2 changes: 1 addition & 1 deletion lib/libc/include/libc_private.h
Expand Up @@ -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().
Expand Down

0 comments on commit 2f81c0d

Please sign in to comment.