This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH v2] Account for padding in FreeBSD/mipsn32 NT_PRSTATUS notes.
- From: Alan Modra <amodra at gmail dot com>
- To: John Baldwin <jhb at FreeBSD dot org>
- Cc: binutils at sourceware dot org
- Date: Fri, 6 Oct 2017 11:37:37 +1030
- Subject: Re: [PATCH v2] Account for padding in FreeBSD/mipsn32 NT_PRSTATUS notes.
- Authentication-results: sourceware.org; auth=none
- References: <20171005170815.14565-1-jhb@FreeBSD.org>
On Thu, Oct 05, 2017 at 10:08:15AM -0700, John Baldwin wrote:
> * elf-bfd.h (struct elf_backend_data): Add
> `elf_backend_grok_freebsd_prstatus'.
> * elf.c (elfcore_grok_freebsd_note): Call
> `elf_backend_grok_freebsd_prstatus' to handle NT_PRSTATUS if
> present.
> * elfn32-mips.c (elf_n32_mips_grok_freebsd_prstatus): New
> function.
> (elf_backend_grok_freebsd_prstatus): Define.
> * elfxx-target.h (elf_backend_grok_freebsd_prstatus): Define.
> (elfNN_bed): Initialize `elf_backend_grok_freebsd_prstatus'.
OK, except for a couple of style nits.
> +static bfd_boolean
> +elf_n32_mips_grok_freebsd_prstatus (bfd *abfd, Elf_Internal_Note *note)
> +{
> + size_t offset;
> + size_t size;
> + size_t min_size;
> +
> + /* Compute offset of pr_getregsz, skipping over pr_statussz.
> + Also compute minimum size of this note. */
> + offset = 4 + 4;
> + min_size = offset + (4 * 2) + 4 + 4 + 4;
Excess parentheses.
> +
> + if (note->descsz < min_size)
> + return FALSE;
> +
> + /* Check for version 1 in pr_version. */
> + if (bfd_h_get_32 (abfd, (bfd_byte *) note->descdata) != 1)
> + return FALSE;
> +
> + /* Extract size of pr_reg from pr_gregsetsz. */
> + /* Skip over pr_gregsetsz and pr_fpregsetsz. */
> + size = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + offset);
> + offset += 4 * 2;
> +
> + /* Skip over pr_osreldate. */
> + offset += 4;
> +
> + /* Read signal from pr_cursig. */
> + if (elf_tdata (abfd)->core->signal == 0)
> + elf_tdata (abfd)->core->signal
> + = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + offset);
> + offset += 4;
> +
> + /* Read TID from pr_pid. */
> + elf_tdata (abfd)->core->lwpid
> + = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + offset);
> + offset += 4;
> +
> + /* Padding before pr_reg. */
> + offset += 4;
> +
> + /* Make sure that there is enough data remaining in the note. */
> + if ((note->descsz - offset) < size)
And here.
--
Alan Modra
Australia Development Lab, IBM