Commit Graph

5986 Commits

Author SHA1 Message Date
Saleem Abdulrasool 0165015f6c builtins: silence GCC warning
If the builtins are built with libgcc as the unwind provider on ARM, the exposed
_Unwind_SetIP is a macro.  This results in the following warning due to
expansion of the argument:

warning: suggest parentheses around arithmetic in operand of ‘|’ [-Wparentheses]

Add a no-op set of parenthesis around the argument that will prevent this
warning.

llvm-svn: 248686
2015-09-27 17:16:46 +00:00
Saleem Abdulrasool f88e4fabb5 build: separate flags
This somehow worked with the build on Linux, but seems to fail on the buildbots.
Split the flags apart here as otherwise the two flags are treated as one, and
cause a compilation failure.

llvm-svn: 248654
2015-09-26 04:40:45 +00:00
Saleem Abdulrasool 29e12a1128 sanitizer: fix -pedantic warnings
Silence a few "warning: extra ';'" warnings from GCC.

llvm-svn: 248653
2015-09-26 04:40:42 +00:00
Saleem Abdulrasool 96c5023e53 build: create two versions of ARM builtins
This adds a new name for ARM32 (armhf).  We now force that the default build for
ARM32 (arm) to be soft-float ABI.  This has a corresponding clang change to look
for these names based on the floating point ABI.  The functions are built
identically (the functions are marked as AAPCS, so the calling convention does
not change, as per the RTABI specification), however, the object file contains
attributes indicating the build configuration which the linker will ensure are
not mix and matched.  We now built the appropriate named archive so that we can
link properly.

llvm-svn: 248648
2015-09-26 03:26:01 +00:00
Chris Bieneman bb62ec2cd6 [CMake] [darwin] [builtins] Make darwin_lipo_libs take OUTPUT_DIR as an option. NFC.
This refactoring will allow me to reuse this function when calling lipo with outputs in different directories.

llvm-svn: 248639
2015-09-25 23:55:53 +00:00
Chris Bieneman cc8c7773c5 [CMake] [darwin] Refactor darwin_read_exclude_file to be reusable. NFC.
Rename darwin_read_exclude_file to more generic darwin_read_list_from_file, and make it take the file path instead of constructing it so it can be reused more freely.

llvm-svn: 248635
2015-09-25 23:29:03 +00:00
Chris Bieneman 905f9fce0a [CMake] [darwin] [builtins] Should install the lipo'd builtin libraries.
On darwin we don't install the single-architecture builtin libraries, but we do need to install the lipo'd ones.

llvm-svn: 248630
2015-09-25 22:39:19 +00:00
Chris Bieneman 75c7c9ce8b [CMake] [darwin] [builtins] Should be reading the OS variable that is passed in, not the bleed through from the function above. NFC.
llvm-svn: 248629
2015-09-25 22:31:17 +00:00
Chris Bieneman 7146f7bcf9 [CMake] [darwin] [cc_kext] In addition to builtin sources the cc_kext builtins include some functions from clang_rt.profile.
llvm-svn: 248548
2015-09-24 22:29:58 +00:00
Chris Bieneman 590a48d4de [CMake] [darwin] [builtins] Refactoring darwin_find_excluded_builtins_list to parse arguments instead of only handling positional arguments.
OS and ARCH must be specified, but minimum version may not. Excluding the minimum version will only apply the filters for builtins not supported by the OS and OS-Arch pair.

llvm-svn: 248543
2015-09-24 21:51:09 +00:00
Chris Bieneman 5fbaeb9e5c [CMake] [darwin] [builtins] Refactoring code to filter builtin lists out into a function. NFC.
llvm-svn: 248542
2015-09-24 21:40:06 +00:00
Chris Bieneman 4acaa8fd9d [autoconf] Fixing a bug I introduced r248441
llvm-svn: 248529
2015-09-24 19:35:36 +00:00
Chris Bieneman 9b788a452b [CMake] [darwin] [builtins] Match clang_darwin.mk's compiler flags when building builtin libraries
On Darwin we have a very restrictive set of flags used when building the builtins. This change makes CMake match autoconf.

llvm-svn: 248523
2015-09-24 18:26:34 +00:00
Dmitry Vyukov 2fe0efcc69 tsan: add test for issue #602
llvm-svn: 248522
2015-09-24 17:38:56 +00:00
Chris Bieneman d983ae0a0e [CMake] pass -Wno-pedantic to cc_kext builtins build
We don't pass -pedantic to the builtin builds in the makefiles, so we shouldn't do it here. This is a temporary fix for the broken bot:

http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA_build/7526/warnings8Result/new/

A more correct solution is in the works.

llvm-svn: 248515
2015-09-24 16:47:26 +00:00
Vasileios Kalintiris 22db068008 Be consistent in the way we define 32/64-bit arches in ALL_*_SUPPORTED_ARCH variables. NFC.
Reviewers: samsonov

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D13095

llvm-svn: 248514
2015-09-24 16:45:58 +00:00
Chris Bieneman 01ebf004ff [CMake] [Darwin] Bug 21562 - Add a CMake equivalent for make/platform/clang_darwin.mk in compiler_rt
Summary: First pass at adding cc_kext_* builtin libraries. I need to cleanup and refactor the builtin filtering so that I can use it to filter the builtin symbols list, but this is the first step in the right direction.

Reviewers: bob.wilson, bogner, samsonov

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D13115

llvm-svn: 248443
2015-09-23 23:05:32 +00:00
Chris Bieneman eb71c99684 [darwin] [builtins] Stop generating cc_kext_ios5 and move iOS architectures out of cc_kext into cc_kext_ios
Summary:
Xcode 7 doesn't support targeting iOS5 and earlier. Instead of just dropping cc_kext_ios5, I've repurposed it to cc_kext_ios, and I'm pulling the iOS architectures out of cc_kext. Putting OS X and iOS slices inside the same archive was just odd.

There is a cooresponding clang change coming too.

Reviewers: bogner, bob.wilson

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D13112

llvm-svn: 248441
2015-09-23 22:52:26 +00:00
Chris Bieneman 2a6c13274c [CMake] [builtins] Only include the atomic builtins if(APPLE).
There are lingering issues building the atomic builtins with various versions of gcc. To unblock people we can only include them on Apple platforms where they are more tested.

llvm-svn: 248386
2015-09-23 15:28:44 +00:00
Chris Bieneman 9c46be2d2f Code cleanup based on post-commit review from Aaron Ballman.
llvm-svn: 248385
2015-09-23 15:28:35 +00:00
Chris Bieneman 0d427986f5 [CMake] [Darwin] Bug 21562 - Add a CMake equivalent for make/platform/clang_darwin.mk in compiler_rt
Summary:
Building the builtins on Darwin platforms is a bit complicated. This is a first-pass implementation of the functionality from clang_darwin.mk into CMake.

When building the builtins on Darwin we have layers of blacklists that we apply based on platform, architecture, and minimum supported OS version.

Reviewers: bogner, filcab, bob.wilson, samsonov

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D13059

llvm-svn: 248383
2015-09-23 15:18:17 +00:00
Chris Bieneman be61720c4e [builtins] Fixing broken bot building on linux with -Werror
Returning a void expression is bad.

llvm-svn: 248346
2015-09-22 23:35:24 +00:00
Evgeniy Stepanov a7ecbe5685 [asan] Add missing -pthread in tests.
llvm-svn: 248332
2015-09-22 22:24:46 +00:00
Chris Bieneman 0a9466c11e [builtins] One more stab at fixing the bots.
llvm-svn: 248330
2015-09-22 22:19:21 +00:00
Chris Bieneman 7908b12967 [builtins] Fixing atomic builtins to be compiled out if stdatomic.h isn't available.
This should fix the bots broken by r248322.

Reviewed by bogner over my shoulder.

llvm-svn: 248328
2015-09-22 21:50:43 +00:00
Evgeniy Stepanov 9147de0ddf [asan] Versioned interceptor for pthread_create.
This fixes a crash in pthread_create on linux/i386 due to abi
incompatibility between intercepted and non-intercepted functions.

See the test case for more details.

llvm-svn: 248325
2015-09-22 21:34:44 +00:00
Chris Bieneman 54445f92a9 [CMake] Add atomic builtins to GENERIC_SOURCES list.
Reviewers: bogner, samsonov

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D13069

llvm-svn: 248322
2015-09-22 21:18:19 +00:00
Renato Golin 7716df5b7d Disable final MSAN test in AArch64 to get the bots green
llvm-svn: 248014
2015-09-18 18:02:55 +00:00
Renato Golin 4610486e88 Disable one MSAN test in AArch64 until we have a proper fix
llvm-svn: 248008
2015-09-18 17:22:48 +00:00
Adhemerval Zanella dab7043d89 [compiler-rt] [sanitizer] Clean buildbot failures for aarch64
Currently aarch64 lacks instrumentation support for variadic arguments
for MSan.  This patch sets the UBSan tests that uses it as to require
stable-runtime and sets aarch64/ubsan as an unstable one.

llvm-svn: 247996
2015-09-18 15:48:32 +00:00
Evgeniy Stepanov 6e663a1e32 Revert "ubsan: Implement memory permission validation for vtables."
This reverts r247484 and two follow-up commits.
Breaks ppc and x86_64 sanitizer bots.

llvm-svn: 247921
2015-09-17 19:15:54 +00:00
Reid Kleckner 3e9d733e68 [Windows] xfail a test that uses C++ EH
llvm-svn: 247845
2015-09-16 20:32:22 +00:00
Evgeniy Stepanov 10c9ea51a0 Fix compilation warning in compiler-rt.
error: width of bit-field 'allocated' (8 bits) exceeds the width of
its type; value will be truncated to 1 bit [-Werror,-Wbitfield-width]

llvm-svn: 247840
2015-09-16 19:54:36 +00:00
Chris Bieneman 672311b368 [CMake] Make the sample program in darwin_test_archs have a symbol it needs to link.
This resolves an issue building compiler-rt using Xcode 7 that was reported on llvm-dev:

http://lists.llvm.org/pipermail/llvm-dev/2015-September/090245.html

llvm-svn: 247833
2015-09-16 18:29:52 +00:00
Adhemerval Zanella 19074450ee [MSan] Enable MSAN for aarch64
This patch enabled msan for aarch64 with 39-bit VMA and 42-bit VMA.
As defined by lib/msan/msan.h the memory layout used is for 39-bit is:

   00 0000 0000 - 40 0000 0000:  invalid
   40 0000 0000 - 43 0000 0000:  shadow
   43 0000 0000 - 46 0000 0000:  origin
   46 0000 0000 - 55 0000 0000:  invalid
   55 0000 0000 - 56 0000 0000:  app (low)
   56 0000 0000 - 70 0000 0000:  invalid
   70 0000 0000 - 80 0000 0000:  app (high)

And for 42-bit VMA:

   000 0000 0000 - 100 0000 0000:  invalid
   100 0000 0000 - 11b 0000 0000:  shadow
   11b 0000 0000 - 120 0000 0000:  invalid
   120 0000 0000 - 13b 0000 0000:  origin
   13b 0000 0000 - 2aa 0000 0000:  invalid
   2aa 0000 0000 - 2ab 0000 0000:  app (low)
   2ab 0000 0000 - 3f0 0000 0000:  invalid
   3f0 0000 0000 - 400 0000 0000:  app (high)

Most of tests are passing with exception of:

   * Linux/mallinfo.cc
   * chained_origin_limits.cc
   * dlerror.cc
   * param_tls_limit.cc
   * signal_stress_test.cc
   * nonnull-arg.cpp

The 'Linux/mallinfo.cc' is due the fact AArch64 returns the sret in 'x8'
instead of default first argument 'x1'.  So a function prototype that
aims  to mimic (by using first argument as the return of function) won't
work. For GCC one can make a register alias (register var asm ("r8")), but
for clang it detects is an unused variable and generate wrong code.

The 'chained_origin_limits' is probably due a wrong code generation,
since it fails only when origin memory is used
(-fsanitize-memory-track-origins=2) and only in the returned code
(return buf[50]).

The 'signal_streess_test' and 'nonnull-arg' are due currently missing variadic
argument handling in memory sanitizer code instrumentation on LLVM side.

Both 'dlerror' and 'param_tls_test' are unknown failures that require
further investigation.

All the failures are XFAIL for aarch64 for now.

llvm-svn: 247809
2015-09-16 15:12:25 +00:00
Naomi Musgrave 36597fa128 Explicit reference to bug highlighted by
test/msan/dtor-trivial.cpp. Runtime testing for poisoning
vtable pointer in dtor.

Summary: Runtime testing for vtable ptr poisoning in dtor.

Reviewers: eugenis, kcc

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D12713

Clean test case & comments.

Update tests for vptr poisoning order.

Simplify test to rely upon globals.

Assertions verify that vtable still accessible from dtors.

Testing linear inheritance and multiple inheritance for vtable poisoning.

Macros for testing expected failing functions.

Rename macros.

Removed xfail, modified FileCheck commands, to expect test to crash.

llvm-svn: 247763
2015-09-16 00:41:28 +00:00
Alexey Samsonov f23dee5408 [ASan] Add test for .preinit_array/.init_array/.fini_array sections.
llvm-svn: 247737
2015-09-15 23:06:17 +00:00
Adhemerval Zanella 172cc32ef3 [sanitizer] Move CheckVMASize after flag initialization
llvm-svn: 247684
2015-09-15 13:22:54 +00:00
Alexey Samsonov 1b76da6a6c Support inline functions symbolization in Addr2Line symbolizer.
Patch by Maxim Ostapenko!

Summary:
Right now, Addr2Line symbolizer in asan_symbolize.py doesn't support inline functions symbolization. This might be a useful feature for using ASan on embedded systems.

Test results:

$ cat test.c

static inline void FooBarBaz() {
  __sanitizer_print_stack_trace();
}

int main() {
  FooBarBaz();
  return 0;
}

$ clang  test.c -fsanitize=address -g -O2 -o test.x && ./test.x &> /tmp/test.log
$ ./projects/compiler-rt/lib/asan/scripts/asan_symbolize.py  -l /tmp/test.log
    #0 0x42095e in __sanitizer_print_stack_trace _asan_rtl_
    #1 0x4cec07 in FooBarBaz /home/max/build/llvm/asan/test.c:4
    #2 0x4cec07 in main /home/max/build/llvm/asan/test.c:8
    #3 0x7f89f0891ec4 in __libc_start_main /build/buildd/eglibc-2.19/csu/libc-start.c:287

Reviewers: glider, samsonov

Subscribers: jevinskie, llvm-commits, ygribov

Differential Revision: http://reviews.llvm.org/D12153

llvm-svn: 247642
2015-09-14 23:56:42 +00:00
Chris Bieneman 679ab85a7c [CMake] Add options to control building sanitizers and builtins.
There are situations where a user may want to build only the compiler-rt builtins, or only the sanitizer runtimes. This exposes options to do that. Both default to On, so there should be no implicit change in behavior.

llvm-svn: 247607
2015-09-14 19:59:24 +00:00
Chris Bieneman fb92d9a249 [CMake] If COMPILER_RT_INCLUDE_TESTS is off we shouldn't include the root test directory.
llvm-svn: 247606
2015-09-14 19:54:12 +00:00
Peter Collingbourne dcba38a78b ubsan: Also disable vptr validation on powerpc64le.
llvm-svn: 247499
2015-09-12 05:24:44 +00:00
Peter Collingbourne e299bc51b6 ubsan: Disable vptr validation on powerpc64.
Should fix sanitizer-ppc64-linux1 bot.

llvm-svn: 247493
2015-09-12 00:08:28 +00:00
Peter Collingbourne cf303a4d8b ubsan: Implement memory permission validation for vtables.
If the pointer passed to the getVtablePrefix function was read from a freed
object, we may end up following pointers into objects on the heap and
printing bogus dynamic type names in diagnostics. However, we know that
vtable pointers will generally only point into memory mapped from object
files, not objects on the heap.

This change causes us to only follow pointers in a vtable if the vtable
and one of the virtual functions it points to appear to have appropriate
permissions (i.e. non-writable, and maybe executable), which will generally
exclude heap pointers.

Only enabled for Linux; this hasn't been tested on FreeBSD, and vtables are
writable on Mac (PR24782) so this won't work there.

Differential Revision: http://reviews.llvm.org/D12790

llvm-svn: 247484
2015-09-11 22:18:35 +00:00
Adhemerval Zanella 0563686a1c [compiler-rt] [sanitizers] Add VMA size check at runtime
This patch adds a runtime check for asan, dfsan, msan, and tsan for
architectures that support multiple VMA size (like aarch64).  Currently
the check only prints a warning indicating which is the VMA built and
expected against the one detected at runtime.

llvm-svn: 247413
2015-09-11 13:55:00 +00:00
Roman Divacky 7433cd4fe6 Unbreak building on FreeBSD.
llvm-svn: 247347
2015-09-10 21:56:16 +00:00
Peter Collingbourne 6f94087329 CFI: Run the tests only on supported architectures/OSs.
Specifically, only run the cfi-icall tests on x86/x86_64, and add
an XFAIL for darwin.

llvm-svn: 247325
2015-09-10 19:18:08 +00:00
Peter Collingbourne 1db3a448b5 CFI: Add diagnostic handler and tests for indirect call checker.
Differential Revision: http://reviews.llvm.org/D11858

llvm-svn: 247239
2015-09-10 02:18:02 +00:00
Evgeniy Stepanov 4c2dd111f2 [msan] Unpoison dlpi_phdr in dl_iterate_phdr.
In some cases, PHDR table is allocated with malloc() by the linker
instead of being mapped from file. It needs to be unpoisoned in the
dl_iterate_phdr callback then.

This happens when program headers are not part of any loadable ELF
segment.

llvm-svn: 247100
2015-09-08 23:14:44 +00:00
Alexey Samsonov 63eaeca7d0 [CMake] Remove all uses of LLVM_NATIVE_ARCH.
Instead, assume we're going to target triple specified by
COMPILER_RT_DEFAULT_TARGET_TRIPLE and build runtimes for this triple
(and hope that the host compiler can target them).

This will help users that use cross-compiler on their host to build
Clang that would work on a different architecture. This will also come in
handy if one would want to configure several compiler-rt build trees on
the same host, using just-built Clang that can target many
architectures.

This doesn't change the behavior in the default build configuration.

llvm-svn: 247099
2015-09-08 23:13:47 +00:00