]> Cypherpunks repositories - gostls13.git/commitdiff
fix gotest by fixing nm -s to print in file order by storing a sequence number
authorRob Pike <r@golang.org>
Thu, 16 Apr 2009 04:57:55 +0000 (21:57 -0700)
committerRob Pike <r@golang.org>
Thu, 16 Apr 2009 04:57:55 +0000 (21:57 -0700)
as the .6 file is read.   now tests will be run in file order.

R=rsc
DELTA=9  (6 added, 1 deleted, 2 changed)
OCL=27542
CL=27544

include/mach_amd64.h
src/cmd/nm/nm.c
src/libmach_amd64/obj.c

index 3ad0efcbb8a3f57cbac94eea9f81f9de54c17317..30cd4dcd0e408e9842a05006c43dc3bdf9e630a9 100644 (file)
@@ -85,6 +85,7 @@ struct        Sym
        char    type;
        char    *name;
        char *gotype;
+       int     sequence;       // order in file
 };
 /*
  * End of Plan 9 a.out.h
index 63c77bd921453c7f1964899696190cabedc06cbf..66748eef7cdb4907feb84205281fe778bcff14cc 100644 (file)
@@ -185,11 +185,13 @@ cmp(void *vs, void *vt)
 
        s = vs;
        t = vt;
-       if(nflag)
+       if(nflag)       // sort on address (numeric) order
                if((*s)->value < (*t)->value)
                        return -1;
                else
                        return (*s)->value > (*t)->value;
+       if(sflag)       // sort on file order (sequence)
+               return (*s)->sequence - (*t)->sequence;
        return strcmp((*s)->name, (*t)->name);
 }
 /*
@@ -298,8 +300,7 @@ printsyms(Sym **symptr, long nsym)
        char *cp;
        char path[512];
 
-       if(!sflag)
-               qsort(symptr, nsym, sizeof(*symptr), (void*)cmp);
+       qsort(symptr, nsym, sizeof(*symptr), (void*)cmp);
 
        wid = 0;
        for (i=0; i<nsym; i++) {
index 7a6e2045108877139f80ba94d034fd398f80afda..8bd138421bc6d0b552e4dc1879598549d5a0d282 100644 (file)
@@ -108,6 +108,8 @@ static      void    objreset(void);
 static void    objlookup(int, char *, int, uint);
 static void    objupdate(int, int);
 
+static int     sequence;
+
 int
 objtype(Biobuf *bp, char **name)
 {
@@ -295,6 +297,7 @@ objlookup(int id, char *name, int type, uint sig)
        sp->s.type = type;
        sp->s.sig = sig;
        sp->s.value = islocal(type) ? MAXOFF : 0;
+       sp->s.sequence = sequence++;
        names[id] = &sp->s;
        sp->next = hash[h];
        hash[h] = sp;