aboutsummaryrefslogtreecommitdiff
path: root/include/coff
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 /include/coff
parent3bb1480e2a85de6850863d245e7b6da03a3887f7 (diff)
downloadbinutils-a2c7ca15a5609ea230771fc418511a3b8db16bd1.zip
binutils-a2c7ca15a5609ea230771fc418511a3b8db16bd1.tar.gz
binutils-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 'include/coff')
-rw-r--r--include/coff/internal.h80
1 files changed, 40 insertions, 40 deletions
diff --git a/include/coff/internal.h b/include/coff/internal.h
index 9d742d9..92a0abf 100644
--- a/include/coff/internal.h
+++ b/include/coff/internal.h
@@ -549,40 +549,40 @@ union internal_auxent
{
union
{
- long l; /* str, un, or enum tag indx */
+ uint32_t u32; /* str, un, or enum tag indx */
struct coff_ptr_struct *p;
- } x_tagndx;
+ } x_tagndx;
union
{
struct
{
- unsigned short x_lnno; /* declaration line number */
- unsigned short x_size; /* str/union/array size */
- } x_lnsz;
- long x_fsize; /* size of function */
- } x_misc;
+ uint16_t x_lnno; /* declaration line number */
+ uint16_t x_size; /* str/union/array size */
+ } x_lnsz;
+ uint32_t x_fsize; /* size of function */
+ } x_misc;
union
{
struct
{ /* if ISFCN, tag, or .bb */
- bfd_signed_vma x_lnnoptr; /* ptr to fcn line # */
+ uint64_t x_lnnoptr; /* ptr to fcn line # */
union
{ /* entry ndx past block end */
- long l;
+ uint32_t u32;
struct coff_ptr_struct *p;
- } x_endndx;
- } x_fcn;
+ } x_endndx;
+ } x_fcn;
struct
{ /* if ISARY, up to 4 dimen. */
- unsigned short x_dimen[DIMNUM];
- } x_ary;
- } x_fcnary;
+ uint16_t x_dimen[DIMNUM];
+ } x_ary;
+ } x_fcnary;
- unsigned short x_tvndx; /* tv index */
- } x_sym;
+ uint16_t x_tvndx; /* tv index */
+ } x_sym;
struct
{
@@ -600,28 +600,28 @@ union internal_auxent
32 bits. */
uintptr_t x_zeroes;
uintptr_t x_offset;
- } x_n;
+ } x_n;
} x_n;
- unsigned char x_ftype;
- } x_file;
+ uint8_t x_ftype;
+ } x_file;
struct
{
- long x_scnlen; /* section length */
- unsigned short x_nreloc; /* # relocation entries */
- unsigned short x_nlinno; /* # line numbers */
- unsigned long x_checksum; /* section COMDAT checksum for PE */
- unsigned short x_associated; /* COMDAT associated section index for PE */
- unsigned char x_comdat; /* COMDAT selection number for PE */
- } x_scn;
+ uint32_t x_scnlen; /* section length */
+ uint16_t x_nreloc; /* # relocation entries */
+ uint16_t x_nlinno; /* # line numbers */
+ uint32_t x_checksum; /* section COMDAT checksum for PE */
+ uint16_t x_associated; /* COMDAT associated section index for PE */
+ uint8_t x_comdat; /* COMDAT selection number for PE */
+ } x_scn;
struct
{
- long x_tvfill; /* tv fill value */
- unsigned short x_tvlen; /* length of .tv */
- unsigned short x_tvran[2]; /* tv range */
- } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
+ uint32_t x_tvfill; /* tv fill value */
+ uint16_t x_tvlen; /* length of .tv */
+ uint16_t x_tvran[2]; /* tv range */
+ } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
/******************************************
* RS/6000-specific auxent - last auxent for every external symbol
@@ -630,18 +630,18 @@ union internal_auxent
{
union
{ /* csect length or enclosing csect */
- bfd_signed_vma l;
+ uint64_t u64;
struct coff_ptr_struct *p;
} x_scnlen;
- long x_parmhash; /* parm type hash index */
- unsigned short x_snhash; /* sect num with parm hash */
- unsigned char x_smtyp; /* symbol align and type */
+ uint32_t x_parmhash; /* parm type hash index */
+ uint16_t x_snhash; /* sect num with parm hash */
+ uint8_t x_smtyp; /* symbol align and type */
/* 0-4 - Log 2 of alignment */
/* 5-7 - symbol type */
- unsigned char x_smclas; /* storage mapping class */
- long x_stab; /* dbx stab info index */
- unsigned short x_snstab; /* sect num with dbx stab */
- } x_csect; /* csect definition information */
+ uint8_t x_smclas; /* storage mapping class */
+ uint32_t x_stab; /* dbx stab info index */
+ uint16_t x_snstab; /* sect num with dbx stab */
+ } x_csect; /* csect definition information */
/* x_smtyp values: */
@@ -677,8 +677,8 @@ union internal_auxent
struct
{
- long x_scnlen; /* Section length */
- long x_nreloc; /* Number of relocation entries */
+ uint64_t x_scnlen; /* Section length */
+ uint64_t x_nreloc; /* Number of relocation entries */
} x_sect;
};