summaryrefslogtreecommitdiff
path: root/bfd/elfcode.h
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2007-08-14 08:04:47 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2007-08-14 08:04:47 +0000
commit71c9999fc322dac29cd9844ab2632acb506f80ea (patch)
treeb2448d2774e2ce48289ae31fc1d8d3ea1f6fdff0 /bfd/elfcode.h
parenta8ac42a2ca0b05bbe035a9bf3cfd443847870c94 (diff)
downloadbinutils-redhat-71c9999fc322dac29cd9844ab2632acb506f80ea.tar.gz
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.h22
1 files changed, 12 insertions, 10 deletions
diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index e16f579f95..e1f5801674 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