Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sanitizer_common: Try looking up symbols with RTLD_DEFAULT if RTLD_NE…
…XT does not work. If the lookup using RTLD_NEXT failed, the sanitizer runtime library is later in the library search order than the DSO that we are trying to intercept, which means that we cannot intercept this function. We still want the address of the real definition, though, so look it up using RTLD_DEFAULT. Differential Revision: https://reviews.llvm.org/D39779 llvm-svn: 317930
- Loading branch information
Showing
4 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
compiler-rt/test/ubsan/TestCases/Misc/Inputs/no-interception-dso.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
int dso_function(int i) { | ||
return i + 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// REQUIRES: android | ||
|
||
// Tests that ubsan can detect errors on Android if libc appears before the | ||
// runtime in the library search order, which means that we cannot intercept | ||
// symbols. | ||
|
||
// RUN: %clangxx %p/Inputs/no-interception-dso.c -fsanitize=undefined -fPIC -shared -o %dynamiclib %ld_flags_rpath_so | ||
|
||
// Make sure that libc is first in DT_NEEDED. | ||
// RUN: %clangxx %s -lc -o %t %ld_flags_rpath_exe | ||
// RUN: %run %t 2>&1 | FileCheck %s | ||
|
||
#include <limits.h> | ||
|
||
int dso_function(int); | ||
|
||
int main(int argc, char **argv) { | ||
// CHECK: signed integer overflow | ||
dso_function(INT_MAX); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters