summaryrefslogtreecommitdiff
path: root/bfd/cofflink.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/cofflink.c
parent3bb1480e2a85de6850863d245e7b6da03a3887f7 (diff)
downloadbinutils-gdb-a2c7ca15a5609ea230771fc418511a3b8db16bd1.tar.gz
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/cofflink.c')
-rw-r--r--bfd/cofflink.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/bfd/cofflink.c b/bfd/cofflink.c
index 0de2e0bc391..9baec2fc712 100644
--- a/bfd/cofflink.c
+++ b/bfd/cofflink.c
@@ -1617,7 +1617,7 @@ _bfd_coff_link_input_bfd (struct coff_final_link_info *flaginfo, bfd *input_bfd)
islp = isymp + 2;
esl = esym + 2 * isymesz;
eslend = ((bfd_byte *) obj_coff_external_syms (input_bfd)
- + aux.x_sym.x_fcnary.x_fcn.x_endndx.l * isymesz);
+ + aux.x_sym.x_fcnary.x_fcn.x_endndx.u32 * isymesz);
while (esl < eslend)
{
const char *elename;
@@ -1656,7 +1656,7 @@ _bfd_coff_link_input_bfd (struct coff_final_link_info *flaginfo, bfd *input_bfd)
bfd_coff_swap_aux_in (input_bfd, (esl + isymesz),
islp->n_type, islp->n_sclass, 0,
islp->n_numaux, &eleaux);
- indx = eleaux.x_sym.x_tagndx.l;
+ indx = eleaux.x_sym.x_tagndx.u32;
/* FIXME: If this tagndx entry refers to a symbol
defined later in this file, we just ignore it.
@@ -1997,7 +1997,7 @@ _bfd_coff_link_input_bfd (struct coff_final_link_info *flaginfo, bfd *input_bfd)
|| isymp->n_sclass == C_BLOCK
|| isymp->n_sclass == C_FCN)
{
- indx = auxp->x_sym.x_fcnary.x_fcn.x_endndx.l;
+ indx = auxp->x_sym.x_fcnary.x_fcn.x_endndx.u32;
if (indx > 0
&& indx < obj_raw_syment_count (input_bfd))
{
@@ -2014,20 +2014,20 @@ _bfd_coff_link_input_bfd (struct coff_final_link_info *flaginfo, bfd *input_bfd)
indx = output_index;
else
indx = flaginfo->sym_indices[indx];
- auxp->x_sym.x_fcnary.x_fcn.x_endndx.l = indx;
+ auxp->x_sym.x_fcnary.x_fcn.x_endndx.u32 = indx;
}
}
- indx = auxp->x_sym.x_tagndx.l;
+ indx = auxp->x_sym.x_tagndx.u32;
if (indx > 0 && indx < obj_raw_syment_count (input_bfd))
{
long symindx;
symindx = flaginfo->sym_indices[indx];
if (symindx < 0)
- auxp->x_sym.x_tagndx.l = 0;
+ auxp->x_sym.x_tagndx.u32 = 0;
else
- auxp->x_sym.x_tagndx.l = symindx;
+ auxp->x_sym.x_tagndx.u32 = symindx;
}
/* The .bf symbols are supposed to be linked through
@@ -2045,7 +2045,7 @@ _bfd_coff_link_input_bfd (struct coff_final_link_info *flaginfo, bfd *input_bfd)
{
if (flaginfo->last_bf_index != -1)
{
- flaginfo->last_bf.x_sym.x_fcnary.x_fcn.x_endndx.l =
+ flaginfo->last_bf.x_sym.x_fcnary.x_fcn.x_endndx.u32 =
*indexp;
if ((bfd_size_type) flaginfo->last_bf_index
@@ -2093,7 +2093,7 @@ _bfd_coff_link_input_bfd (struct coff_final_link_info *flaginfo, bfd *input_bfd)
}
}
- if (auxp->x_sym.x_fcnary.x_fcn.x_endndx.l != 0)
+ if (auxp->x_sym.x_fcnary.x_fcn.x_endndx.u32 != 0)
flaginfo->last_bf_index = -1;
else
{
@@ -3002,8 +3002,8 @@ _bfd_coff_generic_relocate_section (bfd *output_bfd,
external causes the library member to be linked.
See also linker.c: generic_link_check_archive_element. */
struct coff_link_hash_entry *h2 =
- h->auxbfd->tdata.coff_obj_data->sym_hashes[
- h->aux->x_sym.x_tagndx.l];
+ h->auxbfd->tdata.coff_obj_data->sym_hashes
+ [h->aux->x_sym.x_tagndx.u32];
if (!h2 || h2->root.type == bfd_link_hash_undefined)
{