[llvm] [BOLT] Support runtime library hook via DT_INIT_ARRAY (PR #167467)

Maksim Panchenko via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 25 00:38:24 PST 2025


================
@@ -4849,9 +5023,13 @@ void RewriteInstance::patchELFSectionHeaderTable(ELFObjectFile<ELFT> *File) {
   ELFEhdrTy NewEhdr = Obj.getHeader();
 
   if (BC->HasRelocations) {
-    if (RuntimeLibrary *RtLibrary = BC->getRuntimeLibrary())
+    RuntimeLibrary *RtLibrary = BC->getRuntimeLibrary();
+    if (RtLibrary && opts::RuntimeLibInitHook == opts::RLIH_ENTRY_POINT) {
       NewEhdr.e_entry = RtLibrary->getRuntimeStartAddress();
-    else
+      outs() << "BOLT-INFO: Runtime library initialization was hooked via ELF "
----------------
maksfb wrote:

```suggestion
      BC->outs() << "BOLT-INFO: runtime library initialization was hooked via ELF "
```

https://github.com/llvm/llvm-project/pull/167467


More information about the llvm-commits mailing list