Nikita Ermoshkin via llvm-dev
2022-Jan-28 21:41 UTC
[llvm-dev] Symbolizing relocations in disassembly
Hi LLVM devs, In my experimental backend, I’d like to symbolize the disassembled ELF and object files generated by the backend, so that labels/function names are printed instead of just memory addresses. When using objdump. The simplest implementation I’ve found is the AMDGPU symbolizer in the Disassembler, which I mimicked. This works fine only in very specific cases, where the address in the operand exists in the section’s symbol table. However, if the symbol to reference is in another section, or if the operand value is just 0 with a fix-up/relocation, it obviously doesn’t give correct results. So the question: is there a more robust way to get access to all the symbols and relocation data in the target Disassembler? I haven’t fully dug through how x86 does it but it seems really complicated, and my much simpler backend probably doesn’t need that level of complexity. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20220128/b0f23856/attachment.html>
David Blaikie via llvm-dev
2022-Jan-28 21:54 UTC
[llvm-dev] Symbolizing relocations in disassembly
Not sure I'm entirely following - llvm-symbolizer can symbolize addresses in object files, I think, including applying/interacting with relocations - I don't think it involves any use of the Disassembler. On Fri, Jan 28, 2022 at 1:41 PM Nikita Ermoshkin via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hi LLVM devs, > > In my experimental backend, I’d like to symbolize the disassembled ELF and > object files generated by the backend, so that labels/function names are > printed instead of just memory addresses. When using objdump. The simplest > implementation I’ve found is the AMDGPU symbolizer in the Disassembler, > which I mimicked. This works fine only in very specific cases, where the > address in the operand exists in the section’s symbol table. However, if > the symbol to reference is in another section, or if the operand value is > just 0 with a fix-up/relocation, it obviously doesn’t give correct results. > > So the question: is there a more robust way to get access to all the > symbols and relocation data in the target Disassembler? I haven’t fully dug > through how x86 does it but it seems really complicated, and my much > simpler backend probably doesn’t need that level of complexity. > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20220128/c610ef03/attachment.html>