diff options
author | Dave Anglin <dave.anglin@nrc.ca> | 2007-12-28 23:43:45 +0000 |
---|---|---|
committer | Dave Anglin <dave.anglin@nrc.ca> | 2007-12-28 23:43:45 +0000 |
commit | 7ae8e4e8051c4f9320f95e568ac4b03604999d45 (patch) | |
tree | b8a882e35d1b0e00ade14809e3aad9ddf04a0aac /bfd/elf-hppa.h | |
parent | 7833b9b3df967c4f0b08e86960f25d25e19c2037 (diff) | |
download | gdb-7ae8e4e8051c4f9320f95e568ac4b03604999d45.zip gdb-7ae8e4e8051c4f9320f95e568ac4b03604999d45.tar.gz gdb-7ae8e4e8051c4f9320f95e568ac4b03604999d45.tar.bz2 |
* elf-hppa.h (elf_hppa_osec_to_segment): New function.
(elf_hppa_record_segment_addrs): Use elf_hppa_osec_to_segment.
Remove ATTRIBUTE_UNUSED from abfd argument.
* elf32-hppa.c (hppa_record_segment_addr): Likewise.
Diffstat (limited to 'bfd/elf-hppa.h')
-rw-r--r-- | bfd/elf-hppa.h | 60 |
1 files changed, 46 insertions, 14 deletions
diff --git a/bfd/elf-hppa.h b/bfd/elf-hppa.h index dfe692f..a7850ce 100644 --- a/bfd/elf-hppa.h +++ b/bfd/elf-hppa.h @@ -1088,6 +1088,35 @@ elf_hppa_fake_sections (bfd *abfd, Elf_Internal_Shdr *hdr, asection *sec) return TRUE; } +/* Find the segment number in which OSEC, and output section, is + located. */ + +static unsigned +elf_hppa_osec_to_segment (bfd *output_bfd, asection *osec) +{ + struct elf_segment_map *m; + Elf_Internal_Phdr *p; + + /* Find the segment that contains the output_section. */ + for (m = elf_tdata (output_bfd)->segment_map, + p = elf_tdata (output_bfd)->phdr; + m != NULL; + m = m->next, p++) + { + int i; + + for (i = m->count - 1; i >= 0; i--) + if (m->sections[i] == osec) + break; + + if (i >= 0) + break; + } + + BFD_ASSERT (m); + return p - elf_tdata (output_bfd)->phdr; +} + static void elf_hppa_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED) @@ -1300,25 +1329,28 @@ elf_hppa_is_dynamic_loader_symbol (const char *name) /* Record the lowest address for the data and text segments. */ static void -elf_hppa_record_segment_addrs (bfd *abfd ATTRIBUTE_UNUSED, +elf_hppa_record_segment_addrs (bfd *abfd, asection *section, void *data) { - struct elf64_hppa_link_hash_table *hppa_info; - bfd_vma value; - - hppa_info = data; + struct elf64_hppa_link_hash_table *hppa_info = data; - value = section->vma - section->filepos; + if ((section->flags & (SEC_ALLOC | SEC_LOAD)) == (SEC_ALLOC | SEC_LOAD)) + { + unsigned seg = elf_hppa_osec_to_segment (abfd, section->output_section); + bfd_vma value = elf_tdata (abfd)->phdr[seg].p_vaddr; - if (((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY)) - == (SEC_ALLOC | SEC_LOAD | SEC_READONLY)) - && value < hppa_info->text_segment_base) - hppa_info->text_segment_base = value; - else if (((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY)) - == (SEC_ALLOC | SEC_LOAD)) - && value < hppa_info->data_segment_base) - hppa_info->data_segment_base = value; + if (section->flags & SEC_READONLY) + { + if (value < hppa_info->text_segment_base) + hppa_info->text_segment_base = value; + } + else + { + if (value < hppa_info->data_segment_base) + hppa_info->data_segment_base = value; + } + } } /* Called after we have seen all the input files/sections, but before |