This is an archive of the discontinued LLVM Phabricator instance.

[OffloadPackager] Add ability to extract images from other file types
ClosedPublic

Authored by jhuber6 on Aug 24 2022, 2:16 PM.

Details

Summary

A previous patch added support for extracting images from offloading
binaries. Users may wish to extract these files from the file types they
are most commonly emebedded in, such as an ELF or bitcode. This can be
difficult for the user to do manually, as these could be stored in
different section names potentially. This patch addsp support for
extracting these file types.

Diff Detail

Event Timeline

jhuber6 created this revision.Aug 24 2022, 2:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 24 2022, 2:16 PM
Herald added a subscriber: mgorny. · View Herald Transcript
jhuber6 requested review of this revision.Aug 24 2022, 2:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 24 2022, 2:16 PM
tra added a comment.Aug 24 2022, 2:48 PM

Should these be merged into a public interface via Object/OffloadBinary.h?

I'm all for consolidating relevant code.

Should these be merged into a public interface via Object/OffloadBinary.h?

I'm all for consolidating relevant code.

Basically it would be a free function doing that extractFromBuffer does here. I would also need to define a wrapper around OwningBinary<OffloadBinary> as that's what I use in the linker wrapper.

I'm not sure if it would be easier to consolidate this before or after this patch.

tra added a comment.Aug 24 2022, 2:56 PM

before or after this patch.

That would be your call. I personally would be biased towards doing refactoring early. Once something is in place, the temptation not to fix what already works might win.

jhuber6 updated this revision to Diff 455663.Aug 25 2022, 11:18 AM

Updating after refactoring extraction code.

jhuber6 updated this revision to Diff 455664.Aug 25 2022, 11:18 AM

CMake changes no longer needed

yaxunl added inline comments.Aug 26 2022, 7:22 AM
clang/tools/clang-offload-packager/ClangOffloadPackager.cpp
17–21

Are these include files necessary? I do not see code changes that need new include files. Or they were missing before?

jhuber6 added inline comments.Aug 26 2022, 7:24 AM
clang/tools/clang-offload-packager/ClangOffloadPackager.cpp
17–21

You're right, they were included previously but I since rolled that logic into D132689. I'll remove them.

jhuber6 updated this revision to Diff 455929.Aug 26 2022, 8:44 AM

Removing unused headers.

jhuber6 retitled this revision from [OffloadPackager] Add ability to extract mages from other file types to [OffloadPackager] Add ability to extract images from other file types.Sep 2 2022, 11:50 AM
saiislam accepted this revision.Sep 4 2022, 11:51 PM

LGTM. Thanks!

This revision is now accepted and ready to land.Sep 4 2022, 11:51 PM