aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2004-09-06 20:55:23 +0000
committerMark Mitchell <mark@codesourcery.com>2004-09-06 20:55:23 +0000
commit229fcec57051103b79422353f53b6053fc5fc4b4 (patch)
treee9620d5259158d88238cd849061f454202b01dca /bfd/elf.c
parentd597aff735ca792afe4d7508fe83e7891e50e5e9 (diff)
downloadgdb-229fcec57051103b79422353f53b6053fc5fc4b4.zip
gdb-229fcec57051103b79422353f53b6053fc5fc4b4.tar.gz
gdb-229fcec57051103b79422353f53b6053fc5fc4b4.tar.bz2
* elf-bfd.h (_bfd_elf_make_dynamic_segment): Declare it.
* elf.c (_bfd_elf_make_dynamic_segment): New function, split out from ... (map_sections_to_segments): ... here. Use it. Assign a file position to the .dynamic section if it is not loadable, but part of the PT_DYNAMIC segment. * elf32-arm.h (elf32_arm_finish_dynamic_sections): Use file offsets, not VMAs, for the BPABI. Do not fill in the header in the .got.plt section for the BPABI. * elfarm-nabi.c (elf32_arm_symbian_modify_segment_map): Add a PT_DYNAMIC segment. (elf_backend_want_got_plt): Define to zero for Symbian OS. * emulparams/armsymbian.sh: Use armbpabi script. * scripttempl/armbpabi.sc: New script.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r--bfd/elf.c43
1 files changed, 36 insertions, 7 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index f9e2235..b317d7e 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -3329,6 +3329,25 @@ make_mapping (bfd *abfd,
return m;
}
+/* Create the PT_DYNAMIC segment, which includes DYNSEC. Returns NULL
+ on failure. */
+
+struct elf_segment_map *
+_bfd_elf_make_dynamic_segment (bfd *abfd, asection *dynsec)
+{
+ struct elf_segment_map *m;
+
+ m = bfd_zalloc (abfd, sizeof (struct elf_segment_map));
+ if (m == NULL)
+ return NULL;
+ m->next = NULL;
+ m->p_type = PT_DYNAMIC;
+ m->count = 1;
+ m->sections[0] = dynsec;
+
+ return m;
+}
+
/* Set up a mapping from BFD sections to program segments. */
static bfd_boolean
@@ -3566,15 +3585,9 @@ map_sections_to_segments (bfd *abfd)
/* If there is a .dynamic section, throw in a PT_DYNAMIC segment. */
if (dynsec != NULL)
{
- amt = sizeof (struct elf_segment_map);
- m = bfd_zalloc (abfd, amt);
+ m = _bfd_elf_make_dynamic_segment (abfd, dynsec);
if (m == NULL)
goto error_return;
- m->next = NULL;
- m->p_type = PT_DYNAMIC;
- m->count = 1;
- m->sections[0] = dynsec;
-
*pm = m;
pm = &m->next;
}
@@ -4215,6 +4228,22 @@ Error: First section in segment (%s) starts at 0x%x whereas the segment starts a
if (p->p_type != PT_LOAD && m->count > 0)
{
BFD_ASSERT (! m->includes_filehdr && ! m->includes_phdrs);
+ /* If the section has not yet been assigned a file position,
+ do so now. The ARM BPABI requires that .dynamic section
+ not be marked SEC_ALLOC because it is not part of any
+ PT_LOAD segment, so it will not be processed above. */
+ if (p->p_type == PT_DYNAMIC && m->sections[0]->filepos == 0)
+ {
+ unsigned int i;
+ Elf_Internal_Shdr ** const i_shdrpp = elf_elfsections (abfd);
+
+ i = 1;
+ while (i_shdrpp[i]->bfd_section != m->sections[0])
+ ++i;
+ off = (_bfd_elf_assign_file_position_for_section
+ (i_shdrpp[i], off, TRUE));
+ p->p_filesz = m->sections[0]->size;
+ }
p->p_offset = m->sections[0]->filepos;
}
if (m->count == 0)