pic@mimir.dmt.oz (Peter Corke) (12/08/86)
I have been experimenting with the nlist(3) function to obtain the address and type of C global variables. nlist() returns a structure from the a.out file's symbol table, that contains the symbol's address, its segment (text, data, bss), and n_desc which I gather should have its type (double, int, short etc) encoded in bitfields (according to man 5 stab). However, the nlist() function returns nonsense for this field of the structure. If I "cc -S" the source, I see that the compiler is generating the .stabs directives with the correct values in all fields. It seems that after linking this field contains garbage. A small demo program is appended which prints out the field values returned. The variables f & g which are of the same type, have different n_desc values; 124 & 125 respectively. This effect occurs on a Vax/4.2bsd and a Sun 3.2 system. If anybody has any ideas please mail me at the address below. Thanks, Peter ----------------- cut here ---------------------------------------------- #include <stdio.h> #include <nlist.h> int i; float f, g; struct nlist n[] = { {"_i"}, {"_f"}, {"_g"}, {""} }; main(ac, av) int ac; char **av; { struct nlist *p = n; printf("nlist status %d\n", nlist(av[0], n)); while (p->n_name[0] != '\0') { printf("%s, typ %x, val %x, desc %x\n", p->n_name, p->n_type, p->n_value, p->n_desc ); p++; } } ----------------- cut here ---------------------------------------------- -- Peter Corke, PHONE: +61 (03)487-9259 CSIRO ACSNET:pic@mimir.dmt.oz Div. Manufacturing Technology ARPA: pic%mimir.dmt.oz@seismo.arpa Melbourne CSNET: pic@mimir.dmt.oz Australia. UUCP: {seismo,ukc,mcvax}!munnari!mimir.dmt!pic 3072 {decvax,pesnta,vax135}!mulga!mimir.dmt!pic
narayan@twg-ap.UUCP (Narayan Mohanram) (12/12/86)
Is there any programs that would sort an a.out (such as /unix) for
system V. Berkley used to have one called Symsort or Symorder.
nlist seems to take forever on system V machines. It could be
speeded up a great deal if the symbols were sorted, and the
often used ones put in front of the Symbol table.
--
Narayan Mohanram
Phone: 415-962 7170
ARPANET twg-ap!narayan@lll-tis-b.ARPA
Usenet {attunix, ihnp4}!amdahl!twg-ap!narayan
USnail The Wollongong Group
1129 San Antonio Road
Palo Alto, CA 94303. USA
=========================================================
|| If you can't lick it, try some whipped cream ||
=========================================================