forked from OSchip/llvm-project
[OpenMP][Driver] Put target binary for each offload target into a
separate section, by Sergey Dmitriev Linker script that is generated by the clang driver for creating fat binary puts target binaries for all offload targets into a single ELF section .omp_offloading. This is not convenient because it greatly complicates operations with the final fat binary once it is linked. For example extracting target binary for a particular target from such fat executable would not be an easy task if you have more than one offload target. Attached patch changes clang driver to put target binary for each offload target into a separate ELF section .omp_offloading.<target triple>. Differential Revision: https://reviews.llvm.org/D33254 llvm-svn: 304229
This commit is contained in:
parent
3fa5db4c04
commit
9780faaf8f
|
@ -278,20 +278,20 @@ static void AddOpenMPLinkerScript(const ToolChain &TC, Compilation &C,
|
|||
|
||||
LksStream << "SECTIONS\n";
|
||||
LksStream << "{\n";
|
||||
LksStream << " .omp_offloading :\n";
|
||||
LksStream << " ALIGN(0x10)\n";
|
||||
LksStream << " {\n";
|
||||
|
||||
for (auto &BI : InputBinaryInfo) {
|
||||
LksStream << " . = ALIGN(0x10);\n";
|
||||
// Put each target binary into a separate section.
|
||||
for (const auto &BI : InputBinaryInfo) {
|
||||
LksStream << " .omp_offloading." << BI.first << " :\n";
|
||||
LksStream << " ALIGN(0x10)\n";
|
||||
LksStream << " {\n";
|
||||
LksStream << " PROVIDE_HIDDEN(.omp_offloading.img_start." << BI.first
|
||||
<< " = .);\n";
|
||||
LksStream << " " << BI.second << "\n";
|
||||
LksStream << " PROVIDE_HIDDEN(.omp_offloading.img_end." << BI.first
|
||||
<< " = .);\n";
|
||||
LksStream << " }\n";
|
||||
}
|
||||
|
||||
LksStream << " }\n";
|
||||
// Add commands to define host entries begin and end. We use 1-byte subalign
|
||||
// so that the linker does not add any padding and the elements in this
|
||||
// section form an array.
|
||||
|
|
|
@ -210,14 +210,16 @@
|
|||
// CHK-LKS-ST: INPUT([[T2BIN:.+\.out-openmp-x86_64-pc-linux-gnu]])
|
||||
// CHK-LKS: SECTIONS
|
||||
// CHK-LKS: {
|
||||
// CHK-LKS: .omp_offloading :
|
||||
// CHK-LKS: .omp_offloading.powerpc64le-ibm-linux-gnu :
|
||||
// CHK-LKS: ALIGN(0x10)
|
||||
// CHK-LKS: {
|
||||
// CHK-LKS: . = ALIGN(0x10);
|
||||
// CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_start.powerpc64le-ibm-linux-gnu = .);
|
||||
// CHK-LKS: [[T1BIN]]
|
||||
// CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_end.powerpc64le-ibm-linux-gnu = .);
|
||||
// CHK-LKS: . = ALIGN(0x10);
|
||||
// CHK-LKS: }
|
||||
// CHK-LKS: .omp_offloading.x86_64-pc-linux-gnu :
|
||||
// CHK-LKS: ALIGN(0x10)
|
||||
// CHK-LKS: {
|
||||
// CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_start.x86_64-pc-linux-gnu = .);
|
||||
// CHK-LKS: [[T2BIN]]
|
||||
// CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_end.x86_64-pc-linux-gnu = .);
|
||||
|
|
Loading…
Reference in New Issue