aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2014-01-10 21:11:46 +1030
committerAlan Modra <amodra@gmail.com>2014-01-10 21:49:56 +1030
commiteec2f3ed9f053653ed5d629eb50e08e3ee61e9bd (patch)
tree2a12dda58d04db24d58892f45db6eab16240bb00 /bfd
parenta2cd8cfed14491303eb8338f90e206034c5a3fe2 (diff)
downloadgdb-eec2f3ed9f053653ed5d629eb50e08e3ee61e9bd.zip
gdb-eec2f3ed9f053653ed5d629eb50e08e3ee61e9bd.tar.gz
gdb-eec2f3ed9f053653ed5d629eb50e08e3ee61e9bd.tar.bz2
Don't adjust LOAD segment to match GNU_RELRO segment
Instead, fix Jakub's original code setting up the PR_GNU_RELRO header from the PT_LOAD header. PR ld/14207 PR ld/16322 PR binutils/16323 bfd/ * elf.c (assign_file_positions_for_load_sections): Revert last change. (assign_file_positions_for_non_load_sections): When setting up PT_GNU_RELRO header, don't require a corresponding PT_LOAD header that completely covers the relro region. ld/ * ldlang.c (lang_size_sections): Remove unneeded RELRO base adjust. Tidy comments. * ld.texinfo (DATA_SEGMENT_RELRO_END): Correct description. ld/testsuite/ * ld-x86-64/pr14207.d: Adjust
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog10
-rw-r--r--bfd/elf.c37
2 files changed, 10 insertions, 37 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 18f0f06..597bcf2 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,13 @@
+2014-01-10 Alan Modra <amodra@gmail.com>
+
+ PR ld/14207
+ PR ld/16322
+ PR binutils/16323
+ * elf.c (assign_file_positions_for_load_sections): Revert last change.
+ (assign_file_positions_for_non_load_sections): When setting up
+ PT_GNU_RELRO header, don't require a corresponding PT_LOAD
+ header that completely covers the relro region.
+
2014-01-09 Tristan Gingold <gingold@adacore.com>
* coff-rs6000.c (rs6000coff_vec, pmac_xcoff_vec): use jump
diff --git a/bfd/elf.c b/bfd/elf.c
index 870e281..3815e32 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -4376,7 +4376,6 @@ assign_file_positions_for_load_sections (bfd *abfd,
unsigned int alloc;
unsigned int i, j;
bfd_vma header_pad = 0;
- bfd_vma relro_start = 0, relro_end = 0;
if (link_info == NULL
&& !_bfd_elf_map_sections_to_segments (abfd, link_info))
@@ -4447,23 +4446,6 @@ assign_file_positions_for_load_sections (bfd *abfd,
header_pad -= off;
off += header_pad;
- /* Get start and end of PT_GNU_RELRO segment. */
- if (link_info != NULL)
- {
- relro_start = link_info->relro_start;
- relro_end = link_info->relro_end;
- }
- else
- {
- for (m = elf_seg_map (abfd); m != NULL; m = m->next)
- if (m->p_type == PT_GNU_RELRO)
- {
- relro_start = m->p_paddr;
- relro_end = relro_start + m->p_size;
- break;
- }
- }
-
for (m = elf_seg_map (abfd), p = phdrs, j = 0;
m != NULL;
m = m->next, p++, j++)
@@ -4807,22 +4789,6 @@ assign_file_positions_for_load_sections (bfd *abfd,
}
}
- if (relro_start != 0
- && p->p_type == PT_LOAD
- && p->p_vaddr >= relro_start)
- {
- /* If PT_LOAD segment doesn't fit PT_GNU_RELRO segment,
- adjust its p_filesz and p_memsz. */
- if (p->p_vaddr + p->p_filesz < relro_end)
- {
- bfd_vma adjust = relro_end - (p->p_vaddr + p->p_filesz);
- p->p_filesz += adjust;
- off += adjust;
- }
- if (p->p_vaddr + p->p_memsz < relro_end)
- p->p_memsz += relro_end - (p->p_vaddr + p->p_memsz);
- }
-
off -= off_adjust;
/* Check that all sections are in a PT_LOAD segment.
@@ -5024,14 +4990,11 @@ assign_file_positions_for_non_load_sections (bfd *abfd,
{
if (lp->p_type == PT_LOAD
&& lp->p_vaddr < link_info->relro_end
- && lp->p_vaddr + lp->p_filesz >= link_info->relro_end
&& lm->count != 0
&& lm->sections[0]->vma >= link_info->relro_start)
break;
}
- /* PR ld/14207. If the RELRO segment doesn't fit in the
- LOAD segment, it should be removed. */
BFD_ASSERT (lm != NULL);
}
else