Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA/PATCH] Fix recognition of NT_PRXFREG notes
@ 2002-07-04  8:15 Mark Kettenis
  2002-07-04 20:05 ` Alan Modra
  2002-07-05  7:45 ` Nick Clifton
  0 siblings, 2 replies; 3+ messages in thread
From: Mark Kettenis @ 2002-07-04  8:15 UTC (permalink / raw)
  To: binutils; +Cc: gdb-patches

After Alan's 2002-06-25 change some tests in GDB's testsuite have been
failing on Linux.  Turns out the current code that reads NT_PRXFREG
notes expects note->namesz to be 5, but with the trailing 0, the
length of "LINUX" is 6.  Turns out the Linux kernel doesn't include
the trailing 0 in the name size.  According to the Systemm V ABI the
trailing 0 should be included, so Alan's change is correct and Linux
is wrong here.  But since changing the Linux kernel isn't going to
happen overnight, I propose the attached fix.

Ok to check this in?

Mark


Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* elf.c (elfcore_grok_note): Fix recognition of NT_PRXFREG notes.

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;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFA/PATCH] Fix recognition of NT_PRXFREG notes
  2002-07-04  8:15 [RFA/PATCH] Fix recognition of NT_PRXFREG notes Mark Kettenis
@ 2002-07-04 20:05 ` Alan Modra
  2002-07-05  7:45 ` Nick Clifton
  1 sibling, 0 replies; 3+ messages in thread
From: Alan Modra @ 2002-07-04 20:05 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: binutils, gdb-patches

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFA/PATCH] Fix recognition of NT_PRXFREG notes
  2002-07-04  8:15 [RFA/PATCH] Fix recognition of NT_PRXFREG notes Mark Kettenis
  2002-07-04 20:05 ` Alan Modra
@ 2002-07-05  7:45 ` Nick Clifton
  1 sibling, 0 replies; 3+ messages in thread
From: Nick Clifton @ 2002-07-05  7:45 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: binutils, gdb-patches

Hi Mark,

> After Alan's 2002-06-25 change some tests in GDB's testsuite have been
> failing on Linux.  Turns out the current code that reads NT_PRXFREG
> notes expects note->namesz to be 5, but with the trailing 0, the
> length of "LINUX" is 6.  Turns out the Linux kernel doesn't include
> the trailing 0 in the name size.  According to the Systemm V ABI the
> trailing 0 should be included, so Alan's change is correct and Linux
> is wrong here.  But since changing the Linux kernel isn't going to
> happen overnight, I propose the attached fix.
> 
> Ok to check this in?
 
> Index: ChangeLog
> from  Mark Kettenis  <kettenis@gnu.org>
> 
> 	* elf.c (elfcore_grok_note): Fix recognition of NT_PRXFREG notes.

Approved - but, please add a comment explaining this situation, so
that somebody is not tempted to change the code back.

Cheers
        Nick


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-07-05 14:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-04  8:15 [RFA/PATCH] Fix recognition of NT_PRXFREG notes Mark Kettenis
2002-07-04 20:05 ` Alan Modra
2002-07-05  7:45 ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox