Commit Graph

15790 Commits

Author SHA1 Message Date
Rainer Orth b4ae67fffa [asan][test] XFAIL global-location-nodebug.cpp on Solaris
A new test `FAIL`s on Solaris:

  FAIL: AddressSanitizer-i386-sunos ::
TestCases/global-location-nodebug.cpp (465 of 64279)
  FAIL: AddressSanitizer-i386-sunos-dynamic ::
TestCases/global-location-nodebug.cpp (961 of 64279)

The problem is the unconditional use of `-Wl,-S`:

  ld: fatal: dlopen() of support library (-lstdc++) failed with error:
ld.so.1: ld: -lstdc++: open failed: No such file or directory

`ld -S` has a completely different semantics compared to GNU `ld
-S`/`--strip-debug`: specify a link-edit support library.  To avoid this,
I've chosen to `XFAIL` the test.

Tested on `amd64-pc-solaris2.11`.

Differential Revision: https://reviews.llvm.org/D128516
2022-06-25 10:40:11 +02:00
Petr Hosek f3caa98e49 Revert "[CMake][compiler-rt] Clean up the use of libcxx and libcxxabi"
This reverts commit 4164cfa537 since
it broke the clang-x86_64-debian-fast builder:

  https://lab.llvm.org/buildbot/#/builders/109/builds/41339
2022-06-25 03:10:55 +00:00
Petr Hosek 4164cfa537 [CMake][compiler-rt] Clean up the use of libcxx and libcxxabi
We no longer support the use of LLVM_ENABLE_PROJECTS for libcxx and
libcxxabi. We don't use paths to libcxx and libcxxabi in compiler-rt.

Differential Revision: https://reviews.llvm.org/D126905
2022-06-25 02:53:43 +00:00
Petr Hosek 72ec31afad [CMake] Use set rather than list PREPEND
list PREPEND is only supported since CMake 3.15.

Differential Revision: https://reviews.llvm.org/D128548
2022-06-25 02:19:55 +00:00
Petr Hosek 048e6bb46b [CMake][compiler-rt] Treat target cflags as list rather than string
This is need after 30dfe016d4.

Differential Revision: https://reviews.llvm.org/D128548
2022-06-24 22:37:00 +00:00
Mitch Phillips faf5e0ec73 Add no_sanitize('hwaddress') (and 'memtag', but that's a no-op).
Currently, `__attribute__((no_sanitize('hwaddress')))` is not possible. Add this piece of plumbing, and now that we properly support copying attributes between an old and a new global variable, add a regression test for the GlobalOpt bug that previously lost the attribute.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D127544
2022-06-24 12:04:11 -07:00
Kai Luo acc22aeb0f [AIX][libatomic] Fix link flags after 30dfe016d4 for libatomic on AIX
After 30dfe016d4, we no longer use string as link flags.

Patch by @tingwang.

Reviewed By: tingwang

Differential Revision: https://reviews.llvm.org/D128524
2022-06-24 13:56:32 +00:00
Petr Hosek 8bee6e52f8 Revert "[CMake][compiler-rt] Clean up the use of libcxx and libcxxabi"
This reverts commit c0d4f2282d which
broke clang-x86_64-debian-fast:

  https://lab.llvm.org/buildbot/#/builders/109/builds/41268
2022-06-24 08:24:45 +00:00
Petr Hosek c0d4f2282d [CMake][compiler-rt] Clean up the use of libcxx and libcxxabi
We no longer support the use of LLVM_ENABLE_PROJECTS for libcxx and
libcxxabi. We don't use paths to libcxx and libcxxabi in compiler-rt.

Differential Revision: https://reviews.llvm.org/D126905
2022-06-24 08:11:37 +00:00
Petr Hosek 30dfe016d4 [CMake][compiler-rt] Use COMPILE_OPTIONS and LINK_OPTIONS
This avoids the need for string-ification and lets CMake deduplicate
potentially duplicate flags.

Differential Revision: https://reviews.llvm.org/D122750
2022-06-24 06:55:10 +00:00
Sergey Kosukhin 9f1d90bf91 [compiler-rt] Fix false positive detection of a target in compile-only mode
When `compiler-rt` is configured as a runtime, the configure-time target
detection for builtins is done in compile-only mode, which is basically a
test of whether the newly-built `clang` can compile a simple program with
an additional flag (`-m32` and `-m64` in my case). The problem is that on
my Debian system `clang` can compile `int foo(int x, int y) { return x + y; }`
with `-m32` but fails to include `limits.h` (or any other target-specific
header) for the `i386` target:
```
$ /path/to/build/./bin/clang --target=x86_64-unknown-linux-gnu -DVISIBILITY_HIDDEN  -O3 -DNDEBUG  -m32 -std=c11 -fPIC -fno-builtin -fvisibility=hidden -fomit-frame-pointer -MD -MT CMakeFiles/clang_rt.builtins-i386.dir/absvdi2.c.o -MF CMakeFiles/clang_rt.builtins-i386.dir/absvdi2.c.o.d -o CMakeFiles/clang_rt.builtins-i386.dir/absvdi2.c.o -c /path/to/src/compiler-rt/lib/builtins/absvdi2.c
In file included from /path/to/src/compiler-rt/lib/builtins/absvdi2.c:13:
In file included from /path/to/src/compiler-rt/lib/builtins/int_lib.h:93:
In file included from /path/to/build/lib/clang/15.0.0/include/limits.h:21:
In file included from /usr/include/limits.h:25:
/usr/include/features.h:364:12: fatal error: 'sys/cdefs.h' file not found
           ^~~~~~~~~~~~~
1 error generated.
```

This is an attempt to make the target detection more robust: extend the test
program with `#include <limits.h>`.

Differential Revision: https://reviews.llvm.org/D127975
2022-06-23 15:11:39 +03:00
Julian Lettner f4a3df18a7 [ASan][Darwin] XFAIL test; atos does not show line numbers for globals
atos currently doesn't show source line numbers for global variables, so
global-location.cpp is failing after we switched from ASan-specific
metadata to normal symbolication.

See:
https://reviews.llvm.org/D127552
2022-06-22 18:19:31 -07:00
Lang Hames 232bd331cb [ORC-RT] Make the ORC runtime C API public.
This is a first step towards allowing programs to pre-link against the ORC
runtime, which would allow us to move some code that is currently in the LLVM
OrcTarget library into the ORC runtime instead.

The C API header has limited utility as-is, but serves as a minimal first step
and provides clients with tools for interacting with wrapper functions.

Reviewed By: beanz

Differential Revision: https://reviews.llvm.org/D127324
2022-06-16 19:02:23 -07:00
Fangrui Song 0e182469ee [sanitizer] Delete empty sanitizer_openbsd.cpp after D89759 2022-06-16 16:38:01 -07:00
Mitch Phillips 13e9c1d18e Reland "[ASan] Use debuginfo for symbolization."
This reverts commit 99796d06db.

Hint: Looking here because your manual invocation of something in
'check-asan' broke? You need a new symbolizer (after D123538).

An upcoming patch will remove the internal metadata for global
variables. With D123534 and D123538, clang now emits DWARF debug info
for constant strings (the only global variable type it was missing), and
llvm-symbolizer is now able to symbolize all global variable addresses
(where previously it wouldn't give you the file:line information).

Move ASan's runtime over from the internal metadata to DWARF.

Differential Revision: https://reviews.llvm.org/D127552
2022-06-16 13:58:55 -07:00
Kristina Bessonova 5cfbfa035f [sanitizer_common] Fix SanitizerCommon.ChainedOriginDepotStats test
This test was failing with the following error message if to run the test binary
directly, w/o using lit:

  $ Sanitizer-x86_64-Test --gtest_filter=SanitizerCommon.ChainedOriginDepot*
  ...
  [ RUN      ] SanitizerCommon.ChainedOriginDepotStats
  compiler-rt/lib/sanitizer_common/tests/sanitizer_chained_origin_depot_test.cpp:77: Failure
  Expected: (stats1.allocated) > (stats0.allocated), actual: 196608 vs 196608
  [  FAILED  ] SanitizerCommon.ChainedOriginDepotStats (867 ms)

Since the ChainedOriginDepot* tests are not doing any cleanup, by the time
SanitizerCommon.ChainedOriginDepotStats test starts executing the depot
may not be empty, so there will be no allocation for the test.

This patch introduces ChainedOriginDepot::TestOnlyUnmap() API that deallocates
memory when requested. This makes sure underlying TwoLevelMap initiates
the expected allocation during the test.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D127621
2022-06-16 11:59:58 +02:00
Colin Cross 80aa41d9df Pass through even more LIBCXX_* variables to libfuzzer's custom lib++
Similar to D120946, pass LIBCXX_HAS_GCC_S_LIB and LIBCXX_USE_COMPILER_RT
through to the custom lib++ builds so that libfuzzer doesn't end up with
a .deplibs section that links against those libraries when the
variables are set to false.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D127912
2022-06-15 19:05:29 -07:00
Kirill Stoimenov 99796d06db Revert "[ASan] Use debuginfo for symbolization."
This reverts commit f0ab8d90d4.
2022-06-15 23:42:46 +00:00
Mitch Phillips f0ab8d90d4 [ASan] Use debuginfo for symbolization.
Hint: Looking here because your manual invocation of something in
'check-asan' broke? You need a new symbolizer (after D123538).

An upcoming patch will remove the internal metadata for global
variables. With D123534 and D123538, clang now emits DWARF debug info
for constant strings (the only global variable type it was missing), and
llvm-symbolizer is now able to symbolize all global variable addresses
(where previously it wouldn't give you the file:line information).

Move ASan's runtime over from the internal metadata to DWARF.

Differential Revision: https://reviews.llvm.org/D127552
2022-06-15 15:36:36 -07:00
Benjamin Kramer 8bc0bb9564 Add a conversion from double to bf16
This introduces a new compiler-rt function `__truncdfbf2`.
2022-06-15 12:56:31 +02:00
Benjamin Kramer fb34d531af Promote bf16 to f32 when the target doesn't support it
This is modeled after the half-precision fp support. Two new nodes are
introduced for casting from and to bf16. Since casting from bf16 is a
simple operation I opted to always directly lower it to integer
arithmetic. The other way round is more complicated if you want to
preserve IEEE semantics, so it's handled by a new __truncsfbf2
compiler-rt builtin.

This is of course very bare bones, but sufficient to get a semi-softened
fadd on x86.

Possible future improvements:
 - Targets with bf16 conversion instructions can now make fp_to_bf16 legal
 - The software conversion to bf16 can be replaced by a trivial
   implementation under fast math.

Differential Revision: https://reviews.llvm.org/D126953
2022-06-15 12:56:31 +02:00
Petr Hosek 7524fe962e [libFuzzer] Use the compiler to link the relocatable object
Rather than invoking the linker directly, let the compiler driver
handle it. This ensures that we use the correct linker in the case
of cross-compiling.

Differential Revision: https://reviews.llvm.org/D127828
2022-06-15 07:16:40 +00:00
Peter S. Housel 612f0a7789 [ORC-RT] Add integration tests for AArch64
This change adds test cases targeting the AArch64 Linux platform to
the ORC runtime integration test suite.

Reviewed By: lhames, sunho

Differential Revision: https://reviews.llvm.org/D127720
2022-06-14 20:49:56 -07:00
Petr Hosek 18a1fc8459 [CMake][compiler-rt] Provide a dedicated option for LLVM unwinder
This allows configuring LLVM unwinder separately from the C++ library
matching how we configure it in libcxx.

This also applies changes made to libunwind+libcxxabi+libcxx in D113253
to compiler-rt.

Differential Revision: https://reviews.llvm.org/D115674
2022-06-14 17:26:25 +00:00
Mariusz Borsa a4bf361454 Revert "[Sanitizers] Cleanup handling of stat64/statfs64"
This reverts commit 6d890a0fb8.
2022-06-10 10:56:26 -07:00
Peter S. Housel 2be5abb7e9 [ORC][ORC_RT] Handle ELF .init_array with non-default priority
ELF-based platforms currently support defining multiple static
initializer table sections with differing priorities, for example
.init_array.0 or .init_array.100; the default .init_array corresponds
to a priority of 65535. When building a shared library or executable,
the system linker normally sorts these sections and combines them into
a single .init_array section. This change adds the capability to
recognize ELF static initializers with priorities other than the
default, and to properly sort them by priority, to Orc and the Orc
runtime.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D127056
2022-06-09 22:47:58 -07:00
Peter S. Housel 1aa71f8679 [ORC][ORC_RT] Integrate ORC platforms with LLJIT and lli
This change enables integrating orc::LLJIT with the ORCv2
platforms (MachOPlatform and ELFNixPlatform) and the compiler-rt orc
runtime. Changes include:

- Adding SPS wrapper functions for the orc runtime's dlfcn emulation
  functions, allowing initialization and deinitialization to be invoked
  by LLJIT.

- Changing the LLJIT code generation default to add UseInitArray so
  that .init_array constructors are generated for ELF platforms.

- Integrating the ORCv2 Platforms into lli, and adding a
  PlatformSupport implementation to the LLJIT instance used by lli which
  implements initialization and deinitialization by calling the new
  wrapper functions in the runtime.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D126492
2022-06-09 22:47:58 -07:00
Mariusz Borsa 6d890a0fb8 [Sanitizers] Cleanup handling of stat64/statfs64
There are differences in handling of stat64/statfs64 calls by sanitizers between Linux and macOS. Versions of macOS starting with 10.6 drop the stat64/statfs64 APIs completely, relying on the linker to redirect stat/statfs to the appropriate 64 bit versions. Emitting variables needed by sanitizers is thus controlled by convoluted sets of conditions, involving Linux, IOS, macOS and Android, sprinkled around files.

This change adresses it, allowing to specify presence/absence of stat64/statfs64 for each platform, in a single location. Also, it adresses the Android case which handles stat64, but not statfs64.

Adding Vitaly as a reviewer since he seems to be actively working on sanitizers, perhaps can comment on the Android bit

Differential Revision: https://reviews.llvm.org/D127343
2022-06-09 12:51:34 -07:00
Andrew Turner 95141aa9cb Fix TableLookupTest on FreeBSD
As with Linux placce the Counters array in the __libfuzzer_extra_counters
section. This fixes the test on FreeBSD.

Reviewed by: vitalybuka

Differential Revision: https://reviews.llvm.org/D125902
2022-06-09 09:24:09 -04:00
David Carlier a4c97e1937 [Sanitizers] prctl interception update for the PR_SET_VMA option case.
Supports on Android but also from Linux 5.17

Reviewers: vitalybuka, eugenis

Reviewed-By: vitalybuka

Differential Revision: https://reviews.llvm.org/D127326
2022-06-09 06:07:26 +01:00
Fangrui Song 62309ed955 [msan][test] Fix cpusetsize for another pthread_getaffinity_np.cpp test
Similar to D127368
2022-06-08 20:08:05 -07:00
Fangrui Song a86b171d8c [msan][test] Use a large cpusetsize for pthread_getaffinity_np
pthread_getaffinity_np (Linux `kernel/sched/core.c:sched_getaffinity`) fails
with EINVAL if 8*cpusetsize (constant in glibc: 1024) is smaller than
`nr_cpu_ids` (CONFIG_NR_CPUS, which is 2048 for several arch/powerpc/configs
configurations).

The build bot clang-ppc64le-linux-lnt seems to have a larger `nr_cpu_ids`.

Differential Revision: https://reviews.llvm.org/D127368
2022-06-08 18:50:23 -07:00
Kevin Athey 0777be69fb [MSAN] print out the only possible invalid parameter (EINVAL is returned)
One more round attempting to figure what is wrong.

Depends on: https://reviews.llvm.org/D127346

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D127359
2022-06-08 16:23:04 -07:00
Andrew Turner ccae01cbce [compiler-rt] Fix Mmap on FreeBSD AArch64
On FreeBSD AArch64 safestack needs to use __syscall to handle 64 bit arguments

Reviewed by: MaskRay, vitalybuka

Differential Revision: https://reviews.llvm.org/D125901
2022-06-08 17:22:33 -04:00
Andrew Turner ad3faddaa6 [compiler-rt] Fix the longjmp sp slot on FreeBSD AArch64
The stack pointer is stored in the second slot in the jump buffer on
AArch64. Use the correct slot value to read this rather than the
following register.

Reviewed by: melver

Differential Revision: https://reviews.llvm.org/D125762
2022-06-08 17:22:27 -04:00
Andrew Turner b3c1442c6c [compiler-rt] Add the FreeBSD AArch64 shadow offset
As with 64 bit x86 use an offset in middle of the address space scaled up
to work with the full 48 bit space.

Reviewed by: MaskRay

Differential Revision: https://reviews.llvm.org/D125757
2022-06-08 17:22:16 -04:00
Andrew Turner 9496e39b4a [compiler-rt] Add the common FreeBSD AArch64 support
Reviewed by: vitalybuka

Differential Revision: https://reviews.llvm.org/D125756
2022-06-08 17:22:01 -04:00
Kevin Athey d97d930d92 [MSAN] send output to stderr in test: pthread_getaffinity_np.
Must send output to stderr to view it.
This will be rolled back when diagnosis is complete.

Depends on: https://reviews.llvm.org/D127320

Differential Revision: https://reviews.llvm.org/D127346
2022-06-08 14:16:08 -07:00
Kevin Athey d50dc33d29 [MSAN] Add comment regarding why pthread_getaffinity_np is not supported on Android.
Depends on: https://reviews.llvm.org/D127264

Reviewed By: vitalybuka, fmayer

Differential Revision: https://reviews.llvm.org/D127327
2022-06-08 13:53:59 -07:00
Paul Kirth 56eb8dcf1e [compiler-rt][test] Restore original symbolize_stack test
In D126580 we updated the test to reflect that there should always
be a full trace. However, some executions do not have symbolizer
information, so we will restore the original test until we can formulate
a more robust test.

Reviewed By: leonardchan

Differential Revision: https://reviews.llvm.org/D127334
2022-06-08 19:15:52 +00:00
Leonard Chan 060907dd00 Revert "Reland "[NFC][compiler-rt][asan] Unify asan and lsan allocator settings""
This reverts commit b37d84aa8d.

This broke aarch64 asan builders for fuchsia. I accidentally changed the allocator
settings for fuchsia on aarch64 because the new asan allocator settings use:

```
// AArch64/SANITIZER_CAN_USE_ALLOCATOR64 is only for 42-bit VMA
// so no need to different values for different VMA.
const uptr kAllocatorSpace =  0x10000000000ULL;
const uptr kAllocatorSize  =  0x10000000000ULL;  // 3T.
typedef DefaultSizeClassMap SizeClassMap;
```

rather than reaching the final `#else` which would use fuchsia's lsan config.
2022-06-08 11:56:33 -07:00
Leonard Chan 033af5a537 [compiler-rt][hwasan] Check address tagging mode in InitializeOsSupport on Fuchsia
Differential Revision: https://reviews.llvm.org/D127262
2022-06-08 11:34:50 -07:00
Kevin Athey 7b1aa20a76 [MSAN] Add result printing for failed call in pthread_getaffinity_np.
Will be reverted when test failure is diagnosed.

Depends on: https://reviews.llvm.org/D127185

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D127320
2022-06-08 11:14:24 -07:00
Nikita Popov 38ad963cc9 [sanitizer] Fix shift UB in LEB128 test
If u64 and uptr have the same size, then this will perform a shift
by the bitwidth, which is UB. We only need this code if uptr is
smaller than u64.
2022-06-08 14:21:25 +02:00
David CARLIER c06ef17359 [Sanitizers] intercept FreeBSD procctl
Reviewers: vitalybuka, emaster

Reviewed-By: viatelybuka

Differential Revision: https://reviews.llvm.org/D127069
2022-06-08 08:55:10 +01:00
Leonard Chan b37d84aa8d Reland "[NFC][compiler-rt][asan] Unify asan and lsan allocator settings"
I believe this should've been fixed with 4b15e665f8
which landed after this initial patch, but I reverted too early before I
saw the builder turn green again.
2022-06-07 18:09:48 -07:00
Kevin Athey 67069e1980 [MSAN] exclude android from pthread_getaffinity_np interceptor
Depends on https://reviews.llvm.org/D127185.

Differential Revision: https://reviews.llvm.org/D127264
2022-06-07 17:53:32 -07:00
Leonard Chan 13eb4fc3ce Revert "[NFC][compiler-rt][asan] Unify asan and lsan allocator settings"
This reverts commit dd045ddffc.

This broke the sanitizer-windows builder at https://lab.llvm.org/buildbot/#/builders/127/builds/30751.
2022-06-07 17:34:29 -07:00
Leonard Chan d1fb0a5a63 Fix for e1d84c421d
One of the checks in realloc_too_big.c actually printed a regular warning
and not an OOM error, so the check shouldn't be updated.
2022-06-07 17:28:24 -07:00
Leonard Chan 4b15e665f8 [compiler-rt][lsan] Choose lsan allocator via SANITIZER_CAN_USE_ALLOCATOR64
Rather than checking a bunch of individual platforms.

Differential Revision: https://reviews.llvm.org/D126825
2022-06-07 17:23:38 -07:00