-
Notifications
You must be signed in to change notification settings - Fork 108
Fix debuginfo for machO #759
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
Conversation
This only fixes it when using object::write as backend, and not when using faerie. There were two problems: * object::write doesn't replace .debug_info with __debug_info, unlike faerie * machO requires section relative relocations, and not symbol relative relocations. When using symbol relative relocations, the linker interprets the relocations as section relative. Thus writing the wrong values to the debug sections. Fixes #303
Both of these might be candidates for including in object::write somehow. I'll have to take some time to understand the relocations though. Fixing it here first is fine of course. |
For the section names, ideally For the relocations, it looks like LLVM always uses section relative relocations where possible (see One thing I need to learn more about is that, for debuginfo, I think references to global data shouldn't be section-relative, but references to global functions should be section-relative, but I don't know where LLVM makes this decision, so I'm not sure if I have this completely right yet. |
I would prefer to keep it that way. Symbol relative relocations are much more useful when having to look at the output object files than section relative relocations. For the later, you would have to search for which symbol is declared at the given offset, while for the former you can see the symbol name immediately. It may be useful to have a function from symbol relative -> section relative relocation. |
So I think the way this works in LLVM is that the function addresses in debuginfo are references to temporary labels, not the function symbol, and so they are converted to section relative relocations.
|
deedf6f
to
51cddef
Compare
51cddef
to
8536514
Compare
Adapted for gimli-rs/object#133 and confirmed that that Linux debuginfo still works. |
This only fixes it when using object::write as backend, and not when using faerie.
There were two problems:
relocations. When using symbol relative relocations, the linker
interprets the relocations as section relative. Thus writing the wrong
values to the debug sections.
Fixes #303
cc @philipc
TODO