From: "H . J . Lu" <hjl@lucon.org>
To: gdb@sources.redhat.com
Subject: Re: The problem with stabs and sign extension
Date: Wed, 08 Aug 2001 17:03:00 -0000 [thread overview]
Message-ID: <20010808170326.A4132@lucon.org> (raw)
In-Reply-To: <20010808165359.A3964@lucon.org>
On Wed, Aug 08, 2001 at 04:53:59PM -0700, H . J . Lu wrote:
> With this patch, I can do
>
> # gdb vmlinux
> ...
> (gdb) print printk
> $1 = {int (char *)} 0x8011c5b0 <printk>
> (gdb) list printk
> 250 printk.c: No such file or directory.
> in printk.c
>
>
Here is an update.
H.J.
---
2001-08-08 H.J. Lu (hjl@gnu.org)
* dbxread.c (COERCE32): New.
(SWAP_SYMBOL): Removed.
(INTERNALIZE_SYMBOL): Check sign extended vma.
(read_ofile_symtab): Set text_offset with COERCE32 if
necessary.
--- gdb/dbxread.c.vma Fri Jul 13 12:12:34 2001
+++ gdb/dbxread.c Wed Aug 8 17:00:26 2001
@@ -109,6 +109,10 @@ struct symloc
#define SYMBOL_OFFSET(p) (SYMLOC(p)->symbol_offset)
#define STRING_OFFSET(p) (SYMLOC(p)->string_offset)
#define FILE_STRING_OFFSET(p) (SYMLOC(p)->file_string_offset)
+
+/* Sign extension to bfd_signed_vma. */
+#define COERCE32(x) \
+ ((bfd_signed_vma) (long) (((unsigned long) (x) ^ 0x80000000) - 0x80000000))
\f
/* Remember what we deduced to be the source language of this psymtab. */
@@ -946,22 +950,15 @@ fill_symbuf (bfd *sym_bfd)
symbuf_read += nbytes;
}
-#define SWAP_SYMBOL(symp, abfd) \
- { \
- (symp)->n_strx = bfd_h_get_32(abfd, \
- (unsigned char *)&(symp)->n_strx); \
- (symp)->n_desc = bfd_h_get_16 (abfd, \
- (unsigned char *)&(symp)->n_desc); \
- (symp)->n_value = bfd_h_get_32 (abfd, \
- (unsigned char *)&(symp)->n_value); \
- }
-
#define INTERNALIZE_SYMBOL(intern, extern, abfd) \
{ \
(intern).n_type = bfd_h_get_8 (abfd, (extern)->e_type); \
(intern).n_strx = bfd_h_get_32 (abfd, (extern)->e_strx); \
(intern).n_desc = bfd_h_get_16 (abfd, (extern)->e_desc); \
- (intern).n_value = bfd_h_get_32 (abfd, (extern)->e_value); \
+ if (bfd_get_sign_extend_vma (abfd)) \
+ (intern).n_value = bfd_h_get_signed_32 (abfd, (extern)->e_value); \
+ else \
+ (intern).n_value = bfd_h_get_32 (abfd, (extern)->e_value); \
}
/* Invariant: The symbol pointed to by symbuf_idx is the first one
@@ -1685,9 +1682,13 @@ read_ofile_symtab (struct partial_symtab
struct section_offsets *section_offsets;
objfile = pst->objfile;
+ abfd = objfile->obfd;
sym_offset = LDSYMOFF (pst);
sym_size = LDSYMLEN (pst);
- text_offset = pst->textlow;
+ if (bfd_get_sign_extend_vma (abfd))
+ text_offset = COERCE32 (pst->textlow);
+ else
+ text_offset = pst->textlow;
text_size = pst->texthigh - pst->textlow;
/* This cannot be simply objfile->section_offsets because of
elfstab_offset_sections() which initializes the psymtab section
@@ -1701,7 +1702,6 @@ read_ofile_symtab (struct partial_symtab
stringtab_global = DBX_STRINGTAB (objfile);
last_source_file = NULL;
- abfd = objfile->obfd;
symfile_bfd = objfile->obfd; /* Implicit param to next_text_symbol */
symbuf_end = symbuf_idx = 0;
next prev parent reply other threads:[~2001-08-08 17:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-08-08 14:11 Daniel Jacobowitz
2001-08-08 16:14 ` H . J . Lu
2001-08-08 16:54 ` H . J . Lu
2001-08-08 17:03 ` H . J . Lu [this message]
2001-08-08 17:15 ` [rfa] " Daniel Jacobowitz
2001-08-08 21:06 ` H . J . Lu
2001-08-10 15:31 ` H . J . Lu
2001-08-14 21:58 ` Elena Zannoni
2001-08-14 22:04 ` H . J . Lu
[not found] ` <15226.51428.874589.613358@krustylu.cygnus.com>
2001-08-15 12:04 ` H . J . Lu
2001-08-16 15:13 ` Daniel Jacobowitz
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=20010808170326.A4132@lucon.org \
--to=hjl@lucon.org \
--cc=gdb@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