diff options
author | Alan Modra <amodra@gmail.com> | 2014-01-10 21:11:46 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2014-01-10 21:49:56 +1030 |
commit | eec2f3ed9f053653ed5d629eb50e08e3ee61e9bd (patch) | |
tree | 2a12dda58d04db24d58892f45db6eab16240bb00 /ld/ldlang.c | |
parent | a2cd8cfed14491303eb8338f90e206034c5a3fe2 (diff) | |
download | gdb-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 'ld/ldlang.c')
-rw-r--r-- | ld/ldlang.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/ld/ldlang.c b/ld/ldlang.c index 7851615..c5e7a3d 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -5362,18 +5362,14 @@ lang_size_sections (bfd_boolean *relax, bfd_boolean check_regions) && link_info.relro && expld.dataseg.relro_end) { /* If DATA_SEGMENT_ALIGN DATA_SEGMENT_RELRO_END pair was seen, try - to put expld.dataseg.relro on a (common) page boundary. */ - bfd_vma min_base, old_base, relro_end, maxpage; + to put expld.dataseg.relro_end on a (common) page boundary. */ + bfd_vma min_base, relro_end, maxpage; expld.dataseg.phase = exp_dataseg_relro_adjust; maxpage = expld.dataseg.maxpagesize; /* MIN_BASE is the absolute minimum address we are allowed to start the read-write segment (byte before will be mapped read-only). */ min_base = (expld.dataseg.min_base + maxpage - 1) & ~(maxpage - 1); - /* OLD_BASE is the address for a feasible minimum address which will - still not cause a data overlap inside MAXPAGE causing file offset skip - by MAXPAGE. */ - old_base = expld.dataseg.base; expld.dataseg.base += (-expld.dataseg.relro_end & (expld.dataseg.pagesize - 1)); /* Compute the expected PT_GNU_RELRO segment end. */ @@ -5389,9 +5385,9 @@ lang_size_sections (bfd_boolean *relax, bfd_boolean check_regions) if (expld.dataseg.relro_end > relro_end) { /* The alignment of sections between DATA_SEGMENT_ALIGN - and DATA_SEGMENT_RELRO_END caused huge padding to be - inserted at DATA_SEGMENT_RELRO_END. Try to start a bit lower so - that the section alignments will fit in. */ + and DATA_SEGMENT_RELRO_END can cause excessive padding to + be inserted at DATA_SEGMENT_RELRO_END. Try to start a + bit lower so that the section alignments will fit in. */ asection *sec; unsigned int max_alignment_power = 0; @@ -5405,9 +5401,10 @@ lang_size_sections (bfd_boolean *relax, bfd_boolean check_regions) if (((bfd_vma) 1 << max_alignment_power) < expld.dataseg.pagesize) { - if (expld.dataseg.base - (1 << max_alignment_power) < old_base) - expld.dataseg.base += expld.dataseg.pagesize; - /* Properly align base to max_alignment_power. */ + /* Aligning the adjusted base guarantees the padding + between sections won't change. This is better than + simply subtracting 1 << max_alignment_power which is + what we used to do here. */ expld.dataseg.base &= ~((1 << max_alignment_power) - 1); lang_reset_memory_regions (); one_lang_size_sections_pass (relax, check_regions); |