[binutils-gdb] Remove BFD64 checks from rs6000-core.c
Alan Modra via Binutils-cvs <[email protected]> Fri, 31 Jul 2026 08:30:15 +0000 (GMT)
| Newsgroups | gmane.comp.gnu.binutils.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Db46f479ff693= 935f2c5cf9fa2f5d30a4949b1919 commit b46f479ff693935f2c5cf9fa2f5d30a4949b1919 Author: Alan Modra <[email protected]> Date: Thu Jul 30 14:54:23 2026 +0930 Remove BFD64 checks from rs6000-core.c =20 On a 32-bit system it is possible to build binutils with --enable-64-bit-bfd or with --enable-targets choosing extra targets that require a 64-bit bfd. So all of the BFD64 tests added in commit d6867a7559 and further modified in commit f03265d9cd are bogus, in particular the removal of code by #ifndef BFD64. It looks to me that this would break reading of core files in rs6000-aix4.2 or earlier. =20 Besides removing the BFD64 ifdefs this patch also initialises c_extoff in a !CORE_NEW code path. Diff: --- bfd/rs6000-core.c | 58 ++++++++-------------------------------------------= ---- 1 file changed, 8 insertions(+), 50 deletions(-) diff --git a/bfd/rs6000-core.c b/bfd/rs6000-core.c index 0635960eaee..287738609e7 100644 --- a/bfd/rs6000-core.c +++ b/bfd/rs6000-core.c @@ -109,10 +109,8 @@ typedef union #else struct core_dump new_dump; /* For simpler coding. */ #endif -#ifndef BFD64 /* Use old only if gdb is 32-bit. */ struct core_dump old; /* Old AIX 4.2- core dump, still used on 4.3+ with appropriate SMIT config. */ -#endif } CoreHdr; =20 /* Union of old and new vm_info structures. */ @@ -125,20 +123,14 @@ typedef union #else struct vm_info new_dump; #endif -#ifndef BFD64 struct vm_info old; -#endif } VmInfo; #endif =20 /* Return whether CoreHdr C is in new or old format. */ =20 #ifdef AIX_CORE_DUMPX_CORE -# ifndef BFD64 -# define CORE_NEW(c) (!(c).old.c_entries) -# else -# define CORE_NEW(c) 1 -# endif +# define CORE_NEW(c) ((c).old.c_entries =3D=3D 0) #else # define CORE_NEW(c) 0 #endif @@ -267,13 +259,9 @@ typedef union =20 /* Size of the leading portion that old and new core dump structures have = in common. */ -#ifdef AIX_CORE_DUMPX_CORE -#define CORE_COMMONSZ ((long) &((struct core_dumpx *) 0)->c_entries \ - + sizeof (((struct core_dumpx *) 0)->c_entries)) -#else #define CORE_COMMONSZ ((int) &((struct core_dump *) 0)->c_entries \ + sizeof (((struct core_dump *) 0)->c_entries)) -#endif + /* Define prototypes for certain functions, to avoid a compiler warning saying that they are missing. */ =20 @@ -302,10 +290,8 @@ read_hdr (bfd *abfd, CoreHdr *core) /* Read the trailing portion of the structure. */ if (CORE_NEW (*core)) size =3D sizeof (core->new_dump); -#ifndef BFD64 else size =3D sizeof (core->old); -#endif size -=3D CORE_COMMONSZ; return bfd_read ((char *) core + CORE_COMMONSZ, size, abfd) =3D=3D size; } @@ -371,7 +357,6 @@ rs6000coff_core_p (bfd *abfd) c_lsize =3D CNEW_LSIZE (core.new_dump); c_loader =3D CNEW_LOADER (core.new_dump); c_extoff =3D core.new_dump.c_extctx; -#ifndef BFD64 proc64 =3D CNEW_PROC64 (core.new_dump); } else @@ -382,7 +367,7 @@ rs6000coff_core_p (bfd *abfd) c_stackend =3D COLD_STACKEND; c_lsize =3D 0x7ffffff; c_loader =3D (file_ptr) (ptr_to_uint) COLD_LOADER (core.old); -#endif + c_extoff =3D 0; proc64 =3D 0; } =20 @@ -396,13 +381,12 @@ rs6000coff_core_p (bfd *abfd) c_regsize =3D sizeof (CNEW_MSTSAVE (core.new_dump)); c_regptr =3D &CNEW_MSTSAVE (core.new_dump); } -#ifndef BFD64 else { c_regsize =3D sizeof (COLD_MSTSAVE (core.old)); c_regptr =3D &COLD_MSTSAVE (core.old); } -#endif + c_regoff =3D (char *) c_regptr - (char *) &core; =20 if (bfd_stat (abfd, &statbuf) < 0) @@ -453,12 +437,7 @@ rs6000coff_core_p (bfd *abfd) =20 /* Sanity check on the c_tab field. */ if (!CORE_NEW (core) - && ( -#ifndef BFD64 - c_loader < (file_ptr) sizeof core.old -#else - c_loader < (file_ptr) sizeof core.new_dump -#endif + && (c_loader < (file_ptr) sizeof core.old || c_loader >=3D statbuf.st_size || c_loader >=3D c_stack)) { @@ -471,11 +450,7 @@ rs6000coff_core_p (bfd *abfd) _bfd_error_handler (_("%pB: warning core file truncated"), abfd); =20 /* Allocate core file header. */ -#ifndef BFD64 size =3D CORE_NEW (core) ? sizeof (core.new_dump) : sizeof (core.old); -#else - size =3D sizeof (core.new_dump); -#endif tmpptr =3D bfd_alloc (abfd, size + 1); if (!tmpptr) return NULL; @@ -585,7 +560,6 @@ rs6000coff_core_p (bfd *abfd) c_vmregions =3D core.new_dump.c_vmregions; c_vmm =3D (file_ptr) core.new_dump.c_vmm; } -#ifndef BFD64 else { c_datasize =3D core.old.c_datasize; @@ -593,7 +567,6 @@ rs6000coff_core_p (bfd *abfd) c_vmregions =3D core.old.c_vmregions; c_vmm =3D (file_ptr) (ptr_to_uint) core.old.c_vmm; } -#endif =20 /* .data section from executable. */ if (c_datasize) @@ -668,11 +641,7 @@ rs6000coff_core_p (bfd *abfd) file_ptr vminfo_offset; bfd_vma vminfo_addr; =20 -#ifndef BFD64 size =3D CORE_NEW (core) ? sizeof (vminfo.new_dump) : sizeof (vminfo.= old); -#else - size =3D sizeof (vminfo.new_dump); -#endif if (bfd_read (&vminfo, size, abfd) !=3D size) goto fail; =20 @@ -682,14 +651,12 @@ rs6000coff_core_p (bfd *abfd) vminfo_size =3D vminfo.new_dump.vminfo_size; vminfo_offset =3D vminfo.new_dump.vminfo_offset; } -#ifndef BFD64 else { vminfo_addr =3D (bfd_vma) (ptr_to_uint) vminfo.old.vminfo_addr; vminfo_size =3D vminfo.old.vminfo_size; vminfo_offset =3D vminfo.old.vminfo_offset; } -#endif =20 if (vminfo_offset) if (!make_bfd_asection (abfd, ".vmdata", @@ -729,10 +696,8 @@ rs6000coff_core_file_matches_executable_p (bfd *core_b= fd, bfd *exec_bfd) =20 if (CORE_NEW (core)) c_loader =3D CNEW_LOADER (core.new_dump); -#ifndef BFD64 else c_loader =3D (file_ptr) (ptr_to_uint) COLD_LOADER (core.old); -#endif =20 if (CORE_NEW (core) && CNEW_PROC64 (core.new_dump)) size =3D (int) ((LdInfo *) 0)->l64.ldinfo_filename; @@ -795,12 +760,9 @@ char * rs6000coff_core_file_failing_command (bfd *abfd) { CoreHdr *core =3D core_hdr (abfd); -#ifndef BFD64 - char *com =3D CORE_NEW (*core) ? - CNEW_COMM (core->new_dump) : COLD_COMM (core->old); -#else - char *com =3D CNEW_COMM (core->new_dump); -#endif + char *com =3D (CORE_NEW (*core) + ? CNEW_COMM (core->new_dump) + : COLD_COMM (core->old)); =20 if (*com) return com; @@ -812,11 +774,7 @@ int rs6000coff_core_file_failing_signal (bfd *abfd) { CoreHdr *core =3D core_hdr (abfd); -#ifndef BFD64 return CORE_NEW (*core) ? core->new_dump.c_signo : core->old.c_signo; -#else - return core->new_dump.c_signo; -#endif } =20 #endif /* AIX_CORE */