From: Alan Modra <amodra@bigpond.net.au>
To: Geoff Keating <geoffk@desire.geoffk.org>
Cc: cagney@gnu.org, kettenis@chello.nl, gcc-patches@gcc.gnu.org,
dje@watson.ibm.com, gdb-patches@sources.redhat.com,
Ulrich.Weigand@de.ibm.com
Subject: Re: Incorrect DWARF-2 register numbers on PPC64?
Date: Fri, 09 Jan 2004 02:34:00 -0000 [thread overview]
Message-ID: <20040109023442.GF2969@bubble.modra.org> (raw)
In-Reply-To: <200401080501.i0851VBx016440@desire.geoffk.org>
On Wed, Jan 07, 2004 at 09:01:31PM -0800, Geoff Keating wrote:
> That will also mean that executables built with a new version of GCC won't
> run on operating systems with an old libgcc. For Darwin, because of
> historical mistakes involving non-shared libgcc, it will make life
> very difficult.
I hadn't thought of that. This means we are stuck with the current
.eh_frame register numbering. It should be possible to fix .debug_frame
with something like the following totally untested patch. I'm throwing
it out to the list now for comment.
With a little more work, I can get rid of DWARF_REG_TO_UNWIND_COLUMN
by having the SPE hack generate a number suitable for .eh_frame, and
mapping up to 1200 in DBX_REGISTER_NUMBER and the new
DWARF2_FRAME_REG_OUT. So the final patch won't increasing the number of
macros littering gcc. :)
* config/rs6000/sysv4.h (DWARF2_FRAME_REG_OUT): Define.
* dwraf2out.c (output_cfi): Map regs using DWARF2_FRAME_REG_OUT.
Index: gcc/config/rs6000/sysv4.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/sysv4.h,v
retrieving revision 1.144
diff -u -p -r1.144 sysv4.h
--- gcc/config/rs6000/sysv4.h 7 Jan 2004 01:21:28 -0000 1.144
+++ gcc/config/rs6000/sysv4.h 9 Jan 2004 02:24:39 -0000
@@ -744,6 +744,18 @@ extern int fixuplabelno;
#define DBX_REGISTER_NUMBER(REGNO) rs6000_dbx_register_number (REGNO)
+/* Map register numbers held in the call frame info that gcc has
+ collected using DWARF_FRAME_REGNUM to those that should be output in
+ .debug_frame and .eh_frame. We continue to use gcc hard reg numbers
+ for .eh_frame, but use the numbers mandated by the various ABIs for
+ .debug_frame. rs6000_emit_prologue has translated any combination of
+ CR2, CR3, CR4 saves to a save of CR2. The actual code emitted saves
+ the whole of CR, so we map CR2_REGNO to the DWARF reg for CR. */
+#define DWARF2_FRAME_REG_OUT(REGNO, FOR_EH) \
+ ((FOR_EH) ? (REGNO) \
+ : (REGNO) == CR2_REGNO ? 64 \
+ : DBX_REGISTER_NUMBER (REGNO))
+
#define TARGET_ENCODE_SECTION_INFO rs6000_elf_encode_section_info
#define TARGET_IN_SMALL_DATA_P rs6000_elf_in_small_data_p
#define TARGET_SECTION_TYPE_FLAGS rs6000_elf_section_type_flags
Index: gcc/dwarf2out.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dwarf2out.c,v
retrieving revision 1.471
diff -u -p -r1.471 dwarf2out.c
--- gcc/dwarf2out.c 8 Jan 2004 07:54:11 -0000 1.471
+++ gcc/dwarf2out.c 9 Jan 2004 02:24:32 -0000
@@ -1783,11 +1783,21 @@ dw_cfi_oprnd2_desc (enum dwarf_call_fram
#if defined (DWARF2_DEBUGGING_INFO) || defined (DWARF2_UNWIND_INFO)
+/* Map register numbers held in the call frame info that gcc has
+ collected using DWARF_FRAME_REGNUM to those that should be output in
+ .debug_frame and .eh_frame. */
+#ifndef DWARF2_FRAME_REG_OUT
+#define DWARF2_FRAME_REG_OUT(REGNO, FOR_EH) (REGNO)
+#endif
+
/* Output a Call Frame Information opcode and its operand(s). */
static void
output_cfi (dw_cfi_ref cfi, dw_fde_ref fde, int for_eh)
{
+ unsigned long op1_reg;
+ op1_reg = DWARF2_FRAME_REG_OUT (cfi->dw_cfi_oprnd1.dw_cfi_reg_num, for_eh);
+
if (cfi->dw_cfi_opc == DW_CFA_advance_loc)
dw2_asm_output_data (1, (cfi->dw_cfi_opc
| (cfi->dw_cfi_oprnd1.dw_cfi_offset & 0x3f)),
@@ -1795,17 +1805,15 @@ output_cfi (dw_cfi_ref cfi, dw_fde_ref f
cfi->dw_cfi_oprnd1.dw_cfi_offset);
else if (cfi->dw_cfi_opc == DW_CFA_offset)
{
- dw2_asm_output_data (1, (cfi->dw_cfi_opc
- | (cfi->dw_cfi_oprnd1.dw_cfi_reg_num & 0x3f)),
+ dw2_asm_output_data (1, (cfi->dw_cfi_opc | (op1_reg & 0x3f)),
"DW_CFA_offset, column 0x%lx",
- cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
+ op1_reg);
dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd2.dw_cfi_offset, NULL);
}
else if (cfi->dw_cfi_opc == DW_CFA_restore)
- dw2_asm_output_data (1, (cfi->dw_cfi_opc
- | (cfi->dw_cfi_oprnd1.dw_cfi_reg_num & 0x3f)),
+ dw2_asm_output_data (1, (cfi->dw_cfi_opc | (op1_reg & 0x3f)),
"DW_CFA_restore, column 0x%lx",
- cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
+ op1_reg);
else
{
dw2_asm_output_data (1, cfi->dw_cfi_opc,
@@ -1850,15 +1858,13 @@ output_cfi (dw_cfi_ref cfi, dw_fde_ref f
case DW_CFA_offset_extended:
case DW_CFA_def_cfa:
- dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num,
- NULL);
+ dw2_asm_output_data_uleb128 (op1_reg, NULL);
dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd2.dw_cfi_offset, NULL);
break;
case DW_CFA_offset_extended_sf:
case DW_CFA_def_cfa_sf:
- dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num,
- NULL);
+ dw2_asm_output_data_uleb128 (op1_reg, NULL);
dw2_asm_output_data_sleb128 (cfi->dw_cfi_oprnd2.dw_cfi_offset, NULL);
break;
@@ -1866,15 +1872,14 @@ output_cfi (dw_cfi_ref cfi, dw_fde_ref f
case DW_CFA_undefined:
case DW_CFA_same_value:
case DW_CFA_def_cfa_register:
- dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num,
- NULL);
+ dw2_asm_output_data_uleb128 (op1_reg, NULL);
break;
case DW_CFA_register:
- dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd1.dw_cfi_reg_num,
- NULL);
- dw2_asm_output_data_uleb128 (cfi->dw_cfi_oprnd2.dw_cfi_reg_num,
- NULL);
+ dw2_asm_output_data_uleb128 (op1_reg, NULL);
+ dw2_asm_output_data_uleb128
+ (DWARF2_FRAME_REG_OUT (cfi->dw_cfi_oprnd2.dw_cfi_reg_num, for_eh),
+ NULL);
break;
case DW_CFA_def_cfa_offset:
@@ -1904,7 +1909,7 @@ output_cfi (dw_cfi_ref cfi, dw_fde_ref f
}
}
-/* Output the call frame information used to used to record information
+/* Output the call frame information used to record information
that relates to calculating the frame pointer, and records the
location of saved registers. */
--
Alan Modra
IBM OzLabs - Linux Technology Centre
next prev parent reply other threads:[~2004-01-09 2:34 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <OFEA5CA921.302AEEB5-ON41256E00.005FB141@de.ibm.com>
2003-12-18 22:58 ` David Edelsohn
2003-12-20 15:27 ` Mark Kettenis
2004-01-02 16:46 ` Andrew Cagney
2004-01-02 23:18 ` Geoff Keating
2004-01-06 15:27 ` Alan Modra
[not found] ` <amodra@bigpond.net.au>
2004-01-06 16:02 ` David Edelsohn
2004-01-06 18:07 ` Geoff Keating
2004-01-06 18:10 ` David Edelsohn
2004-01-06 22:05 ` Geoff Keating
2004-01-06 22:09 ` David Edelsohn
2004-01-06 22:34 ` Geoff Keating
2004-01-07 0:27 ` Alan Modra
2004-01-07 17:43 ` Mark Kettenis
2004-01-07 22:29 ` Alan Modra
2004-01-07 23:36 ` Andrew Cagney
2004-01-08 0:48 ` Alan Modra
2004-01-08 5:02 ` Geoff Keating
2004-01-09 2:34 ` Alan Modra [this message]
2004-01-09 2:49 ` Alan Modra
2004-01-09 6:39 ` Alan Modra
2004-01-09 15:16 ` Mark Kettenis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040109023442.GF2969@bubble.modra.org \
--to=amodra@bigpond.net.au \
--cc=Ulrich.Weigand@de.ibm.com \
--cc=cagney@gnu.org \
--cc=dje@watson.ibm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=gdb-patches@sources.redhat.com \
--cc=geoffk@desire.geoffk.org \
--cc=kettenis@chello.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox