This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [RFA] Relocations in dwarf2, 2nd attempt
- From: Michal Ludvig <mludvig at suse dot cz>
- To: Daniel Jacobowitz <drow at mvista dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Tue, 29 Oct 2002 16:53:51 +0100
- Subject: Re: [RFA] Relocations in dwarf2, 2nd attempt
- Organization: SuSE CR
- References: <3DBE9F16.9080105@suse.cz> <20021029145810.GA12716@nevyn.them.org>
Daniel Jacobowitz wrote:
Two problems:
- You introduce long lines.
Fixed.
- Please add a fast-path exit from bfd_simple_get_relocated_section_contents
that just calls bfd_get_section_contents if ! SEC_RELOC.
Done.
Approved?
Michal Ludvig
--
* SuSE CR, s.r.o * mludvig@suse.cz
* (+420) 296.545.373 * http://www.suse.cz
Index: dwarf2.c
===================================================================
RCS file: /cvs/src/src/bfd/dwarf2.c,v
retrieving revision 1.38
diff -u -p -r1.38 dwarf2.c
--- dwarf2.c 25 Oct 2002 02:45:53 -0000 1.38
+++ dwarf2.c 29 Oct 2002 15:51:05 -0000
@@ -389,8 +389,8 @@ read_indirect_string (unit, buf, bytes_r
if (! stash->dwarf_abbrev_buffer)
return NULL;
- if (! bfd_get_section_contents (abfd, msec, stash->dwarf_str_buffer,
- (bfd_vma) 0, msec->_raw_size))
+ if (!bfd_simple_get_relocated_section_contents
+ (abfd, msec, stash->dwarf_str_buffer))
return NULL;
}
@@ -550,8 +550,8 @@ read_abbrevs (abfd, offset, stash)
if (! stash->dwarf_abbrev_buffer)
return 0;
- if (! bfd_get_section_contents (abfd, msec, stash->dwarf_abbrev_buffer,
- (bfd_vma) 0, msec->_raw_size))
+ if (!bfd_simple_get_relocated_section_contents
+ (abfd, msec, stash->dwarf_abbrev_buffer))
return 0;
}
@@ -1023,8 +1023,8 @@ decode_line_info (unit, stash)
if (! stash->dwarf_line_buffer)
return 0;
- if (! bfd_get_section_contents (abfd, msec, stash->dwarf_line_buffer,
- (bfd_vma) 0, msec->_raw_size))
+ if (!bfd_simple_get_relocated_section_contents
+ (abfd, msec, stash->dwarf_line_buffer))
return 0;
/* FIXME: We ought to apply the relocs against this section before
@@ -1939,8 +1939,8 @@ _bfd_dwarf2_find_nearest_line (abfd, sec
start = stash->info_ptr_end - stash->info_ptr;
- if (! bfd_get_section_contents (abfd, msec, stash->info_ptr + start,
- (bfd_vma) 0, size))
+ if (!bfd_simple_get_relocated_section_contents
+ (abfd, msec, stash->info_ptr + start))
continue;
stash->info_ptr_end = stash->info_ptr + start + size;
Index: reloc.c
===================================================================
RCS file: /cvs/src/src/bfd/reloc.c,v
retrieving revision 1.69
diff -u -p -r1.69 reloc.c
--- reloc.c 25 Oct 2002 02:45:53 -0000 1.69
+++ reloc.c 29 Oct 2002 15:51:06 -0000
@@ -645,7 +645,7 @@ bfd_perform_relocation (abfd, reloc_entr
reloc_target_output_section = symbol->section->output_section;
/* Convert input-section-relative symbol value to absolute. */
- if (output_bfd && ! howto->partial_inplace)
+ if ((output_bfd && ! howto->partial_inplace) || !reloc_target_output_section)
output_base = 0;
else
output_base = reloc_target_output_section->vma;
Index: simple.c
===================================================================
RCS file: /cvs/src/src/bfd/simple.c,v
retrieving revision 1.2
diff -u -p -r1.2 simple.c
--- simple.c 25 Oct 2002 03:19:29 -0000 1.2
+++ simple.c 29 Oct 2002 15:51:06 -0000
@@ -148,6 +148,19 @@ bfd_simple_get_relocated_section_content
int storage_needed, number_of_symbols;
asymbol **symbol_table;
+ if (! (sec->flags & SEC_RELOC))
+ {
+ bfd_size_type size = bfd_section_size (abfd, sec);
+ if (outbuf == NULL)
+ contents = bfd_malloc (size);
+ else
+ contents = outbuf;
+
+ bfd_get_section_contents (abfd, sec, contents, 0, size);
+
+ return contents;
+ }
+
/* In order to use bfd_get_relocated_section_contents, we need
to forge some data structures that it expects. */