james@bigtex.cactus.org (James Van Artsdalen) (06/05/89)
There appears to be a bug in the way that gcc outputs sdb debugging
information. In addition, there may also be a bug in the way gdb
3.1.2 reads the COFF symbol table. This is i386-sysv gcc & gdb,
without GNU as.
Here's the source file:
-----
struct syment
{
union
{
char _n_name[8]; /* old COFF version */
struct
{
long _n_zeroes; /* new == 0 */
long _n_offset; /* offset into string table */
} _n_n;
char *_n_nptr[2]; /* allows for overlaying */
} _n;
long n_value; /* value of symbol */
short n_scnum; /* section number */
unsigned short n_type; /* type and derived type */
char n_sclass; /* storage class */
char n_numaux; /* number of aux. entries */
};
struct syment a;
main()
{
}
-----
Here's a short session with that source, using both cc and gcc.
/usr/local/src/binutils> gcc -g a.c -o a
/usr/local/src/binutils> gdb -q a
Reading symbol data from /usr/local/src/binutils/a...done.
(gdb) whatis a
type = struct syment {
union {<no data fields>
} _n;
int n_value;
short n_scnum;
unsigned short n_type;
char n_sclass;
char n_numaux;
}
(gdb) q
/usr/local/src/binutils> cc -g a.c -o a
/usr/local/src/binutils> gdb -q a
Reading symbol data from /usr/local/src/binutils/a...done.
(gdb) whatis a
type = struct syment {
union .1fake _n;
int n_value;
short n_scnum;
unsigned short n_type;
char n_sclass;
char n_numaux;
}
Here's the .s output from cc:
-----
.file "a.c"
.version "02.01"
.data
.text
.def .0fake; .scl 10; .type 010; .size 8; .endef
.def _n_zeroes; .val 0; .scl 8; .type 04; .endef
.def _n_offset; .val 4; .scl 8; .type 04; .endef
.def .eos; .val 8; .scl 102; .tag .0fake; .size 8; .endef
.data
.text
.def .1fake; .scl 12; .type 011; .size 8; .endef
.def _n_name; .val 0; .scl 11; .type 062; .dim 8; .size 8; .endef
.def _n_n; .val 0; .scl 11; .type 010; .tag .0fake; .size 8; .endef
.def _n_nptr; .val 0; .scl 11; .type 0162; .dim 2; .size 8; .endef
.def .eos; .val 8; .scl 102; .tag .1fake; .size 8; .endef
.data
.text
.def syment; .scl 10; .type 010; .size 20; .endef
.def _n; .val 0; .scl 8; .type 011; .tag .1fake; .size 8; .endef
.def n_value; .val 8; .scl 8; .type 04; .endef
.def n_scnum; .val 12; .scl 8; .type 03; .endef
.def n_type; .val 14; .scl 8; .type 015; .endef
.def n_sclass; .val 16; .scl 8; .type 02; .endef
.def n_numaux; .val 17; .scl 8; .type 02; .endef
.def .eos; .val 20; .scl 102; .tag syment; .size 20; .endef
.data
.def a; .val a; .scl 2; .type 010; .tag syment; .size 20; .endef
.comm a,20
.text
.align 4
.def main; .val main; .scl 2; .type 044; .endef
.globl main
main:
jmp .L15
.L14:
.ln 1
.def .bf; .val .; .scl 101; .line 23; .endef
/REGAL 0 NODBL
.L13:
.def .ef; .val .; .scl 101; .line 2; .endef
.ln 2
leave
ret
.L15:
pushl %ebp
movl %esp,%ebp
jmp .L14
.def main; .val .; .scl -1; .endef
.data
-----
Here's the .s output from gcc:
-----
.file "a.c"
gcc_compiled.:
.text
.def syment; .scl 10; .type 010; .size 20; .endef
.def _n; .val 0; .scl 8; .size 8; .type 011; .endef
.def n_value; .val 8; .scl 8; .type 04; .endef
.def n_scnum; .val 12; .scl 8; .type 03; .endef
.def n_type; .val 14; .scl 8; .type 015; .endef
.def n_sclass; .val 16; .scl 8; .type 02; .endef
.def n_numaux; .val 17; .scl 8; .type 02; .endef
.def .eos; .val 20; .scl 102; .tag syment; .size 20; .endef
.align 4
.def .0fake; .scl 12; .type 011; .size 8; .endef
.def _n_name; .val 0; .scl 11; .dim 8; .size 8; .type 062; .endef
.def _n_n; .val 0; .scl 11; .size 8; .type 010; .endef
.def _n_nptr; .val 0; .scl 11; .dim 2; .size 8; .type 0162; .endef
.def .eos; .val 8; .scl 102; .tag .0fake; .size 8; .endef
.def .1fake; .scl 10; .type 010; .size 8; .endef
.def _n_zeroes; .val 0; .scl 8; .type 04; .endef
.def _n_offset; .val 4; .scl 8; .type 04; .endef
.def .eos; .val 8; .scl 102; .tag .1fake; .size 8; .endef
.def main; .val main; .scl 2; .type 044; .endef
.globl main
main:
.ln 1
pushl %ebp
movl %esp,%ebp
.def .bf; .val .; .scl 101; .line 23; .endef
.ln 2
.L1:
.def .ef; .val .; .scl 101; .line 2; .endef
leave
ret
.def main; .val .; .scl -1; .endef
.def a; .val a; .scl 2; .tag syment; .size 20; .type 010; .endef
.comm a,20
-----
"printsyms" for the cc compiled version yields
Symtab for file _globals_
Line table:
Blockvector:
block #000 (object 0x40bdf0) [0x0..0x11c]
int environ; static at 0x40035c,
struct syment {
union .1fake _n;
int n_value;
short n_scnum;
unsigned short n_type;
char n_sclass;
char n_numaux;
} a; static at 0x40078c,
int _ctype; static at 0x400360,
int errno; static at 0x400588,
int __dbargs; static at 0x40058c,
block #001 (object 0x40bdd8) [0x0..0x11c] (under 0x40bdf0)
Symtab for file ctype.c
Line table:
Blockvector:
block #000 (object 0x40bd28) [0x128..0x1f0]
block #001 (object 0x40bd0c) [0x128..0x1f0] (under 0x40bd28)
int first_call; static at 0x400564,
Symtab for file a.c
Line table:
line 23 at 11e
line 24 at 11e
Blockvector:
block #000 (object 0x40bcc0) [0x11c..0x128]
int main(); block (object 0x40bc84) starting at 0x11c,
block #001 (object 0x40bc9c) [0x11c..0x128] (under 0x40bcc0)
struct .0fake {
int _n_zeroes;
int _n_offset;
};
union .1fake {
char _n_name[8];
struct .0fake _n_n;
char *_n_nptr[2];
};
struct syment {
union .1fake _n;
int n_value;
short n_scnum;
unsigned short n_type;
char n_sclass;
char n_numaux;
};
block #002 (object 0x40bc84) [0x11c..0x125] (under 0x40bc9c) main
"printsyms" for the gcc compiled version yields
Blockvector:
block #000 (object 0x40bd68) [0x11c..0x124]
int main(); block (object 0x40bd2c) starting at 0x11c,
block #001 (object 0x40bd44) [0x11c..0x124] (under 0x40bd68)
struct syment {
union {<no data fields>
} _n;
int n_value;
short n_scnum;
unsigned short n_type;
char n_sclass;
char n_numaux;
};
union .0fake {
char _n_name[8];
struct {<no data fields>
} _n_n;
char *_n_nptr[2];
};
struct .1fake {
int _n_zeroes;
int _n_offset;
};
block #002 (object 0x40bd2c) [0x11c..0x121] (under 0x40bd44) main
--
James R. Van Artsdalen james@bigtex.cactus.org "Live Free or Die"
Dell Computer Co 9505 Arboretum Blvd Austin TX 78759 512-338-8789