[PATCH] D82858: [llvm-objdump] Detect note section for ELF objects

Ronak Chauhan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 30 23:25:38 PDT 2020


rochauha added a comment.

> 1. Having multiple tools to do the same job is not a good idea - each requires its own maintenance, the behaviour can diverge, bugs might require fixing in two places/support for new things etc etc etc. In an ideal world, we'd merge all the binary tools (GNU and LLVM) into a single tool, or redistribute functionality somehow, so that we don't have duplicate functionality like we already do. This takes us further away from that ideal.

I agree that having a single tool is the direction we must aim for. But to do so, one tool needs to be improved to the point that it is 'feature complete'. llvm-objdump already disassembles all contents of the binary. It's just that everything is disassembled as instructions. Even notes are disassembled as instructions today. This patch is allowing llvm-objdump to disassemble notes in a way that they are readable for the user. I am not 'adding' anything new; just trying to 'correct' the existing output. Targets will still need to do implement things from their side(if needed) to take advantages of the infrastructure changes.
The initial plan would be to have note record handling in the MC layer. llvm-objdump will just iterate over the notes section. For each note record it will query the registered targets. The owning target will appropriately disassemble the bytes. A note record must be disassembled using the .byte directive if no target owns the note / printing for a particular kind of note is not implemented.

> 3. I'm not convinced people actually find dumping all sections in an interpreted form at once useful. Do you actually have any users for that? I think most people are interested in the disassembly of their code, but are unlikely to want this information in the same output as note information.

Yes, it is super helpful even if the user can just take a look at an entire binary and make sense of it. He/she shouldn't need two tools to do that. Many times note records contain useful information. Looking at the entire binary in an understandable text form can even help when working on bugs.

> 4. I don't quite follow whether you're saying that one motivation is to make things re-assembleable, but if it is, the .note section is not the place to start - there are other sections where this would be more useful (e.g. data sections).

Before even thinking of re-assembly, we need to first make sure that all entities are disassembled in a //proper// way. For example AMDGPU kernel descriptors as assembler directives rather than instructions. Similarly for notes. It may be considered as a //low hanging fruit//. But it definitely needs to be done. All entities need to be disassembled appropriately to make the text relevant to the assembler.

> 5. I'm not sure I follow your "feature rich" comment. llvm-readelf for example has just as much access to the object as a whole and so is able to use target-specific information where appropriate (for example, it knows about various target-specific flags, can parse the target-specific attributes section etc).

I meant that llvm-objdump can also disassemble and thus allows handling bytes in target specific way.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82858/new/

https://reviews.llvm.org/D82858





More information about the llvm-commits mailing list