@@ -80,6 +80,7 @@ namespace opts {
8080extern cl::list<std::string> HotTextMoveSections;
8181extern cl::opt<bool > Hugify;
8282extern cl::opt<bool > Instrument;
83+ extern cl::opt<uint32_t > InstrumentationSleepTime;
8384extern cl::opt<bool > KeepNops;
8485extern cl::opt<bool > Lite;
8586extern cl::list<std::string> PrintOnly;
@@ -1501,6 +1502,10 @@ Error RewriteInstance::discoverRtFiniAddress() {
15011502 }
15021503
15031504 if (!BC->FiniArrayAddress || !BC->FiniArraySize ) {
1505+ // It is still possible to generate profile without fini hook if
1506+ // InstrumentationSleepTime is set
1507+ if (opts::InstrumentationSleepTime > 0 )
1508+ return Error::success ();
15041509 return createStringError (
15051510 std::errc::not_supported,
15061511 " Instrumentation needs either DT_FINI or DT_FINI_ARRAY" );
@@ -1601,6 +1606,13 @@ void RewriteInstance::updateRtFiniReloc() {
16011606 if (!RT || !RT->getRuntimeFiniAddress ())
16021607 return ;
16031608
1609+ // It is still possible to generate profile without fini hook if
1610+ // InstrumentationSleepTime is set
1611+ if ((!BC->FiniArrayAddress || !BC->FiniArraySize ) &&
1612+ opts::InstrumentationSleepTime > 0 ) {
1613+ return ;
1614+ }
1615+
16041616 assert (BC->FiniArrayAddress && BC->FiniArraySize &&
16051617 " inconsistent .fini_array state" );
16061618
0 commit comments