This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] [tsan] Add support for PIE build on AArch64
ClosedPublic

Authored by zatrazz on Dec 11 2015, 5:27 AM.

Details

Summary

This patch adds PIE executable support for aarch64-linux. It adds
two more segments:

  • 0x05500000000-0x05600000000: 39-bits PIE program segments
  • 0x2aa00000000-0x2ab00000000: 42-bits PIE program segments

Fortunately it is possible to use the same transformation formula for
the new segments range with some adjustments in shadow to memory
formula (it adds a constant offset based on the VMA size).

I checked by running the testcase build with and without PIE flags.
No regressions found.

This closes the concerns raised in [1] and [2] regarding PIE support
to tsan on aarch64-linux-gnu.

[1] http://reviews.llvm.org/D14199
[2] http://reviews.llvm.org/D15308

Diff Detail

Event Timeline

zatrazz updated this revision to Diff 42515.Dec 11 2015, 5:27 AM
zatrazz retitled this revision from to [compiler-rt] [tsan] Add support for PIE build on AArch64.
zatrazz updated this object.
zatrazz added reviewers: dvyukov, eugenis, samsonov, rengolin, kcc.
zatrazz added a subscriber: llvm-commits.
dvyukov edited edge metadata.Dec 17 2015, 5:43 AM

Are there any existing tests that fail without this change? If not, please add a test with -pie.

Currently no tests actually fail, to test the patch I changed the lit for testcases to build all with PIE. I will add a testcase for this.

zatrazz updated this revision to Diff 43169.Dec 17 2015, 12:12 PM
zatrazz edited edge metadata.

Changes from previous version:

  • Added a simple test to check if tsan works with PIE programs.
dvyukov accepted this revision.Dec 18 2015, 2:03 AM
dvyukov edited edge metadata.
This revision is now accepted and ready to land.Dec 18 2015, 2:03 AM

I am seeing on x86_64:

FATAL: ThreadSanitizer: unexpected memory mapping 0x560d6052a000-0x560d605fc000

Should I XFAIL it for x86?

Do you have 4.1+ linux kernel?
If yes, then this is https://github.com/google/sanitizers/issues/503. And yes, I guess, we need to XFAIL it on linux until the issue is resolved.
If no, then I would like to understand why it fails first.

I am using the updated 3.19 kernel from Ubuntu 14.04, which does have the "mm: split ET_DYN ASLR from mmap ASLR" patch backported (I checked on the package source code).

So now I am not sure which would be the best option to add the PIE test, marking it as XFAIL might not fail with a kernel without this patch and I also do not think the best would be mark X86 as unstable (to check for stable-required).

There must be some annotation that prevents a test from building. Probably it is:
// UNSUPPORTED: linux

But please add a comment as to why it is unsupported on linux.

I think we can only disable for x86, as:

// UNSUPPORTED: x86

And add a comment explaining some kernel might map PIE segments outside of current defined TSAN segments for x86.

zatrazz closed this revision.Dec 22 2015, 4:56 AM