aboutsummaryrefslogtreecommitdiff
path: root/gdb/coffread.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2023-03-25 21:15:46 +1030
committerAlan Modra <amodra@gmail.com>2023-03-27 21:58:46 +1030
commita2c7ca15a5609ea230771fc418511a3b8db16bd1 (patch)
tree3e5b9c33b8f90ce7b8afd8621ca7cdf5ea35caff /gdb/coffread.c
parent3bb1480e2a85de6850863d245e7b6da03a3887f7 (diff)
downloadgdb-a2c7ca15a5609ea230771fc418511a3b8db16bd1.zip
gdb-a2c7ca15a5609ea230771fc418511a3b8db16bd1.tar.gz
gdb-a2c7ca15a5609ea230771fc418511a3b8db16bd1.tar.bz2
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.
Diffstat (limited to 'gdb/coffread.c')
-rw-r--r--gdb/coffread.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/gdb/coffread.c b/gdb/coffread.c
index e993b17..8e88aac 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1767,7 +1767,7 @@ decode_type (struct coff_symbol *cs, unsigned int c_type,
/* Define an array type. */
/* auxent refers to array, not base type. */
- if (aux->x_sym.x_tagndx.l == 0)
+ if (aux->x_sym.x_tagndx.u32 == 0)
cs->c_naux = 0;
/* Shift the indices down. */
@@ -1794,14 +1794,14 @@ decode_type (struct coff_symbol *cs, unsigned int c_type,
unions, and enums, so we have to check the c_sclass field. SCO
3.2v4 cc gets confused with pointers to pointers to defined
structs, and generates negative x_tagndx fields. */
- if (cs->c_naux > 0 && aux->x_sym.x_tagndx.l != 0)
+ if (cs->c_naux > 0 && aux->x_sym.x_tagndx.u32 != 0)
{
if (cs->c_sclass != C_STRTAG
&& cs->c_sclass != C_UNTAG
&& cs->c_sclass != C_ENTAG
- && aux->x_sym.x_tagndx.l >= 0)
+ && (int32_t) aux->x_sym.x_tagndx.u32 >= 0)
{
- type = coff_alloc_type (aux->x_sym.x_tagndx.l);
+ type = coff_alloc_type (aux->x_sym.x_tagndx.u32);
return type;
}
else
@@ -1824,7 +1824,7 @@ decode_function_type (struct coff_symbol *cs,
union internal_auxent *aux,
struct objfile *objfile)
{
- if (aux->x_sym.x_tagndx.l == 0)
+ if (aux->x_sym.x_tagndx.u32 == 0)
cs->c_naux = 0; /* auxent refers to function, not base
type. */
@@ -1896,7 +1896,7 @@ decode_base_type (struct coff_symbol *cs,
{
type = coff_read_struct_type (cs->c_symnum,
aux->x_sym.x_misc.x_lnsz.x_size,
- aux->x_sym.x_fcnary.x_fcn.x_endndx.l,
+ aux->x_sym.x_fcnary.x_fcn.x_endndx.u32,
objfile);
}
return type;
@@ -1916,7 +1916,7 @@ decode_base_type (struct coff_symbol *cs,
{
type = coff_read_struct_type (cs->c_symnum,
aux->x_sym.x_misc.x_lnsz.x_size,
- aux->x_sym.x_fcnary.x_fcn.x_endndx.l,
+ aux->x_sym.x_fcnary.x_fcn.x_endndx.u32,
objfile);
}
type->set_code (TYPE_CODE_UNION);
@@ -1937,7 +1937,7 @@ decode_base_type (struct coff_symbol *cs,
{
type = coff_read_enum_type (cs->c_symnum,
aux->x_sym.x_misc.x_lnsz.x_size,
- aux->x_sym.x_fcnary.x_fcn.x_endndx.l,
+ aux->x_sym.x_fcnary.x_fcn.x_endndx.u32,
objfile);
}
return type;