Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!munnari!mimir!pic From: pic@mimir.dmt.oz (Peter Corke) Newsgroups: comp.unix.wizards Subject: a.out symbol table problems Message-ID: <774@mimir.dmt.oz> Date: Mon, 8-Dec-86 00:50:12 EST Article-I.D.: mimir.774 Posted: Mon Dec 8 00:50:12 1986 Date-Received: Tue, 9-Dec-86 11:12:49 EST Organization: CSIRO Manufacturing Technology, Melbourne Lines: 61 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 #include 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