@@ -95,6 +95,8 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA,
95
95
std::string Dyld = D.DyldPrefix ;
96
96
if (SanArgs.needsAsanRt () && SanArgs.needsSharedRt ())
97
97
Dyld += " asan/" ;
98
+ if (SanArgs.needsHwasanRt () && SanArgs.needsSharedRt ())
99
+ Dyld += " hwasan/" ;
98
100
if (SanArgs.needsTsanRt () && SanArgs.needsSharedRt ())
99
101
Dyld += " tsan/" ;
100
102
Dyld += " ld.so.1" ;
@@ -210,23 +212,41 @@ Fuchsia::Fuchsia(const Driver &D, const llvm::Triple &Triple,
210
212
.flag (" +fsanitize=address" )
211
213
.flag (" -fexceptions" )
212
214
.flag (" +fno-exceptions" ));
215
+ // HWASan has higher priority because we always want the instrumentated
216
+ // version.
217
+ Multilibs.push_back (
218
+ Multilib (" hwasan" , {}, {}, 4 ).flag (" +fsanitize=hwaddress" ));
219
+ // Use the hwasan+noexcept variant with HWASan and -fno-exceptions.
220
+ Multilibs.push_back (Multilib (" hwasan+noexcept" , {}, {}, 5 )
221
+ .flag (" +fsanitize=hwaddress" )
222
+ .flag (" -fexceptions" )
223
+ .flag (" +fno-exceptions" ));
213
224
// Use the relative vtables ABI.
214
225
// TODO: Remove these multilibs once relative vtables are enabled by default
215
226
// for Fuchsia.
216
- Multilibs.push_back (Multilib (" relative-vtables" , {}, {}, 4 )
227
+ Multilibs.push_back (Multilib (" relative-vtables" , {}, {}, 6 )
217
228
.flag (" +fexperimental-relative-c++-abi-vtables" ));
218
- Multilibs.push_back (Multilib (" relative-vtables+noexcept" , {}, {}, 5 )
229
+ Multilibs.push_back (Multilib (" relative-vtables+noexcept" , {}, {}, 7 )
219
230
.flag (" +fexperimental-relative-c++-abi-vtables" )
220
231
.flag (" -fexceptions" )
221
232
.flag (" +fno-exceptions" ));
222
- Multilibs.push_back (Multilib (" relative-vtables+asan" , {}, {}, 6 )
233
+ Multilibs.push_back (Multilib (" relative-vtables+asan" , {}, {}, 8 )
223
234
.flag (" +fexperimental-relative-c++-abi-vtables" )
224
235
.flag (" +fsanitize=address" ));
225
- Multilibs.push_back (Multilib (" relative-vtables+asan+noexcept" , {}, {}, 7 )
236
+ Multilibs.push_back (Multilib (" relative-vtables+asan+noexcept" , {}, {}, 9 )
226
237
.flag (" +fexperimental-relative-c++-abi-vtables" )
227
238
.flag (" +fsanitize=address" )
228
239
.flag (" -fexceptions" )
229
240
.flag (" +fno-exceptions" ));
241
+ Multilibs.push_back (Multilib (" relative-vtables+hwasan" , {}, {}, 10 )
242
+ .flag (" +fexperimental-relative-c++-abi-vtables" )
243
+ .flag (" +fsanitize=hwaddress" ));
244
+ Multilibs.push_back (Multilib (" relative-vtables+hwasan+noexcept" , {}, {}, 11 )
245
+ .flag (" +fexperimental-relative-c++-abi-vtables" )
246
+ .flag (" +fsanitize=hwaddress" )
247
+ .flag (" -fexceptions" )
248
+ .flag (" +fno-exceptions" ));
249
+
230
250
Multilibs.FilterOut ([&](const Multilib &M) {
231
251
std::vector<std::string> RD = FilePaths (M);
232
252
return std::all_of (RD.begin (), RD.end (), [&](std::string P) {
@@ -239,6 +259,8 @@ Fuchsia::Fuchsia(const Driver &D, const llvm::Triple &Triple,
239
259
Args.hasFlag (options::OPT_fexceptions, options::OPT_fno_exceptions, true ),
240
260
" fexceptions" , Flags);
241
261
addMultilibFlag (getSanitizerArgs ().needsAsanRt (), " fsanitize=address" , Flags);
262
+ addMultilibFlag (getSanitizerArgs ().needsHwasanRt (), " fsanitize=hwaddress" ,
263
+ Flags);
242
264
243
265
addMultilibFlag (
244
266
Args.hasFlag (options::OPT_fexperimental_relative_cxx_abi_vtables,
@@ -368,6 +390,7 @@ void Fuchsia::AddCXXStdlibLibArgs(const ArgList &Args,
368
390
SanitizerMask Fuchsia::getSupportedSanitizers () const {
369
391
SanitizerMask Res = ToolChain::getSupportedSanitizers ();
370
392
Res |= SanitizerKind::Address;
393
+ Res |= SanitizerKind::HWAddress;
371
394
Res |= SanitizerKind::PointerCompare;
372
395
Res |= SanitizerKind::PointerSubtract;
373
396
Res |= SanitizerKind::Fuzzer;
0 commit comments