[PATCH/RFC 01/02 v2] Refactor PRPSINFO handling on Binutils

H.J. Lu hjl.tools@gmail.com
Mon Dec 17 15:43:00 GMT 2012


On Sun, Dec 16, 2012 at 7:09 PM, Sergio Durigan Junior
<sergiodj@redhat.com> wrote:
> Hi,
>
> This is a follow-up on:
>      <http://sourceware.org/ml/binutils/2012-11/msg00240.html>
>
> Sorry for the delay on this.  I addressed Pedro's and H.J.'s comments,
> and took some time to test the patch on different architectures.
>
> It also took me some time to decide the best way to handle several
> little issues that I was facing: different declarations for PPC needed,
> different declarations for PRPSINFO structures, etc.
>
> Anyway, I hope I managed to solve these problems, but I would really
> appreciate some comments (if you have, of course) about the code.  The
> idea was to simplify the handling of PRPSINFO, so:
>
> 1) I created elf_{internal,external}_prpsinfo* structures, organized
> differently according to their purposes.
>
> 2) I created the new PRPSINFO*_COPY_FIELDS macros, which take care of
> (duh) copying the fields from the internal to the external structures,
> obeying bitness and such.
>
> 3) I also took the liberty to implement the i386 version of the
> *_write_core_note.
>
> 4) I removed some dependency on the CORE_HEADER macro (suggested by
> Pedro).  Not sure if everything is correct, though.
>
> Anyway, I guess those are the main changes.  Please let me know if you
> have some question about the patch.  Thanks.
>

> +
> +static char *
> +elf_i386_write_core_note (bfd *abfd, char *buf, int *bufsiz,
> +                         int note_type, ...)
> +{
> +  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
> +  va_list ap;
> +  const struct elf_internal_prpsinfo *prpsinfo;
> +  long pid;
> +  int cursig;
> +  const void *gregs;
> +  struct elf_external_prpsinfo32 data;
> +
> +  switch (note_type)
> +    {
> +    default:
> +      return NULL;
> +
> +    case NT_PRPSINFO:
> +      va_start (ap, note_type);
> +      prpsinfo = va_arg (ap, const struct elf_internal_prpsinfo *);
> +      va_end (ap);
> +
> +      memset (&data, 0, sizeof (data));
> +      PRPSINFO32_COPY_FIELDS (abfd, prpsinfo, data);
> +
> +      return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type,
> +                                &data, sizeof (data));
> +      /* NOTREACHED */
> +
> +    case NT_PRSTATUS:
> +      va_start (ap, note_type);
> +      pid = va_arg (ap, long);
> +      cursig = va_arg (ap, int);
> +      gregs = va_arg (ap, const void *);
> +      va_end (ap);
> +
> +      if (bed->elf_machine_code == EM_X86_64)
> +       {
> +         prstatusx32_t prstat;
> +         memset (&prstat, 0, sizeof (prstat));
> +         prstat.pr_pid = pid;
> +         prstat.pr_cursig = cursig;
> +         memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
> +         return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type,
> +                                    &prstat, sizeof (prstat));
> +       }
> +      else

When will elf_i386_write_core_note be called for
x32 process?


-- 
H.J.



More information about the Binutils mailing list