This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2] Account for padding in FreeBSD/mipsn32 NT_PRSTATUS notes.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]