Patch 2 of 2 for ILP32 aarch64

Message ID 1487980010.2866.198.camel@caviumnetworks.com
State New, archived
Headers

Commit Message

Steve Ellcey Feb. 24, 2017, 11:46 p.m. UTC
  Here is a new version of patch 2.  I added the one line descriptions
that were missing, fixed the configure.ac problems that Andreas pointed
out (and ran autoconf to make sure they were tested) and changed the
default version in shlib-versions to 2.26.

Steve Ellcey
sellcey@cavium.com


2017-02-24  Andrew Pinski  <andrew.pinski@caviumnetworks.com>
	    Yury Norov  <ynorov@caviumnetworks.com>
	    Steve Ellcey  <sellcey@caviumnetworks.com>

	* elf/cache.c (print_entry): Add FLAG_AARCH64_LIB32.
	* sysdeps/aarch64/configure.ac (HAVE_AARCH64_ILP32): New define.
	(default-abi): Allow for ilp32 ABI.
	* sysdeps/aarch64/configure: Regenerate.
	* sysdeps/aarch64/Implies: Deleted.
	* sysdeps/aarch64/ilp32/Implies: New file.
	* sysdeps/aarch64/ilp32/Implies-after: New file.
	* sysdeps/aarch64/lp64/Implies: New file.
	* sysdeps/aarch64/lp64/Implies-after: New file.
	* sysdeps/aarch64/preconfigure (machine): Check for ilp32/lp64.
	* sysdeps/aarch64/tls-macros.h (TLS_IE): Remove register specification
	for __result and ifdef for ILP32.
	* sysdeps/generic/ldconfig.h (FLAG_AARCH64_LIB32): New define.
	* sysdeps/unix/sysv/linux/aarch64/Implies: Remove generic and
	wordsize-64 entries.
	* sysdeps/unix/sysv/linux/aarch64/Makefile (abi-variants): Add
	new variants for ilp32 and ilp32_be.
	(abi-lp64-options, abi-lp64_be-options): define __LP64__ and
	undefine __ILP32__.
	(abi-lp64-condition, abi-lp64_be-condition): Check for __WORDSIZE
	equal to 64.
	(abi-ilp32-options, abi-ilp32-condition, abi-ilp32_be-options,
	abi-ilp32_be-condition): New.
	* sysdeps/unix/sysv/linux/aarch64/configure.ac (arch_minimum_kernel):
	Use different value for ILP32.
	(LIBC_SLIBDIR_RTLDDIR): Modify for ILP32.
	* sysdeps/unix/sysv/linux/aarch64/configure: Regenerate.
	* sysdeps/unix/sysv/linux/aarch64/ilp32/Implies: New file.
	* sysdeps/unix/sysv/linux/aarch64/ilp32/c++-types.data: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/ilp32/kernel_stat.h: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/ilp32/shlib-versions: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/bits/stat.h: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/bits/statfs.h: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/bits/typesizes.h: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/bits/utmp.h: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/bits/utmpx.h: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/kernel-features.h: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/Implies: Add unix/sysv/linux/aarch64.
	* sysdeps/unix/sysv/linux/aarch64/ioctl.S: Move to lp64 directory.
	* sysdeps/unix/sysv/linux/aarch64/mmap.c: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/shlib-versions: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/c++-types.data: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/ldd-rewrite.sed: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/ipc_priv.h (__IPC_64): Check __ILP32
	when setting.
	* sysdeps/unix/sysv/linux/arm/readelflib.c (process_elf_file):
	Check for EM_AARCH64 when processing ELFCLASS32 object.
	* sysdeps/unix/sysv/linux/bits/fcntl-linux.h (F_GETLK, F_SETLCK,
	F_SETLKW): Check for __OFF_T_MATCHES_OFF64_T when defining.
  

Comments

Andreas Schwab March 1, 2017, 6:49 p.m. UTC | #1
https://build.opensuse.org/project/show/devel:ARM:Factory:Contrib:ILP32
has been updated with this patch, and is currently rebuilding the world.

Andreas.
  
Mike Frysinger March 17, 2017, 4:08 a.m. UTC | #2
On 24 Feb 2017 15:46, Steve Ellcey wrote:
> --- a/sysdeps/aarch64/preconfigure
> +++ b/sysdeps/aarch64/preconfigure
> @@ -1,6 +1,14 @@
>  case "$machine" in
>  aarch64*)
> +	abiflag=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null`
>  	base_machine=aarch64

i know this file already has incorrect indentation style, but since
it only has two broken lines, can we fix it while we're here ?

> -	machine=aarch64
> +	case "$abiflag" in
> +		*"#define __ILP32__ 1"*) aarch64_config_abi=ilp32 ;;
> +		*) aarch64_config_abi=lp64 ;;
> +	esac

shouldn't this be a standard #if/#error style test rather than
grepping the raw cpp output ?
-mike
  
Szabolcs Nagy June 9, 2017, 8:47 a.m. UTC | #3
On 24/02/17 23:46, Steve Ellcey wrote:
> 
> Here is a new version of patch 2.  I added the one line descriptions
> that were missing, fixed the configure.ac problems that Andreas pointed
> out (and ran autoconf to make sure they were tested) and changed the
> default version in shlib-versions to 2.26.
> 

i assume this is the latest glibc ilp32 patch.

without patch 1 (abilist updates) and after i drop the
sysdeps/unix/sysv/linux/aarch64/mmap.c change and remove
the malloc/tst-mallocstate test,

using CC='gcc -mabi=ilp32' (so c++ tests are unsupported), i get

FAIL: check-local-headers
FAIL: crypt/check-abi-libcrypt
UNSUPPORTED: debug/tst-chk4
UNSUPPORTED: debug/tst-chk5
UNSUPPORTED: debug/tst-chk6
UNSUPPORTED: debug/tst-lfschk4
UNSUPPORTED: debug/tst-lfschk5
UNSUPPORTED: debug/tst-lfschk6
UNSUPPORTED: dlfcn/bug-atexit3
FAIL: dlfcn/check-abi-libdl
FAIL: elf/check-abi-ld
FAIL: elf/check-abi-libc
XPASS: elf/tst-protected1a
XPASS: elf/tst-protected1b
FAIL: locale/check-abi-libBrokenLocale
FAIL: login/check-abi-libutil
FAIL: malloc/tst-dynarray-fail
FAIL: math/check-abi-libm
FAIL: math/test-double-finite-lrint
FAIL: math/test-double-finite-lround
FAIL: math/test-double-lrint
FAIL: math/test-double-lround
UNSUPPORTED: math/test-fesetexcept-traps
UNSUPPORTED: math/test-fexcept-traps
FAIL: math/test-float-finite-lrint
FAIL: math/test-float-finite-lround
FAIL: math/test-float-lrint
FAIL: math/test-float-lround
UNSUPPORTED: math/test-nearbyint-except-2
FAIL: nis/check-abi-libnsl
FAIL: nptl/check-abi-libpthread
UNSUPPORTED: nptl/test-cond-printers
UNSUPPORTED: nptl/test-condattr-printers
UNSUPPORTED: nptl/test-mutex-printers
UNSUPPORTED: nptl/test-mutexattr-printers
UNSUPPORTED: nptl/test-rwlock-printers
UNSUPPORTED: nptl/test-rwlockattr-printers
UNSUPPORTED: nptl/tst-cancel24
UNSUPPORTED: nptl/tst-cancel24-static
FAIL: nptl/tst-initializers1
FAIL: nptl/tst-initializers1-c11
FAIL: nptl/tst-initializers1-c89
FAIL: nptl/tst-initializers1-c99
FAIL: nptl/tst-initializers1-gnu11
FAIL: nptl/tst-initializers1-gnu89
FAIL: nptl/tst-initializers1-gnu99
UNSUPPORTED: nptl/tst-once5
FAIL: nptl/tst-rwlock15
FAIL: nptl/tst-stack4
UNSUPPORTED: nptl/tst-thread_local1
FAIL: nptl_db/check-abi-libthread_db
FAIL: nss/bug17079
FAIL: posix/tst-mmap-offset
FAIL: resolv/check-abi-libanl
FAIL: resolv/check-abi-libresolv
FAIL: resolv/tst-bug18665
FAIL: resolv/tst-resolv-search
FAIL: rt/check-abi-librt
FAIL: stdlib/tst-makecontext3
UNSUPPORTED: stdlib/tst-quick_exit
UNSUPPORTED: stdlib/tst-thread-quick_exit
Summary of test results:
     37 FAIL
   3607 PASS
     22 UNSUPPORTED
     31 XFAIL
      2 XPASS

are these failures expected (other than the abi failures)?

> Steve Ellcey
> sellcey@cavium.com
> 
> 
> 2017-02-24  Andrew Pinski  <andrew.pinski@caviumnetworks.com>
> 	    Yury Norov  <ynorov@caviumnetworks.com>
> 	    Steve Ellcey  <sellcey@caviumnetworks.com>
> 
> 	* elf/cache.c (print_entry): Add FLAG_AARCH64_LIB32.
> 	* sysdeps/aarch64/configure.ac (HAVE_AARCH64_ILP32): New define.
> 	(default-abi): Allow for ilp32 ABI.
> 	* sysdeps/aarch64/configure: Regenerate.
> 	* sysdeps/aarch64/Implies: Deleted.
> 	* sysdeps/aarch64/ilp32/Implies: New file.
> 	* sysdeps/aarch64/ilp32/Implies-after: New file.
> 	* sysdeps/aarch64/lp64/Implies: New file.
> 	* sysdeps/aarch64/lp64/Implies-after: New file.
> 	* sysdeps/aarch64/preconfigure (machine): Check for ilp32/lp64.
> 	* sysdeps/aarch64/tls-macros.h (TLS_IE): Remove register specification
> 	for __result and ifdef for ILP32.
> 	* sysdeps/generic/ldconfig.h (FLAG_AARCH64_LIB32): New define.
> 	* sysdeps/unix/sysv/linux/aarch64/Implies: Remove generic and
> 	wordsize-64 entries.
> 	* sysdeps/unix/sysv/linux/aarch64/Makefile (abi-variants): Add
> 	new variants for ilp32 and ilp32_be.
> 	(abi-lp64-options, abi-lp64_be-options): define __LP64__ and
> 	undefine __ILP32__.
> 	(abi-lp64-condition, abi-lp64_be-condition): Check for __WORDSIZE
> 	equal to 64.
> 	(abi-ilp32-options, abi-ilp32-condition, abi-ilp32_be-options,
> 	abi-ilp32_be-condition): New.
> 	* sysdeps/unix/sysv/linux/aarch64/configure.ac (arch_minimum_kernel):
> 	Use different value for ILP32.
> 	(LIBC_SLIBDIR_RTLDDIR): Modify for ILP32.
> 	* sysdeps/unix/sysv/linux/aarch64/configure: Regenerate.
> 	* sysdeps/unix/sysv/linux/aarch64/ilp32/Implies: New file.
> 	* sysdeps/unix/sysv/linux/aarch64/ilp32/c++-types.data: Likewise.
> 	* sysdeps/unix/sysv/linux/aarch64/ilp32/kernel_stat.h: Likewise.
> 	* sysdeps/unix/sysv/linux/aarch64/ilp32/shlib-versions: Likewise.
> 	* sysdeps/unix/sysv/linux/aarch64/bits/stat.h: Likewise.
> 	* sysdeps/unix/sysv/linux/aarch64/bits/statfs.h: Likewise.
> 	* sysdeps/unix/sysv/linux/aarch64/bits/typesizes.h: Likewise.
> 	* sysdeps/unix/sysv/linux/aarch64/bits/utmp.h: Likewise.
> 	* sysdeps/unix/sysv/linux/aarch64/bits/utmpx.h: Likewise.
> 	* sysdeps/unix/sysv/linux/aarch64/kernel-features.h: Likewise.
> 	* sysdeps/unix/sysv/linux/aarch64/Implies: Add unix/sysv/linux/aarch64.
> 	* sysdeps/unix/sysv/linux/aarch64/ioctl.S: Move to lp64 directory.
> 	* sysdeps/unix/sysv/linux/aarch64/mmap.c: Likewise.
> 	* sysdeps/unix/sysv/linux/aarch64/shlib-versions: Likewise.
> 	* sysdeps/unix/sysv/linux/aarch64/c++-types.data: Likewise.
> 	* sysdeps/unix/sysv/linux/aarch64/ldd-rewrite.sed: Likewise.
> 	* sysdeps/unix/sysv/linux/aarch64/ipc_priv.h (__IPC_64): Check __ILP32
> 	when setting.
> 	* sysdeps/unix/sysv/linux/arm/readelflib.c (process_elf_file):
> 	Check for EM_AARCH64 when processing ELFCLASS32 object.
> 	* sysdeps/unix/sysv/linux/bits/fcntl-linux.h (F_GETLK, F_SETLCK,
> 	F_SETLKW): Check for __OFF_T_MATCHES_OFF64_T when defining.
>
  
Szabolcs Nagy June 9, 2017, 10:48 a.m. UTC | #4
On 09/06/17 09:47, Szabolcs Nagy wrote:
> On 24/02/17 23:46, Steve Ellcey wrote:
>>
>> Here is a new version of patch 2.  I added the one line descriptions
>> that were missing, fixed the configure.ac problems that Andreas pointed
>> out (and ran autoconf to make sure they were tested) and changed the
>> default version in shlib-versions to 2.26.
>>
> 
> i assume this is the latest glibc ilp32 patch.
> 
> without patch 1 (abilist updates) and after i drop the
> sysdeps/unix/sysv/linux/aarch64/mmap.c change and remove
> the malloc/tst-mallocstate test,
> 
> using CC='gcc -mabi=ilp32' (so c++ tests are unsupported), i get
> 

removing abi, c++ and known aarch64 issues

> FAIL: check-local-headers
*** $(common-objpfx)elf/readlib.o: uses /usr/include/gnu/lib-names-ilp32.h
*** /usr/include/gnu/lib-names-ilp32.h: uses /usr/include/gnu/lib-names-ilp32.h:
...
lib-names-ilp32.h was not generated, only lib-names-lp64.h

for some reason default-abi is lp64 in config.make,
even though preconfigure set aarch64_config_abi to ilp32

> FAIL: malloc/tst-dynarray-fail
timeout, cannot reproduce it now so it may be spurious error.

> FAIL: math/test-double-finite-lrint
> FAIL: math/test-double-finite-lround
> FAIL: math/test-double-lrint
> FAIL: math/test-double-lround
> FAIL: math/test-float-finite-lrint
> FAIL: math/test-float-finite-lround
> FAIL: math/test-float-lrint
> FAIL: math/test-float-lround
things like
Failure: lrint (0x1p31): Exception "Invalid operation" not set
Failure: lrint (0x1p32): Exception "Invalid operation" not set

i guess it's x vs w reg in the inline asm code

> FAIL: nptl/tst-initializers1
> FAIL: nptl/tst-initializers1-c11
> FAIL: nptl/tst-initializers1-c89
> FAIL: nptl/tst-initializers1-c99
> FAIL: nptl/tst-initializers1-gnu11
> FAIL: nptl/tst-initializers1-gnu89
> FAIL: nptl/tst-initializers1-gnu99
fails at
if (rwl_writer.__data.__flags
      != PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP)

> FAIL: nptl/tst-rwlock15
timeout

> FAIL: nptl/tst-stack4
segfault

> FAIL: nss/bug17079
info: 10 test items
Timed out: killed the child process

> FAIL: posix/tst-mmap-offset
error: tst-mmap-offset.c:65: ftruncate64 failed
error: 1 test failures

> FAIL: resolv/tst-bug18665
timeout

> FAIL: resolv/tst-resolv-search
timeout

> FAIL: stdlib/tst-makecontext3
making contexts
start f1(a00=00000001,a01=00000004,a02=00000012,a03=00000048,
         a04=00000123,a05=0000048d,a06=00001234,a07=000048d1,
         a08=00012345,a09=00123456,a10=01234567,a11=12345678,
         a12=23456789,a13=3456789a,a14=456789ab,a15=56789abc,
         a16=6789abcd,a17=789abcde,a18=89abcdef,a19=9abcdef0,
         a20=abcdef0f,a21=00000000,a22=00000000,a23=00400b14,
         a24=00000000,a25=00000000,a26=00400aec,a27=00000000,
         a28=00000000,a29=da721e98,a30=c174bda8,a31=004005b0,
         a32=ffffffff) [0]
arg mismatch
program did not reach main again


i dont have debug tools on this machine, but i'd like
to know if others see similar failures on a ilp32 system.
  
Florian Weimer June 9, 2017, 1:44 p.m. UTC | #5
Szabolcs Nagy <szabolcs.nagy@arm.com> writes:

>> FAIL: malloc/tst-dynarray-fail
> timeout, cannot reproduce it now so it may be spurious error.

For the timeouts, please try running the tests with a generous
TIMEOUTFACTOR.  Hopefully, most tests honor that.

>> FAIL: math/test-double-finite-lrint
>> FAIL: math/test-double-finite-lround
>> FAIL: math/test-double-lrint
>> FAIL: math/test-double-lround
>> FAIL: math/test-float-finite-lrint
>> FAIL: math/test-float-finite-lround
>> FAIL: math/test-float-lrint
>> FAIL: math/test-float-lround
> things like
> Failure: lrint (0x1p31): Exception "Invalid operation" not set
> Failure: lrint (0x1p32): Exception "Invalid operation" not set
>
> i guess it's x vs w reg in the inline asm code

So this needs more investigation and might be an actual bug?

>> FAIL: nptl/tst-initializers1
>> FAIL: nptl/tst-initializers1-c11
>> FAIL: nptl/tst-initializers1-c89
>> FAIL: nptl/tst-initializers1-c99
>> FAIL: nptl/tst-initializers1-gnu11
>> FAIL: nptl/tst-initializers1-gnu89
>> FAIL: nptl/tst-initializers1-gnu99
> fails at
> if (rwl_writer.__data.__flags
>       != PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP)

That looks like it would need fixing.

>> FAIL: nptl/tst-stack4
> segfault

That's an architecture-independent issue.

>> FAIL: nss/bug17079
> info: 10 test items
> Timed out: killed the child process
>
>> FAIL: posix/tst-mmap-offset
> error: tst-mmap-offset.c:65: ftruncate64 failed
> error: 1 test failures

That looks very much like a genuine bug, unless there's some external
restriction on file size in the test environment.

Maybe add this change to the test and try again?

-    FAIL_RET ("ftruncate64 failed");
+    FAIL_RET ("ftruncate64 failed: %m");

>> FAIL: stdlib/tst-makecontext3
> making contexts
> start f1(a00=00000001,a01=00000004,a02=00000012,a03=00000048,
>          a04=00000123,a05=0000048d,a06=00001234,a07=000048d1,
>          a08=00012345,a09=00123456,a10=01234567,a11=12345678,
>          a12=23456789,a13=3456789a,a14=456789ab,a15=56789abc,
>          a16=6789abcd,a17=789abcde,a18=89abcdef,a19=9abcdef0,
>          a20=abcdef0f,a21=00000000,a22=00000000,a23=00400b14,
>          a24=00000000,a25=00000000,a26=00400aec,a27=00000000,
>          a28=00000000,a29=da721e98,a30=c174bda8,a31=004005b0,
>          a32=ffffffff) [0]
> arg mismatch
> program did not reach main again

Looks like a genuine bug, too.

Thanks,
Florian
  
Steve Ellcey June 9, 2017, 7:46 p.m. UTC | #6
Here is my latest list of failures which is larger than the last time I
ran the testsuite.  This is with Top-of-tree glibc, gcc, binutils, and
a 4.10 kernel with ILP32 patches applied to it.  I installed the ilp32
libraries in /libilp32 before running to deal with the pthread tests
that fail when libpthread is not installed in the normal location.

FAIL: elf/check-abi-libc
XPASS: elf/tst-protected1a
XPASS: elf/tst-protected1b
FAIL: grp/testgrp
FAIL: math/test-double-finite-lrint
FAIL: math/test-double-finite-lround
FAIL: math/test-double-lrint
FAIL: math/test-double-lround
UNSUPPORTED: math/test-fesetexcept-traps
UNSUPPORTED: math/test-fexcept-traps
FAIL: math/test-float-finite-lrint
FAIL: math/test-float-finite-lround
FAIL: math/test-float-lrint
FAIL: math/test-float-lround
UNSUPPORTED: math/test-nearbyint-except-2
UNSUPPORTED: nptl/test-cond-printers
UNSUPPORTED: nptl/test-condattr-printers
UNSUPPORTED: nptl/test-mutex-printers
UNSUPPORTED: nptl/test-mutexattr-printers
UNSUPPORTED: nptl/test-rwlock-printers
UNSUPPORTED: nptl/test-rwlockattr-printers
FAIL: nptl/tst-initializers1
FAIL: nptl/tst-initializers1-c11
FAIL: nptl/tst-initializers1-c89
FAIL: nptl/tst-initializers1-c99
FAIL: nptl/tst-initializers1-gnu11
FAIL: nptl/tst-initializers1-gnu89
FAIL: nptl/tst-initializers1-gnu99
FAIL: nptl/tst-rwlock15
FAIL: nptl/tst-stack4
FAIL: nss/bug17079
FAIL: posix/globtest
FAIL: pwd/tst-getpw
FAIL: stdlib/tst-makecontext3
FAIL: timezone/tst-tzset
Summary of test results:
     24 FAIL
   3673 PASS
      9 UNSUPPORTED
     33 XFAIL
      2 XPASS

I had to disable (remove) one test, tst-mallocstate, because
it kills the entire testsuite run.  See:

https://sourceware.org/ml/libc-alpha/2016-12/msg00527.html

I have a fix for some of the math failures.  See:

https://sourceware.org/ml/libc-alpha/2016-11/msg01075.html


stdlib/tst-makecontext3 and nptl/tst-stack4 are long
standing failures that I don't fully understand. tst-stack4
fails in LP64 mode as well.

The tst-initializers1* failures are new failures to me.  They
were not failing before.  I will take a look at them.

grp/testgrp, nss/bug17079, posix/globtest, and pwd/tst-getpw
look like they may be configuration issues on my system.  They
are having problems querying user information.

timezone/tst-tzset is getting a segfault and I need to look into
it some more.

Steve Ellcey
sellcey@cavium.com
  
Szabolcs Nagy June 12, 2017, 10:14 a.m. UTC | #7
On 09/06/17 11:48, Szabolcs Nagy wrote:
> On 09/06/17 09:47, Szabolcs Nagy wrote:
>> On 24/02/17 23:46, Steve Ellcey wrote:
>>>
>>> Here is a new version of patch 2.  I added the one line descriptions
>>> that were missing, fixed the configure.ac problems that Andreas pointed
>>> out (and ran autoconf to make sure they were tested) and changed the
>>> default version in shlib-versions to 2.26.
>>>
>>
>> i assume this is the latest glibc ilp32 patch.
>>
>> without patch 1 (abilist updates) and after i drop the
>> sysdeps/unix/sysv/linux/aarch64/mmap.c change and remove
>> the malloc/tst-mallocstate test,
>>
>> using CC='gcc -mabi=ilp32' (so c++ tests are unsupported), i get
>>
> 
> removing abi, c++ and known aarch64 issues
> 
>> FAIL: check-local-headers
> *** $(common-objpfx)elf/readlib.o: uses /usr/include/gnu/lib-names-ilp32.h
> *** /usr/include/gnu/lib-names-ilp32.h: uses /usr/include/gnu/lib-names-ilp32.h:
> ...
> lib-names-ilp32.h was not generated, only lib-names-lp64.h
> 
> for some reason default-abi is lp64 in config.make,
> even though preconfigure set aarch64_config_abi to ilp32
> 

this happened because the posted patch did not
have regenerated sysdeps/aarch64/configure
  
Steve Ellcey June 12, 2017, 4:15 p.m. UTC | #8
On Mon, 2017-06-12 at 11:14 +0100, Szabolcs Nagy wrote:

> > 
> > for some reason default-abi is lp64 in config.make,
> > even though preconfigure set aarch64_config_abi to ilp32
> > 
> this happened because the posted patch did not
> have regenerated sysdeps/aarch64/configure

My understanding that regenerated files should not be part of a patch
(Wiki section 4.4).  Maybe I should have included an explicit statement
about the need to run autoconf, I have certainly made that mistake (not
running autoconf) myself a number of times.  When I apply the patch, I
do the following before building:

(cd sysdeps/unix/sysv/linux/aarch64; autoconf -I../../../../..)
(cd sysdeps/aarch64; autoconf -I../..)

vi sysdeps/unix/sysv/linux/aarch64/configure
# Change the linux kernel version check from 10.0 to whatever version
# I am currently using.

Steve Ellcey
sellcey@cavium.com
  
Szabolcs Nagy June 12, 2017, 4:26 p.m. UTC | #9
On 12/06/17 17:15, Steve Ellcey wrote:
> On Mon, 2017-06-12 at 11:14 +0100, Szabolcs Nagy wrote:
>>  
>>>
>>> for some reason default-abi is lp64 in config.make,
>>> even though preconfigure set aarch64_config_abi to ilp32
>>>
>> this happened because the posted patch did not
>> have regenerated sysdeps/aarch64/configure
> 
> My understanding that regenerated files should not be part of a patch
> (Wiki section 4.4).  Maybe I should have included an explicit statement

thanks, i didn't know that

> about the need to run autoconf, I have certainly made that mistake (not
> running autoconf) myself a number of times.  When I apply the patch, I
> do the following before building:
> 
> (cd sysdeps/unix/sysv/linux/aarch64; autoconf -I../../../../..)
> (cd sysdeps/aarch64; autoconf -I../..)
> 
> vi sysdeps/unix/sysv/linux/aarch64/configure
> # Change the linux kernel version check from 10.0 to whatever version
> # I am currently using.
> 
> Steve Ellcey
> sellcey@cavium.com
>
  
Andreas Schwab June 12, 2017, 4:44 p.m. UTC | #10
On Jun 12 2017, Steve Ellcey <sellcey@cavium.com> wrote:

> (cd sysdeps/unix/sysv/linux/aarch64; autoconf -I../../../../..)
> (cd sysdeps/aarch64; autoconf -I../..)

This is actually done automatically, if you configure with
--enable-maintainer-mode.

Andreas.
  
Zack Weinberg June 12, 2017, 4:53 p.m. UTC | #11
On Mon, Jun 12, 2017 at 12:44 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> On Jun 12 2017, Steve Ellcey <sellcey@cavium.com> wrote:
>
>> (cd sysdeps/unix/sysv/linux/aarch64; autoconf -I../../../../..)
>> (cd sysdeps/aarch64; autoconf -I../..)

Wouldn't it be nice if there were no generated files checked into
version control?

> This is actually done automatically, if you configure with
> --enable-maintainer-mode.

Wouldn't it be nice if that were the default when building out of a
git checkout?

zw
  
Joseph Myers June 12, 2017, 5:34 p.m. UTC | #12
On Mon, 12 Jun 2017, Zack Weinberg wrote:

> On Mon, Jun 12, 2017 at 12:44 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> > On Jun 12 2017, Steve Ellcey <sellcey@cavium.com> wrote:
> >
> >> (cd sysdeps/unix/sysv/linux/aarch64; autoconf -I../../../../..)
> >> (cd sysdeps/aarch64; autoconf -I../..)
> 
> Wouldn't it be nice if there were no generated files checked into
> version control?

That would mean you can't build from a read-only checkout.  (Which you 
can't now, because of .mo file generation in the source directory, but 
that's bug 14121, which would be good to fix.  Building from read-only 
sources would help make sure nothing writes into the source directory, 
even temporarily, during a build, so that building multiple configurations 
in parallel with the same source directory is safe.)

That would mean "make dist" can no longer use "git archive" and needs 
instead e.g. to construct a clean source directory and generate required 
files there.

That would mean building from a checkout requires a range of tools, in 
precise versions, that are not currently required.

That would make libm testing from a checkout very slow 
(auto-libm-test-out-cacos and auto-libm-test-out-cacosh take about 80 
minutes each to generate on my system; at present, you only care about 
that if you're changing tests for those functions), as well as requiring 
development headers and libraries for an unreleased version of MPC (for an 
mpc_atan bug fix affecting glibc tests).

Now, for particular cases of generated files, without strong version 
requirements or slow generation or needing to be generated to run 
configure, we might consider case by case "require gperf to build glibc" 
or "require bison to build glibc" or (for Unicode data) "require python3 
to build glibc" or (for C-translit.h) "require perl to build glibc", for 
example - if you require it for releases, not just checkouts, you can 
generate the file in the build directory and not affect use of "git 
archive", and in such cases I'd probably think not checking in the 
generated files is an improvement.  I'm more doubtful about it for 
configure scripts or libm tests (or anything else with tight version 
requirements, unusual tools or slow generation).

(In the Unicode data case I think it copies part of the original file and 
edits other parts.  Let's assume it would be changed to have a checked-in 
template file without the automatically generated parts, from which a full 
file gets generated in the build directory which is then installed in 
/usr/share/i18n and used in generating binary locales.)
  
Zack Weinberg June 12, 2017, 6:04 p.m. UTC | #13
On Mon, Jun 12, 2017 at 1:34 PM, Joseph Myers <joseph@codesourcery.com> wrote:
> On Mon, 12 Jun 2017, Zack Weinberg wrote:
>
>> On Mon, Jun 12, 2017 at 12:44 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:
>> > On Jun 12 2017, Steve Ellcey <sellcey@cavium.com> wrote:
>> >
>> >> (cd sysdeps/unix/sysv/linux/aarch64; autoconf -I../../../../..)
>> >> (cd sysdeps/aarch64; autoconf -I../..)
>>
>> Wouldn't it be nice if there were no generated files checked into
>> version control?
>
> [a number of excellent reasons why we can't do that right now]

I was being a bit tongue-in-cheek here, and I realize we can't get
there immediately, but I really do think "no generated files
whatsoever in source control" is a desirable goal to strive for in the
long term.  No checked-in files generated by autoconf, in particular,
I think should be relatively easy.  (Obviously not for 2.26.)

To some of your specific points ...

> That would mean you can't build from a read-only checkout.  (Which you
> can't now, because of .mo file generation in the source directory, but
> that's bug 14121, which would be good to fix.  Building from read-only
> sources would help make sure nothing writes into the source directory,
> even temporarily, during a build, so that building multiple configurations
> in parallel with the same source directory is safe.)

autoconf's insistence on writing files into the source tree, and
having the main "configure" script be located at the top of the source
tree, is somewhat unfortunate, yes.

However, for this use case, it should be good enough to check out the
tree, run autoreconf, and _then_ mark the source tree read-only.  If
we can't make a single invocation of autoreconf do everything that's
needed, that would be another bug to fix.

(I entirely agree that .mo files should be generated in the build directory.)

> That would mean "make dist" can no longer use "git archive" and needs
> instead e.g. to construct a clean source directory and generate required
> files there.

This is a big headache, yeah.  Automake makes you list in the
makefiles every single file that belongs in the distribution, which is
a pain.  On the other hand, it means that "make dist" works _from_ a
tarball release, which can be useful (e.g. unpack a tarball and run
"make dist", you should get another bit-identical tarball, or
something is horribly wrong).

A third way might be to rely on git for the things that are checked
in, but the makefiles for generated files that need to be in a tarball
release.

> That would mean building from a checkout requires a range of tools, in
> precise versions, that are not currently required.

I tend to think that == dependencies on tools should automatically be
considered bugs.  >= dependencies are OK, and I am actually fine with
requiring bleeding-edge tools for working with a git checkout (as
opposed to building a release).  I don't see a lot of value in
facilitating _development_ in old LTS-type environments.

> That would make libm testing from a checkout very slow
> (auto-libm-test-out-cacos and auto-libm-test-out-cacosh take about 80
> minutes each to generate on my system; at present, you only care about
> that if you're changing tests for those functions), as well as requiring
> development headers and libraries for an unreleased version of MPC (for an
> mpc_atan bug fix affecting glibc tests).

These are expectations for the math functions, computed with an
independent, extra-high-precision implementation, right?

It might make sense to maintain these separately from the glibc
repository.  You could test _any_ math library with them, after all?
I'd still structure that repo with no generated files checked in on
master, but have an alternative trunk that _just_ contained the
generated expectations, with parallel tags.  Then glibc could pull
that in as a submodule as appropriate.  (Or something like that.  Just
thinking out loud here.)

> Now, for particular cases of generated files, without strong version
> requirements or slow generation or needing to be generated to run
> configure, we might consider case by case "require gperf to build glibc"
> or "require bison to build glibc" or (for Unicode data) "require python3
> to build glibc" or (for C-translit.h) "require perl to build glibc", for
> example - if you require it for releases, not just checkouts, you can
> generate the file in the build directory and not affect use of "git
> archive", and in such cases I'd probably think not checking in the
> generated files is an improvement.

For requiring more tools to build from _releases_, we need to think
more carefully about available tools in old LTS-type environments.
python3 strikes me as the most likely to be trouble, which is
unfortunate, because I really want that one. :)  But I agree with the
principles here.

zw
  
Joseph Myers June 12, 2017, 7:56 p.m. UTC | #14
On Mon, 12 Jun 2017, Zack Weinberg wrote:

> > That would mean building from a checkout requires a range of tools, in
> > precise versions, that are not currently required.
> 
> I tend to think that == dependencies on tools should automatically be
> considered bugs.  >= dependencies are OK, and I am actually fine with
> requiring bleeding-edge tools for working with a git checkout (as
> opposed to building a release).  I don't see a lot of value in
> facilitating _development_ in old LTS-type environments.

There's a difference between old LTS, and the current LTS release of a 
distribution (which might still be a couple of years old).  And some 
dependencies may be on things not in any release at all.

> > That would make libm testing from a checkout very slow
> > (auto-libm-test-out-cacos and auto-libm-test-out-cacosh take about 80
> > minutes each to generate on my system; at present, you only care about
> > that if you're changing tests for those functions), as well as requiring
> > development headers and libraries for an unreleased version of MPC (for an
> > mpc_atan bug fix affecting glibc tests).
> 
> These are expectations for the math functions, computed with an
> independent, extra-high-precision implementation, right?
> 
> It might make sense to maintain these separately from the glibc
> repository.  You could test _any_ math library with them, after all?

In theory.  gen-auto-libm-tests is closely tied to glibc's particular 
choices regarding e.g. when underflow exceptions should be allowed or 
permitted very close to the underflow threshold, and various changes would 
be needed to defer such choices to a later stage than when the 
expectations are generated.  It's also closely tied to the 
libm-test-driver and gen-libm-test.pl; I don't expect any of that to work 
as-is with another libm implementation.

> I'd still structure that repo with no generated files checked in on
> master, but have an alternative trunk that _just_ contained the
> generated expectations, with parallel tags.  Then glibc could pull
> that in as a submodule as appropriate.  (Or something like that.  Just
> thinking out loud here.)

I think things such as submodules are best avoided for glibc (as 
complicating tagging, branching, atomic committing etc. across the whole 
tree).
  
Szabolcs Nagy June 13, 2017, 9:09 a.m. UTC | #15
On 12/06/17 17:26, Szabolcs Nagy wrote:
> On 12/06/17 17:15, Steve Ellcey wrote:
>> On Mon, 2017-06-12 at 11:14 +0100, Szabolcs Nagy wrote:
>>>  
>>>>
>>>> for some reason default-abi is lp64 in config.make,
>>>> even though preconfigure set aarch64_config_abi to ilp32
>>>>
>>> this happened because the posted patch did not
>>> have regenerated sysdeps/aarch64/configure
>>
>> My understanding that regenerated files should not be part of a patch
>> (Wiki section 4.4).  Maybe I should have included an explicit statement
> 
> thanks, i didn't know that
> 

after fixing this and my c++ toolchain, i get

FAIL: elf/check-abi-libc
XPASS: elf/tst-protected1a
XPASS: elf/tst-protected1b
FAIL: math/test-double-finite-lrint
FAIL: math/test-double-finite-lround
FAIL: math/test-double-lrint
FAIL: math/test-double-lround
UNSUPPORTED: math/test-fesetexcept-traps
UNSUPPORTED: math/test-fexcept-traps
FAIL: math/test-float-finite-lrint
FAIL: math/test-float-finite-lround
FAIL: math/test-float-lrint
FAIL: math/test-float-lround
UNSUPPORTED: math/test-nearbyint-except-2
UNSUPPORTED: nptl/test-cond-printers
UNSUPPORTED: nptl/test-condattr-printers
UNSUPPORTED: nptl/test-mutex-printers
UNSUPPORTED: nptl/test-mutexattr-printers
UNSUPPORTED: nptl/test-rwlock-printers
UNSUPPORTED: nptl/test-rwlockattr-printers
FAIL: nptl/tst-initializers1
FAIL: nptl/tst-initializers1-c11
FAIL: nptl/tst-initializers1-c89
FAIL: nptl/tst-initializers1-c99
FAIL: nptl/tst-initializers1-gnu11
FAIL: nptl/tst-initializers1-gnu89
FAIL: nptl/tst-initializers1-gnu99
FAIL: nptl/tst-rwlock15
FAIL: nptl/tst-stack4
FAIL: posix/tst-mmap-offset
FAIL: resolv/tst-bug18665
FAIL: resolv/tst-resolv-search
FAIL: stdlib/tst-makecontext3
Summary of test results:
     22 FAIL
   3685 PASS
      9 UNSUPPORTED
     32 XFAIL
      2 XPASS

the tst-mmap-offset and resolv failures are most likely
local environment issues.
  

Patch

diff --git a/elf/cache.c b/elf/cache.c
index a76f892..765917f 100644
--- a/elf/cache.c
+++ b/elf/cache.c
@@ -101,6 +101,9 @@  print_entry (const char *lib, int flag, unsigned int osversion,
     case FLAG_AARCH64_LIB64:
       fputs (",AArch64", stdout);
       break;
+    case FLAG_AARCH64_LIB32:
+      fputs (",ILP32", stdout);
+      break;
     /* Uses the ARM soft-float ABI.  */
     case FLAG_ARM_LIBSF:
       fputs (",soft-float", stdout);
diff --git a/sysdeps/aarch64/configure.ac b/sysdeps/aarch64/configure.ac
index 7851dd4..9069325 100644
--- a/sysdeps/aarch64/configure.ac
+++ b/sysdeps/aarch64/configure.ac
@@ -14,9 +14,16 @@  AC_CACHE_CHECK([for big endian],
                       yes
                      #endif
   ], libc_cv_aarch64_be=yes, libc_cv_aarch64_be=no)])
+
+if test $aarch64_config_abi = ilp32; then
+  AC_DEFINE(HAVE_AARCH64_ILP32)
+fi
+
 if test $libc_cv_aarch64_be = yes; then
   AC_DEFINE(HAVE_AARCH64_BE)
-  LIBC_CONFIG_VAR([default-abi], [lp64_be])
+  libc_aarch64_be=_be
 else
-  LIBC_CONFIG_VAR([default-abi], [lp64])
+  libc_aarch64_be=
 fi
+
+LIBC_CONFIG_VAR([default-abi], [${aarch64_config_abi}${libc_aarch64_be}])
diff --git a/sysdeps/aarch64/Implies b/sysdeps/aarch64/ilp32/Implies
similarity index 88%
copy from sysdeps/aarch64/Implies
copy to sysdeps/aarch64/ilp32/Implies
index e5adf4d..a9e5910 100644
--- a/sysdeps/aarch64/Implies
+++ b/sysdeps/aarch64/ilp32/Implies
@@ -1,4 +1,4 @@ 
-wordsize-64
+aarch64/fpu
 ieee754/ldbl-128
 ieee754/dbl-64/wordsize-64
 ieee754/dbl-64
diff --git a/sysdeps/aarch64/ilp32/Implies-after b/sysdeps/aarch64/ilp32/Implies-after
new file mode 100644
index 0000000..39a34c5
--- /dev/null
+++ b/sysdeps/aarch64/ilp32/Implies-after
@@ -0,0 +1 @@ 
+wordsize-32
diff --git a/sysdeps/aarch64/Implies b/sysdeps/aarch64/lp64/Implies
similarity index 88%
rename from sysdeps/aarch64/Implies
rename to sysdeps/aarch64/lp64/Implies
index e5adf4d..a9e5910 100644
--- a/sysdeps/aarch64/Implies
+++ b/sysdeps/aarch64/lp64/Implies
@@ -1,4 +1,4 @@ 
-wordsize-64
+aarch64/fpu
 ieee754/ldbl-128
 ieee754/dbl-64/wordsize-64
 ieee754/dbl-64
diff --git a/sysdeps/aarch64/lp64/Implies-after b/sysdeps/aarch64/lp64/Implies-after
new file mode 100644
index 0000000..a8cae95
--- /dev/null
+++ b/sysdeps/aarch64/lp64/Implies-after
@@ -0,0 +1 @@ 
+wordsize-64
diff --git a/sysdeps/aarch64/preconfigure b/sysdeps/aarch64/preconfigure
index d9bd1f8..b56d0aa 100644
--- a/sysdeps/aarch64/preconfigure
+++ b/sysdeps/aarch64/preconfigure
@@ -1,6 +1,14 @@ 
 case "$machine" in
 aarch64*)
+	abiflag=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null`
 	base_machine=aarch64
-	machine=aarch64
+	case "$abiflag" in
+		*"#define __ILP32__ 1"*) aarch64_config_abi=ilp32 ;;
+		*) aarch64_config_abi=lp64 ;;
+	esac
+	case $aarch64_config_abi in
+		ilp32) machine=aarch64/ilp32 ;;
+		lp64) machine=aarch64/lp64 ;;
+	esac
 	;;
 esac
diff --git a/sysdeps/aarch64/tls-macros.h b/sysdeps/aarch64/tls-macros.h
index 358ccbc..fa27dc0 100644
--- a/sysdeps/aarch64/tls-macros.h
+++ b/sysdeps/aarch64/tls-macros.h
@@ -32,8 +32,9 @@ 
 	    "x30", "memory", "cc");			\
      (int *) (__result); })
 
-#define TLS_IE(x)					\
-  ({ register unsigned long __result asm ("x0");	\
+#ifdef __LP64__
+# define TLS_IE(x)					\
+  ({ register unsigned long __result;			\
      register unsigned long __t;			\
      asm ("mrs	%1, tpidr_el0; "			\
 	  "adrp	%0, :gottprel:" #x "; "			\
@@ -41,6 +42,17 @@ 
 	  "add	%0, %0, %1"				\
 	  : "=r" (__result), "=r" (__t));		\
      (int *) (__result); })
+#else
+# define TLS_IE(x)					\
+  ({ register unsigned long __result;			\
+     register unsigned long __t;			\
+     asm ("mrs	%1, tpidr_el0; "			\
+	  "adrp	%0, :gottprel:" #x "; "			\
+	  "ldr	%w0, [%0, #:gottprel_lo12:" #x "]; "	\
+	  "add	%0, %0, %1"				\
+	  : "=r" (__result), "=r" (__t));		\
+     (int *) (__result); })
+#endif
 
 #define TLS_LE(x)					\
   ({ register unsigned long __result asm ("x0");	\
diff --git a/sysdeps/generic/ldconfig.h b/sysdeps/generic/ldconfig.h
index a61ce5c..be6b70c 100644
--- a/sysdeps/generic/ldconfig.h
+++ b/sysdeps/generic/ldconfig.h
@@ -42,6 +42,7 @@ 
 #define FLAG_MIPS_LIB32_NAN2008		0x0c00
 #define FLAG_MIPS64_LIBN32_NAN2008	0x0d00
 #define FLAG_MIPS64_LIBN64_NAN2008	0x0e00
+#define FLAG_AARCH64_LIB32		0x0f00
 
 /* Name of auxiliary cache.  */
 #define _PATH_LDCONFIG_AUX_CACHE "/var/cache/ldconfig/aux-cache"
diff --git a/sysdeps/unix/sysv/linux/aarch64/Implies b/sysdeps/unix/sysv/linux/aarch64/Implies
index 4409e19..c508f2e 100644
--- a/sysdeps/unix/sysv/linux/aarch64/Implies
+++ b/sysdeps/unix/sysv/linux/aarch64/Implies
@@ -1,3 +1 @@ 
 aarch64/nptl
-unix/sysv/linux/generic
-unix/sysv/linux/wordsize-64
diff --git a/sysdeps/unix/sysv/linux/aarch64/Makefile b/sysdeps/unix/sysv/linux/aarch64/Makefile
index 6b4e620..67619f5 100644
--- a/sysdeps/unix/sysv/linux/aarch64/Makefile
+++ b/sysdeps/unix/sysv/linux/aarch64/Makefile
@@ -23,13 +23,21 @@  endif
 
 abi-variants := lp64
 abi-variants += lp64_be
+abi-variants += ilp32
+abi-variants += ilp32_be
 
 ifeq (,$(filter $(default-abi),$(abi-variants)))
 Unknown ABI, must be one of $(abi-variants)
 endif
 
-abi-lp64-options := -U__AARCH64EB__
-abi-lp64-condition := !defined __AARCH64EB__
+abi-lp64-options := -U__AARCH64EB__ -D__LP64__ -U__ILP32__
+abi-lp64-condition := __WORDSIZE == 64 && !defined __AARCH64EB__
 
-abi-lp64_be-options := -D__AARCH64EB__
-abi-lp64_be-condition := defined __AARCH64EB__
+abi-lp64_be-options := -D__AARCH64EB__ -D__LP64__ -U__ILP32__
+abi-lp64_be-condition := __WORDSIZE == 64 && defined __AARCH64EB__
+
+abi-ilp32-options := -U__AARCH64EB__ -U__LP64__ -D__ILP32__
+abi-ilp32-condition := __WORDSIZE == 32 && !defined __AARCH64EB__
+
+abi-ilp32_be-options := -D__AARCH64EB__ -U__LP64__ -D__ILP32__
+abi-ilp32_be-condition := __WORDSIZE == 32 && defined __AARCH64EB__
diff --git a/sysdeps/unix/sysv/linux/aarch64/bits/stat.h b/sysdeps/unix/sysv/linux/aarch64/bits/stat.h
new file mode 100644
index 0000000..4472fb1
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/aarch64/bits/stat.h
@@ -0,0 +1,178 @@ 
+/* Definition of `struct stat' used in the kernel.
+   Copyright (C) 2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C 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 the GNU C Library.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#if !defined _SYS_STAT_H && !defined _FCNTL_H
+# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
+#endif
+
+#ifndef _BITS_STAT_H
+#define _BITS_STAT_H	1
+
+#include <bits/wordsize.h>
+
+/* 64-bit libc uses the kernel's 'struct stat', accessed via the
+   stat() syscall; 32-bit libc uses the kernel's 'struct stat64'
+   and accesses it via the stat64() syscall.  All the various
+   APIs offered by libc use the kernel shape for their struct stat
+   structure; the only difference is that 32-bit programs not
+   using __USE_FILE_OFFSET64 only see the low 32 bits of some
+   of the fields (specifically st_ino, st_size, and st_blocks).  */
+#define _STAT_VER_KERNEL	0
+#define _STAT_VER_LINUX		0
+#define _STAT_VER		_STAT_VER_KERNEL
+
+/* Versions of the `xmknod' interface.  */
+#define _MKNOD_VER_LINUX	0
+
+struct stat
+  {
+    __dev_t st_dev;		/* Device.  */
+#ifdef __LP64__
+    __ino_t st_ino;		/* File serial number. */
+#else
+    unsigned int __pad0;
+    unsigned int __st_ino;	/* 32bit file serial number.	*/
+#endif
+    __mode_t st_mode;		/* File mode.  */
+    __nlink_t st_nlink;		/* Link count.  */
+    __uid_t st_uid;		/* User ID of the file's owner.	*/
+    __gid_t st_gid;		/* Group ID of the file's group.*/
+    __dev_t st_rdev;		/* Device number, if device.  */
+    __dev_t __pad1;
+    __off_t st_size;		/* Size of file, in bytes. */
+    __blksize_t st_blksize;	/* Optimal block size for I/O.  */
+#ifdef __LP64__
+    int __pad2;
+#endif
+    __blkcnt_t st_blocks;	/* 512-byte blocks */
+#ifdef __USE_XOPEN2K8
+    /* Nanosecond resolution timestamps are stored in a format
+       equivalent to 'struct timespec'.  This is the type used
+       whenever possible but the Unix namespace rules do not allow the
+       identifier 'timespec' to appear in the <sys/stat.h> header.
+       Therefore we have to handle the use of this header in strictly
+       standard-compliant sources special.  */
+    struct timespec st_atim;		/* Time of last access.  */
+    struct timespec st_mtim;		/* Time of last modification.  */
+    struct timespec st_ctim;		/* Time of last status change.  */
+# define st_atime st_atim.tv_sec	/* Backward compatibility.  */
+# define st_mtime st_mtim.tv_sec
+# define st_ctime st_ctim.tv_sec
+#else
+    __time_t st_atime;			/* Time of last access.  */
+    unsigned long int st_atimensec;	/* Nscecs of last access.  */
+    __time_t st_mtime;			/* Time of last modification.  */
+    unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
+    __time_t st_ctime;			/* Time of last status change.  */
+    unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
+#endif
+#ifdef __LP64__
+    int __glibc_reserved[2];
+#else
+    __ino_t st_ino;			/* File serial number.	*/
+#endif
+  };
+
+#ifdef __USE_LARGEFILE64
+struct stat64
+  {
+    __dev_t st_dev;		/* Device.  */
+# ifdef __LP64__
+    __ino64_t st_ino;		/* File serial number. */
+# else
+    unsigned int __pad0;
+    unsigned int __st_ino;	/* 32bit file serial number.	*/
+# endif
+    __mode_t st_mode;		/* File mode.  */
+    __nlink_t st_nlink;		/* Link count.  */
+    __uid_t st_uid;		/* User ID of the file's owner.	*/
+    __gid_t st_gid;		/* Group ID of the file's group.*/
+    __dev_t st_rdev;		/* Device number, if device.  */
+    __dev_t __pad1;
+    __off64_t st_size;		/* Size of file, in bytes.  */
+    __blksize_t st_blksize;	/* Optimal block size for I/O.  */
+# ifdef __LP64__
+    int __pad2;
+# endif
+    __blkcnt64_t st_blocks;	/* Nr. 512-byte blocks allocated.  */
+# ifdef __USE_XOPEN2K8
+    /* Nanosecond resolution timestamps are stored in a format
+       equivalent to 'struct timespec'.  This is the type used
+       whenever possible but the Unix namespace rules do not allow the
+       identifier 'timespec' to appear in the <sys/stat.h> header.
+       Therefore we have to handle the use of this header in strictly
+       standard-compliant sources special.  */
+    struct timespec st_atim;		/* Time of last access.  */
+    struct timespec st_mtim;		/* Time of last modification.  */
+    struct timespec st_ctim;		/* Time of last status change.  */
+# else
+    __time_t st_atime;			/* Time of last access.  */
+    unsigned long int st_atimensec;	/* Nscecs of last access.  */
+    __time_t st_mtime;			/* Time of last modification.  */
+    unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
+    __time_t st_ctime;			/* Time of last status change.  */
+    unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
+# endif
+# ifdef __LP64__
+    int __glibc_reserved[2];
+# else
+    __ino_t st_ino;			/* File serial number.	*/
+# endif
+  };
+#endif
+
+/* Tell code we have these members.  */
+#define _STATBUF_ST_BLKSIZE
+#define _STATBUF_ST_RDEV
+/* Nanosecond resolution time values are supported.  */
+#define _STATBUF_ST_NSEC
+
+/* Encoding of the file mode.  */
+
+#define __S_IFMT	0170000	/* These bits determine file type.  */
+
+/* File types.  */
+#define __S_IFDIR	0040000	/* Directory.  */
+#define __S_IFCHR	0020000	/* Character device.  */
+#define __S_IFBLK	0060000	/* Block device.  */
+#define __S_IFREG	0100000	/* Regular file.  */
+#define __S_IFIFO	0010000	/* FIFO.  */
+#define __S_IFLNK	0120000	/* Symbolic link.  */
+#define __S_IFSOCK	0140000	/* Socket.  */
+
+/* POSIX.1b objects.  Note that these macros always evaluate to zero.  But
+   they do it by enforcing the correct use of the macros.  */
+#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
+#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
+#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
+
+/* Protection bits.  */
+
+#define __S_ISUID	04000	/* Set user ID on execution.  */
+#define __S_ISGID	02000	/* Set group ID on execution.  */
+#define __S_ISVTX	01000	/* Save swapped text after use (sticky).  */
+#define __S_IREAD	0400	/* Read by owner.  */
+#define __S_IWRITE	0200	/* Write by owner.  */
+#define __S_IEXEC	0100	/* Execute by owner.  */
+
+#ifdef __USE_ATFILE
+# define UTIME_NOW	((1l << 30) - 1l)
+# define UTIME_OMIT	((1l << 30) - 2l)
+#endif
+
+#endif /* bits/stat.h */
diff --git a/sysdeps/unix/sysv/linux/aarch64/bits/statfs.h b/sysdeps/unix/sysv/linux/aarch64/bits/statfs.h
new file mode 100644
index 0000000..23953b9
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/aarch64/bits/statfs.h
@@ -0,0 +1,68 @@ 
+/* Definition of `struct statfs', information about a filesystem.
+   Copyright (C) 2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C 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 the GNU C Library.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _SYS_STATFS_H
+# error "Never include <bits/statfs.h> directly; use <sys/statfs.h> instead."
+#endif
+
+#include <endian.h>
+#include <bits/types.h>
+#include <bits/wordsize.h>
+
+/* On AArch64 both the 32-bit and 64-bit libc's use the kernels
+   'struct statfs' with 64 bit f_blocks/f_bfree/f_bavail/f_files/f_ffree
+   fields.  This means the statfs and statfs64 structs are identical
+   and the statfs and statfs64 calls can be aliases.  */
+
+struct statfs
+  {
+    __SWORD_TYPE f_type;
+    __SWORD_TYPE f_bsize;
+    __fsblkcnt_t f_blocks;
+    __fsblkcnt_t f_bfree;
+    __fsblkcnt_t f_bavail;
+    __fsfilcnt_t f_files;
+    __fsfilcnt_t f_ffree;
+    __fsid_t f_fsid;
+    __SWORD_TYPE f_namelen;
+    __SWORD_TYPE f_frsize;
+    __SWORD_TYPE f_flags;
+    __SWORD_TYPE f_spare[4];
+  };
+
+struct statfs64
+  {
+    __SWORD_TYPE f_type;
+    __SWORD_TYPE f_bsize;
+    __fsblkcnt64_t f_blocks;
+    __fsblkcnt64_t f_bfree;
+    __fsblkcnt64_t f_bavail;
+    __fsfilcnt64_t f_files;
+    __fsfilcnt64_t f_ffree;
+    __fsid_t f_fsid;
+    __SWORD_TYPE f_namelen;
+    __SWORD_TYPE f_frsize;
+    __SWORD_TYPE f_flags;
+    __SWORD_TYPE f_spare[4];
+  };
+
+/* Tell code we have these members.  */
+#define _STATFS_F_NAMELEN
+#define _STATFS_F_FRSIZE
+#define _STATFS_F_FLAGS
diff --git a/sysdeps/unix/sysv/linux/aarch64/bits/typesizes.h b/sysdeps/unix/sysv/linux/aarch64/bits/typesizes.h
new file mode 100644
index 0000000..e3975c7
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/aarch64/bits/typesizes.h
@@ -0,0 +1,88 @@ 
+/* bits/typesizes.h -- underlying types for *_t.  Linux/AArch64 version.
+   Copyright (C) 2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C 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 the GNU C Library.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _BITS_TYPES_H
+# error "Never include <bits/typesizes.h> directly; use <sys/types.h> instead."
+#endif
+
+#ifndef	_BITS_TYPESIZES_H
+#define _BITS_TYPESIZES_H	1
+
+/* See <bits/types.h> for the meaning of these macros.  This file exists so
+   that <bits/types.h> need not vary across different GNU platforms.  */
+
+#define __DEV_T_TYPE		__UQUAD_TYPE
+#define __UID_T_TYPE		__U32_TYPE
+#define __GID_T_TYPE		__U32_TYPE
+#define __INO_T_TYPE		__UQUAD_TYPE
+#define __INO64_T_TYPE		__UQUAD_TYPE
+#define __MODE_T_TYPE		__U32_TYPE
+#define __NLINK_T_TYPE		__U32_TYPE
+#define __OFF_T_TYPE		__SQUAD_TYPE
+#define __OFF64_T_TYPE		__SQUAD_TYPE
+#define __PID_T_TYPE		__S32_TYPE
+#define __RLIM_T_TYPE		__UQUAD_TYPE
+#define __RLIM64_T_TYPE		__UQUAD_TYPE
+#define __BLKCNT_T_TYPE		__SQUAD_TYPE
+#define __BLKCNT64_T_TYPE	__SQUAD_TYPE
+#define __FSBLKCNT_T_TYPE	__UQUAD_TYPE
+#define __FSBLKCNT64_T_TYPE	__UQUAD_TYPE
+#define __FSFILCNT_T_TYPE	__UQUAD_TYPE
+#define __FSFILCNT64_T_TYPE	__UQUAD_TYPE
+#define __FSWORD_T_TYPE		__SWORD_TYPE
+#define __ID_T_TYPE		__U32_TYPE
+#define __CLOCK_T_TYPE		__SLONGWORD_TYPE
+#define __TIME_T_TYPE		__SLONGWORD_TYPE
+#define __USECONDS_T_TYPE	__U32_TYPE
+#define __SUSECONDS_T_TYPE	__SLONGWORD_TYPE
+#define __DADDR_T_TYPE		__S32_TYPE
+#define __KEY_T_TYPE		__S32_TYPE
+#define __CLOCKID_T_TYPE	__S32_TYPE
+#define __TIMER_T_TYPE		void *
+#define __BLKSIZE_T_TYPE	__S32_TYPE
+#define __FSID_T_TYPE		struct { int __val[2]; }
+/* ssize_t is always singed long in both ABIs. */
+#define __SSIZE_T_TYPE		__SLONGWORD_TYPE
+#define __SYSCALL_SLONG_TYPE	__SLONGWORD_TYPE
+#define __SYSCALL_ULONG_TYPE	__ULONGWORD_TYPE
+#define __CPU_MASK_TYPE         __ULONGWORD_TYPE
+
+/* Tell the libc code that off_t and off64_t are actually the same type
+   for all ABI purposes, even if possibly expressed as different base types
+   for C type-checking purposes.  */
+#define __OFF_T_MATCHES_OFF64_T				1
+
+/* Same for ino_t and ino64_t.  */
+#define __INO_T_MATCHES_INO64_T				1
+
+/* And for rlim_t and rlim64_t.  */
+#define __RLIM_T_MATCHES_RLIM64_T			1
+
+/* And for __blkcnt_t and __blkcnt64_t.  */
+#define __BLKCNT_T_TYPE_MATCHES_BLKCNT64_T_TYPE	1
+
+/* And for __fsblkcnt_t and __fsblkcnt64_t.  */
+#define __FSBLKCNT_T_TYPE_MATCHES_FSBLKCNT64_T_TYPE	1
+
+/* And for __fsbilcnt_t and __fsbilcnt64_t.  */
+#define __FSFILCNT_T_TYPE_MATCHES_FSFILCNT64_T_TYPE	1
+
+/* Number of descriptors that can fit in an `fd_set'.  */
+#define __FD_SETSIZE		1024
+
+#endif /* bits/typesizes.h */
diff --git a/sysdeps/unix/sysv/linux/aarch64/bits/utmp.h b/sysdeps/unix/sysv/linux/aarch64/bits/utmp.h
new file mode 100644
index 0000000..8505175
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/aarch64/bits/utmp.h
@@ -0,0 +1,125 @@ 
+/* The `struct utmp' type, describing entries in the utmp file.
+   Linux/AArch64 version.
+
+   Copyright (C) 2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C 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 the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _UTMP_H
+# error "Never include <bits/utmp.h> directly; use <utmp.h> instead."
+#endif
+
+#include <paths.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <bits/wordsize.h>
+
+
+#define UT_LINESIZE	32
+#define UT_NAMESIZE	32
+#define UT_HOSTSIZE	256
+
+
+/* The structure describing an entry in the database of
+   previous logins.  */
+struct lastlog
+  {
+#if __WORDSIZE == 32
+    int64_t ll_time;
+#else
+    __time_t ll_time;
+#endif
+    char ll_line[UT_LINESIZE];
+    char ll_host[UT_HOSTSIZE];
+  };
+
+
+/* The structure describing the status of a terminated process.  This
+   type is used in `struct utmp' below.  */
+struct exit_status
+  {
+    short int e_termination;	/* Process termination status.  */
+    short int e_exit;		/* Process exit status.  */
+  };
+
+
+/* The structure describing an entry in the user accounting database.  */
+struct utmp
+{
+  short int ut_type;		/* Type of login.  */
+  pid_t ut_pid;			/* Process ID of login process.  */
+  char ut_line[UT_LINESIZE];	/* Devicename.  */
+  char ut_id[4];		/* Inittab ID.  */
+  char ut_user[UT_NAMESIZE];	/* Username.  */
+  char ut_host[UT_HOSTSIZE];	/* Hostname for remote login.  */
+  struct exit_status ut_exit;	/* Exit status of a process marked
+				   as DEAD_PROCESS.  */
+/* The ut_session and ut_tv fields must be the same size when compiled
+   32- and 64-bit.  This allows data files and shared memory to be
+   shared between 32- and 64-bit applications.  */
+#if __WORDSIZE == 32
+  int64_t ut_session;		/* Session ID, used for windowing.  */
+  struct
+  {
+    int64_t tv_sec;		/* Seconds.  */
+    int64_t tv_usec;		/* Microseconds.  */
+  } ut_tv;			/* Time entry was made.  */
+#else
+  long int ut_session;		/* Session ID, used for windowing.  */
+  struct timeval ut_tv;		/* Time entry was made.  */
+#endif
+
+  int32_t ut_addr_v6[4];	/* Internet address of remote host.  */
+  char __glibc_reserved[20];		/* Reserved for future use.  */
+};
+
+/* Backwards compatibility hacks.  */
+#define ut_name		ut_user
+#ifndef _NO_UT_TIME
+/* We have a problem here: `ut_time' is also used otherwise.  Define
+   _NO_UT_TIME if the compiler complains.  */
+# define ut_time	ut_tv.tv_sec
+#endif
+#define ut_xtime	ut_tv.tv_sec
+#define ut_addr		ut_addr_v6[0]
+
+
+/* Values for the `ut_type' field of a `struct utmp'.  */
+#define EMPTY		0	/* No valid user accounting information.  */
+
+#define RUN_LVL		1	/* The system's runlevel.  */
+#define BOOT_TIME	2	/* Time of system boot.  */
+#define NEW_TIME	3	/* Time after system clock changed.  */
+#define OLD_TIME	4	/* Time when system clock changed.  */
+
+#define INIT_PROCESS	5	/* Process spawned by the init process.  */
+#define LOGIN_PROCESS	6	/* Session leader of a logged in user.  */
+#define USER_PROCESS	7	/* Normal process.  */
+#define DEAD_PROCESS	8	/* Terminated process.  */
+
+#define ACCOUNTING	9
+
+/* Old Linux name for the EMPTY type.  */
+#define UT_UNKNOWN	EMPTY
+
+
+/* Tell the user that we have a modern system with UT_HOST, UT_PID,
+   UT_TYPE, UT_ID and UT_TV fields.  */
+#define _HAVE_UT_TYPE	1
+#define _HAVE_UT_PID	1
+#define _HAVE_UT_ID	1
+#define _HAVE_UT_TV	1
+#define _HAVE_UT_HOST	1
diff --git a/sysdeps/unix/sysv/linux/aarch64/bits/utmpx.h b/sysdeps/unix/sysv/linux/aarch64/bits/utmpx.h
new file mode 100644
index 0000000..bffd45c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/aarch64/bits/utmpx.h
@@ -0,0 +1,104 @@ 
+/* Structures and definitions for the user accounting database.
+   Linux/AArch64 version.
+
+   Copyright (C) 2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C 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 the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _UTMPX_H
+# error "Never include <bits/utmpx.h> directly; use <utmpx.h> instead."
+#endif
+
+#include <bits/types.h>
+#include <sys/time.h>
+#include <bits/wordsize.h>
+
+
+#ifdef __USE_GNU
+# include <paths.h>
+# define _PATH_UTMPX	_PATH_UTMP
+# define _PATH_WTMPX	_PATH_WTMP
+#endif
+
+
+#define __UT_LINESIZE	32
+#define __UT_NAMESIZE	32
+#define __UT_HOSTSIZE	256
+
+
+/* The structure describing the status of a terminated process.  This
+   type is used in `struct utmpx' below.  */
+struct __exit_status
+  {
+#ifdef __USE_GNU
+    short int e_termination;	/* Process termination status.  */
+    short int e_exit;		/* Process exit status.  */
+#else
+    short int __e_termination;	/* Process termination status.  */
+    short int __e_exit;		/* Process exit status.  */
+#endif
+  };
+
+
+/* The structure describing an entry in the user accounting database.  */
+struct utmpx
+{
+  short int ut_type;		/* Type of login.  */
+  __pid_t ut_pid;		/* Process ID of login process.  */
+  char ut_line[__UT_LINESIZE];	/* Devicename.  */
+  char ut_id[4];		/* Inittab ID. */
+  char ut_user[__UT_NAMESIZE];	/* Username.  */
+  char ut_host[__UT_HOSTSIZE];	/* Hostname for remote login.  */
+  struct __exit_status ut_exit;	/* Exit status of a process marked
+				   as DEAD_PROCESS.  */
+
+/* The fields ut_session and ut_tv must be the same size when compiled
+   32- and 64-bit.  This allows files and shared memory to be shared
+   between 32- and 64-bit applications.  */
+#if __WORDSIZE == 32
+  __int64_t ut_session;		/* Session ID, used for windowing.  */
+  struct
+  {
+    __int64_t tv_sec;		/* Seconds.  */
+    __int64_t tv_usec;		/* Microseconds.  */
+  } ut_tv;			/* Time entry was made.  */
+#else
+  long int ut_session;		/* Session ID, used for windowing.  */
+  struct timeval ut_tv;		/* Time entry was made.  */
+#endif
+  __int32_t ut_addr_v6[4];	/* Internet address of remote host.  */
+  char __glibc_reserved[20];		/* Reserved for future use.  */
+};
+
+
+/* Values for the `ut_type' field of a `struct utmpx'.  */
+#define EMPTY		0	/* No valid user accounting information.  */
+
+#ifdef __USE_GNU
+# define RUN_LVL	1	/* The system's runlevel.  */
+#endif
+#define BOOT_TIME	2	/* Time of system boot.  */
+#define NEW_TIME	3	/* Time after system clock changed.  */
+#define OLD_TIME	4	/* Time when system clock changed.  */
+
+#define INIT_PROCESS	5	/* Process spawned by the init process.  */
+#define LOGIN_PROCESS	6	/* Session leader of a logged in user.  */
+#define USER_PROCESS	7	/* Normal process.  */
+#define DEAD_PROCESS	8	/* Terminated process.  */
+
+#ifdef __USE_GNU
+# define ACCOUNTING	9	/* System accounting.  */
+#endif
diff --git a/sysdeps/unix/sysv/linux/aarch64/configure.ac b/sysdeps/unix/sysv/linux/aarch64/configure.ac
index 211fa9c..8cc97ef 100644
--- a/sysdeps/unix/sysv/linux/aarch64/configure.ac
+++ b/sysdeps/unix/sysv/linux/aarch64/configure.ac
@@ -1,6 +1,12 @@ 
 GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
 # Local configure fragment for sysdeps/unix/sysv/linux/aarch64.
 
-arch_minimum_kernel=3.7.0
+if test $aarch64_config_abi = ilp32; then
+  arch_minimum_kernel=10.0.0
+  LIBC_SLIBDIR_RTLDDIR([libilp32], [lib])
+else
+  arch_minimum_kernel=3.7.0
+  LIBC_SLIBDIR_RTLDDIR([lib64], [lib])
+fi
 
-LIBC_SLIBDIR_RTLDDIR([lib64], [lib])
+ldd_rewrite_script=$dir/ldd-rewrite.sed
diff --git a/sysdeps/unix/sysv/linux/aarch64/ilp32/Implies b/sysdeps/unix/sysv/linux/aarch64/ilp32/Implies
new file mode 100644
index 0000000..7dd239e
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/aarch64/ilp32/Implies
@@ -0,0 +1,4 @@ 
+aarch64/nptl
+unix/sysv/linux/aarch64
+unix/sysv/linux/generic/wordsize-32
+unix/sysv/linux/generic
diff --git a/sysdeps/unix/sysv/linux/aarch64/c++-types.data b/sysdeps/unix/sysv/linux/aarch64/ilp32/c++-types.data
similarity index 77%
copy from sysdeps/unix/sysv/linux/aarch64/c++-types.data
copy to sysdeps/unix/sysv/linux/aarch64/ilp32/c++-types.data
index ac925cc..3fe2e2b 100644
--- a/sysdeps/unix/sysv/linux/aarch64/c++-types.data
+++ b/sysdeps/unix/sysv/linux/aarch64/ilp32/c++-types.data
@@ -1,32 +1,32 @@ 
-blkcnt64_t:l
-blkcnt_t:l
+blkcnt64_t:x
+blkcnt_t:x
 blksize_t:i
 caddr_t:Pc
 clockid_t:i
 clock_t:l
 daddr_t:i
-dev_t:m
+dev_t:y
 fd_mask:l
-fsblkcnt64_t:m
-fsblkcnt_t:m
-fsfilcnt64_t:m
-fsfilcnt_t:m
+fsblkcnt64_t:y
+fsblkcnt_t:y
+fsfilcnt64_t:y
+fsfilcnt_t:y
 fsid_t:8__fsid_t
 gid_t:j
 id_t:j
-ino64_t:m
-ino_t:m
+ino64_t:y
+ino_t:y
 int16_t:s
 int32_t:i
-int64_t:l
+int64_t:x
 int8_t:a
-intptr_t:l
+intptr_t:i
 key_t:i
-loff_t:l
+loff_t:x
 mode_t:j
 nlink_t:j
-off64_t:l
-off_t:l
+off64_t:x
+off_t:x
 pid_t:i
 pthread_attr_t:14pthread_attr_t
 pthread_barrier_t:17pthread_barrier_t
@@ -41,10 +41,10 @@  pthread_rwlock_t:16pthread_rwlock_t
 pthread_rwlockattr_t:20pthread_rwlockattr_t
 pthread_spinlock_t:i
 pthread_t:m
-quad_t:l
-register_t:l
-rlim64_t:m
-rlim_t:m
+quad_t:x
+register_t:x
+rlim64_t:y
+rlim_t:y
 sigset_t:10__sigset_t
 size_t:m
 socklen_t:j
@@ -57,11 +57,11 @@  uint:j
 u_int:j
 u_int16_t:t
 u_int32_t:j
-u_int64_t:m
+u_int64_t:y
 u_int8_t:h
 ulong:m
 u_long:m
-u_quad_t:m
+u_quad_t:y
 useconds_t:j
 ushort:t
 u_short:t
diff --git a/sysdeps/unix/sysv/linux/aarch64/ilp32/kernel_stat.h b/sysdeps/unix/sysv/linux/aarch64/ilp32/kernel_stat.h
new file mode 100644
index 0000000..ac50f0e
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/aarch64/ilp32/kernel_stat.h
@@ -0,0 +1,3 @@ 
+#define XSTAT_IS_XSTAT64	1
+#define STATFS_IS_STATFS64	1
+#define STAT_IS_KERNEL_STAT
diff --git a/sysdeps/unix/sysv/linux/aarch64/ilp32/shlib-versions b/sysdeps/unix/sysv/linux/aarch64/ilp32/shlib-versions
new file mode 100644
index 0000000..b714a92
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/aarch64/ilp32/shlib-versions
@@ -0,0 +1,7 @@ 
+DEFAULT			GLIBC_2.26
+
+%ifdef HAVE_AARCH64_BE
+ld=ld-linux-aarch64_be_ilp32.so.1
+%else
+ld=ld-linux-aarch64_ilp32.so.1
+%endif
diff --git a/sysdeps/unix/sysv/linux/aarch64/ipc_priv.h b/sysdeps/unix/sysv/linux/aarch64/ipc_priv.h
index 8d12f31..40a4d04 100644
--- a/sysdeps/unix/sysv/linux/aarch64/ipc_priv.h
+++ b/sysdeps/unix/sysv/linux/aarch64/ipc_priv.h
@@ -18,4 +18,8 @@ 
 
 #include <sys/ipc.h>  /* For __key_t  */
 
-#define __IPC_64	0x0
+#ifdef __LP64__
+# define __IPC_64	0x0
+#else /* __ILP32  */
+# define __IPC_64	0x100
+#endif
diff --git a/sysdeps/unix/sysv/linux/aarch64/ipc_priv.h b/sysdeps/unix/sysv/linux/aarch64/kernel-features.h
similarity index 55%
copy from sysdeps/unix/sysv/linux/aarch64/ipc_priv.h
copy to sysdeps/unix/sysv/linux/aarch64/kernel-features.h
index 8d12f31..37e563a 100644
--- a/sysdeps/unix/sysv/linux/aarch64/ipc_priv.h
+++ b/sysdeps/unix/sysv/linux/aarch64/kernel-features.h
@@ -1,5 +1,7 @@ 
-/* Old SysV permission definition for Linux.  AArch64 version.
-   Copyright (C) 2016-2017 Free Software Foundation, Inc.
+/* Set flags signalling availability of kernel features based on given
+   kernel version number.
+
+   Copyright (C) 2017 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -13,9 +15,16 @@ 
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
+   License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <sys/ipc.h>  /* For __key_t  */
+#include_next <kernel-features.h>
+
+#ifdef __ILP32__
+/* ARM fadvise64_64 reorganize the syscall arguments.  */
+# define __ASSUME_FADVISE64_64_6ARG	1
 
-#define __IPC_64	0x0
+/* Define this if your 32-bit syscall API requires 64-bit register
+   pairs to start with an even-number register.  */
+# define __ASSUME_ALIGNED_REGISTER_PAIRS	1
+#endif /* __ILP32__ */
diff --git a/sysdeps/unix/sysv/linux/aarch64/ldd-rewrite.sed b/sysdeps/unix/sysv/linux/aarch64/ldd-rewrite.sed
new file mode 100644
index 0000000..2f3bbb9
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/aarch64/ldd-rewrite.sed
@@ -0,0 +1 @@ 
+s_^\(RTLDLIST=\)\(.*lib/\)\([^/]*\)\(-aarch64\)\(\|\_be\)\(\|\_ilp32\)\(.so\.[0-9.]*\)$_\1"\2\3-aarch64\5\7 \2\3-aarch64\5\_ilp32\7"_
diff --git a/sysdeps/unix/sysv/linux/aarch64/Implies b/sysdeps/unix/sysv/linux/aarch64/lp64/Implies
similarity index 73%
copy from sysdeps/unix/sysv/linux/aarch64/Implies
copy to sysdeps/unix/sysv/linux/aarch64/lp64/Implies
index 4409e19..6418211 100644
--- a/sysdeps/unix/sysv/linux/aarch64/Implies
+++ b/sysdeps/unix/sysv/linux/aarch64/lp64/Implies
@@ -1,3 +1,4 @@ 
 aarch64/nptl
+unix/sysv/linux/aarch64
 unix/sysv/linux/generic
 unix/sysv/linux/wordsize-64
diff --git a/sysdeps/unix/sysv/linux/aarch64/c++-types.data b/sysdeps/unix/sysv/linux/aarch64/lp64/c++-types.data
similarity index 100%
rename from sysdeps/unix/sysv/linux/aarch64/c++-types.data
rename to sysdeps/unix/sysv/linux/aarch64/lp64/c++-types.data
diff --git a/sysdeps/unix/sysv/linux/aarch64/ioctl.S b/sysdeps/unix/sysv/linux/aarch64/lp64/ioctl.S
similarity index 100%
rename from sysdeps/unix/sysv/linux/aarch64/ioctl.S
rename to sysdeps/unix/sysv/linux/aarch64/lp64/ioctl.S
diff --git a/sysdeps/unix/sysv/linux/aarch64/mmap.c b/sysdeps/unix/sysv/linux/aarch64/lp64/mmap.c
similarity index 100%
rename from sysdeps/unix/sysv/linux/aarch64/mmap.c
rename to sysdeps/unix/sysv/linux/aarch64/lp64/mmap.c
diff --git a/sysdeps/unix/sysv/linux/aarch64/shlib-versions b/sysdeps/unix/sysv/linux/aarch64/lp64/shlib-versions
similarity index 100%
rename from sysdeps/unix/sysv/linux/aarch64/shlib-versions
rename to sysdeps/unix/sysv/linux/aarch64/lp64/shlib-versions
diff --git a/sysdeps/unix/sysv/linux/arm/readelflib.c b/sysdeps/unix/sysv/linux/arm/readelflib.c
index 65273bc..dfb8fd4 100644
--- a/sysdeps/unix/sysv/linux/arm/readelflib.c
+++ b/sysdeps/unix/sysv/linux/arm/readelflib.c
@@ -41,7 +41,11 @@  process_elf_file (const char *file_name, const char *lib, int *flag,
       ret = process_elf32_file (file_name, lib, flag, osversion, soname,
 				file_contents, file_length);
 
-      if (!ret && EF_ARM_EABI_VERSION (elf32_header->e_flags) == EF_ARM_EABI_VER5)
+      if (!ret && elf_header->e_machine == EM_AARCH64)
+	*flag = FLAG_AARCH64_LIB32|FLAG_ELF_LIBC6;
+      else if (!ret
+	       && EF_ARM_EABI_VERSION (elf32_header->e_flags)
+		  == EF_ARM_EABI_VER5)
 	{
 	  if (elf32_header->e_flags & EF_ARM_ABI_FLOAT_HARD)
 	    *flag = FLAG_ARM_LIBHF|FLAG_ELF_LIBC6;
diff --git a/sysdeps/unix/sysv/linux/bits/fcntl-linux.h b/sysdeps/unix/sysv/linux/bits/fcntl-linux.h
index 59d6631..b14d02c 100644
--- a/sysdeps/unix/sysv/linux/bits/fcntl-linux.h
+++ b/sysdeps/unix/sysv/linux/bits/fcntl-linux.h
@@ -101,7 +101,7 @@ 
 #endif
 
 #ifndef F_GETLK
-# ifndef __USE_FILE_OFFSET64
+# if !defined (__USE_FILE_OFFSET64) && !defined (__OFF_T_MATCHES_OFF64_T)
 #  define F_GETLK	5	/* Get record locking info.  */
 #  define F_SETLK	6	/* Set record locking info (non-blocking).  */
 #  define F_SETLKW	7	/* Set record locking info (blocking).	*/