[clang-offload-wrapper] Add standard notes for ELF offload images
authorVyacheslav Zakharin <vyacheslav.p.zakharin@intel.com>
Fri, 13 Aug 2021 00:23:28 +0000 (17:23 -0700)
committerVyacheslav Zakharin <vyacheslav.p.zakharin@intel.com>
Mon, 16 Aug 2021 20:09:01 +0000 (13:09 -0700)
commit93d08acaacec951dbb302f77eeae51974985b6b2
tree76681d7413ced2b85ff813cd53b8c85408775c88
parent877572cc193a470f310eec46a7ce793a6cc97c2f
[clang-offload-wrapper] Add standard notes for ELF offload images

The patch adds ELF notes into SHT_NOTE sections of ELF offload images
passed to clang-offload-wrapper.

The new notes use a null-terminated "LLVMOMPOFFLOAD" note name.
There are currently three types of notes:

VERSION: a string (not null-terminated) representing the ELF offload
image structure. The current version '1.0' does not put any restrictions
on the structure of the image. If we ever need to come up with a common
structure for ELF offload images (e.g. to be able to analyze the images
in libomptarget in some standard way), then we will introduce new versions.

PRODUCER: a vendor specific name of the producing toolchain.
Upstream LLVM uses "LLVM" (not null-terminated).

PRODUCER_VERSION: a vendor specific version of the producing toolchain.
Upstream LLVM uses LLVM_VERSION_STRING with optional <space> LLVM_REVISION.

All three notes are not mandatory currently.

Differential Revision: https://reviews.llvm.org/D99551
clang/test/Driver/Inputs/empty-elf-template.yaml [new file with mode: 0644]
clang/test/Driver/clang-offload-wrapper.c
clang/tools/clang-offload-wrapper/CMakeLists.txt
clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp