public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Re: [PATCH] i386/x86-64: adjust unwind information register encodings
@ 2005-05-06 15:30 Jan Beulich
  0 siblings, 0 replies; 7+ messages in thread
From: Jan Beulich @ 2005-05-06 15:30 UTC (permalink / raw)
  To: hjl; +Cc: binutils

>>> "H. J. Lu" <hjl@lucon.org> 06.05.05 16:00:38 >>>
>On Fri, May 06, 2005 at 02:01:21PM +0200, Jan Beulich wrote:
>> The register numbers used in x86-64's .eh_frame entries neither matched the
>> ABI nor the gcc implementation. Additionally, a significant amount of
>> registers were missing in both 32- and 64-bit modes (even now there are, but
>> only those for which there don't appear to be register numbers assigned in
>> the respective ABI).
>> 
>
>Have we been generating wrong unwind info up to now?

Yes, it looks like that.

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

* Re: [PATCH] i386/x86-64: adjust unwind information register encodings
  2005-05-06 16:06 Jan Beulich
@ 2005-05-06 16:14 ` H. J. Lu
  0 siblings, 0 replies; 7+ messages in thread
From: H. J. Lu @ 2005-05-06 16:14 UTC (permalink / raw)
  To: Jan Beulich; +Cc: binutils

On Fri, May 06, 2005 at 06:04:45PM +0200, Jan Beulich wrote:
> >>> "H. J. Lu" <hjl@lucon.org> 06.05.05 17:33:26 >>>
> >On Fri, May 06, 2005 at 05:05:48PM +0200, Jan Beulich wrote:
> >> >>> "H. J. Lu" <hjl@lucon.org> 06.05.05 16:00:38 >>>
> >> >On Fri, May 06, 2005 at 02:01:21PM +0200, Jan Beulich wrote:
> >> >> The register numbers used in x86-64's .eh_frame entries neither matched the
> >> >> ABI nor the gcc implementation. Additionally, a significant amount of
> >> >> registers were missing in both 32- and 64-bit modes (even now there are, but
> >> >> only those for which there don't appear to be register numbers assigned in
> >> >> the respective ABI).
> >> >> 
> >> >
> >> >Have we been generating wrong unwind info up to now?
> >> 
> >> Yes, it looks like that.
> >
> >How has it ever worked with glibc and gdb?
> 
> Because the CFI directives are rarely used, and (as Daniel pointed out) only some registers were mis-numbered.
> 

CFI directives are used in glibc. Have you double checked them?


H.J.

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

* Re: [PATCH] i386/x86-64: adjust unwind information register encodings
@ 2005-05-06 16:06 Jan Beulich
  2005-05-06 16:14 ` H. J. Lu
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Beulich @ 2005-05-06 16:06 UTC (permalink / raw)
  To: hjl; +Cc: binutils

>>> "H. J. Lu" <hjl@lucon.org> 06.05.05 17:33:26 >>>
>On Fri, May 06, 2005 at 05:05:48PM +0200, Jan Beulich wrote:
>> >>> "H. J. Lu" <hjl@lucon.org> 06.05.05 16:00:38 >>>
>> >On Fri, May 06, 2005 at 02:01:21PM +0200, Jan Beulich wrote:
>> >> The register numbers used in x86-64's .eh_frame entries neither matched the
>> >> ABI nor the gcc implementation. Additionally, a significant amount of
>> >> registers were missing in both 32- and 64-bit modes (even now there are, but
>> >> only those for which there don't appear to be register numbers assigned in
>> >> the respective ABI).
>> >> 
>> >
>> >Have we been generating wrong unwind info up to now?
>> 
>> Yes, it looks like that.
>
>How has it ever worked with glibc and gdb?

Because the CFI directives are rarely used, and (as Daniel pointed out) only some registers were mis-numbered.

Jan

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

* Re: [PATCH] i386/x86-64: adjust unwind information register encodings
  2005-05-06 15:37 ` H. J. Lu
@ 2005-05-06 15:42   ` Daniel Jacobowitz
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Jacobowitz @ 2005-05-06 15:42 UTC (permalink / raw)
  To: H. J. Lu; +Cc: Jan Beulich, binutils

On Fri, May 06, 2005 at 08:33:26AM -0700, H. J. Lu wrote:
> On Fri, May 06, 2005 at 05:05:48PM +0200, Jan Beulich wrote:
> > >>> "H. J. Lu" <hjl@lucon.org> 06.05.05 16:00:38 >>>
> > >On Fri, May 06, 2005 at 02:01:21PM +0200, Jan Beulich wrote:
> > >> The register numbers used in x86-64's .eh_frame entries neither matched the
> > >> ABI nor the gcc implementation. Additionally, a significant amount of
> > >> registers were missing in both 32- and 64-bit modes (even now there are, but
> > >> only those for which there don't appear to be register numbers assigned in
> > >> the respective ABI).
> > >> 
> > >
> > >Have we been generating wrong unwind info up to now?
> > 
> > Yes, it looks like that.
> 
> How has it ever worked with glibc and gdb?

Take a look at the changes in Jan's patch.  The errors only affect a
couple of GPRs, in 64-bit mode, when using gas's .cfi operators.

-- 
Daniel Jacobowitz
CodeSourcery, LLC

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

* Re: [PATCH] i386/x86-64: adjust unwind information register encodings
       [not found] <s27b95cc.095@emea1-mh.id2.novell.com>
@ 2005-05-06 15:37 ` H. J. Lu
  2005-05-06 15:42   ` Daniel Jacobowitz
  0 siblings, 1 reply; 7+ messages in thread
From: H. J. Lu @ 2005-05-06 15:37 UTC (permalink / raw)
  To: Jan Beulich; +Cc: binutils

On Fri, May 06, 2005 at 05:05:48PM +0200, Jan Beulich wrote:
> >>> "H. J. Lu" <hjl@lucon.org> 06.05.05 16:00:38 >>>
> >On Fri, May 06, 2005 at 02:01:21PM +0200, Jan Beulich wrote:
> >> The register numbers used in x86-64's .eh_frame entries neither matched the
> >> ABI nor the gcc implementation. Additionally, a significant amount of
> >> registers were missing in both 32- and 64-bit modes (even now there are, but
> >> only those for which there don't appear to be register numbers assigned in
> >> the respective ABI).
> >> 
> >
> >Have we been generating wrong unwind info up to now?
> 
> Yes, it looks like that.

How has it ever worked with glibc and gdb?


H.J.

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

* Re: [PATCH] i386/x86-64: adjust unwind information register encodings
  2005-05-06 12:02 Jan Beulich
@ 2005-05-06 14:00 ` H. J. Lu
  0 siblings, 0 replies; 7+ messages in thread
From: H. J. Lu @ 2005-05-06 14:00 UTC (permalink / raw)
  To: Jan Beulich; +Cc: binutils

On Fri, May 06, 2005 at 02:01:21PM +0200, Jan Beulich wrote:
> The register numbers used in x86-64's .eh_frame entries neither matched the
> ABI nor the gcc implementation. Additionally, a significant amount of
> registers were missing in both 32- and 64-bit modes (even now there are, but
> only those for which there don't appear to be register numbers assigned in
> the respective ABI).
> 

Have we been generating wrong unwind info up to now?


H.J.

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

* [PATCH] i386/x86-64: adjust unwind information register encodings
@ 2005-05-06 12:02 Jan Beulich
  2005-05-06 14:00 ` H. J. Lu
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Beulich @ 2005-05-06 12:02 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 2574 bytes --]

The register numbers used in x86-64's .eh_frame entries neither matched the
ABI nor the gcc implementation. Additionally, a significant amount of
registers were missing in both 32- and 64-bit modes (even now there are, but
only those for which there don't appear to be register numbers assigned in
the respective ABI).

Built and tested on i686-pc-linux-gnu and x86_64-unknown-linux-gnu.

Jan

gas/
2005-05-06  Jan Beulich  <jbeulich@novell.com>

	* config/tc-i386.c (tc_x86_regname_to_dw2regnum): Correct 64-bit mode
	names to match ABI. Add more registers for 32-bit and 64-bit modes.
	Make name array static and const. Adjust lookup to account for NULL
	entries (standing for unused register numbers).

--- /home/jbeulich/src/binutils/mainline/2005-05-06/gas/config/tc-i386.c	2005-05-06 08:24:28.000000000 +0200
+++ 2005-05-06/gas/config/tc-i386.c	2005-05-06 11:45:55.861726528 +0200
@@ -6777,21 +6796,36 @@ tc_x86_regname_to_dw2regnum (const char 
 {
   unsigned int regnum;
   unsigned int regnames_count;
-  char *regnames_32[] =
+  static const char *const regnames_32[] =
     {
       "eax", "ecx", "edx", "ebx",
       "esp", "ebp", "esi", "edi",
-      "eip"
+      "eip", "eflags", NULL,
+      "st0", "st1", "st2", "st3",
+      "st4", "st5", "st6", "st7",
+      NULL, NULL,
+      "xmm0", "xmm1", "xmm2", "xmm3",
+      "xmm4", "xmm5", "xmm6", "xmm7",
+      "mm0", "mm1", "mm2", "mm3",
+      "mm4", "mm5", "mm6", "mm7"
     };
-  char *regnames_64[] =
+  static const char *const regnames_64[] =
     {
-      "rax", "rbx", "rcx", "rdx",
-      "rdi", "rsi", "rbp", "rsp",
-      "r8", "r9", "r10", "r11",
+      "rax", "rdx", "rcx", "rbx",
+      "rsi", "rdi", "rbp", "rsp",
+      "r8",  "r9",  "r10", "r11",
       "r12", "r13", "r14", "r15",
-      "rip"
+      "rip",
+      "xmm0",  "xmm1",  "xmm2",  "xmm3",
+      "xmm4",  "xmm5",  "xmm6",  "xmm7",
+      "xmm8",  "xmm9",  "xmm10", "xmm11",
+      "xmm12", "xmm13", "xmm14", "xmm15",
+      "st0", "st1", "st2", "st3",
+      "st4", "st5", "st6", "st7",
+      "mm0", "mm1", "mm2", "mm3",
+      "mm4", "mm5", "mm6", "mm7"
     };
-  char **regnames;
+  const char *const *regnames;
 
   if (flag_code == CODE_64BIT)
     {
@@ -6805,7 +6839,8 @@ tc_x86_regname_to_dw2regnum (const char 
     }
 
   for (regnum = 0; regnum < regnames_count; regnum++)
-    if (strcmp (regname, regnames[regnum]) == 0)
+    if (regnames[regnum] != NULL
+	&& strcmp (regname, regnames[regnum]) == 0)
       return regnum;
 
   return -1;



[-- Attachment #2: binutils-mainline-x86-cfi-regnum.patch --]
[-- Type: text/plain, Size: 2495 bytes --]

The register numbers used in x86-64's .eh_frame entries neither matched the
ABI nor the gcc implementation. Additionally, a significant amount of
registers were missing in both 32- and 64-bit modes (even now there are, but
only those for which there don't appear to be register numbers assigned in
the respective ABI).

Built and tested on i686-pc-linux-gnu and x86_64-unknown-linux-gnu.

Jan

gas/
2005-05-06  Jan Beulich  <jbeulich@novell.com>

	* config/tc-i386.c (tc_x86_regname_to_dw2regnum): Correct 64-bit mode
	names to match ABI. Add more registers for 32-bit and 64-bit modes.
	Make name array static and const. Adjust lookup to account for NULL
	entries (standing for unused register numbers).

--- /home/jbeulich/src/binutils/mainline/2005-05-06/gas/config/tc-i386.c	2005-05-06 08:24:28.000000000 +0200
+++ 2005-05-06/gas/config/tc-i386.c	2005-05-06 11:45:55.861726528 +0200
@@ -6777,21 +6796,36 @@ tc_x86_regname_to_dw2regnum (const char 
 {
   unsigned int regnum;
   unsigned int regnames_count;
-  char *regnames_32[] =
+  static const char *const regnames_32[] =
     {
       "eax", "ecx", "edx", "ebx",
       "esp", "ebp", "esi", "edi",
-      "eip"
+      "eip", "eflags", NULL,
+      "st0", "st1", "st2", "st3",
+      "st4", "st5", "st6", "st7",
+      NULL, NULL,
+      "xmm0", "xmm1", "xmm2", "xmm3",
+      "xmm4", "xmm5", "xmm6", "xmm7",
+      "mm0", "mm1", "mm2", "mm3",
+      "mm4", "mm5", "mm6", "mm7"
     };
-  char *regnames_64[] =
+  static const char *const regnames_64[] =
     {
-      "rax", "rbx", "rcx", "rdx",
-      "rdi", "rsi", "rbp", "rsp",
-      "r8", "r9", "r10", "r11",
+      "rax", "rdx", "rcx", "rbx",
+      "rsi", "rdi", "rbp", "rsp",
+      "r8",  "r9",  "r10", "r11",
       "r12", "r13", "r14", "r15",
-      "rip"
+      "rip",
+      "xmm0",  "xmm1",  "xmm2",  "xmm3",
+      "xmm4",  "xmm5",  "xmm6",  "xmm7",
+      "xmm8",  "xmm9",  "xmm10", "xmm11",
+      "xmm12", "xmm13", "xmm14", "xmm15",
+      "st0", "st1", "st2", "st3",
+      "st4", "st5", "st6", "st7",
+      "mm0", "mm1", "mm2", "mm3",
+      "mm4", "mm5", "mm6", "mm7"
     };
-  char **regnames;
+  const char *const *regnames;
 
   if (flag_code == CODE_64BIT)
     {
@@ -6805,7 +6839,8 @@ tc_x86_regname_to_dw2regnum (const char 
     }
 
   for (regnum = 0; regnum < regnames_count; regnum++)
-    if (strcmp (regname, regnames[regnum]) == 0)
+    if (regnames[regnum] != NULL
+	&& strcmp (regname, regnames[regnum]) == 0)
       return regnum;
 
   return -1;

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

end of thread, other threads:[~2005-05-06 16:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-06 15:30 [PATCH] i386/x86-64: adjust unwind information register encodings Jan Beulich
  -- strict thread matches above, loose matches on Subject: below --
2005-05-06 16:06 Jan Beulich
2005-05-06 16:14 ` H. J. Lu
     [not found] <s27b95cc.095@emea1-mh.id2.novell.com>
2005-05-06 15:37 ` H. J. Lu
2005-05-06 15:42   ` Daniel Jacobowitz
2005-05-06 12:02 Jan Beulich
2005-05-06 14:00 ` H. J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).