[compiler-rt] dc58f78 - [ORC-RT] Fix ptrauth signing for dlsym return value (#75972)

via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 19 14:56:46 PST 2023


Author: Ben Langmuir
Date: 2023-12-19T14:56:42-08:00
New Revision: dc58f781b69b58db76be1e0e03493ebfa1d25794

URL: https://github.com/llvm/llvm-project/commit/dc58f781b69b58db76be1e0e03493ebfa1d25794
DIFF: https://github.com/llvm/llvm-project/commit/dc58f781b69b58db76be1e0e03493ebfa1d25794.diff

LOG: [ORC-RT] Fix ptrauth signing for dlsym return value (#75972)

dlsym signs text symbols as functions rather than data in dyld, so match
that for orc runtime dlsym. This fixes run_program on arm64e.

Added: 
    

Modified: 
    compiler-rt/lib/orc/macho_platform.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/orc/macho_platform.cpp b/compiler-rt/lib/orc/macho_platform.cpp
index e3a1cdf3c4fcc3..340846f5f90017 100644
--- a/compiler-rt/lib/orc/macho_platform.cpp
+++ b/compiler-rt/lib/orc/macho_platform.cpp
@@ -825,6 +825,10 @@ void *MachOPlatformRuntimeState::dlsym(void *DSOHandle, const char *Symbol) {
     return nullptr;
   }
 
+  // Sign callable symbols as functions, to match dyld.
+  if ((Result.second & MachOExecutorSymbolFlags::Callable) ==
+      MachOExecutorSymbolFlags::Callable)
+    return reinterpret_cast<void *>(Result.first.toPtr<void(void)>());
   return Result.first.toPtr<void *>();
 }
 


        


More information about the llvm-commits mailing list