From: "Martin M. Hunt" <hunt@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: [RFA] dwarf2-frame.c sign extension patch
Date: Tue, 20 Jul 2004 19:11:00 -0000 [thread overview]
Message-ID: <1090350684.3030.10.camel@dragon> (raw)
[-- Attachment #1: Type: text/plain, Size: 637 bytes --]
This patch fixes some dwarf2 problems with sign-extension.
2004-07-20 Kevin Buettner and Martin Hunt <hunt@redhat.com>
* dwarf2-frame.c (execute_cfa_program): Fix typo in which the
alignment was being added to the offset instead of multiplied.
(struct comp_unit): Add new field ``signed_addr_p''.
(encoding_for_size): Add new parameter ``signed_addr_p''.
Adjust all callers. Add code for handling signed encodings.
(dwarf2_build_frame_info): Initialize ``unit.signed_addr_p''.
(dwarf2_build_frame_info): Set unit.addr_size.
--
Martin M. Hunt <hunt@redhat.com>
Red Hat Inc.
[-- Attachment #2: cfi_patch --]
[-- Type: text/x-patch, Size: 2606 bytes --]
Index: dwarf2-frame.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2-frame.c,v
retrieving revision 1.36
diff -w -u -r1.36 dwarf2-frame.c
--- dwarf2-frame.c 15 Jun 2004 01:04:19 -0000 1.36
+++ dwarf2-frame.c 20 Jul 2004 18:54:54 -0000
@@ -426,7 +428,7 @@
case DW_CFA_offset_extended_sf:
insn_ptr = read_uleb128 (insn_ptr, insn_end, ®);
insn_ptr = read_sleb128 (insn_ptr, insn_end, &offset);
- offset += fs->data_align;
+ offset *= fs->data_align;
dwarf2_frame_state_alloc_regs (&fs->regs, reg + 1);
fs->regs.reg[reg].how = DWARF2_FRAME_REG_SAVED_OFFSET;
fs->regs.reg[reg].loc.offset = offset;
@@ -893,6 +895,9 @@
/* Address size for this unit - from unit header. */
unsigned char addr_size;
+ /* Are addresses signed? */
+ unsigned char signed_addr_p;
+
/* Pointer to the .debug_frame section loaded into memory. */
char *dwarf_frame_buffer;
@@ -1021,15 +1026,24 @@
should be dereferenced. */
static unsigned char
-encoding_for_size (unsigned int size)
+encoding_for_size (unsigned int size, int signed_addr_p)
{
switch (size)
{
case 2:
+ if (signed_addr_p)
+ return DW_EH_PE_sdata2;
+ else
return DW_EH_PE_udata2;
case 4:
+ if (signed_addr_p)
+ return DW_EH_PE_sdata4;
+ else
return DW_EH_PE_udata4;
case 8:
+ if (signed_addr_p)
+ return DW_EH_PE_sdata8;
+ else
return DW_EH_PE_udata8;
default:
internal_error (__FILE__, __LINE__, "Unsupported address size");
@@ -1110,7 +1124,7 @@
}
if ((encoding & 0x0f) == 0x00)
- encoding |= encoding_for_size (ptr_len);
+ encoding |= encoding_for_size (ptr_len, unit->signed_addr_p);
switch (encoding & 0x0f)
{
@@ -1286,7 +1300,7 @@
/* The encoding for FDE's in a normal .debug_frame section
depends on the target address size as specified in the
Compilation Unit Header. */
- cie->encoding = encoding_for_size (unit->addr_size);
+ cie->encoding = encoding_for_size (unit->addr_size, unit->signed_addr_p);
/* Check version number. */
cie_version = read_1_byte (unit->abfd, buf);
@@ -1557,7 +1571,8 @@
/* Build a minimal decoding of the DWARF2 compilation unit. */
unit.abfd = objfile->obfd;
unit.objfile = objfile;
- unit.addr_size = objfile->obfd->arch_info->bits_per_address / 8;
+ unit.addr_size = TYPE_LENGTH (builtin_type_void_data_ptr);
+ unit.signed_addr_p = bfd_get_sign_extend_vma (unit.abfd);
unit.dbase = 0;
unit.tbase = 0;
next reply other threads:[~2004-07-20 19:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-20 19:11 Martin M. Hunt [this message]
2004-07-21 20:30 ` Mark Kettenis
2004-07-21 21:18 ` Daniel Jacobowitz
2004-07-22 0:41 ` Kevin Buettner
2004-07-22 0:47 ` Daniel Jacobowitz
2004-07-22 20:46 ` Mark Kettenis
2004-07-22 20:59 ` Daniel Jacobowitz
2004-07-23 17:54 ` Martin M. Hunt
2004-07-23 22:10 ` 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=1090350684.3030.10.camel@dragon \
--to=hunt@redhat.com \
--cc=gdb-patches@sources.redhat.com \
/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