From a2c7ca15a5609ea230771fc418511a3b8db16bd1 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Sat, 25 Mar 2023 21:15:46 +1030 Subject: 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. --- ld/pe-dll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ld') diff --git a/ld/pe-dll.c b/ld/pe-dll.c index 7e0d886cfb9..ab13e3bb94a 100644 --- a/ld/pe-dll.c +++ b/ld/pe-dll.c @@ -1611,7 +1611,7 @@ generate_reloc (bfd *abfd, struct bfd_link_info *info) if (h->symbol_class != C_NT_WEAK || h->numaux != 1) continue; h2 = h->auxbfd->tdata.coff_obj_data->sym_hashes - [h->aux->x_sym.x_tagndx.l]; + [h->aux->x_sym.x_tagndx.u32]; /* We don't want a base reloc if the aux sym is not found, undefined, or if it is the constant ABS zero default value. (We broaden that slightly by -- cgit v1.2.1