This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objdump][Offload] Use common offload extraction method
ClosedPublic

Authored by jhuber6 on Oct 26 2022, 2:51 PM.

Details

Summary

A previous patch introduced a common function used to extract offloading
binaries from an image. Therefore we no longer need to duplicate the
functionality in the llvm-objdump implementation. Functionally, this
removes the old warning behaviour when given malformed input. This has
been changed to a hard error, which is effectively the same.

This required a slight tweak in the linker wrapper to filter out the
user passing shared objects directly.

Diff Detail

Event Timeline

jhuber6 created this revision.Oct 26 2022, 2:51 PM
Herald added a reviewer: MaskRay. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: hiraditya. · View Herald Transcript
jhuber6 requested review of this revision.Oct 26 2022, 2:51 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 26 2022, 2:51 PM

As a general rule, dumping tools should avoid hard errors, because usually they prevent the dumping tool from continuing to dump other useful and valid information as part of the same execution. I don't have a strong objection in this particular case, because I presume this error could be avoided by simply not dumping the offloading sections, but I wanted to make the context clear.

llvm/lib/Object/OffloadBinary.cpp
261–264

Is there test code showing the ET_EXEC and ET_DYN objects work here?

jhuber6 updated this revision to Diff 471132.Oct 27 2022, 5:08 AM

Adding separate tests for ET_REL, ET_EXEC, and ET_DYN.

jhenderson added inline comments.Nov 1 2022, 2:01 AM
llvm/test/tools/llvm-objdump/Offloading/elf_dynamic.test
1 ↗(On Diff #471132)

Rather than duplicating this and the ET_REL cases, you can use yaml2obj's -D option to parameterise the ELF type. Rough code:

# RUN: yaml2obj %S/Inputs/binary.yaml -D TYPE=ET_DYN -o %t.so
# RUN: yaml2obj %S/Inputs/binary.yaml -D TYPE=ET_EXEC -o %t.bin
# RUN: yaml2obj %S/Inputs/binary.yaml -D TYPE=ET_REL -o %t.o

...
  Data: ELFDATA2LSB
  Type: [[TYPE]]
...
llvm/tools/llvm-objdump/OffloadDump.cpp
63–65

Not sure why this was changed.

76

Should this be "contained in this buffer" rather than "at"?

jhuber6 updated this revision to Diff 472265.Nov 1 2022, 5:32 AM

Addressing comments.

Is this good to land now?

Is this good to land now?

The LLVM community practice is to wait a week between pings unless there's something urgent (and if something is urgent, please say so).

Aside from the clang bit of the patch, this seems good to me, but it would be worth another person involved with offloading to give the final thumbs up.

clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
1262–1265

This change seems not really part of the patch, since it's touching clang but the patch is for llvm-objdump.

Is this good to land now?

The LLVM community practice is to wait a week between pings unless there's something urgent (and if something is urgent, please say so).

Aside from the clang bit of the patch, this seems good to me, but it would be worth another person involved with offloading to give the final thumbs up.

I could precommit that part if it would make it cleaner, but since this patch changes the extract routine to handle relocatable objects we need to filter those out of the input since the linker wrapper can't handle them.

tra accepted this revision.Nov 3 2022, 1:00 PM

LGTM, modulo separating clang-related change into a separate patch.

clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
1262–1265

+1 to landing this separately, possibly with a relevant test.

This revision is now accepted and ready to land.Nov 3 2022, 1:00 PM
This revision was landed with ongoing or failed builds.Nov 3 2022, 2:19 PM
This revision was automatically updated to reflect the committed changes.
jhuber6 added inline comments.Nov 3 2022, 2:21 PM
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
1262–1265

I put it in a separate commit but it seems arcanist squashed it in the background.

llvm/test/tools/llvm-objdump/Offloading/elf.test