On Wed, 12 Dec 2012 18:10:02 +0000
Steve Capper <steve.cap...@arm.com> wrote:

> This patch adds support for the ARM architecture to libhugetlbfs.
> 
> We do not add the xBT/xBDT style linker scripts as these have been
> deprecated in favour of adjusting the page sizes via command line
> parameter to ld.

Have you considered using the CUSTOM_LDSCRIPTS variable in the Makefile?
It was introduced with the s390 support for the very same reason, i.e.
to make it easier to provide arch support w/o the xBT/xBDT scripts, see
git commit 5be36294eabcb289111686530396424e13e5e057.

> 
> Signed-off-by: Steve Capper <steve.cap...@arm.com>
> ---
>  Makefile                |  6 ++++++
>  ld.hugetlbfs            | 12 ++++++++++++
>  sys-armelf_linux_eabi.S | 32 ++++++++++++++++++++++++++++++++
>  tests/Makefile          |  8 ++++++--
>  4 files changed, 56 insertions(+), 2 deletions(-)
>  create mode 100644 sys-armelf_linux_eabi.S
> 
> diff --git a/Makefile b/Makefile
> index 796b063..ce6d531 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -51,6 +51,11 @@ CC32 = gcc -m32
>  ELF32 = elf32ppclinux
>  TMPLIB32 = lib
>  else
> +ifeq ($(ARCH),armv7l)
> +CC32 = gcc
> +TMPLIB32 = lib
> +ELF32 += armelf_linux_eabi
> +else
>  ifeq ($(ARCH),i386)
>  CC32 = gcc
>  ELF32 = elf_i386
> @@ -93,6 +98,7 @@ endif
>  endif
>  endif
>  endif
> +endif
> 
>  ifdef CC32
>  OBJDIRS += obj32
> diff --git a/ld.hugetlbfs b/ld.hugetlbfs
> index 199bf97..d6d12c4 100755
> --- a/ld.hugetlbfs
> +++ b/ld.hugetlbfs
> @@ -79,6 +79,11 @@ if [ -n "$HTLB_LINK" ]; then
>      HTLB_ALIGN="" # --hugetlbfs-link overrides --hugetlbfs-align
>      LDSCRIPT="$EMU.x$HTLB_LINK"
>      HTLBOPTS="-T${HUGETLB_LDSCRIPT_PATH}/${LDSCRIPT}"
> +
> +    if [ "$EMU" == "armelf_linux_eabi" ]; then
> +        echo "Please use --hugetlbfs-align when targeting ARM."
> +     exit -1
> +    fi
>  fi
> 
>  MB=$((1024*1024))
> @@ -86,11 +91,18 @@ 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 ;;
> elf_s390|elf64_s390)  HPAGE_SIZE=$((1*$MB))
> SLICE_SIZE=$HPAGE_SIZE ;; +armelf_linux_eabi)
> HPAGE_SIZE=$((2*$MB)) SLICE_SIZE=$HPAGE_SIZE ;; esac
> 
>  if [ "$HTLB_ALIGN" == "slice" ]; then
>       HTLBOPTS="-zcommon-page-size=$SLICE_SIZE
> -zmax-page-size=$SLICE_SIZE" HTLBOPTS="$HTLBOPTS -lhugetlbfs"
> +
> +     # targeting the ARM platform one needs to explicitly set the
> text segment offset
> +     # otherwise it will be NULL.
> +     if [ "$EMU" == "armelf_linux_eabi" ]; then
> +             HTLBOPTS="$HTLBOPTS -Ttext-segment=$SLICE_SIZE"
> +     fi
>  fi
> 
>  ${LD} "${args[@]}" ${HTLBOPTS}
> diff --git a/sys-armelf_linux_eabi.S b/sys-armelf_linux_eabi.S
> new file mode 100644
> index 0000000..983d28b
> --- /dev/null
> +++ b/sys-armelf_linux_eabi.S
> @@ -0,0 +1,32 @@
> +/*
> + * libhugetlbfs - Easy use of Linux hugepages
> + * Copyright (C) 2012 ARM Ltd.
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public License
> + * version 2.1 as published by the Free Software Foundation.
> + *
> + * This library is distributed in the hope that it will be useful,
> but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, write to the Free
> Software
> + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> 02110-1301 USA
> + */
> +
> +        .text
> +
> +        .globl  direct_syscall
> +direct_syscall:
> +     mov     ip, sp
> +     stmfd   sp!, {r4, r5, r6, r7}
> +     mov     r7, r0
> +     mov     r0, r1
> +     mov     r1, r2
> +     mov     r2, r3
> +     ldmfd   ip, {r3, r4, r5, r6}
> +     swi     0x0
> +     ldmfd   sp!, {r4, r5, r6, r7}
> +     bx      lr
> diff --git a/tests/Makefile b/tests/Makefile
> index 231e3b0..90005d1 100644
> --- a/tests/Makefile
> +++ b/tests/Makefile
> @@ -42,8 +42,12 @@ INSTALL = install
>  TESTS = $(LIB_TESTS) $(NOLIB_TESTS) $(STRESS_TESTS) dummy.ldscript
>  ifdef ELF32
>  ifeq ($(CUSTOM_LDSCRIPTS),yes)

Setting CUSTOM_LDSCRIPTS to "no" for your architecture should give the
same result w/o changing tests/Makefile at all.

> -TESTS += $(LDSCRIPT_TESTS) $(HUGELINK_TESTS)
> $(HUGELINK_TESTS:%=xB.%) \
> -     $(HUGELINK_TESTS:%=xBDT.%) $(HUGELINK_RW_TESTS)
> +TESTS += $(LDSCRIPT_TESTS) $(HUGELINK_TESTS) $(HUGELINK_RW_TESTS)
> +# xB and xDT are deprecated for new versions of ld, for ARM
> +# we skip these tests as the linker is new.
> +ifneq ($(ARCH),armv7l)
> +TESTS += $(HUGELINK_TESTS:%=xB.%) $(HUGELINK_TESTS:%=xBDT.%)
> +endif
>  else
>  TESTS += $(LDSCRIPT_TESTS) $(HUGELINK_TESTS) $(HUGELINK_RW_TESTS)
>  endif


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to