mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-26 17:18:55 +00:00
Use stdint types in coff internal_auxent
long is a poor choice of type to store 32-bit values read from objects files by H_GET_32. H_GET_32 doesn't sign extend so tests like that in gdb/coffread.c for "negative" values won't work if long is larger than 32 bits. If long is 32-bit then code needs to be careful to not accidentally index negative array elements. (I'd rather see a segfault on an unmapped 4G array index than silently reading bogus data.) long is also a poor choice for x_sect.s_scnlen, which might have 64-bit values. It's better to use unsigned exact width types to avoid surprises. I decided to change the field names too, which makes most of this patch simply renaming. Besides that there are a few places where casts are no longer needed, and where printf format strings or tests need adjusting. include/ * coff/internal.h (union internal_auxent): Use unsigned stdint types. Rename l fields to u32 and u64 as appropriate. bfd/ * coff-bfd.c, * coff-rs6000.c, * coff64-rs6000.c, * coffcode.h, * coffgen.c, * cofflink.c, * coffswap.h, * peXXigen.c, * xcofflink.c: Adjust to suit internal_auxent changes. binutils/ * rdcoff.c: Adjust to suit internal_auxent changes. gas/ * config/obj-coff.h, * config/tc-ppc.c: Adjust to suit internal_auxent changes. gdb/ * coffread.c, * xcoffread.c: Adjust to suit internal_auxent changes. ld/ * pe-dll.c: Adjust to suit internal_auxent changes.
This commit is contained in:
@@ -176,13 +176,13 @@ parse_coff_type (bfd *abfd, struct coff_symbols *symbols,
|
||||
return type;
|
||||
}
|
||||
|
||||
if (pauxent != NULL && pauxent->x_sym.x_tagndx.l > 0)
|
||||
if (pauxent != NULL && (int32_t) pauxent->x_sym.x_tagndx.u32 > 0)
|
||||
{
|
||||
debug_type *slot;
|
||||
|
||||
/* This is a reference to an existing type. FIXME: gdb checks
|
||||
that the class is not C_STRTAG, nor C_UNTAG, nor C_ENTAG. */
|
||||
slot = coff_get_slot (types, pauxent->x_sym.x_tagndx.l);
|
||||
slot = coff_get_slot (types, pauxent->x_sym.x_tagndx.u32);
|
||||
if (*slot != DEBUG_TYPE_NULL)
|
||||
return *slot;
|
||||
else
|
||||
@@ -328,7 +328,7 @@ parse_coff_struct_type (bfd *abfd, struct coff_symbols *symbols,
|
||||
int count;
|
||||
bool done;
|
||||
|
||||
symend = pauxent->x_sym.x_fcnary.x_fcn.x_endndx.l;
|
||||
symend = pauxent->x_sym.x_fcnary.x_fcn.x_endndx.u32;
|
||||
|
||||
alloc = 10;
|
||||
fields = (debug_field *) xmalloc (alloc * sizeof *fields);
|
||||
@@ -438,7 +438,7 @@ parse_coff_enum_type (bfd *abfd, struct coff_symbols *symbols,
|
||||
int count;
|
||||
bool done;
|
||||
|
||||
symend = pauxent->x_sym.x_fcnary.x_fcn.x_endndx.l;
|
||||
symend = pauxent->x_sym.x_fcnary.x_fcn.x_endndx.u32;
|
||||
|
||||
alloc = 10;
|
||||
names = (const char **) xmalloc (alloc * sizeof *names);
|
||||
|
||||
Reference in New Issue
Block a user