This is an archive of the discontinued LLVM Phabricator instance.

[asan] Add support for AArch64 ILP32
AbandonedPublic

Authored by zatrazz on Nov 16 2017, 8:47 AM.

Details

Summary

This patch adds asan support for AArch64 ILP32 abi. ILP32 [1] is a new abi
for AArch64 similar to x32 where AArch64 instruction set are coupled with a
data model where int, long and pointer are 32-bit.

Unfortunately current support is not upstream for all projects. Binutils
and GCC are already covered, but GLIBC [2] and Linux [3] are maintained in
out of tree branches.

Also current LLVM also does not have support for ILP32, so current idea
of this patch is to eventually sync with gcc libsanitizer. In fact runtime
testing were done on gcc.

Main changes for compiler-rt is support the kernel ABI for internal
syscalls. Different than x32, ILP32 tries to leverage 32-bits syscalls
so kernel ABI for 64 bit argument passing (for ftruncate for instance)
are passed using the new Linux generic way for 32 bits (by splitting
high and low in two registers).

So instead of adding more adhoc defines to ILP32 I extende the
SANITIZER_USES_CANONICAL_LINUX_SYSCALLS to represent both 64 bits
argument syscalls (value of 1) and 32 bits (value of 2).

It also fixes an AArch64 issue with upcoming GLIBC 2.27 (the one which
also ILP32 is currently based) with mcontext_t definition (GLIBC now does
not based it on kernel sigcontext_t anymore, but rather redefines it with
slight different members name).

I did a sanity check against AArch64 ILP64 and x86_64 on Linux without
any regressions.

[1] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0490a/ar01s01.html
[2] https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/arm/ilp32
[3] git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git

Diff Detail

Event Timeline

zatrazz created this revision.Nov 16 2017, 8:47 AM
kubamracek edited edge metadata.Nov 29 2017, 8:18 AM

Is there a bot that builds for this architecture?

lib/sanitizer_common/sanitizer_platform.h
223

The value of "2" is really weird here. Can we use a separate constant?

Is there a bot that builds for this architecture?

As I described in the message there is some issue with current ABI approach:

  1. LLVM does not have support for AArch64 ILP32
  2. GLIBC and Linux are maintained in out of tree branches.

So no current buildbot enabled.

lib/sanitizer_common/sanitizer_platform.h
223

I don't see why not, maybe 32 and 64 to represent the underlying wordsize expected?

nsz added a subscriber: nsz.Jan 26 2018, 8:05 AM
nsz added inline comments.
lib/sanitizer_common/sanitizer_linux.cc
1669–1686

this will be fixed in glibc, so the old code works.

zatrazz abandoned this revision.May 4 2018, 7:39 AM