aboutsummaryrefslogtreecommitdiff
path: root/bfd/coff64-rs6000.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 /bfd/coff64-rs6000.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 'bfd/coff64-rs6000.c')
-rw-r--r--bfd/coff64-rs6000.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c
index e3a5da3..f8a0bde 100644
--- a/bfd/coff64-rs6000.c
+++ b/bfd/coff64-rs6000.c
@@ -411,10 +411,10 @@ _bfd_xcoff64_swap_aux_in (bfd *abfd, void *ext1, int type ATTRIBUTE_UNUSED,
if (auxtype != _AUX_CSECT)
goto error;
- bfd_vma h = H_GET_S32 (abfd, ext->x_csect.x_scnlen_hi);
+ bfd_vma h = H_GET_32 (abfd, ext->x_csect.x_scnlen_hi);
bfd_vma l = H_GET_32 (abfd, ext->x_csect.x_scnlen_lo);
- in->x_csect.x_scnlen.l = h << 32 | (l & 0xffffffff);
+ in->x_csect.x_scnlen.u64 = h << 32 | (l & 0xffffffff);
in->x_csect.x_parmhash = H_GET_32 (abfd, ext->x_csect.x_parmhash);
in->x_csect.x_snhash = H_GET_16 (abfd, ext->x_csect.x_snhash);
@@ -436,7 +436,7 @@ _bfd_xcoff64_swap_aux_in (bfd *abfd, void *ext1, int type ATTRIBUTE_UNUSED,
= H_GET_64 (abfd, ext->x_fcn.x_lnnoptr);
in->x_sym.x_misc.x_fsize
= H_GET_32 (abfd, ext->x_fcn.x_fsize);
- in->x_sym.x_fcnary.x_fcn.x_endndx.l
+ in->x_sym.x_fcnary.x_fcn.x_endndx.u32
= H_GET_32 (abfd, ext->x_fcn.x_endndx);
}
break;
@@ -524,9 +524,9 @@ _bfd_xcoff64_swap_aux_out (bfd *abfd, void *inp, int type ATTRIBUTE_UNUSED,
{
bfd_vma temp;
- temp = in->x_csect.x_scnlen.l & 0xffffffff;
+ temp = in->x_csect.x_scnlen.u64 & 0xffffffff;
H_PUT_32 (abfd, temp, ext->x_csect.x_scnlen_lo);
- temp = in->x_csect.x_scnlen.l >> 32;
+ temp = in->x_csect.x_scnlen.u64 >> 32;
H_PUT_32 (abfd, temp, ext->x_csect.x_scnlen_hi);
H_PUT_32 (abfd, in->x_csect.x_parmhash, ext->x_csect.x_parmhash);
H_PUT_16 (abfd, in->x_csect.x_snhash, ext->x_csect.x_snhash);
@@ -542,7 +542,7 @@ _bfd_xcoff64_swap_aux_out (bfd *abfd, void *inp, int type ATTRIBUTE_UNUSED,
H_PUT_64 (abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr,
ext->x_fcn.x_lnnoptr);
H_PUT_32 (abfd, in->x_sym.x_misc.x_fsize, ext->x_fcn.x_fsize);
- H_PUT_32 (abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l,
+ H_PUT_32 (abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.u32,
ext->x_fcn.x_endndx);
H_PUT_8 (abfd, _AUX_FCN, ext->x_csect.x_auxtype);
}
@@ -2265,7 +2265,7 @@ xcoff64_generate_rtinit (bfd *abfd, const char *init, const char *fini,
syment.n_scnum = 2;
syment.n_sclass = C_HIDEXT;
syment.n_numaux = 1;
- auxent.x_csect.x_scnlen.l = data_buffer_size;
+ auxent.x_csect.x_scnlen.u64 = data_buffer_size;
auxent.x_csect.x_smtyp = 3 << 3 | XTY_SD;
auxent.x_csect.x_smclas = XMC_RW;
bfd_coff_swap_sym_out (abfd, &syment,