[PATCH] bfd/elf.c: Replace __sparcv9 with autoconf variables.
msnyder@cygnus.com
msnyder@cygnus.com
Wed Jun 14 12:42:00 GMT 2000
Earlier I submitted a patch to enable elf.c to read 32-bit core files
when bfd was compiled as a 64-bit library. This patch cleans up that
previous patch by adding autoconf variables to take the place of the
system- and architecture-specific macro "__sparcv9".
Nick, may I check it in?
2000-06-14 Michael Snyder <msnyder@seadog.cygnus.com>
* elf.c: Eliminate references to __sparcv9 macro; replace with
autoconf variables HAVE_PSINFO32_T etc.
* configure.in: Auto-configure HAVE_PSINFO_32_T, HAVE_PRPSINFO32_T,
HAVE_PSTATUS32_T, HAVE_PRSTATUS32_T, HAVE_PRSTATUS32_T_PR_WHO.
* config.in: Ditto.
* acinclude.m4 (BFD_HAVE_SYS_PROCFS_TYPE) define _SYSCALL32 so it can
detect the above typedefs. (BFD_HAVE_SYS_PROCFS_TYPE_MEMBER): Ditto.
* aclocal.m4: Ditto.
* configure: Regenerate.
Index: configure.in
===================================================================
RCS file: /cvs/src/src/bfd/configure.in,v
retrieving revision 1.25
diff -p -r1.25 configure.in
*** configure.in 2000/06/08 19:00:01 1.25
--- configure.in 2000/06/14 19:38:41
*************** changequote([,])dnl
*** 339,348 ****
--- 339,353 ----
AC_CHECK_HEADERS(sys/procfs.h)
if test "$ac_cv_header_sys_procfs_h" = yes; then
BFD_HAVE_SYS_PROCFS_TYPE(prstatus_t)
+ BFD_HAVE_SYS_PROCFS_TYPE(prstatus32_t)
BFD_HAVE_SYS_PROCFS_TYPE_MEMBER(prstatus_t, pr_who)
+ BFD_HAVE_SYS_PROCFS_TYPE_MEMBER(prstatus32_t, pr_who)
BFD_HAVE_SYS_PROCFS_TYPE(pstatus_t)
+ BFD_HAVE_SYS_PROCFS_TYPE(pstatus32_t)
BFD_HAVE_SYS_PROCFS_TYPE(prpsinfo_t)
+ BFD_HAVE_SYS_PROCFS_TYPE(prpsinfo32_t)
BFD_HAVE_SYS_PROCFS_TYPE(psinfo_t)
+ BFD_HAVE_SYS_PROCFS_TYPE(psinfo32_t)
BFD_HAVE_SYS_PROCFS_TYPE(lwpstatus_t)
BFD_HAVE_SYS_PROCFS_TYPE_MEMBER(lwpstatus_t, pr_context)
BFD_HAVE_SYS_PROCFS_TYPE_MEMBER(lwpstatus_t, pr_reg)
Index: config.in
===================================================================
RCS file: /cvs/src/src/bfd/config.in,v
retrieving revision 1.3
diff -p -r1.3 config.in
*** config.in 2000/01/10 18:50:16 1.3
--- config.in 2000/06/14 19:38:41
***************
*** 211,227 ****
--- 211,242 ----
/* Define if <sys/procfs.h> has prstatus_t. */
#undef HAVE_PRSTATUS_T
+ /* Define if <sys/procfs.h> has prstatus32_t. */
+ #undef HAVE_PRSTATUS32_T
+
/* Define if <sys/procfs.h> has prstatus_t.pr_who. */
#undef HAVE_PRSTATUS_T_PR_WHO
+ /* Define if <sys/procfs.h> has prstatus32_t.pr_who. */
+ #undef HAVE_PRSTATUS32_T_PR_WHO
+
/* Define if <sys/procfs.h> has pstatus_t. */
#undef HAVE_PSTATUS_T
+ /* Define if <sys/procfs.h> has pstatus32_t. */
+ #undef HAVE_PSTATUS32_T
+
/* Define if <sys/procfs.h> has prpsinfo_t. */
#undef HAVE_PRPSINFO_T
+ /* Define if <sys/procfs.h> has prpsinfo32_t. */
+ #undef HAVE_PRPSINFO32_T
+
/* Define if <sys/procfs.h> has psinfo_t. */
#undef HAVE_PSINFO_T
+
+ /* Define if <sys/procfs.h> has psinfo32_t. */
+ #undef HAVE_PSINFO32_T
/* Define if <sys/procfs.h> has lwpstatus_t. */
#undef HAVE_LWPSTATUS_T
Index: acinclude.m4
===================================================================
RCS file: /cvs/src/src/bfd/acinclude.m4,v
retrieving revision 1.3
diff -p -r1.3 acinclude.m4
*** acinclude.m4 1999/08/08 16:01:13 1.3
--- acinclude.m4 2000/06/14 19:38:41
*************** dnl Check for existence of a type $1 in
*** 74,80 ****
AC_DEFUN(BFD_HAVE_SYS_PROCFS_TYPE,
[AC_MSG_CHECKING([for $1 in sys/procfs.h])
AC_CACHE_VAL(bfd_cv_have_sys_procfs_type_$1,
! [AC_TRY_COMPILE([#include <sys/procfs.h>],
[$1 avar],
bfd_cv_have_sys_procfs_type_$1=yes,
bfd_cv_have_sys_procfs_type_$1=no
--- 74,82 ----
AC_DEFUN(BFD_HAVE_SYS_PROCFS_TYPE,
[AC_MSG_CHECKING([for $1 in sys/procfs.h])
AC_CACHE_VAL(bfd_cv_have_sys_procfs_type_$1,
! [AC_TRY_COMPILE([
! #define _SYSCALL32
! #include <sys/procfs.h>],
[$1 avar],
bfd_cv_have_sys_procfs_type_$1=yes,
bfd_cv_have_sys_procfs_type_$1=no
*************** dnl Check for existence of member $2 in
*** 92,98 ****
AC_DEFUN(BFD_HAVE_SYS_PROCFS_TYPE_MEMBER,
[AC_MSG_CHECKING([for $1.$2 in sys/procfs.h])
AC_CACHE_VAL(bfd_cv_have_sys_procfs_type_member_$1_$2,
! [AC_TRY_COMPILE([#include <sys/procfs.h>],
[$1 avar; void* aref = (void*) &avar.$2],
bfd_cv_have_sys_procfs_type_member_$1_$2=yes,
bfd_cv_have_sys_procfs_type_member_$1_$2=no
--- 94,102 ----
AC_DEFUN(BFD_HAVE_SYS_PROCFS_TYPE_MEMBER,
[AC_MSG_CHECKING([for $1.$2 in sys/procfs.h])
AC_CACHE_VAL(bfd_cv_have_sys_procfs_type_member_$1_$2,
! [AC_TRY_COMPILE([
! #define _SYSCALL32
! #include <sys/procfs.h>],
[$1 avar; void* aref = (void*) &avar.$2],
bfd_cv_have_sys_procfs_type_member_$1_$2=yes,
bfd_cv_have_sys_procfs_type_member_$1_$2=no
Index: aclocal.m4
===================================================================
RCS file: /cvs/src/src/bfd/aclocal.m4,v
retrieving revision 1.5
diff -p -r1.5 aclocal.m4
*** aclocal.m4 2000/02/27 16:50:14 1.5
--- aclocal.m4 2000/06/14 19:38:41
***************
*** 1,3 ****
--- 1,4 ----
+
dnl aclocal.m4 generated automatically by aclocal 1.4
dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
*************** dnl Check for existence of a type $1 in
*** 86,92 ****
AC_DEFUN(BFD_HAVE_SYS_PROCFS_TYPE,
[AC_MSG_CHECKING([for $1 in sys/procfs.h])
AC_CACHE_VAL(bfd_cv_have_sys_procfs_type_$1,
! [AC_TRY_COMPILE([#include <sys/procfs.h>],
[$1 avar],
bfd_cv_have_sys_procfs_type_$1=yes,
bfd_cv_have_sys_procfs_type_$1=no
--- 87,95 ----
AC_DEFUN(BFD_HAVE_SYS_PROCFS_TYPE,
[AC_MSG_CHECKING([for $1 in sys/procfs.h])
AC_CACHE_VAL(bfd_cv_have_sys_procfs_type_$1,
! [AC_TRY_COMPILE([
! #define _SYSCALL32
! #include <sys/procfs.h>],
[$1 avar],
bfd_cv_have_sys_procfs_type_$1=yes,
bfd_cv_have_sys_procfs_type_$1=no
*************** dnl Check for existence of member $2 in
*** 104,110 ****
AC_DEFUN(BFD_HAVE_SYS_PROCFS_TYPE_MEMBER,
[AC_MSG_CHECKING([for $1.$2 in sys/procfs.h])
AC_CACHE_VAL(bfd_cv_have_sys_procfs_type_member_$1_$2,
! [AC_TRY_COMPILE([#include <sys/procfs.h>],
[$1 avar; void* aref = (void*) &avar.$2],
bfd_cv_have_sys_procfs_type_member_$1_$2=yes,
bfd_cv_have_sys_procfs_type_member_$1_$2=no
--- 107,115 ----
AC_DEFUN(BFD_HAVE_SYS_PROCFS_TYPE_MEMBER,
[AC_MSG_CHECKING([for $1.$2 in sys/procfs.h])
AC_CACHE_VAL(bfd_cv_have_sys_procfs_type_member_$1_$2,
! [AC_TRY_COMPILE([
! #define _SYSCALL32
! #include <sys/procfs.h>],
[$1 avar; void* aref = (void*) &avar.$2],
bfd_cv_have_sys_procfs_type_member_$1_$2=yes,
bfd_cv_have_sys_procfs_type_member_$1_$2=no
Index: elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.35
diff -p -r1.35 elf.c
*** elf.c 2000/06/06 20:00:33 1.35
--- elf.c 2000/06/14 19:38:41
*************** SECTION
*** 31,40 ****
haven't bothered yet.
*/
! #ifdef __sparcv9
! #define _SYSCALL32 /* For Sparc64-cross-32 */
! #endif
!
#include "bfd.h"
#include "sysdep.h"
#include "bfdlink.h"
--- 31,38 ----
haven't bothered yet.
*/
! /* For sparc64-cross-sparc32. */
! #define _SYSCALL32
#include "bfd.h"
#include "sysdep.h"
#include "bfdlink.h"
*************** bfd_elf_print_symbol (abfd, filep, symbo
*** 775,781 ****
if (name == NULL)
{
! name = symbol->name;
bfd_print_symbol_vandf ((PTR) file, symbol);
}
--- 773,779 ----
if (name == NULL)
{
! name = symbol->name;
bfd_print_symbol_vandf ((PTR) file, symbol);
}
*************** _bfd_elf_link_hash_copy_indirect (dir, i
*** 954,960 ****
}
void
! _bfd_elf_link_hash_hide_symbol(h)
struct elf_link_hash_entry *h;
{
h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
--- 952,958 ----
}
void
! _bfd_elf_link_hash_hide_symbol (h)
struct elf_link_hash_entry *h;
{
h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
*************** elfcore_grok_prstatus (abfd, note)
*** 5128,5139 ****
--- 5126,5139 ----
char* name;
asection* sect;
int raw_size;
+ int offset;
if (note->descsz == sizeof (prstatus_t))
{
prstatus_t prstat;
raw_size = sizeof (prstat.pr_reg);
+ offset = offsetof (prstatus_t, pr_reg);
memcpy (&prstat, note->descdata, sizeof (prstat));
elf_tdata (abfd)->core_signal = prstat.pr_cursig;
*************** elfcore_grok_prstatus (abfd, note)
*** 5149,5161 ****
elf_tdata (abfd)->core_lwpid = prstat.pr_who;
#endif
}
! #if defined (__sparcv9)
else if (note->descsz == sizeof (prstatus32_t))
{
/* 64-bit host, 32-bit corefile */
prstatus32_t prstat;
raw_size = sizeof (prstat.pr_reg);
memcpy (&prstat, note->descdata, sizeof (prstat));
elf_tdata (abfd)->core_signal = prstat.pr_cursig;
--- 5149,5162 ----
elf_tdata (abfd)->core_lwpid = prstat.pr_who;
#endif
}
! #if defined (HAVE_PRSTATUS32_T)
else if (note->descsz == sizeof (prstatus32_t))
{
/* 64-bit host, 32-bit corefile */
prstatus32_t prstat;
raw_size = sizeof (prstat.pr_reg);
+ offset = offsetof (prstatus32_t, pr_reg);
memcpy (&prstat, note->descdata, sizeof (prstat));
elf_tdata (abfd)->core_signal = prstat.pr_cursig;
*************** elfcore_grok_prstatus (abfd, note)
*** 5167,5177 ****
pr_who doesn't exist on:
linux 2.[01]
*/
! #if defined (HAVE_PRSTATUS_T_PR_WHO)
elf_tdata (abfd)->core_lwpid = prstat.pr_who;
#endif
}
! #endif /* __sparcv9 */
else
{
/* Fail - we don't know how to handle any other
--- 5168,5178 ----
pr_who doesn't exist on:
linux 2.[01]
*/
! #if defined (HAVE_PRSTATUS32_T_PR_WHO)
elf_tdata (abfd)->core_lwpid = prstat.pr_who;
#endif
}
! #endif /* HAVE_PRSTATUS32_T */
else
{
/* Fail - we don't know how to handle any other
*************** elfcore_grok_prstatus (abfd, note)
*** 5191,5208 ****
if (sect == NULL)
return false;
! if (note->descsz == sizeof (prstatus_t))
! {
! sect->_raw_size = raw_size;
! sect->filepos = note->descpos + offsetof (prstatus_t, pr_reg);
! }
! #if defined (__sparcv9)
! else if (note->descsz == sizeof (prstatus32_t))
! {
! sect->_raw_size = raw_size;
! sect->filepos = note->descpos + offsetof (prstatus32_t, pr_reg);
! }
! #endif
sect->flags = SEC_HAS_CONTENTS;
sect->alignment_power = 2;
--- 5192,5199 ----
if (sect == NULL)
return false;
! sect->_raw_size = raw_size;
! sect->filepos = note->descpos + offset;
sect->flags = SEC_HAS_CONTENTS;
sect->alignment_power = 2;
*************** elfcore_grok_prxfpreg (abfd, note)
*** 5282,5295 ****
#if defined (HAVE_PRPSINFO_T)
typedef prpsinfo_t elfcore_psinfo_t;
! #if defined (__sparcv9) /* Sparc64 cross Sparc32 */
typedef prpsinfo32_t elfcore_psinfo32_t;
#endif
#endif
#if defined (HAVE_PSINFO_T)
typedef psinfo_t elfcore_psinfo_t;
! #if defined (__sparcv9) /* Sparc64 cross Sparc32 */
typedef psinfo32_t elfcore_psinfo32_t;
#endif
#endif
--- 5273,5286 ----
#if defined (HAVE_PRPSINFO_T)
typedef prpsinfo_t elfcore_psinfo_t;
! #if defined (HAVE_PRPSINFO32_T) /* Sparc64 cross Sparc32 */
typedef prpsinfo32_t elfcore_psinfo32_t;
#endif
#endif
#if defined (HAVE_PSINFO_T)
typedef psinfo_t elfcore_psinfo_t;
! #if defined (HAVE_PSINFO32_T) /* Sparc64 cross Sparc32 */
typedef psinfo32_t elfcore_psinfo32_t;
#endif
#endif
*************** elfcore_grok_psinfo (abfd, note)
*** 5335,5341 ****
{
elfcore_psinfo_t psinfo;
! memcpy (&psinfo, note->descdata, note->descsz);
elf_tdata (abfd)->core_program
= elfcore_strndup (abfd, psinfo.pr_fname, sizeof (psinfo.pr_fname));
--- 5326,5332 ----
{
elfcore_psinfo_t psinfo;
! memcpy (&psinfo, note->descdata, sizeof (psinfo));
elf_tdata (abfd)->core_program
= elfcore_strndup (abfd, psinfo.pr_fname, sizeof (psinfo.pr_fname));
*************** elfcore_grok_psinfo (abfd, note)
*** 5343,5355 ****
elf_tdata (abfd)->core_command
= elfcore_strndup (abfd, psinfo.pr_psargs, sizeof (psinfo.pr_psargs));
}
! #if defined (__sparcv9)
else if (note->descsz == sizeof (elfcore_psinfo32_t))
{
/* 64-bit host, 32-bit corefile */
elfcore_psinfo32_t psinfo;
! memcpy (&psinfo, note->descdata, note->descsz);
elf_tdata (abfd)->core_program
= elfcore_strndup (abfd, psinfo.pr_fname, sizeof (psinfo.pr_fname));
--- 5334,5346 ----
elf_tdata (abfd)->core_command
= elfcore_strndup (abfd, psinfo.pr_psargs, sizeof (psinfo.pr_psargs));
}
! #if defined (HAVE_PRPSINFO32_T) || defined (HAVE_PSINFO32_T)
else if (note->descsz == sizeof (elfcore_psinfo32_t))
{
/* 64-bit host, 32-bit corefile */
elfcore_psinfo32_t psinfo;
! memcpy (&psinfo, note->descdata, sizeof (psinfo));
elf_tdata (abfd)->core_program
= elfcore_strndup (abfd, psinfo.pr_fname, sizeof (psinfo.pr_fname));
*************** elfcore_grok_pstatus (abfd, note)
*** 5397,5403 ****
elf_tdata (abfd)->core_pid = pstat.pr_pid;
}
! #if defined (__sparcv9)
else if (note->descsz == sizeof (pstatus32_t))
{
/* 64-bit host, 32-bit corefile */
--- 5388,5394 ----
elf_tdata (abfd)->core_pid = pstat.pr_pid;
}
! #if defined (HAVE_PSTATUS32_T)
else if (note->descsz == sizeof (pstatus32_t))
{
/* 64-bit host, 32-bit corefile */
More information about the Binutils
mailing list