[PATCH] D129507: [llvm-objcopy] Add option to dump embedded offloading images

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 14 10:29:48 PDT 2022


MaskRay added a comment.

In D129507#3648113 <https://reviews.llvm.org/D129507#3648113>, @jhuber6 wrote:

> In D129507#3647420 <https://reviews.llvm.org/D129507#3647420>, @jhenderson wrote:
>
>> I'm not familiar with some of the mentioned tools, but I tend to agree with @MaskRay's conclusions.
>>
>> 1. The functionality doesn't really fit in llvm-objcopy because the tool is intended for modifying a file in-place or making a (modified) copy to another place, neither of which is what you'll actually want it for. I think it //would// be appropriate for extracting the offloading section from an ELF binary as a whole, since that would basically just be --dump-section. Ideally, we'd have the ability to extract by section type, not just section name, but that's getting out-of-scope for this discussion.
>>
>> 2. llvm-objdump shouldn't be writing things to a file (or producing "binary" output that is intended for piping directly to a file). It's goal is printing information about object files. It is appropriate for it to be able to dump the offloading sections in an interpreted format, but not to extract them.
>>
>> That means the functionality needs adding to a different tool, I feel (whether that tool is a new one or an existing one, I don't know).
>
> `llvm-objdump` has the `-s -j <secname>` functionality, but that just dumps straight to the screen in hex format. I could put this in the `clang-offload-packger`, the tools that makes these blobs in the first place, but since it's a `clang` tool and doesn't care about object files I figured it wouldn't be a good fit. But if people are opposed to this kind of functionality in `llvm-objdump`, `llvm-readobj`, or `llvm-objcopy` I can just put it in there so it's at least available.

I think none of `llvm-objdump`, `llvm-readobj`, or `llvm-objcopy` is applicable. I don't know the offloading ecosystem well, but it seems that if a tool already does something like extracting an offloading section, it seems natural for it to support `--dump-offloading` if such a debugging functionality is needed.
If `clang-offload-packager` seems misnomer, since the utility is still new, a rename can be considered. If its main code is in `clang/lib`, you can add the dump functionality in `llvm/lib/Object` (to sit beside code which parses/processes some binary formats) and let the tool call that code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129507



More information about the llvm-commits mailing list