From: Roland Puntaier <Roland.Puntaier@br-automation.com>
To: gdb@sources.redhat.com
Subject: relocations when doing file command at gdb prompt
Date: Wed, 07 Mar 2007 16:16:00 -0000 [thread overview]
Message-ID: <OFBFDF245F.7A7D00B6-ONC1257297.0059124B-C1257297.00595BFC@br-automation.com> (raw)
Hi,
maybe someone can help me.
The Problem
-----------
I try to remote debug an embedded device with gdb.
(gdb) target remote XXX
I found that in
remote.c:
get_offsets(){...
objfiles.c:
objfile_relocate(){...
l->item[i].pc is quite out of range.
My investigations so far
------------------------
The pc value comes from the preceeding file command:
(gdb) file -readnow YYY
dbxread.c:
process_one_symbol(){...
function_start_offset = ANOFFSET (section_offsets,
SECT_OFF_TEXT (objfile));
...
case N_SLINE:...
valu += function_start_offset;
...
record_line(,,valu);
buildsym.c:
record_line(,,pc){...e->pc = ADDR_BITS_REMOVE(pc);
function_start_offset had twice the value it should have when
compared to objdump output.
The wrong values showed up first in
bfd/simple.c:
bfd_simple_get_relocated_section_contents(){...
contents = bfd_get_relocated_section_contents(){...
bfd/reloc.c:
bfd_generic_get_relocated_section_contents (reloc.c:4432){...
bfd_perform_relocation{...
symbol = *(reloc_entry->sym_ptr_ptr);
...
relocation = symbol->value;
...
output_base = reloc_target_output_section->vma;
relocation += output_base + symbol->section->output_offset;
...
DOIT(x);
output_base had a value equal x, such that x got doubled.
x is section_offsets from above.
There is a branch, if symbol->section->output_section==0, that
makes output_base=0;
symbol->section->output_section gets its value from the
bfd_simple_get_relocated_section_contents
{...bfd_canonicalize_symtab()
{...elf_slurp_symbol_table (elfcode.h)
{...bfd_elf_get_elf_syms
...
sym->symbol.section = bfd_section_from_elf_index ()
{...return elf_elfsections
(abfd)[index]->bfd_section;
And bfd_section->output_section is filled in
symbol_file_command{...symbol_file_add_main_1{...symbol_file_add{...
symbol_file_add_from_bfd{...
symbol_file_add_with_addrs_or_offsets{...
syms_from_objfile()
{...elf_symfile_read (elfread.c)
{...elfstab_build_psymtabs (dbxread.c)
{...symfile_relocate_debug_section (symfile.c)
{...bfd_map_over_sections (abfd,
symfile_dummy_outputs, NULL);
I first thought to change symfile_dummy_outputs (symfile.c), by replacing
sectp->output_section = sectp;
with
sectp->output_section = NULL;
I tried this, but unfortunately later on in
bfd_simple_get_relocated_section_contents(simple.c:209),
(bfd_map_over_sections (abfd, simple_save_output_info, saved_offsets);)
which is called immediately afterwards from
symfile_relocate_debug_section,
output_section is set to section again. This time by bfd and not gdb.
I changed simple_save_output_info to set output_section=NULL.
And now linetable's pc had the value as in the file.
Question/Goal
-------------
Is there another way to make gdb/bfd consistently relocate symbol
information, when doing the gdb file command?
The best for me would be to have old_offset relative to the
beginning of the sections, then objfile_relocate would add
new_offset-old_offset, where new_offset would be the new address.
regards, Roland
next reply other threads:[~2007-03-07 16:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-07 16:16 Roland Puntaier [this message]
2007-03-08 15:22 ` Daniel Jacobowitz
2007-03-08 15:49 ` Roland Puntaier
2007-03-08 16:05 ` Daniel Jacobowitz
2007-03-08 17:54 ` Antwort: " Roland Puntaier
2007-03-08 18:26 ` Daniel Jacobowitz
2007-03-08 22:24 ` 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=OFBFDF245F.7A7D00B6-ONC1257297.0059124B-C1257297.00595BFC@br-automation.com \
--to=roland.puntaier@br-automation.com \
--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