mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-28 23:39:35 +08:00
2000-05-26 Michael Snyder <msnyder@seadog.cygnus.com>
* elf.c (elfcore_grok_prstatus, elfcore_grok_pstatus, elfcore_grok_psinfo): Add code to allow debugging a 32-bit corefile on a 64-bit (Sparc Solaris) host. Also clean up a few old comments.
This commit is contained in:
@ -62,6 +62,13 @@ Tue May 30 15:39:04 2000 Andrew Cagney <cagney@b1.cygnus.com>
|
|||||||
|
|
||||||
* elf.c (_bfd_elf_link_hash_table_init): Initialize dynlocal.
|
* elf.c (_bfd_elf_link_hash_table_init): Initialize dynlocal.
|
||||||
|
|
||||||
|
2000-05-26 Michael Snyder <msnyder@seadog.cygnus.com>
|
||||||
|
|
||||||
|
* elf.c (elfcore_grok_prstatus, elfcore_grok_pstatus,
|
||||||
|
elfcore_grok_psinfo): Add code to allow debugging a 32-bit
|
||||||
|
corefile on a 64-bit (Sparc Solaris) host. Also clean up
|
||||||
|
a few old comments.
|
||||||
|
|
||||||
2000-05-26 Alan Modra <alan@linuxcare.com.au>
|
2000-05-26 Alan Modra <alan@linuxcare.com.au>
|
||||||
|
|
||||||
* Makefile.am: Update dependencies with "make dep-am"
|
* Makefile.am: Update dependencies with "make dep-am"
|
||||||
|
122
bfd/elf.c
122
bfd/elf.c
@ -31,6 +31,10 @@ SECTION
|
|||||||
haven't bothered yet.
|
haven't bothered yet.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef __sparcv9
|
||||||
|
#define _SYSCALL32 /* For Sparc64-cross-32 */
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "bfd.h"
|
#include "bfd.h"
|
||||||
#include "sysdep.h"
|
#include "sysdep.h"
|
||||||
#include "bfdlink.h"
|
#include "bfdlink.h"
|
||||||
@ -2918,18 +2922,21 @@ assign_file_positions_for_segments (abfd)
|
|||||||
|
|
||||||
if (p->p_type == PT_NOTE && bfd_get_format (abfd) == bfd_core)
|
if (p->p_type == PT_NOTE && bfd_get_format (abfd) == bfd_core)
|
||||||
{
|
{
|
||||||
if (i == 0) /* the actual "note" segment */
|
/* The actual "note" segment has i == 0.
|
||||||
{ /* this one actually contains everything. */
|
This is the one that actually contains everything. */
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
sec->filepos = off;
|
sec->filepos = off;
|
||||||
p->p_filesz = sec->_raw_size;
|
p->p_filesz = sec->_raw_size;
|
||||||
off += sec->_raw_size;
|
off += sec->_raw_size;
|
||||||
voff = off;
|
voff = off;
|
||||||
}
|
}
|
||||||
else /* fake sections -- don't need to be written */
|
else
|
||||||
{
|
{
|
||||||
|
/* Fake sections -- don't need to be written. */
|
||||||
sec->filepos = 0;
|
sec->filepos = 0;
|
||||||
sec->_raw_size = 0;
|
sec->_raw_size = 0;
|
||||||
flags = sec->flags = 0; /* no contents */
|
flags = sec->flags = 0;
|
||||||
}
|
}
|
||||||
p->p_memsz = 0;
|
p->p_memsz = 0;
|
||||||
p->p_align = 1;
|
p->p_align = 1;
|
||||||
@ -5106,7 +5113,7 @@ elfcore_maybe_make_sect (abfd, name, sect)
|
|||||||
|
|
||||||
|
|
||||||
/* prstatus_t exists on:
|
/* prstatus_t exists on:
|
||||||
solaris 2.[567]
|
solaris 2.5+
|
||||||
linux 2.[01] + glibc
|
linux 2.[01] + glibc
|
||||||
unixware 4.2
|
unixware 4.2
|
||||||
*/
|
*/
|
||||||
@ -5117,13 +5124,13 @@ elfcore_grok_prstatus (abfd, note)
|
|||||||
bfd* abfd;
|
bfd* abfd;
|
||||||
Elf_Internal_Note* note;
|
Elf_Internal_Note* note;
|
||||||
{
|
{
|
||||||
prstatus_t prstat;
|
|
||||||
char buf[100];
|
char buf[100];
|
||||||
char* name;
|
char* name;
|
||||||
asection* sect;
|
asection* sect;
|
||||||
|
|
||||||
if (note->descsz != sizeof (prstat))
|
if (note->descsz == sizeof (prstatus_t))
|
||||||
return true;
|
{
|
||||||
|
prstatus_t prstat;
|
||||||
|
|
||||||
memcpy (&prstat, note->descdata, sizeof (prstat));
|
memcpy (&prstat, note->descdata, sizeof (prstat));
|
||||||
|
|
||||||
@ -5131,7 +5138,7 @@ elfcore_grok_prstatus (abfd, note)
|
|||||||
elf_tdata (abfd)->core_pid = prstat.pr_pid;
|
elf_tdata (abfd)->core_pid = prstat.pr_pid;
|
||||||
|
|
||||||
/* pr_who exists on:
|
/* pr_who exists on:
|
||||||
solaris 2.[567]
|
solaris 2.5+
|
||||||
unixware 4.2
|
unixware 4.2
|
||||||
pr_who doesn't exist on:
|
pr_who doesn't exist on:
|
||||||
linux 2.[01]
|
linux 2.[01]
|
||||||
@ -5139,6 +5146,35 @@ elfcore_grok_prstatus (abfd, note)
|
|||||||
#if defined (HAVE_PRSTATUS_T_PR_WHO)
|
#if defined (HAVE_PRSTATUS_T_PR_WHO)
|
||||||
elf_tdata (abfd)->core_lwpid = prstat.pr_who;
|
elf_tdata (abfd)->core_lwpid = prstat.pr_who;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
#if defined (__sparcv9)
|
||||||
|
else if (note->descsz == sizeof (prstatus32_t))
|
||||||
|
{
|
||||||
|
/* 64-bit host, 32-bit corefile */
|
||||||
|
prstatus32_t prstat;
|
||||||
|
|
||||||
|
memcpy (&prstat, note->descdata, sizeof (prstat));
|
||||||
|
|
||||||
|
elf_tdata (abfd)->core_signal = prstat.pr_cursig;
|
||||||
|
elf_tdata (abfd)->core_pid = prstat.pr_pid;
|
||||||
|
|
||||||
|
/* pr_who exists on:
|
||||||
|
solaris 2.5+
|
||||||
|
unixware 4.2
|
||||||
|
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
|
||||||
|
note size (ie. data object type). */
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Make a ".reg/999" section. */
|
/* Make a ".reg/999" section. */
|
||||||
|
|
||||||
@ -5151,8 +5187,20 @@ elfcore_grok_prstatus (abfd, note)
|
|||||||
sect = bfd_make_section (abfd, name);
|
sect = bfd_make_section (abfd, name);
|
||||||
if (sect == NULL)
|
if (sect == NULL)
|
||||||
return false;
|
return false;
|
||||||
sect->_raw_size = sizeof (prstat.pr_reg);
|
|
||||||
|
if (note->descsz == sizeof (prstatus_t))
|
||||||
|
{
|
||||||
|
sect->_raw_size = sizeof (prgregset_t);
|
||||||
sect->filepos = note->descpos + offsetof (prstatus_t, pr_reg);
|
sect->filepos = note->descpos + offsetof (prstatus_t, pr_reg);
|
||||||
|
}
|
||||||
|
#if defined (__sparcv9)
|
||||||
|
else if (note->descsz == sizeof (prstatus32_t))
|
||||||
|
{
|
||||||
|
sect->_raw_size = sizeof (prgregset32_t);
|
||||||
|
sect->filepos = note->descpos + offsetof (prstatus32_t, pr_reg);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
sect->flags = SEC_HAS_CONTENTS;
|
sect->flags = SEC_HAS_CONTENTS;
|
||||||
sect->alignment_power = 2;
|
sect->alignment_power = 2;
|
||||||
|
|
||||||
@ -5230,11 +5278,17 @@ elfcore_grok_prxfpreg (abfd, note)
|
|||||||
|
|
||||||
|
|
||||||
#if defined (HAVE_PRPSINFO_T)
|
#if defined (HAVE_PRPSINFO_T)
|
||||||
# define elfcore_psinfo_t prpsinfo_t
|
typedef prpsinfo_t elfcore_psinfo_t;
|
||||||
|
#if defined (__sparcv9) /* Sparc64 cross Sparc32 */
|
||||||
|
typedef prpsinfo32_t elfcore_psinfo32_t;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined (HAVE_PSINFO_T)
|
#if defined (HAVE_PSINFO_T)
|
||||||
# define elfcore_psinfo_t psinfo_t
|
typedef psinfo_t elfcore_psinfo_t;
|
||||||
|
#if defined (__sparcv9) /* Sparc64 cross Sparc32 */
|
||||||
|
typedef psinfo32_t elfcore_psinfo32_t;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -5273,12 +5327,11 @@ static boolean
|
|||||||
elfcore_grok_psinfo (abfd, note)
|
elfcore_grok_psinfo (abfd, note)
|
||||||
bfd* abfd;
|
bfd* abfd;
|
||||||
Elf_Internal_Note* note;
|
Elf_Internal_Note* note;
|
||||||
|
{
|
||||||
|
if (note->descsz == sizeof (elfcore_psinfo_t))
|
||||||
{
|
{
|
||||||
elfcore_psinfo_t psinfo;
|
elfcore_psinfo_t psinfo;
|
||||||
|
|
||||||
if (note->descsz != sizeof (elfcore_psinfo_t))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
memcpy (&psinfo, note->descdata, note->descsz);
|
memcpy (&psinfo, note->descdata, note->descsz);
|
||||||
|
|
||||||
elf_tdata (abfd)->core_program
|
elf_tdata (abfd)->core_program
|
||||||
@ -5286,6 +5339,29 @@ elfcore_grok_psinfo (abfd, note)
|
|||||||
|
|
||||||
elf_tdata (abfd)->core_command
|
elf_tdata (abfd)->core_command
|
||||||
= elfcore_strndup (abfd, psinfo.pr_psargs, sizeof (psinfo.pr_psargs));
|
= 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));
|
||||||
|
|
||||||
|
elf_tdata (abfd)->core_command
|
||||||
|
= elfcore_strndup (abfd, psinfo.pr_psargs, sizeof (psinfo.pr_psargs));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Fail - we don't know how to handle any other
|
||||||
|
note size (ie. data object type). */
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Note that for some reason, a spurious space is tacked
|
/* Note that for some reason, a spurious space is tacked
|
||||||
onto the end of the args in some (at least one anyway)
|
onto the end of the args in some (at least one anyway)
|
||||||
@ -5309,16 +5385,26 @@ static boolean
|
|||||||
elfcore_grok_pstatus (abfd, note)
|
elfcore_grok_pstatus (abfd, note)
|
||||||
bfd* abfd;
|
bfd* abfd;
|
||||||
Elf_Internal_Note* note;
|
Elf_Internal_Note* note;
|
||||||
|
{
|
||||||
|
if (note->descsz == sizeof (pstatus_t))
|
||||||
{
|
{
|
||||||
pstatus_t pstat;
|
pstatus_t pstat;
|
||||||
|
|
||||||
if (note->descsz != sizeof (pstat))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
memcpy (&pstat, note->descdata, sizeof (pstat));
|
memcpy (&pstat, note->descdata, sizeof (pstat));
|
||||||
|
|
||||||
elf_tdata (abfd)->core_pid = pstat.pr_pid;
|
elf_tdata (abfd)->core_pid = pstat.pr_pid;
|
||||||
|
}
|
||||||
|
#if defined (__sparcv9)
|
||||||
|
else if (note->descsz == sizeof (pstatus32_t))
|
||||||
|
{
|
||||||
|
/* 64-bit host, 32-bit corefile */
|
||||||
|
pstatus32_t pstat;
|
||||||
|
|
||||||
|
memcpy (&pstat, note->descdata, sizeof (pstat));
|
||||||
|
|
||||||
|
elf_tdata (abfd)->core_pid = pstat.pr_pid;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
/* Could grab some more details from the "representative"
|
/* Could grab some more details from the "representative"
|
||||||
lwpstatus_t in pstat.pr_lwp, but we'll catch it all in an
|
lwpstatus_t in pstat.pr_lwp, but we'll catch it all in an
|
||||||
NT_LWPSTATUS note, presumably. */
|
NT_LWPSTATUS note, presumably. */
|
||||||
|
Reference in New Issue
Block a user