|
Jan Kratochvil |
254f0e9 |
http://sourceware.org/ml/binutils/2011-12/msg00298.html
|
|
Jan Kratochvil |
254f0e9 |
Subject: [patch] Fix zero registers core files w/gcc-4.7
|
|
Jan Kratochvil |
254f0e9 |
|
|
Jan Kratochvil |
254f0e9 |
Hello H.J.,
|
|
Jan Kratochvil |
254f0e9 |
|
|
Jan Kratochvil |
254f0e9 |
there is a regression by:
|
|
Jan Kratochvil |
254f0e9 |
commit 2c9c556617a7de8657c25b512d272c26b070ae22
|
|
Jan Kratochvil |
254f0e9 |
Author: H.J. Lu <hjl.tools@gmail.com>
|
|
Jan Kratochvil |
254f0e9 |
Date: Thu Jun 16 22:08:10 2011 +0000
|
|
Jan Kratochvil |
254f0e9 |
Suport x32 gcore.
|
|
Jan Kratochvil |
254f0e9 |
|
|
Jan Kratochvil |
254f0e9 |
when built with -O2 by
|
|
Jan Kratochvil |
254f0e9 |
gcc (GCC) 4.7.0 20111223 (experimental)
|
|
Jan Kratochvil |
254f0e9 |
(not by 4.6.x)
|
|
Jan Kratochvil |
254f0e9 |
|
|
Jan Kratochvil |
254f0e9 |
as the code violates ISO C99 6.2.4 item 5 by using local variable outside of
|
|
Jan Kratochvil |
254f0e9 |
its block, GCC optimizes out the second memcpy, keeping there only that
|
|
Jan Kratochvil |
254f0e9 |
memset.
|
|
Jan Kratochvil |
254f0e9 |
|
|
Jan Kratochvil |
254f0e9 |
./gdb -nx ./gdb -ex start -ex 'gcore 1' -ex 'set confirm no' -ex q;gdb -nx ./gdb ./1 -ex q
|
|
Jan Kratochvil |
254f0e9 |
will print:
|
|
Jan Kratochvil |
254f0e9 |
Core was generated by `.../gdb/gdb'.
|
|
Jan Kratochvil |
254f0e9 |
#0 0x0000000000000000 in ?? ()
|
|
Jan Kratochvil |
254f0e9 |
|
|
Jan Kratochvil |
254f0e9 |
No regressions on x86_64-fedora16-linux-gnu.
|
|
Jan Kratochvil |
254f0e9 |
|
|
Jan Kratochvil |
254f0e9 |
Probably obvious, OK to check it in?
|
|
Jan Kratochvil |
254f0e9 |
|
|
Jan Kratochvil |
254f0e9 |
|
|
Jan Kratochvil |
254f0e9 |
Thanks,
|
|
Jan Kratochvil |
254f0e9 |
Jan
|
|
Jan Kratochvil |
254f0e9 |
|
|
Jan Kratochvil |
254f0e9 |
|
|
Jan Kratochvil |
254f0e9 |
bfd/
|
|
Jan Kratochvil |
254f0e9 |
2011-12-23 Jan Kratochvil <jan.kratochvil@redhat.com>
|
|
Jan Kratochvil |
254f0e9 |
|
|
Jan Kratochvil |
254f0e9 |
Fix zero registers core files when built by gcc-4.7.
|
|
Jan Kratochvil |
254f0e9 |
* elf64-x86-64.c (elf_x86_64_write_core_note): Remove variables p and
|
|
Jan Kratochvil |
254f0e9 |
size. Call elfcore_write_note for the local variables. Remove the
|
|
Jan Kratochvil |
254f0e9 |
final elfcore_write_note call. Add NOTREACHED comments.
|
|
Jan Kratochvil |
254f0e9 |
|
|
Jan Kratochvil |
254f0e9 |
--- a/bfd/elf64-x86-64.c
|
|
Jan Kratochvil |
254f0e9 |
+++ b/bfd/elf64-x86-64.c
|
|
Jan Kratochvil |
254f0e9 |
@@ -420,8 +420,6 @@ elf_x86_64_write_core_note (bfd *abfd, char *buf, int *bufsiz,
|
|
Jan Kratochvil |
254f0e9 |
int note_type, ...)
|
|
Jan Kratochvil |
254f0e9 |
{
|
|
Jan Kratochvil |
254f0e9 |
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
|
|
Jan Kratochvil |
254f0e9 |
- const void *p;
|
|
Jan Kratochvil |
254f0e9 |
- int size;
|
|
Jan Kratochvil |
254f0e9 |
va_list ap;
|
|
Jan Kratochvil |
254f0e9 |
const char *fname, *psargs;
|
|
Jan Kratochvil |
254f0e9 |
long pid;
|
|
Jan Kratochvil |
254f0e9 |
@@ -445,8 +443,8 @@ elf_x86_64_write_core_note (bfd *abfd, char *buf, int *bufsiz,
|
|
Jan Kratochvil |
254f0e9 |
memset (&data, 0, sizeof (data));
|
|
Jan Kratochvil |
254f0e9 |
strncpy (data.pr_fname, fname, sizeof (data.pr_fname));
|
|
Jan Kratochvil |
254f0e9 |
strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs));
|
|
Jan Kratochvil |
254f0e9 |
- p = (const void *) &dat;;
|
|
Jan Kratochvil |
254f0e9 |
- size = sizeof (data);
|
|
Jan Kratochvil |
254f0e9 |
+ return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type,
|
|
Jan Kratochvil |
254f0e9 |
+ &data, sizeof (data));
|
|
Jan Kratochvil |
254f0e9 |
}
|
|
Jan Kratochvil |
254f0e9 |
else
|
|
Jan Kratochvil |
254f0e9 |
{
|
|
Jan Kratochvil |
254f0e9 |
@@ -454,10 +452,10 @@ elf_x86_64_write_core_note (bfd *abfd, char *buf, int *bufsiz,
|
|
Jan Kratochvil |
254f0e9 |
memset (&data, 0, sizeof (data));
|
|
Jan Kratochvil |
254f0e9 |
strncpy (data.pr_fname, fname, sizeof (data.pr_fname));
|
|
Jan Kratochvil |
254f0e9 |
strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs));
|
|
Jan Kratochvil |
254f0e9 |
- p = (const void *) &dat;;
|
|
Jan Kratochvil |
254f0e9 |
- size = sizeof (data);
|
|
Jan Kratochvil |
254f0e9 |
+ return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type,
|
|
Jan Kratochvil |
254f0e9 |
+ &data, sizeof (data));
|
|
Jan Kratochvil |
254f0e9 |
}
|
|
Jan Kratochvil |
254f0e9 |
- break;
|
|
Jan Kratochvil |
254f0e9 |
+ /* NOTREACHED */
|
|
Jan Kratochvil |
254f0e9 |
|
|
Jan Kratochvil |
254f0e9 |
case NT_PRSTATUS:
|
|
Jan Kratochvil |
254f0e9 |
va_start (ap, note_type);
|
|
Jan Kratochvil |
254f0e9 |
@@ -475,8 +473,8 @@ elf_x86_64_write_core_note (bfd *abfd, char *buf, int *bufsiz,
|
|
Jan Kratochvil |
254f0e9 |
prstat.pr_pid = pid;
|
|
Jan Kratochvil |
254f0e9 |
prstat.pr_cursig = cursig;
|
|
Jan Kratochvil |
254f0e9 |
memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
|
|
Jan Kratochvil |
254f0e9 |
- p = (const void *) &prstat;
|
|
Jan Kratochvil |
254f0e9 |
- size = sizeof (prstat);
|
|
Jan Kratochvil |
254f0e9 |
+ return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type,
|
|
Jan Kratochvil |
254f0e9 |
+ &prstat, sizeof (prstat));
|
|
Jan Kratochvil |
254f0e9 |
}
|
|
Jan Kratochvil |
254f0e9 |
else
|
|
Jan Kratochvil |
254f0e9 |
{
|
|
Jan Kratochvil |
254f0e9 |
@@ -485,8 +483,8 @@ elf_x86_64_write_core_note (bfd *abfd, char *buf, int *bufsiz,
|
|
Jan Kratochvil |
254f0e9 |
prstat.pr_pid = pid;
|
|
Jan Kratochvil |
254f0e9 |
prstat.pr_cursig = cursig;
|
|
Jan Kratochvil |
254f0e9 |
memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
|
|
Jan Kratochvil |
254f0e9 |
- p = (const void *) &prstat;
|
|
Jan Kratochvil |
254f0e9 |
- size = sizeof (prstat);
|
|
Jan Kratochvil |
254f0e9 |
+ return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type,
|
|
Jan Kratochvil |
254f0e9 |
+ &prstat, sizeof (prstat));
|
|
Jan Kratochvil |
254f0e9 |
}
|
|
Jan Kratochvil |
254f0e9 |
}
|
|
Jan Kratochvil |
254f0e9 |
else
|
|
Jan Kratochvil |
254f0e9 |
@@ -496,14 +494,11 @@ elf_x86_64_write_core_note (bfd *abfd, char *buf, int *bufsiz,
|
|
Jan Kratochvil |
254f0e9 |
prstat.pr_pid = pid;
|
|
Jan Kratochvil |
254f0e9 |
prstat.pr_cursig = cursig;
|
|
Jan Kratochvil |
254f0e9 |
memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
|
|
Jan Kratochvil |
254f0e9 |
- p = (const void *) &prstat;
|
|
Jan Kratochvil |
254f0e9 |
- size = sizeof (prstat);
|
|
Jan Kratochvil |
254f0e9 |
+ return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type,
|
|
Jan Kratochvil |
254f0e9 |
+ &prstat, sizeof (prstat));
|
|
Jan Kratochvil |
254f0e9 |
}
|
|
Jan Kratochvil |
254f0e9 |
- break;
|
|
Jan Kratochvil |
254f0e9 |
}
|
|
Jan Kratochvil |
254f0e9 |
-
|
|
Jan Kratochvil |
254f0e9 |
- return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type, p,
|
|
Jan Kratochvil |
254f0e9 |
- size);
|
|
Jan Kratochvil |
254f0e9 |
+ /* NOTREACHED */
|
|
Jan Kratochvil |
254f0e9 |
}
|
|
Jan Kratochvil |
254f0e9 |
#endif
|
|
Jan Kratochvil |
254f0e9 |
|
|
Jan Kratochvil |
254f0e9 |
|