-
Notifications
You must be signed in to change notification settings - Fork 13.7k
[clang] Implement address sanitizer on AIX #129925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
072f4ec
bdcac7b
85d9383
9fcb13d
7765182
34c0813
6f90e6b
64660d6
b768d71
6fccd97
94347da
8d816ba
a6bdac7
5254c8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1376,6 +1376,19 @@ static bool addSanitizerDynamicList(const ToolChain &TC, const ArgList &Args, | |
// the option, so don't try to pass it. | ||
if (TC.getTriple().isOSSolaris() && !LinkerIsGnuLd) | ||
return true; | ||
|
||
if (TC.getTriple().isOSAIX()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a review comment, but a question for my own understanding. Why are these exports needed? (I see we are forcing the same on ELF platforms) |
||
SmallString<128> SanRTSymbolList; | ||
(Twine(TC.getRuntimePath().value_or(".")) + "/" + Sanitizer + | ||
".link_with_main_exec.txt") | ||
.toVector(SanRTSymbolList); | ||
if (llvm::sys::fs::exists(SanRTSymbolList)) { | ||
CmdArgs.push_back(Args.MakeArgString(Twine("-bE:") + SanRTSymbolList)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto comment about missing lists. I guess we can't use exactly the same list as |
||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
SmallString<128> SanRT(TC.getCompilerRT(Args, Sanitizer)); | ||
if (llvm::sys::fs::exists(SanRT + ".syms")) { | ||
CmdArgs.push_back(Args.MakeArgString("--dynamic-list=" + SanRT + ".syms")); | ||
|
@@ -1410,7 +1423,9 @@ void tools::linkSanitizerRuntimeDeps(const ToolChain &TC, | |
ArgStringList &CmdArgs) { | ||
// Force linking against the system libraries sanitizers depends on | ||
// (see PR15823 why this is necessary). | ||
addAsNeededOption(TC, Args, CmdArgs, false); | ||
// AIX does not support any --as-needed options. | ||
if (!TC.getTriple().isOSAIX()) | ||
addAsNeededOption(TC, Args, CmdArgs, false); | ||
// There's no libpthread or librt on RTEMS & Android. | ||
if (TC.getTriple().getOS() != llvm::Triple::RTEMS && | ||
!TC.getTriple().isAndroid() && !TC.getTriple().isOHOSFamily()) { | ||
|
@@ -1437,6 +1452,9 @@ void tools::linkSanitizerRuntimeDeps(const ToolChain &TC, | |
if (TC.getTriple().isOSLinux() && !TC.getTriple().isAndroid() && | ||
!TC.getTriple().isMusl()) | ||
CmdArgs.push_back("-lresolv"); | ||
|
||
if (TC.getTriple().isOSAIX()) | ||
CmdArgs.push_back("-latomic"); | ||
} | ||
|
||
static void | ||
|
@@ -1492,7 +1510,8 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args, | |
StaticRuntimes.push_back("stats_client"); | ||
|
||
// Always link the static runtime regardless of DSO or executable. | ||
if (SanArgs.needsAsanRt()) | ||
// Don't see a reason that AIX needs asan_static library though. | ||
if (SanArgs.needsAsanRt() && !TC.getTriple().isOSAIX()) | ||
HelperStaticRuntimes.push_back("asan_static"); | ||
|
||
// Collect static runtimes. | ||
|
@@ -1626,7 +1645,9 @@ bool tools::addSanitizerRuntimes(const ToolChain &TC, const ArgList &Args, | |
addSanitizerRuntime(TC, Args, CmdArgs, RT, false, true); | ||
bool AddExportDynamic = false; | ||
for (auto RT : StaticRuntimes) { | ||
addSanitizerRuntime(TC, Args, CmdArgs, RT, false, true); | ||
// AIX does not support --whole-archive. | ||
addSanitizerRuntime(TC, Args, CmdArgs, RT, false, | ||
!TC.getTriple().isOSAIX()); | ||
AddExportDynamic |= !addSanitizerDynamicList(TC, Args, CmdArgs, RT); | ||
} | ||
for (auto RT : NonWholeStaticRuntimes) { | ||
|
@@ -1635,8 +1656,13 @@ bool tools::addSanitizerRuntimes(const ToolChain &TC, const ArgList &Args, | |
} | ||
// If there is a static runtime with no dynamic list, force all the symbols | ||
// to be dynamic to be sure we export sanitizer interface functions. | ||
if (AddExportDynamic) | ||
CmdArgs.push_back("--export-dynamic"); | ||
if (AddExportDynamic) { | ||
if (!TC.getTriple().isOSAIX()) | ||
CmdArgs.push_back("--export-dynamic"); | ||
else | ||
llvm::report_fatal_error("Sanitizer interface functions must be exported " | ||
"by export files on AIX."); | ||
} | ||
|
||
if (SanArgs.hasCrossDsoCfi() && !AddExportDynamic) | ||
CmdArgs.push_back("--export-dynamic-symbol=__cfi_check"); | ||
|
Uh oh!
There was an error while loading. Please reload this page.