Before doing any segment remapping, the function verify_segment_layout() does
some basic sanity checking to make sure the program segments are properly
aligned for the selected remapping mode.  For segments that will be remapped,
we must be able to align the start down to an address congruent with the target
page size and.  We must similarly align the end upward.

For segments that will not be remapped, we don't actually require such
alignment to be possible but we have been sanity checking it anyway.  This has
been okay for awhile but newer versions of binutils are producing binaries with
segments that are not aligned.  These binaries can work fine with libhugetlbfs
as long as the unaligned segments do not need to be remapped into huge pages.
Update verify_segment_layout() to skip the checks for these segments.

This issue has, so far, only been reproducible when using the B-type linker
scripts because it leaves the text and data segments untouched and creates a
new segment for a huge page BSS.  We need to ignore the boundary between the
text and data segment because it is not important.

Signed-off-by: Adam Litke <[EMAIL PROTECTED]>
---

 elflink.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/elflink.c b/elflink.c
index 63229f6..39d040f 100644
--- a/elflink.c
+++ b/elflink.c
@@ -636,11 +636,20 @@ static int save_phdr(int table_idx, int phnum, const 
ElfW(Phdr) *phdr)
 static int verify_segment_layout(struct seg_layout *segs, int num_segs)
 {
        int i;
+       long base_size = getpagesize();
 
        for (i = 1; i < num_segs; i++) {
                unsigned long prev_end = segs[i - 1].end;
                unsigned long start = segs[i].start;
 
+               /*
+                * Do not worry about the boundary between segments that will
+                * not be remapped.
+                */
+               if (segs[i - 1].page_size == base_size &&
+                               segs[i].page_size == base_size)
+                       continue;
+
                /* Make sure alignment hasn't caused segments to overlap */
                if (prev_end > start) {
                        WARNING("Layout problem with segments %i and %i:\n\t"


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to