Use the objc runtime's callback to customize the image name for JITDylibs to match their name. This allows some mechanisms that look up files next to binaries to work correctly if the JITDylib name is a path (but not if they use dladdr or dyld_image_path_containing_address for now).
Details
Diff Detail
Event Timeline
compiler-rt/lib/orc/macho_platform.cpp | ||
---|---|---|
372 | I wasn't 100% sure whether this should be a log message or an error. The other objc functionality uses errors, but in those cases the objc code will fail completely if you're missing the runtime functions. In this case, class_getImageName returning nullptr doesn't seem bad enough to make it a hard error to me -- you might not be using that at all. It's too bad there's no such thing as a runtime warning. |
Sorry for the delayed review on this one.
The switch to allocation actions will have broken this -- I'll try to port it to top-of-tree tomorrow.
compiler-rt/lib/orc/executor_address.h | ||
---|---|---|
196–206 | What about using upper-bound here? It has the advantage that you only need to check one range, though you do have to special-case the empty map. if (Map.empty()) return Map.end(); auto I = std::prev(Map.upper_bound({Addr, Addr})); if (I->first.contains(Addr)) return I; return Map.end(); | |
compiler-rt/lib/orc/macho_platform.cpp | ||
372 | For now I think we debug-log when we see objc_setHook_getImageName missing, and hard-error in the hook. Especially in early development I'd rather fail loudly wherever we deviate from AOT behavior. |
compiler-rt/lib/orc/executor_address.h | ||
---|---|---|
196–206 | I think this would work, although you need to check I != Map.begin() before calling prev I believe. |
What about using upper-bound here? It has the advantage that you only need to check one range, though you do have to special-case the empty map.