Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Introduce a new accessor macro N_NAME() to access the n_name...



details:   https://anonhg.NetBSD.org/src/rev/f52579befef9
branches:  trunk
changeset: 746843:f52579befef9
user:      he <he%NetBSD.org@localhost>
date:      Fri Aug 21 08:42:02 2009 +0000

description:
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.

diffstat:

 include/nlist.h              |   4 +++-
 lib/libc/gen/nlist_coff.c    |  10 +++++-----
 lib/libc/gen/nlist_ecoff.c   |  10 +++++-----
 lib/libc/gen/nlist_elf32.c   |  10 +++++-----
 lib/libc/gen/nlist_private.h |   6 ++++--
 5 files changed, 22 insertions(+), 18 deletions(-)

diffs (171 lines):

diff -r 72801dad3d96 -r f52579befef9 include/nlist.h
--- a/include/nlist.h   Fri Aug 21 08:20:30 2009 +0000
+++ b/include/nlist.h   Fri Aug 21 08:42:02 2009 +0000
@@ -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 */
diff -r 72801dad3d96 -r f52579befef9 lib/libc/gen/nlist_coff.c
--- a/lib/libc/gen/nlist_coff.c Fri Aug 21 08:20:30 2009 +0000
+++ b/lib/libc/gen/nlist_coff.c Fri Aug 21 08:42:02 2009 +0000
@@ -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
diff -r 72801dad3d96 -r f52579befef9 lib/libc/gen/nlist_ecoff.c
--- a/lib/libc/gen/nlist_ecoff.c        Fri Aug 21 08:20:30 2009 +0000
+++ b/lib/libc/gen/nlist_ecoff.c        Fri Aug 21 08:42:02 2009 +0000
@@ -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++;
 
diff -r 72801dad3d96 -r f52579befef9 lib/libc/gen/nlist_elf32.c
--- a/lib/libc/gen/nlist_elf32.c        Fri Aug 21 08:20:30 2009 +0000
+++ b/lib/libc/gen/nlist_elf32.c        Fri Aug 21 08:42:02 2009 +0000
@@ -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++;
 
diff -r 72801dad3d96 -r f52579befef9 lib/libc/gen/nlist_private.h
--- a/lib/libc/gen/nlist_private.h      Fri Aug 21 08:20:30 2009 +0000
+++ b/lib/libc/gen/nlist_private.h      Fri Aug 21 08:42:02 2009 +0000
@@ -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 *));



Home | Main Index | Thread Index | Old Index