This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: binutils/1179: -adjust-vma with negative number causes objdump -S to fail
- From: "H. J. Lu" <hjl at lucon dot org>
- To: binutils at sources dot redhat dot com
- Date: Mon, 8 Aug 2005 11:12:58 -0700
- Subject: Re: PATCH: binutils/1179: -adjust-vma with negative number causes objdump -S to fail
- References: <20050808160337.GA23995@lucon.org>
On Mon, Aug 08, 2005 at 09:03:37AM -0700, H. J. Lu wrote:
> I didn't try to support -adjust-vma for non-relocatable files. Without
> relocation information, it is tricky to get the debug info right. I
> am not sure if it is worth the effort. We also have to adjust it for
> debug info. This patch works on ELF/i386.
>
>
Here is an updated patch. We shouldn't adjust vma for debugging
sections since they aren't loaded at all. We don't adjust lma for
DSO and executable so that we can use
sec->vma - (sec->vma - sec->lma) = sec->lma
to find the load bias.
H.J.
----
bfd/
2005-08-08 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/1179
* dwarf2.c (_bfd_dwarf2_find_nearest_line): Use section lma
instead of vma.
(_bfd_dwarf2_find_line): Likewise.
binutils/
2005-08-08 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/1179
* objdump.c (disassemble_bytes): Don't adjust
adjust_section_vma.
(adjust_addresses): Don't adjust vma for debugging section.
Adjust lma only for relocatable files.
(dump_bfd): Tell adjust_addresses if it is a relocatable file.
--- binutils/bfd/dwarf2.c.adjust 2005-07-10 10:14:06.000000000 -0700
+++ binutils/bfd/dwarf2.c 2005-08-08 11:00:13.252485417 -0700
@@ -2175,9 +2175,9 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd
stash = *pinfo;
addr = offset;
if (section->output_section)
- addr += section->output_section->vma + section->output_offset;
+ addr += section->output_section->lma + section->output_offset;
else
- addr += section->vma;
+ addr += section->lma;
*filename_ptr = NULL;
*functionname_ptr = NULL;
*linenumber_ptr = 0;
@@ -2384,9 +2384,9 @@ _bfd_dwarf2_find_line (bfd *abfd,
addr = symbol->value;
if (section->output_section)
- addr += section->output_section->vma + section->output_offset;
+ addr += section->output_section->lma + section->output_offset;
else
- addr += section->vma;
+ addr += section->lma;
*filename_ptr = NULL;
stash = *pinfo;
--- binutils/binutils/objdump.c.adjust 2005-07-08 08:42:24.000000000 -0700
+++ binutils/binutils/objdump.c 2005-08-08 11:02:54.401983613 -0700
@@ -1355,10 +1355,7 @@ disassemble_bytes (struct disassemble_in
done_dot = FALSE;
if (with_line_numbers || with_source_code)
- /* The line number tables will refer to unadjusted
- section VMAs, so we must undo any VMA modifications
- when calling show_line. */
- show_line (aux->abfd, section, addr_offset - adjust_section_vma);
+ show_line (aux->abfd, section, addr_offset);
if (! prefix_addresses)
{
@@ -2601,10 +2598,15 @@ add_include_path (const char *path)
static void
adjust_addresses (bfd *abfd ATTRIBUTE_UNUSED,
asection *section,
- void *dummy ATTRIBUTE_UNUSED)
+ void *arg)
{
- section->vma += adjust_section_vma;
- section->lma += adjust_section_vma;
+ if ((section->flags & SEC_DEBUGGING) == 0)
+ {
+ bfd_boolean *has_reloc_p = (bfd_boolean *) arg;
+ section->vma += adjust_section_vma;
+ if (*has_reloc_p)
+ section->lma += adjust_section_vma;
+ }
}
/* Dump selected contents of ABFD. */
@@ -2616,7 +2618,10 @@ dump_bfd (bfd *abfd)
the BFD information is a hack. However, we must do it, or
bfd_find_nearest_line will not do the right thing. */
if (adjust_section_vma != 0)
- bfd_map_over_sections (abfd, adjust_addresses, NULL);
+ {
+ bfd_boolean has_reloc = (abfd->flags & HAS_RELOC);
+ bfd_map_over_sections (abfd, adjust_addresses, &has_reloc);
+ }
if (! dump_debugging_tags)
printf (_("\n%s: file format %s\n"), bfd_get_filename (abfd),