This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA/PATCH] Fix recognition of NT_PRXFREG notes
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Mark Kettenis <kettenis at chello dot nl>
- Cc: binutils at sources dot redhat dot com, gdb-patches at sources dot redhat dot com
- Date: Fri, 5 Jul 2002 11:00:29 +0930
- Subject: Re: [RFA/PATCH] Fix recognition of NT_PRXFREG notes
- References: <200207041503.g64F3Mj08511@elgar.kettenis.dyndns.org>
On Thu, Jul 04, 2002 at 05:03:22PM +0200, Mark Kettenis wrote:
> Index: elf.c
> ===================================================================
> RCS file: /cvs/src/src/bfd/elf.c,v
> retrieving revision 1.152
> diff -u -p -r1.152 elf.c
> --- elf.c 4 Jul 2002 13:26:30 -0000 1.152
> +++ elf.c 4 Jul 2002 14:54:36 -0000
> @@ -6718,8 +6718,7 @@ elfcore_grok_note (abfd, note)
> #endif
>
> case NT_PRXFPREG: /* Linux SSE extension */
> - if (note->namesz == 5
> - && ! strcmp (note->namedata, "LINUX"))
> + if (strncmp (note->namedata, "LINUX", 5) == 0)
> return elfcore_grok_prxfpreg (abfd, note);
> else
> return true;
Don't the alignment rules require that the name be padded out to a
multiple of 4 chars? (or 8 on 64 bit ELF files). So you should have
'L','I','N','U','X','\0','\0','\0' and thus can use strcmp. Also,
it's a good idea to check namesz before accessing namedata. I'm
sure I can make your strncmp segfault by carefully crafting a
non-compliant note.
Hmm, on re-reading the ELF standard, I see the pad char isn't
specified. :-( But obviously the original strcmp worked, so the
pad from the kernel is zero. Please use
if (note->namesz >= 5
&& strcmp (note->namedata, "LINUX") == 0)
and commit the patch. Thanks.
--
Alan Modra
IBM OzLabs - Linux Technology Centre