aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2008-08-21 13:10:54 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2008-08-21 13:10:54 +0000
commit2b60860a4c823c5de508a6af53fcfd1c57c31cba (patch)
treef10dfea14e939e3f8b1bf79506d436e81ea8b522
parentd9c78d7d2c66f687879ec9399fbaf60d08ed8cc2 (diff)
downloadgdb-2b60860a4c823c5de508a6af53fcfd1c57c31cba.zip
gdb-2b60860a4c823c5de508a6af53fcfd1c57c31cba.tar.gz
gdb-2b60860a4c823c5de508a6af53fcfd1c57c31cba.tar.bz2
PR ld/6833
* ldexp.c (fold_binary <DATA_SEGMENT_ALIGN>): Do not align EXPLD.DATASEG.MIN_BASE. * ldlang.c (lang_size_sections): New variable OLD_BASE. Rename OLD_MIN_BASE to MIN_BASE with the former alignment from `ldexp.c'. Use OLD_BASE now for the minimal base check after the base decrease by the maximum alignment found.
-rw-r--r--ld/ChangeLog10
-rw-r--r--ld/ldexp.c2
-rw-r--r--ld/ldlang.c18
3 files changed, 23 insertions, 7 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 213b5f0..a030e26 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,13 @@
+2008-08-21 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ PR ld/6833
+ * ldexp.c (fold_binary <DATA_SEGMENT_ALIGN>): Do not align
+ EXPLD.DATASEG.MIN_BASE.
+ * ldlang.c (lang_size_sections): New variable OLD_BASE. Rename
+ OLD_MIN_BASE to MIN_BASE with the former alignment from `ldexp.c'.
+ Use OLD_BASE now for the minimal base check after the base decrease by
+ the maximum alignment found.
+
2008-08-17 Alan Modra <amodra@bigpond.net.au>
PR 6478
diff --git a/ld/ldexp.c b/ld/ldexp.c
index 3c6ad0c..08664e6 100644
--- a/ld/ldexp.c
+++ b/ld/ldexp.c
@@ -415,7 +415,7 @@ fold_binary (etree_type *tree)
if (expld.phase == lang_allocating_phase_enum)
{
expld.dataseg.phase = exp_dataseg_align_seen;
- expld.dataseg.min_base = align_n (expld.dot, maxpage);
+ expld.dataseg.min_base = expld.dot;
expld.dataseg.base = expld.result.value;
expld.dataseg.pagesize = commonpage;
expld.dataseg.maxpagesize = maxpage;
diff --git a/ld/ldlang.c b/ld/ldlang.c
index e991646..8d95254 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -5056,17 +5056,23 @@ lang_size_sections (bfd_boolean *relax, bfd_boolean check_regions)
{
/* If DATA_SEGMENT_ALIGN DATA_SEGMENT_RELRO_END pair was seen, try
to put expld.dataseg.relro on a (common) page boundary. */
- bfd_vma old_min_base, relro_end, maxpage;
+ bfd_vma min_base, old_base, relro_end, maxpage;
expld.dataseg.phase = exp_dataseg_relro_adjust;
- old_min_base = expld.dataseg.min_base;
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. */
relro_end = ((expld.dataseg.relro_end + expld.dataseg.pagesize - 1)
& ~(expld.dataseg.pagesize - 1));
- if (old_min_base + maxpage < expld.dataseg.base)
+ if (min_base + maxpage < expld.dataseg.base)
{
expld.dataseg.base -= maxpage;
relro_end -= maxpage;
@@ -5077,7 +5083,8 @@ lang_size_sections (bfd_boolean *relax, bfd_boolean check_regions)
{
/* 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 some other base. */
+ 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;
@@ -5091,8 +5098,7 @@ 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_min_base)
+ if (expld.dataseg.base - (1 << max_alignment_power) < old_base)
expld.dataseg.base += expld.dataseg.pagesize;
expld.dataseg.base -= (1 << max_alignment_power);
lang_reset_memory_regions ();