Module Name: src
Committed By: he
Date: Fri Aug 21 08:42:02 UTC 2009
Modified Files:
src/include: nlist.h
src/lib/libc/gen: nlist_coff.c nlist_ecoff.c nlist_elf32.c
nlist_private.h
Log Message:
Introduce a new accessor macro N_NAME() to access the n_name field
in struct nlist, since it's accessed differently depending on
whether we do a.out or not. Use this macro as appropriate in the
nlist* functions.
Also replace some includes of <a.out.h> with <nlist.h>, to fix build
problem for mips.
To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/include/nlist.h
cvs rdiff -u -r1.7 -r1.8 src/lib/libc/gen/nlist_coff.c
cvs rdiff -u -r1.17 -r1.18 src/lib/libc/gen/nlist_ecoff.c
cvs rdiff -u -r1.30 -r1.31 src/lib/libc/gen/nlist_elf32.c
cvs rdiff -u -r1.18 -r1.19 src/lib/libc/gen/nlist_private.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/include/nlist.h
diff -u src/include/nlist.h:1.13 src/include/nlist.h:1.14
--- src/include/nlist.h:1.13 Sat Feb 26 21:16:35 2005
+++ src/include/nlist.h Fri Aug 21 08:42:02 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: nlist.h,v 1.13 2005/02/26 21:16:35 dsl Exp $ */
+/* $NetBSD: nlist.h,v 1.14 2009/08/21 08:42:02 he Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -51,8 +51,10 @@
__aconst char *n_name; /* symbol name (in memory) */
long n_strx; /* file string table offset (on disk) */
} n_un;
+# define N_NAME(nlp) ((nlp)->n_un.n_name)
#else
const char *n_name; /* symbol name (in memory) */
+# define N_NAME(nlp) ((nlp)->n_name)
#endif
#define N_UNDF 0x00 /* undefined */
Index: src/lib/libc/gen/nlist_coff.c
diff -u src/lib/libc/gen/nlist_coff.c:1.7 src/lib/libc/gen/nlist_coff.c:1.8
--- src/lib/libc/gen/nlist_coff.c:1.7 Mon Feb 16 10:40:45 2009
+++ src/lib/libc/gen/nlist_coff.c Fri Aug 21 08:42:02 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: nlist_coff.c,v 1.7 2009/02/16 10:40:45 lukem Exp $ */
+/* $NetBSD: nlist_coff.c,v 1.8 2009/08/21 08:42:02 he Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou
@@ -36,7 +36,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: nlist_coff.c,v 1.7 2009/02/16 10:40:45 lukem Exp $");
+__RCSID("$NetBSD: nlist_coff.c,v 1.8 2009/08/21 08:42:02 he Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -50,7 +50,7 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
-#include <a.out.h> /* for 'struct nlist' declaration */
+#include <nlist.h>
#include "nlist_private.h"
#ifdef NLIST_COFF
@@ -151,7 +151,7 @@
for (i = 0; i < nesyms; i++) {
char *symtabname;
- char *nlistname;
+ const char *nlistname;
struct coff_extsym esym;
char name[10];
@@ -171,7 +171,7 @@
continue;
for (p = list; !ISLAST(p); p++) {
- nlistname = p->n_un.n_name;
+ nlistname = N_NAME(p);
if (!strcmp(symtabname, nlistname)) {
/*
* Translate (roughly) from COFF to nlist
Index: src/lib/libc/gen/nlist_ecoff.c
diff -u src/lib/libc/gen/nlist_ecoff.c:1.17 src/lib/libc/gen/nlist_ecoff.c:1.18
--- src/lib/libc/gen/nlist_ecoff.c:1.17 Mon Feb 16 10:40:45 2009
+++ src/lib/libc/gen/nlist_ecoff.c Fri Aug 21 08:42:02 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: nlist_ecoff.c,v 1.17 2009/02/16 10:40:45 lukem Exp $ */
+/* $NetBSD: nlist_ecoff.c,v 1.18 2009/08/21 08:42:02 he Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou
@@ -36,7 +36,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: nlist_ecoff.c,v 1.17 2009/02/16 10:40:45 lukem Exp $");
+__RCSID("$NetBSD: nlist_ecoff.c,v 1.18 2009/08/21 08:42:02 he Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -50,7 +50,7 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
-#include <a.out.h> /* for 'struct nlist' declaration */
+#include <nlist.h>
#include "nlist_private.h"
#ifdef NLIST_ECOFF
@@ -151,11 +151,11 @@
for (i = 0; i < nesyms; i++) {
for (p = list; !ISLAST(p); p++) {
- char *nlistname;
+ const char *nlistname;
char *symtabname;
/* This may be incorrect */
- nlistname = p->n_un.n_name;
+ nlistname = N_NAME(p);
if (*nlistname == '_')
nlistname++;
Index: src/lib/libc/gen/nlist_elf32.c
diff -u src/lib/libc/gen/nlist_elf32.c:1.30 src/lib/libc/gen/nlist_elf32.c:1.31
--- src/lib/libc/gen/nlist_elf32.c:1.30 Mon Feb 16 10:40:45 2009
+++ src/lib/libc/gen/nlist_elf32.c Fri Aug 21 08:42:02 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: nlist_elf32.c,v 1.30 2009/02/16 10:40:45 lukem Exp $ */
+/* $NetBSD: nlist_elf32.c,v 1.31 2009/08/21 08:42:02 he Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou
@@ -36,7 +36,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: nlist_elf32.c,v 1.30 2009/02/16 10:40:45 lukem Exp $");
+__RCSID("$NetBSD: nlist_elf32.c,v 1.31 2009/08/21 08:42:02 he Exp $");
#endif /* LIBC_SCCS and not lint */
/* If not included by nlist_elf64.c, ELFSIZE won't be defined. */
@@ -57,7 +57,7 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
-#include <a.out.h> /* for 'struct nlist' declaration */
+#include <nlist.h>
#include "nlist_private.h"
#if defined(NLIST_ELF32) || defined(NLIST_ELF64)
@@ -150,7 +150,7 @@
p->n_other = 0;
p->n_desc = 0;
- nlistname = p->n_un.n_name;
+ nlistname = N_NAME(p);
if (*nlistname == '_')
nlistname++;
@@ -258,7 +258,7 @@
char *symtabname;
/* This may be incorrect */
- nlistname = p->n_un.n_name;
+ nlistname = N_NAME(p);
if (*nlistname == '_')
nlistname++;
Index: src/lib/libc/gen/nlist_private.h
diff -u src/lib/libc/gen/nlist_private.h:1.18 src/lib/libc/gen/nlist_private.h:1.19
--- src/lib/libc/gen/nlist_private.h:1.18 Sun Aug 16 03:56:26 2009
+++ src/lib/libc/gen/nlist_private.h Fri Aug 21 08:42:02 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: nlist_private.h,v 1.18 2009/08/16 03:56:26 matt Exp $ */
+/* $NetBSD: nlist_private.h,v 1.19 2009/08/21 08:42:02 he Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou
@@ -66,7 +66,9 @@
/* #define NLIST_ELF64 */
#endif
-#define ISLAST(p) (p->n_un.n_name == 0 || p->n_un.n_name[0] == 0)
+#define ISLAST(p) (N_NAME(p) == 0 || N_NAME(p)[0] == 0)
+
+struct nlist;
#ifdef NLIST_AOUT
int __fdnlist_aout __P((int, struct nlist *));