* elf.c (elfcore_write_prpsinfo): Provide unconditionally.

Return NULL if core file generation is unsupported.
	(elfcore_write_prstatus): Likewise.
	* elf32-arm.c (elf32_arm_nabi_write_core_note): New function.
	(elf_backend_write_core_note): Define.
This commit is contained in:
Ulrich Weigand 2012-01-20 09:52:43 +00:00
parent 3030c96e66
commit 1f20dca58b
3 changed files with 71 additions and 10 deletions

View File

@ -1,3 +1,11 @@
2012-01-20 Ulrich Weigand <ulrich.weigand@linaro.org>
* elf.c (elfcore_write_prpsinfo): Provide unconditionally.
Return NULL if core file generation is unsupported.
(elfcore_write_prstatus): Likewise.
* elf32-arm.c (elf32_arm_nabi_write_core_note): New function.
(elf_backend_write_core_note): Define.
2012-01-19 Tristan Gingold <gingold@adacore.com> 2012-01-19 Tristan Gingold <gingold@adacore.com>
* pef.c: Add a comment. * pef.c: Add a comment.

View File

@ -8890,7 +8890,6 @@ elfcore_write_note (bfd *abfd,
return buf; return buf;
} }
#if defined (HAVE_PRPSINFO_T) || defined (HAVE_PSINFO_T)
char * char *
elfcore_write_prpsinfo (bfd *abfd, elfcore_write_prpsinfo (bfd *abfd,
char *buf, char *buf,
@ -8898,7 +8897,6 @@ elfcore_write_prpsinfo (bfd *abfd,
const char *fname, const char *fname,
const char *psargs) const char *psargs)
{ {
const char *note_name = "CORE";
const struct elf_backend_data *bed = get_elf_backend_data (abfd); const struct elf_backend_data *bed = get_elf_backend_data (abfd);
if (bed->elf_backend_write_core_note != NULL) if (bed->elf_backend_write_core_note != NULL)
@ -8910,6 +8908,7 @@ elfcore_write_prpsinfo (bfd *abfd,
return ret; return ret;
} }
#if defined (HAVE_PRPSINFO_T) || defined (HAVE_PSINFO_T)
#if defined (HAVE_PRPSINFO32_T) || defined (HAVE_PSINFO32_T) #if defined (HAVE_PRPSINFO32_T) || defined (HAVE_PSINFO32_T)
if (bed->s->elfclass == ELFCLASS32) if (bed->s->elfclass == ELFCLASS32)
{ {
@ -8925,7 +8924,7 @@ elfcore_write_prpsinfo (bfd *abfd,
strncpy (data.pr_fname, fname, sizeof (data.pr_fname)); strncpy (data.pr_fname, fname, sizeof (data.pr_fname));
strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs)); strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs));
return elfcore_write_note (abfd, buf, bufsiz, return elfcore_write_note (abfd, buf, bufsiz,
note_name, note_type, &data, sizeof (data)); "CORE", note_type, &data, sizeof (data));
} }
else else
#endif #endif
@ -8942,12 +8941,14 @@ elfcore_write_prpsinfo (bfd *abfd,
strncpy (data.pr_fname, fname, sizeof (data.pr_fname)); strncpy (data.pr_fname, fname, sizeof (data.pr_fname));
strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs)); strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs));
return elfcore_write_note (abfd, buf, bufsiz, return elfcore_write_note (abfd, buf, bufsiz,
note_name, note_type, &data, sizeof (data)); "CORE", note_type, &data, sizeof (data));
} }
}
#endif /* PSINFO_T or PRPSINFO_T */ #endif /* PSINFO_T or PRPSINFO_T */
#if defined (HAVE_PRSTATUS_T) free (buf);
return NULL;
}
char * char *
elfcore_write_prstatus (bfd *abfd, elfcore_write_prstatus (bfd *abfd,
char *buf, char *buf,
@ -8956,7 +8957,6 @@ elfcore_write_prstatus (bfd *abfd,
int cursig, int cursig,
const void *gregs) const void *gregs)
{ {
const char *note_name = "CORE";
const struct elf_backend_data *bed = get_elf_backend_data (abfd); const struct elf_backend_data *bed = get_elf_backend_data (abfd);
if (bed->elf_backend_write_core_note != NULL) if (bed->elf_backend_write_core_note != NULL)
@ -8969,6 +8969,7 @@ elfcore_write_prstatus (bfd *abfd,
return ret; return ret;
} }
#if defined (HAVE_PRSTATUS_T)
#if defined (HAVE_PRSTATUS32_T) #if defined (HAVE_PRSTATUS32_T)
if (bed->s->elfclass == ELFCLASS32) if (bed->s->elfclass == ELFCLASS32)
{ {
@ -8978,7 +8979,7 @@ elfcore_write_prstatus (bfd *abfd,
prstat.pr_pid = pid; prstat.pr_pid = pid;
prstat.pr_cursig = cursig; prstat.pr_cursig = cursig;
memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg)); memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
return elfcore_write_note (abfd, buf, bufsiz, note_name, return elfcore_write_note (abfd, buf, bufsiz, "CORE",
NT_PRSTATUS, &prstat, sizeof (prstat)); NT_PRSTATUS, &prstat, sizeof (prstat));
} }
else else
@ -8990,12 +8991,15 @@ elfcore_write_prstatus (bfd *abfd,
prstat.pr_pid = pid; prstat.pr_pid = pid;
prstat.pr_cursig = cursig; prstat.pr_cursig = cursig;
memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg)); memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
return elfcore_write_note (abfd, buf, bufsiz, note_name, return elfcore_write_note (abfd, buf, bufsiz, "CORE",
NT_PRSTATUS, &prstat, sizeof (prstat)); NT_PRSTATUS, &prstat, sizeof (prstat));
} }
}
#endif /* HAVE_PRSTATUS_T */ #endif /* HAVE_PRSTATUS_T */
free (buf);
return NULL;
}
#if defined (HAVE_LWPSTATUS_T) #if defined (HAVE_LWPSTATUS_T)
char * char *
elfcore_write_lwpstatus (bfd *abfd, elfcore_write_lwpstatus (bfd *abfd,

View File

@ -1988,6 +1988,54 @@ elf32_arm_nabi_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
return TRUE; return TRUE;
} }
static char *
elf32_arm_nabi_write_core_note (bfd *abfd, char *buf, int *bufsiz,
int note_type, ...)
{
switch (note_type)
{
default:
return NULL;
case NT_PRPSINFO:
{
char data[124];
va_list ap;
va_start (ap, note_type);
memset (data, 0, sizeof (data));
strncpy (data + 28, va_arg (ap, const char *), 16);
strncpy (data + 44, va_arg (ap, const char *), 80);
va_end (ap);
return elfcore_write_note (abfd, buf, bufsiz,
"CORE", note_type, data, sizeof (data));
}
case NT_PRSTATUS:
{
char data[148];
va_list ap;
long pid;
int cursig;
const void *greg;
va_start (ap, note_type);
memset (data, 0, sizeof (data));
pid = va_arg (ap, long);
bfd_put_32 (abfd, pid, data + 24);
cursig = va_arg (ap, int);
bfd_put_16 (abfd, cursig, data + 12);
greg = va_arg (ap, const void *);
memcpy (data + 72, greg, 72);
va_end (ap);
return elfcore_write_note (abfd, buf, bufsiz,
"CORE", note_type, data, sizeof (data));
}
}
}
#define TARGET_LITTLE_SYM bfd_elf32_littlearm_vec #define TARGET_LITTLE_SYM bfd_elf32_littlearm_vec
#define TARGET_LITTLE_NAME "elf32-littlearm" #define TARGET_LITTLE_NAME "elf32-littlearm"
#define TARGET_BIG_SYM bfd_elf32_bigarm_vec #define TARGET_BIG_SYM bfd_elf32_bigarm_vec
@ -1995,6 +2043,7 @@ elf32_arm_nabi_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
#define elf_backend_grok_prstatus elf32_arm_nabi_grok_prstatus #define elf_backend_grok_prstatus elf32_arm_nabi_grok_prstatus
#define elf_backend_grok_psinfo elf32_arm_nabi_grok_psinfo #define elf_backend_grok_psinfo elf32_arm_nabi_grok_psinfo
#define elf_backend_write_core_note elf32_arm_nabi_write_core_note
typedef unsigned long int insn32; typedef unsigned long int insn32;
typedef unsigned short int insn16; typedef unsigned short int insn16;