aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2007-08-13 00:44:20 +0000
committerAlan Modra <amodra@gmail.com>2007-08-13 00:44:20 +0000
commit3dea8fca8b8659aa3888d6b4cc69b6a207e847cf (patch)
treebeabf74141479139d6423faba21dd0b78f443279 /bfd/elf.c
parentac2df442ac7901f00af15b272fc48b594b433713 (diff)
downloadgdb-3dea8fca8b8659aa3888d6b4cc69b6a207e847cf.zip
gdb-3dea8fca8b8659aa3888d6b4cc69b6a207e847cf.tar.gz
gdb-3dea8fca8b8659aa3888d6b4cc69b6a207e847cf.tar.bz2
* elf.c (elf_modify_segment_map): Add remove_empty_load param.
Don't remove empty PT_LOAD header if false. (_bfd_elf_map_sections_to_segments): If user phdrs, pass false to elf_modify_segment_map. (assign_file_positions_for_load_sections): Pass false to elf_modify_segment_map.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r--bfd/elf.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index bd32974..ae3af35 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -3446,7 +3446,9 @@ _bfd_elf_make_dynamic_segment (bfd *abfd, asection *dynsec)
/* Possibly add or remove segments from the segment map. */
static bfd_boolean
-elf_modify_segment_map (bfd *abfd, struct bfd_link_info *info)
+elf_modify_segment_map (bfd *abfd,
+ struct bfd_link_info *info,
+ bfd_boolean remove_empty_load)
{
struct elf_segment_map **m;
const struct elf_backend_data *bed;
@@ -3473,7 +3475,7 @@ elf_modify_segment_map (bfd *abfd, struct bfd_link_info *info)
}
(*m)->count = new_count;
- if ((*m)->p_type == PT_LOAD && (*m)->count == 0)
+ if (remove_empty_load && (*m)->p_type == PT_LOAD && (*m)->count == 0)
*m = (*m)->next;
else
m = &(*m)->next;
@@ -3498,9 +3500,10 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info)
struct elf_segment_map *m;
asection **sections = NULL;
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
+ bfd_boolean no_user_phdrs;
- if (elf_tdata (abfd)->segment_map == NULL
- && bfd_count_sections (abfd) != 0)
+ no_user_phdrs = elf_tdata (abfd)->segment_map == NULL;
+ if (no_user_phdrs && bfd_count_sections (abfd) != 0)
{
asection *s;
unsigned int i;
@@ -3869,7 +3872,7 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info)
elf_tdata (abfd)->segment_map = mfirst;
}
- if (!elf_modify_segment_map (abfd, info))
+ if (!elf_modify_segment_map (abfd, info, no_user_phdrs))
return FALSE;
for (count = 0, m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
@@ -4015,7 +4018,7 @@ assign_file_positions_for_load_sections (bfd *abfd,
unsigned int i, j;
if (link_info == NULL
- && !elf_modify_segment_map (abfd, link_info))
+ && !elf_modify_segment_map (abfd, link_info, FALSE))
return FALSE;
alloc = 0;