[patch] Fix occasional 2MB gap in the linked binary
Jan Kratochvil
jan.kratochvil@redhat.com
Wed Aug 20 22:21:00 GMT 2008
More information about the Binutils mailing list
Wed Aug 20 22:21:00 GMT 2008
- Previous message (by thread): [patch] Fix occasional 2MB gap in the linked binary
- Next message (by thread): [patch] Fix occasional 2MB gap in the linked binary
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, 13 Aug 2008 07:13:41 +0200, Alan Modra wrote: > I was hoping Jakub would review this change since it is his code.. > My opinion is that this would be cleaner if you just saved dot to > min_base here, and moved all the aligning and tweaking to one place, > in ldlang.c. My former patch nullified/regressed the excessive VMA skip optimization: http://www.sourceware.org/ml/binutils/2004-12/msg00152.html The MIN_BASE value should be used in its original way. I just moved its computing to ldlang.c. The value I formerly computed was already stored in BASE so I reused it for not overlapping the file offsets inside a MAXPAGE. Regards, Jan -------------- next part -------------- 2008-08-20 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. --- ld/ldexp.c 7 May 2008 14:30:41 -0000 1.74 +++ ld/ldexp.c 20 Aug 2008 13:10:57 -0000 @@ -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; --- ld/ldlang.c 17 Aug 2008 03:12:50 -0000 1.290 +++ ld/ldlang.c 20 Aug 2008 13:11:02 -0000 @@ -5056,17 +5056,23 @@ lang_size_sections (bfd_boolean *relax, { /* 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, { /* 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, 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 ();
- Previous message (by thread): [patch] Fix occasional 2MB gap in the linked binary
- Next message (by thread): [patch] Fix occasional 2MB gap in the linked binary
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list