summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys-libs/libhugetlbfs/Manifest1
-rw-r--r--sys-libs/libhugetlbfs/files/libhugetlbfs-2.20-noexec-stack.patch135
-rw-r--r--sys-libs/libhugetlbfs/libhugetlbfs-2.20.ebuild167
3 files changed, 303 insertions, 0 deletions
diff --git a/sys-libs/libhugetlbfs/Manifest b/sys-libs/libhugetlbfs/Manifest
index 5a7e936d66d6..e91b029fd477 100644
--- a/sys-libs/libhugetlbfs/Manifest
+++ b/sys-libs/libhugetlbfs/Manifest
@@ -1,2 +1,3 @@
DIST libhugetlbfs-2.18.tar.gz 181275 SHA256 8c6ed5e884988e0c879a3705455ece153cf805f69cb9c710334e2711acbb6a06 SHA512 6dcdbf571d6a723a40c15e10b24533f16d65f67fe149aa2d25bee48a034d003419d4cf4b6e55fcd385e1214fc4f6b4dda72ba429b9eea9b38be9b1a393528746 WHIRLPOOL da0b17ca4d2a61be919ea47733b3da485714ce29cdc5e854e143ef0e9c0e45517a37649cb056eeeb74efe8c538f566267152aaad5d53ff837a3a15a9e11070cd
DIST libhugetlbfs-2.19.tar.gz 181504 SHA256 a5ecb6e925ab2e491bcaa4049fbd6484740950da47d474e7af06dfc6bd1f690b SHA512 d21781fe68736eb3bbafeb8f36f4f34d30f290f2f6744b52c1a40161caf2e28b823cd8e9b9c74ec4e6d11f7d398d909f80eb736cc39a64ecc7bf571018bfec7c WHIRLPOOL bd76e6334acd11e55dec790170781aa418a74e4b1bd0007a15c0b65f5c0f4fd977d02eb89d6b16d48b4e4c7fd980ed2bd7ac9a8246179c0480874afe901da851
+DIST libhugetlbfs-2.20.tar.gz 186750 SHA256 feb51a17456e6ec9806e78720d4ae17a1211a5db8c9bb4ae654b7251a3f76166 SHA512 817fca3f8e3b127b9b877e0a03d0a94bf0c3ec481d3becf995986ce6ae0532629c5460100eb9f2ef3452ed59a3b9d3ac8362df8f87b387803c36d35ab7af0902 WHIRLPOOL e6c0244d47cee5966f1a51d7f39ea1cd0f26a7b1698b4471c6813ed9b2f194bc72d4087f62f72f5c2e5d99fcf00226b72b783a993ec39016625106f8ed17baca
diff --git a/sys-libs/libhugetlbfs/files/libhugetlbfs-2.20-noexec-stack.patch b/sys-libs/libhugetlbfs/files/libhugetlbfs-2.20-noexec-stack.patch
new file mode 100644
index 000000000000..04c8baee37b8
--- /dev/null
+++ b/sys-libs/libhugetlbfs/files/libhugetlbfs-2.20-noexec-stack.patch
@@ -0,0 +1,135 @@
+https://github.com/libhugetlbfs/libhugetlbfs/pull/9
+
+From 1c41d751d57a598919c40ab9c27514a98da93273 Mon Sep 17 00:00:00 2001
+From: "Robin H. Johnson" <robbat2@gentoo.org>
+Date: Sat, 31 Oct 2009 07:59:57 +0000
+Subject: [PATCH] set noexec markers in the asm file directly
+
+Using -Wl,-z,noexecstack can hide real exec stack issues coming from other
+files, and is a bit unportable. Instead, set proper section markers in the
+assembly files directly. It also means people using the static libraries
+won't have to use -Wl,-z,noexecstack when they link their code.
+---
+ Makefile | 2 +-
+ sys-aarch64elf.S | 4 ++++
+ sys-armelf_linux_eabi.S | 4 ++++
+ sys-elf32ppclinux.S | 4 ++++
+ sys-elf64_s390.S | 4 ++++
+ sys-elf64ppc.S | 4 ++++
+ sys-elf_i386.S | 4 ++++
+ sys-elf_s390.S | 4 ++++
+ sys-elf_x86_64.S | 4 ++++
+ 9 files changed, 33 insertions(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index 73ebad7..ca987d9 100644
+--- a/Makefile
++++ b/Makefile
+@@ -27,7 +27,7 @@ NODEPTARGETS=<version.h> <clean>
+
+ INSTALL = install
+
+-LDFLAGS += -Wl,-z,noexecstack -ldl
++LDFLAGS += -ldl
+ CFLAGS ?= -O2 -g
+ CFLAGS += -Wall -fPIC
+ CPPFLAGS += -D__LIBHUGETLBFS__
+diff --git a/sys-aarch64elf.S b/sys-aarch64elf.S
+index 54799d3..210558b 100644
+--- a/sys-aarch64elf.S
++++ b/sys-aarch64elf.S
+@@ -32,3 +32,7 @@ direct_syscall:
+ mov x6, x7
+ svc 0x0
+ ret
++
++#if defined(__linux__) && defined(__ELF__)
++ .section .note.GNU-stack,"",%progbits
++#endif
+diff --git a/sys-armelf_linux_eabi.S b/sys-armelf_linux_eabi.S
+index dfa7407..265b75d 100644
+--- a/sys-armelf_linux_eabi.S
++++ b/sys-armelf_linux_eabi.S
+@@ -31,3 +31,7 @@ direct_syscall:
+ swi 0x0
+ ldmfd sp!, {r4, r5, r6, r7}
+ bx lr
++
++#if defined(__linux__) && defined(__ELF__)
++ .section .note.GNU-stack,"",%progbits
++#endif
+diff --git a/sys-elf32ppclinux.S b/sys-elf32ppclinux.S
+index 65d8b3f..6ba3f22 100644
+--- a/sys-elf32ppclinux.S
++++ b/sys-elf32ppclinux.S
+@@ -32,3 +32,7 @@ direct_syscall:
+ mr 8,9
+ sc
+ blr
++
++#if defined(__linux__) && defined(__ELF__)
++ .section .note.GNU-stack,"",%progbits
++#endif
+diff --git a/sys-elf64_s390.S b/sys-elf64_s390.S
+index 425a387..5c31899 100644
+--- a/sys-elf64_s390.S
++++ b/sys-elf64_s390.S
+@@ -20,3 +20,7 @@ direct_syscall:
+ lgr %r5,%r6
+ svc 0
+ br %r14
++
++#if defined(__linux__) && defined(__ELF__)
++ .section .note.GNU-stack,"",%progbits
++#endif
+diff --git a/sys-elf64ppc.S b/sys-elf64ppc.S
+index d50f4a6..b57a345 100644
+--- a/sys-elf64ppc.S
++++ b/sys-elf64ppc.S
+@@ -46,3 +46,7 @@ direct_syscall:
+ mr 8,9
+ sc
+ blr
++
++#if defined(__linux__) && defined(__ELF__)
++ .section .note.GNU-stack,"",%progbits
++#endif
+diff --git a/sys-elf_i386.S b/sys-elf_i386.S
+index ab30c8d..6182b3d 100644
+--- a/sys-elf_i386.S
++++ b/sys-elf_i386.S
+@@ -40,3 +40,7 @@ direct_syscall:
+ pop %edi
+ pop %ebp
+ ret
++
++#if defined(__linux__) && defined(__ELF__)
++ .section .note.GNU-stack,"",%progbits
++#endif
+diff --git a/sys-elf_s390.S b/sys-elf_s390.S
+index 40630d1..e6a9a96 100644
+--- a/sys-elf_s390.S
++++ b/sys-elf_s390.S
+@@ -20,3 +20,7 @@ direct_syscall:
+ lr %r5,%r6
+ svc 0
+ br %r14
++
++#if defined(__linux__) && defined(__ELF__)
++ .section .note.GNU-stack,"",%progbits
++#endif
+diff --git a/sys-elf_x86_64.S b/sys-elf_x86_64.S
+index 6af06ad..561f49b 100644
+--- a/sys-elf_x86_64.S
++++ b/sys-elf_x86_64.S
+@@ -32,3 +32,7 @@ direct_syscall:
+ mov 0x8(%rsp),%r9
+ syscall
+ retq
++
++#if defined(__linux__) && defined(__ELF__)
++ .section .note.GNU-stack,"",%progbits
++#endif
+--
+2.6.2
+
diff --git a/sys-libs/libhugetlbfs/libhugetlbfs-2.20.ebuild b/sys-libs/libhugetlbfs/libhugetlbfs-2.20.ebuild
new file mode 100644
index 000000000000..3f61f83a7fc1
--- /dev/null
+++ b/sys-libs/libhugetlbfs/libhugetlbfs-2.20.ebuild
@@ -0,0 +1,167 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI="5"
+
+PYTHON_COMPAT=( python2_7 )
+
+inherit eutils multilib toolchain-funcs perl-functions python-any-r1
+
+DESCRIPTION="easy hugepage access"
+HOMEPAGE="https://github.com/libhugetlbfs/libhugetlbfs"
+SRC_URI="https://github.com/libhugetlbfs/libhugetlbfs/archive/${PV}.tar.gz -> ${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~s390 ~x86"
+IUSE="perl static-libs test"
+
+DEPEND="test? ( ${PYTHON_DEPS} )"
+RDEPEND="perl? ( dev-lang/perl:= )"
+
+src_prepare() {
+ perl_set_version
+
+ epatch "${FILESDIR}"/${PN}-2.9-build.patch #332517
+ epatch "${FILESDIR}"/${PN}-2.20-noexec-stack.patch
+ epatch "${FILESDIR}"/${PN}-2.6-fixup-testsuite.patch
+ sed -i \
+ -e '/^PREFIX/s:/local::' \
+ -e '1iBUILDTYPE = NATIVEONLY' \
+ -e '1iV = 1' \
+ -e '/gzip.*MANDIR/d' \
+ -e "/^LIB\(32\)/s:=.*:= $(get_libdir):" \
+ -e '/^CC\(32\|64\)/s:=.*:= $(CC):' \
+ -e "/^PMDIR = .*\/perl5\/TLBC/s::PMDIR = ${VENDOR_LIB}\/TLBC:" \
+ Makefile || die "sed failed"
+ if [ "$(get_libdir)" == "lib64" ]; then
+ sed -i \
+ -e "/^LIB\(32\)/s:=.*:= lib32:" \
+ Makefile
+ fi
+
+ # Tarballs from github don't have the version set.
+ # https://github.com/libhugetlbfs/libhugetlbfs/issues/7
+ [[ -f version ]] || echo "${PV}" > version
+}
+
+src_compile() {
+ tc-export AR
+ emake CC="$(tc-getCC)" libs tools
+}
+
+src_install() {
+ default
+ use static-libs || rm -f "${ED}"/usr/$(get_libdir)/*.a
+ rm "${ED}"/usr/bin/oprofile* || die
+ if ! use perl ; then
+ rm -r \
+ "${ED}"/usr/bin/cpupcstat \
+ "${ED}"/usr/share/man/man8/cpupcstat.8 \
+ "${ED}/${VENDOR_LIB}" \
+ || die
+ fi
+}
+
+src_test_alloc_one() {
+ hugeadm="$1"
+ sign="$2"
+ pagesize="$3"
+ pagecount="$4"
+ ${hugeadm} \
+ --pool-pages-max ${pagesize}:${sign}${pagecount} \
+ && \
+ ${hugeadm} \
+ --pool-pages-min ${pagesize}:${sign}${pagecount}
+ return $?
+}
+
+# die is NOT allowed in this src_test block after the marked point, so that we
+# can clean up memory allocation. You'll leak at LEAST 64MiB per run otherwise.
+src_test() {
+ [[ $UID -eq 0 ]] || die "Need FEATURES=-userpriv to run this testsuite"
+ einfo "Building testsuite"
+ emake -j1 tests || die "Failed to build tests"
+
+ hugeadm='obj/hugeadm'
+ allocated=''
+ rc=0
+ # the testcases need 64MiB per pagesize.
+ MIN_HUGEPAGE_RAM=$((64*1024*1024))
+
+ einfo "Planning allocation"
+ PAGESIZES="$(${hugeadm} --page-sizes-all)"
+
+ # Need to do this before we can create the mountpoints.
+ for pagesize in ${PAGESIZES} ; do
+ # The kernel depends on the location :-(
+ mkdir -p /var/lib/hugetlbfs/pagesize-${pagesize}
+ addwrite /var/lib/hugetlbfs/pagesize-${pagesize}
+ done
+ addwrite /proc/sys/vm/
+ addwrite /proc/sys/kernel/shmall
+ addwrite /proc/sys/kernel/shmmax
+ addwrite /proc/sys/kernel/shmmni
+
+ einfo "Checking HugeTLB mountpoints"
+ ${hugeadm} --create-mounts || die "Failed to set up hugetlb mountpoints."
+
+ # -----------------------------------------------------
+ # --------- die is unsafe after this point. -----------
+ # -----------------------------------------------------
+
+ einfo "Starting allocation"
+ for pagesize in ${PAGESIZES} ; do
+ pagecount=$((${MIN_HUGEPAGE_RAM}/${pagesize}))
+ einfo " ${pagecount} @ ${pagesize}"
+ addwrite /var/lib/hugetlbfs/pagesize-${pagesize}
+ src_test_alloc_one "$hugeadm" "+" "${pagesize}" "${pagecount}"
+ rc=$?
+ if [[ $rc -eq 0 ]]; then
+ allocated="${allocated} ${pagesize}:${pagecount}"
+ else
+ eerror "Failed to add ${pagecount} pages of size ${pagesize}"
+ fi
+ done
+
+ einfo "Allocation status"
+ ${hugeadm} --pool-list
+
+ if [[ -n "${allocated}" ]]; then
+ # All our allocations worked, so time to run.
+ einfo "Starting tests"
+ cd "${S}"/tests
+ TESTOPTS="-t func"
+ case $ARCH in
+ amd64|ppc64)
+ TESTOPTS="${TESTOPTS} -b 64"
+ ;;
+ x86)
+ TESTOPTS="${TESTOPTS} -b 32"
+ ;;
+ esac
+ # This needs a bit of work to give a nice exit code still.
+ ./run_tests.py ${TESTOPTS}
+ rc=$?
+ else
+ eerror "Failed to make HugeTLB allocations."
+ rc=1
+ fi
+
+ einfo "Cleaning up memory"
+ cd "${S}"
+ # Cleanup memory allocation
+ for alloc in ${allocated} ; do
+ pagesize="${alloc/:*}"
+ pagecount="${alloc/*:}"
+ einfo " ${pagecount} @ ${pagesize}"
+ src_test_alloc_one "$hugeadm" "-" "${pagesize}" "${pagecount}"
+ done
+
+ # ---------------------------------------------------------
+ # --------- die is safe again after this point. -----------
+ # ---------------------------------------------------------
+
+ return $rc
+}