This patch adds standard ELF notes into SHT_NOTE sections of ELF offload images passed to clang-offload-wrapper. The notes then can be read by the offload plugins to get some extra information about the image.
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.
The second part of the patch implements an ELF light interface for the plugins to be able to ierate ELF notes in SHT/PT_NOTE sections/segments. One implementation is based on libelf and it can be used for platforms, where libelf depdency can be easily satisfied. The second implementation is based on LLVM ELFObjectFile and requires in-tree build - this one can be used on Windows, etc.
Debug output from the plugins would look like this:
TARGET Common ELF --> LLVMOMPOFFLOAD ELF note NT_LLVM_OPENMP_OFFLOAD_VERSION with value: '1.0'
TARGET Common ELF --> LLVMOMPOFFLOAD ELF note NT_LLVM_OPENMP_OFFLOAD_PRODUCER with value: 'LLVM'
TARGET Common ELF --> LLVMOMPOFFLOAD ELF note NT_LLVM_OPENMP_OFFLOAD_PRODUCER_VERSION with value: '13.0.0git 9f8975163c75b1f9f736f9a8e0a60e29ac062754'
- Find the right place to document clang-offload-wrapper behavior for ELF images.
- Write LIT tests.
- Decide how to test the LLVM ELF implementation of ELF light, since I expect the upstream builds will use libelf implementation.