-
Notifications
You must be signed in to change notification settings - Fork 572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement MacOS private loader #1285
Comments
Xref DynamoRIO/drmemory#1673 where we hit problems due to the lack of a private loader. We should at least ask for up-front binding in clients for now. |
@derekbruening after you mentioned private loader in #5325 (comment), I started to wonder why is that needed on macOS. Unlike Linux, which uses a flat namespace, macOS dyld uses two-level namespace, i.e. a library and a symbol name. Having two symbols in two different libraries does not lead to a conflict as macOS, as the application always links to a particular library. Do I miss something important here? |
I assume you mean, could you take all the 3rd-party libraries a tool uses, make a copy of each, give each a different name, and use the existing application loader to load them? This would help, but I would call it the start of a private loading scheme, so it's a step toward a private loader. It does not solve everything:
|
@derekbruening, I am afraid it could be even more complicated than that, and my opinion is that trying to resolve it the "usual" way will not work. One would have to go the Mac way.
I will need to recheck macOS to be 100% sure of the rest, but I do not think there would be a change with the rest of the wording:
To my eyes, there are some hard limitations on macOS, which DR will not be able to overcome at all. My opinion is that the private loader simply cannot be written with adequate functionality on macOS. However, I do believe that DR can work around this if it tries and adapts to macOS specifics, likely with some limitations.
That is probably it. I would like to know your opinion based on this information, which might not have been clear earlier. Perhaps, a completely different route should be taken than what is described in this issue. To be able to provide a more clear description I would also need better understanding of what DynamoRIO wants to do, rather than how it tries to achieve it on Linux or any other OS. |
The two primary goals are transparency and ease of writing tools. TransparencyTransparency is discussed in the docs, slides, and academic papers in depth: e.g., https://dynamorio.org/transparency.html The main issue is isolation. The more isolated both DR and its client are, the better. In general, DR or a client using the same user library used by the application is asking for trouble. Many functions are not re-entrant and are thus unsafe to use. A simple wrapper around a system call that is known to have zero state might be safe; but who's to say it won't change in the next version and then be non-re-entrant? The maintenance pain of using raw system calls would have to be carefully balanced against the stability risks of using app libraries. It might be that using low-level mostly-stateless known-to-be-rentrant user library functions is the best choice on Mac. On Windows, the situation is similar to Mac: the system call interface is not documented. But the vast majority of user library functions cannot be shared with the application. Even the simple system call wrappers that you would think would be safe for DR to use turn out to have problems due to hooks that software places on them, forcing DR to use raw system calls in many cases. Sometimes DR does use simple functions in low-level Windows user libraries shared with the app when there is no better alternative. Ease of writing tools: library support!I'm not too worried about getting core DR to operate transparently: it already is pretty self-contained and just needs a way to call mmap and other operations. It already easily avoids libc and other libraries. The hard part is supporting a good tool-writing platform. Nobody wants to write a tool that can't leverage existing libraries. These days, most people do not want to write a tool in pure C and have to re-invent data structures: they want C++ and STL. How can that be supported without a way to auto-magically load the C++ shared library and isolate it from the application? Not easily. Statically linking the C++ and C libraries is possible, but not easy: we've looked at in the past and always rejected it. We've worked in scenarios where libraries were not available: when DR and its client are statically linked into the application, and thus there is no nice shared library boundary where isolation can be applied. It is painful to do anything. You have to use custom allocators or use DR's allocator with placement new and be extremely careful about everything you do: make sure anything isn't going to allocate memory or touch other resources under the hood. It is very easy to mess up and have mysterious bugs that are very difficult to track down. It does not make for a good tool platform. |
From derek.br...@gmail.com on October 06, 2013 11:58:28
Splitting from issue #58 as this is not necessary for core DR and will be implemented later.
Xref issue #1284 which is refactoring the core module code, including some of the loader code, but is not filling in MacOS implementations for the loader.
Original issue: http://code.google.com/p/dynamorio/issues/detail?id=1285
The text was updated successfully, but these errors were encountered: