diff options
author | Alan Modra <amodra@gmail.com> | 2023-03-25 21:15:46 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2023-03-27 21:58:46 +1030 |
commit | a2c7ca15a5609ea230771fc418511a3b8db16bd1 (patch) | |
tree | 3e5b9c33b8f90ce7b8afd8621ca7cdf5ea35caff /gas/config/tc-ppc.c | |
parent | 3bb1480e2a85de6850863d245e7b6da03a3887f7 (diff) | |
download | binutils-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 'gas/config/tc-ppc.c')
-rw-r--r-- | gas/config/tc-ppc.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c index a3af5f5e276..d25c751378d 100644 --- a/gas/config/tc-ppc.c +++ b/gas/config/tc-ppc.c @@ -6158,7 +6158,7 @@ ppc_frob_symbol (symbolS *sym) csectaux = &coffsymbol (symbol_get_bfdsym (within)) ->native[S_GET_NUMBER_AUXILIARY(within)].u.auxent; - SA_SET_SYM_FSIZE (sym, csectaux->x_csect.x_scnlen.l); + SA_SET_SYM_FSIZE (sym, csectaux->x_csect.x_scnlen.u64); } } else if (S_GET_STORAGE_CLASS (sym) == C_FCN @@ -6204,7 +6204,7 @@ ppc_frob_symbol (symbolS *sym) { /* This is the TOC table. */ know (strcmp (S_GET_NAME (sym), "TOC") == 0); - a->x_csect.x_scnlen.l = 0; + a->x_csect.x_scnlen.u64 = 0; a->x_csect.x_smtyp = (2 << 3) | XTY_SD; } else if (symbol_get_tc (sym)->subseg != 0) @@ -6212,13 +6212,13 @@ ppc_frob_symbol (symbolS *sym) /* This is a csect symbol. x_scnlen is the size of the csect. */ if (symbol_get_tc (sym)->next == (symbolS *) NULL) - a->x_csect.x_scnlen.l = (bfd_section_size (S_GET_SEGMENT (sym)) - - S_GET_VALUE (sym)); + a->x_csect.x_scnlen.u64 + = bfd_section_size (S_GET_SEGMENT (sym)) - S_GET_VALUE (sym); else { resolve_symbol_value (symbol_get_tc (sym)->next); - a->x_csect.x_scnlen.l = (S_GET_VALUE (symbol_get_tc (sym)->next) - - S_GET_VALUE (sym)); + a->x_csect.x_scnlen.u64 + = S_GET_VALUE (symbol_get_tc (sym)->next) - S_GET_VALUE (sym); } if (symbol_get_tc (sym)->symbol_class == XMC_BS || symbol_get_tc (sym)->symbol_class == XMC_UL) @@ -6230,7 +6230,7 @@ ppc_frob_symbol (symbolS *sym) || S_GET_SEGMENT (sym) == ppc_xcoff_tbss_section.segment) { /* This is a common symbol. */ - a->x_csect.x_scnlen.l = symbol_get_frag (sym)->fr_offset; + a->x_csect.x_scnlen.u64 = symbol_get_frag (sym)->fr_offset; a->x_csect.x_smtyp = (symbol_get_tc (sym)->align << 3) | XTY_CM; if (S_GET_SEGMENT (sym) == ppc_xcoff_tbss_section.segment) symbol_get_tc (sym)->symbol_class = XMC_UL; @@ -6251,7 +6251,7 @@ ppc_frob_symbol (symbolS *sym) else if (! S_IS_DEFINED (sym)) { /* This is an external symbol. */ - a->x_csect.x_scnlen.l = 0; + a->x_csect.x_scnlen.u64 = 0; a->x_csect.x_smtyp = XTY_ER; } else if (ppc_is_toc_sym (sym)) @@ -6267,17 +6267,17 @@ ppc_frob_symbol (symbolS *sym) || (!ppc_is_toc_sym (next))) { if (ppc_after_toc_frag == (fragS *) NULL) - a->x_csect.x_scnlen.l = (bfd_section_size (data_section) - - S_GET_VALUE (sym)); + a->x_csect.x_scnlen.u64 + = bfd_section_size (data_section) - S_GET_VALUE (sym); else - a->x_csect.x_scnlen.l = (ppc_after_toc_frag->fr_address - - S_GET_VALUE (sym)); + a->x_csect.x_scnlen.u64 + = ppc_after_toc_frag->fr_address - S_GET_VALUE (sym); } else { resolve_symbol_value (next); - a->x_csect.x_scnlen.l = (S_GET_VALUE (next) - - S_GET_VALUE (sym)); + a->x_csect.x_scnlen.u64 + = S_GET_VALUE (next) - S_GET_VALUE (sym); } a->x_csect.x_smtyp = (2 << 3) | XTY_SD; } @@ -6302,7 +6302,7 @@ ppc_frob_symbol (symbolS *sym) if (csect == (symbolS *) NULL) { as_warn (_("warning: symbol %s has no csect"), S_GET_NAME (sym)); - a->x_csect.x_scnlen.l = 0; + a->x_csect.x_scnlen.u64 = 0; } else { @@ -6435,7 +6435,7 @@ ppc_adjust_symtab (void) i = S_GET_NUMBER_AUXILIARY (csect); S_SET_NUMBER_AUXILIARY (csect, i + 1); a = &coffsymbol (symbol_get_bfdsym (csect))->native[i + 1].u.auxent; - a->x_csect.x_scnlen.l = 0; + a->x_csect.x_scnlen.u64 = 0; a->x_csect.x_smtyp = XTY_SD; a->x_csect.x_parmhash = 0; a->x_csect.x_snhash = 0; |