diff options
author | Jan Kratochvil <jan.kratochvil@redhat.com> | 2007-08-14 08:04:47 +0000 |
---|---|---|
committer | Jan Kratochvil <jan.kratochvil@redhat.com> | 2007-08-14 08:04:47 +0000 |
commit | 3fec76aafa7293906969f7b6c96e8bcecc88f9d0 (patch) | |
tree | 49db76a661dac41eab268d67a539ae2043fa54f7 /bfd/elfcode.h | |
parent | ac3eeb49116dbc3d917cf431b31816aab7aa129b (diff) | |
download | fsf-binutils-gdb-3fec76aafa7293906969f7b6c96e8bcecc88f9d0.zip fsf-binutils-gdb-3fec76aafa7293906969f7b6c96e8bcecc88f9d0.tar.gz fsf-binutils-gdb-3fec76aafa7293906969f7b6c96e8bcecc88f9d0.tar.bz2 |
2007-08-14 Jan Kratochvil <jan.kratochvil@redhat.com>
* elfcode.h (NAME(_bfd_elf,bfd_from_remote_memory)): LOADBASE is now
initialized only on the first PT_LOAD. New variable LOADBASE_SET.
Removed PF_R checking for IA-64 vDSOs as redundant now.
Code advisory: Roland McGrath
Diffstat (limited to 'bfd/elfcode.h')
-rw-r--r-- | bfd/elfcode.h | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/bfd/elfcode.h b/bfd/elfcode.h index e16f579..e1f5801 100644 --- a/bfd/elfcode.h +++ b/bfd/elfcode.h @@ -1635,6 +1635,7 @@ NAME(_bfd_elf,bfd_from_remote_memory) int err; unsigned int i; bfd_vma loadbase; + bfd_boolean loadbase_set; /* Read in the ELF header in external format. */ err = target_read_memory (ehdr_vma, (bfd_byte *) &x_ehdr, sizeof x_ehdr); @@ -1711,13 +1712,11 @@ NAME(_bfd_elf,bfd_from_remote_memory) contents_size = 0; last_phdr = NULL; loadbase = ehdr_vma; + loadbase_set = FALSE; for (i = 0; i < i_ehdr.e_phnum; ++i) { elf_swap_phdr_in (templ, &x_phdrs[i], &i_phdrs[i]); - /* IA-64 vDSO may have two mappings for one segment, where one mapping - is executable only, and one is read only. We must not use the - executable one. */ - if (i_phdrs[i].p_type == PT_LOAD && (i_phdrs[i].p_flags & PF_R)) + if (i_phdrs[i].p_type == PT_LOAD) { bfd_vma segment_end; segment_end = (i_phdrs[i].p_offset + i_phdrs[i].p_filesz @@ -1725,8 +1724,14 @@ NAME(_bfd_elf,bfd_from_remote_memory) if (segment_end > (bfd_vma) contents_size) contents_size = segment_end; - if ((i_phdrs[i].p_offset & -i_phdrs[i].p_align) == 0) - loadbase = ehdr_vma - (i_phdrs[i].p_vaddr & -i_phdrs[i].p_align); + /* LOADADDR is the `Base address' from the gELF specification: + `lowest p_vaddr value for a PT_LOAD segment' is P_VADDR from the + first PT_LOAD as PT_LOADs are ordered by P_VADDR. */ + if (!loadbase_set && (i_phdrs[i].p_offset & -i_phdrs[i].p_align) == 0) + { + loadbase = ehdr_vma - (i_phdrs[i].p_vaddr & -i_phdrs[i].p_align); + loadbase_set = TRUE; + } last_phdr = &i_phdrs[i]; } @@ -1764,10 +1769,7 @@ NAME(_bfd_elf,bfd_from_remote_memory) } for (i = 0; i < i_ehdr.e_phnum; ++i) - /* IA-64 vDSO may have two mappings for one segment, where one mapping - is executable only, and one is read only. We must not use the - executable one. */ - if (i_phdrs[i].p_type == PT_LOAD && (i_phdrs[i].p_flags & PF_R)) + if (i_phdrs[i].p_type == PT_LOAD) { bfd_vma start = i_phdrs[i].p_offset & -i_phdrs[i].p_align; bfd_vma end = (i_phdrs[i].p_offset + i_phdrs[i].p_filesz |