Use bfd_simple_get_relocated_section_contents() instead of bfd_get_section_contents().

This commit is contained in:
Nick Clifton 2002-11-07 14:36:31 +00:00
parent bde78a07b9
commit ec4530b540
4 changed files with 48 additions and 21 deletions

View File

@ -1,3 +1,14 @@
2002-11-07 Michal Ludvig <mludvig@suse.cz>
* dwarf2.c (read_indirect_string, read_abbrevs, decode_line_info,
_bfd_dwarf2_find_nearest_line): Use
bfd_simple_get_relocated_section_contents() instead of
bfd_get_section_contents().
* reloc.c (bfd_perform_relocation): Add sanity check.
* simple.c (simple_get_relocated_section_contents): If the section
does not have any relocs associated with it, just return the
unadjusted contents.
2002-11-07 Hans-Peter Nilsson <hp@axis.com> 2002-11-07 Hans-Peter Nilsson <hp@axis.com>
* elf32-cris.c (cris_elf_relocate_section) <case R_CRIS_16_GOT, * elf32-cris.c (cris_elf_relocate_section) <case R_CRIS_16_GOT,

View File

@ -389,8 +389,8 @@ read_indirect_string (unit, buf, bytes_read_ptr)
if (! stash->dwarf_abbrev_buffer) if (! stash->dwarf_abbrev_buffer)
return NULL; return NULL;
if (! bfd_get_section_contents (abfd, msec, stash->dwarf_str_buffer, if (! bfd_simple_get_relocated_section_contents
(bfd_vma) 0, msec->_raw_size)) (abfd, msec, stash->dwarf_str_buffer))
return NULL; return NULL;
} }
@ -550,8 +550,8 @@ read_abbrevs (abfd, offset, stash)
if (! stash->dwarf_abbrev_buffer) if (! stash->dwarf_abbrev_buffer)
return 0; return 0;
if (! bfd_get_section_contents (abfd, msec, stash->dwarf_abbrev_buffer, if (! bfd_simple_get_relocated_section_contents
(bfd_vma) 0, msec->_raw_size)) (abfd, msec, stash->dwarf_abbrev_buffer))
return 0; return 0;
} }
@ -1023,8 +1023,8 @@ decode_line_info (unit, stash)
if (! stash->dwarf_line_buffer) if (! stash->dwarf_line_buffer)
return 0; return 0;
if (! bfd_get_section_contents (abfd, msec, stash->dwarf_line_buffer, if (! bfd_simple_get_relocated_section_contents
(bfd_vma) 0, msec->_raw_size)) (abfd, msec, stash->dwarf_line_buffer))
return 0; return 0;
/* FIXME: We ought to apply the relocs against this section before /* FIXME: We ought to apply the relocs against this section before
@ -1939,8 +1939,8 @@ _bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
start = stash->info_ptr_end - stash->info_ptr; start = stash->info_ptr_end - stash->info_ptr;
if (! bfd_get_section_contents (abfd, msec, stash->info_ptr + start, if (! bfd_simple_get_relocated_section_contents
(bfd_vma) 0, size)) (abfd, msec, stash->info_ptr + start))
continue; continue;
stash->info_ptr_end = stash->info_ptr + start + size; stash->info_ptr_end = stash->info_ptr + start + size;

View File

@ -645,7 +645,8 @@ bfd_perform_relocation (abfd, reloc_entry, data, input_section, output_bfd,
reloc_target_output_section = symbol->section->output_section; reloc_target_output_section = symbol->section->output_section;
/* Convert input-section-relative symbol value to absolute. */ /* Convert input-section-relative symbol value to absolute. */
if (output_bfd && ! howto->partial_inplace) if ((output_bfd && ! howto->partial_inplace)
|| reloc_target_output_section == NULL)
output_base = 0; output_base = 0;
else else
output_base = reloc_target_output_section->vma; output_base = reloc_target_output_section->vma;

View File

@ -138,6 +138,21 @@ bfd_simple_get_relocated_section_contents (abfd, sec, outbuf)
int storage_needed, number_of_symbols; int storage_needed, number_of_symbols;
asymbol **symbol_table; 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;
if (contents)
bfd_get_section_contents (abfd, sec, contents, 0, size);
return contents;
}
/* In order to use bfd_get_relocated_section_contents, we need /* In order to use bfd_get_relocated_section_contents, we need
to forge some data structures that it expects. */ to forge some data structures that it expects. */