[LinkerWrapper] Embed OffloadBinaries for OpenMP offloading images
authorJoseph Huber <jhuber6@vols.utk.edu>
Wed, 8 Jun 2022 13:38:41 +0000 (09:38 -0400)
committerJoseph Huber <jhuber6@vols.utk.edu>
Thu, 21 Jul 2022 17:20:01 +0000 (13:20 -0400)
commit080022d8ed6c1bd9ba5ece33cfea248f9473e775
tree7d421e3f7f234e4f13c349072fce82341bbe1647
parent53d7bf3052dcc4959f5e80d657771502a807a9cb
[LinkerWrapper] Embed OffloadBinaries for OpenMP offloading images

The OpenMP offloading runtine currently uses an array of linked
offloading images. One downside to this is that we cannot know the
architecture or triple associated with the given image. In this patch,
instead of embedding the image itself, we embed an offloading binary
instead. This binary is simply a binary format that wraps around the
original linked image to provide some additional metadata. This will
allow us to support offloading to multiple architecture, or performing
future JIT compilation inside of the runtime, more clearly.
Additionally, these can be placed at a special section such that the
supported architectures can be identified using objdump with the support
from D126904. This needs to be stored in a new section name
`.llvm.offloading.images` because the `.llvm.offloading` section
implicitly uses the `SHF_EXCLUDE` flag and will always be stripped.

This patch does not contain the necessary code to parse these in
libomptarget.

Depends on D127246

Reviewed By: saiislam

Differential Revision: https://reviews.llvm.org/D127304
clang/test/Driver/linker-wrapper-image.c
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
clang/tools/clang-linker-wrapper/OffloadWrapper.cpp