Now that elflink.c has been updated to remove linker script dependencies we can
add support to ld.hugetlbfs for new relinking styles. These are implemented by
specifying two options to GNU ld (new in binutils 2.18): -z common-page-size
and -z max-page-size . These options simply create a gap of a desired size
between the text and data segments.
Link Strings:
The new remapping code can be enabled on a binary simply by adjusting the
--hugetlbfs-link=<link string> option to ld.hugetlbfs. The strings 'T', 'D',
and 'TD' can be used to link the binary for text-only, data-only, and text+data
respectively.
Binary Layouts:
The link strings above are mapped to either 1 or 2 possible modified binary
layouts. Architectures that use slices (ppc) require that all pages within one
slice be of the same size. If the text and data segments must be of different
sizes, slice alignment is required between the segments. If both segments may
be the same page size then only huge page alignment is required. For
architectures without slice restrictions, the segments are always huge page
aligned.
Link String Gap Alignment
=========== =============
T,D Slice aligned* * Huge page aligned on machines with
TD Huge page aligned no slice restrictions
Run-time Flexibility:
Use of these new link strings affords more run-time flexibility than was
available with the old B and BDT modes. The HUGETLB_ELFMAP environment
variable can be used to control which segments are placed in huge pages at
run-time. The following table shows the possible combinations when using a
given link string:
Link String Remapping Modes
=========== ===============
T Td tD TD td * This script separates the BSS from the data
D Td tD TD td segment which creates a binary with three
TD TD td loadable segments.
B* tdB tdb
BDT TD td
As shown above, the T and D modes are identical and also the most flexible. By
aligning the binary to a slice, all possible remapping combinations are
available at run-time.
Signed-off-by: Adam Litke <[EMAIL PROTECTED]>
---
ld.hugetlbfs | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/ld.hugetlbfs b/ld.hugetlbfs
index 71e54bd..9a052ed 100755
--- a/ld.hugetlbfs
+++ b/ld.hugetlbfs
@@ -57,7 +57,19 @@ while [ -n "$1" ]; do
shift
done
-if [ -n "$HTLB_LINK" ]; then
+MB=$((1024*1024))
+case "$EMU" in
+elf32ppclinux|elf64ppc) HPAGE_SIZE=$((16*$MB)) SLICE_SIZE=$((256*$MB))
;;
+elf_i386|elf_x86_64) HPAGE_SIZE=$((4*$MB)) SLICE_SIZE=$HPAGE_SIZE ;;
+esac
+
+if [ "$HTLB_LINK" == "TD" ]; then
+ HTLBOPTS="-zcommon-page-size=$HPAGE_SIZE -zmax-page-size=$HPAGE_SIZE"
+ HTLBOPTS="$HTLBOPTS -lhugetlbfs"
+elif [ "$HTLB_LINK" == "T" -o "$HTLB_LINK" == "D" ]; then
+ HTLBOPTS="-zcommon-page-size=$SLICE_SIZE -zmax-page-size=$SLICE_SIZE"
+ HTLBOPTS="$HTLBOPTS -lhugetlbfs"
+else
LDSCRIPT="$EMU.x$HTLB_LINK"
HTLBOPTS="-T${HUGETLB_LDSCRIPT_PATH}/${LDSCRIPT}"
fi
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Libhugetlbfs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel