summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2017-05-30 18:57:51 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2017-05-30 18:57:51 +0000
commit9780faaf8f86b80804ebdbcdf79a28352529f04c (patch)
treeddfcf14237dcb881ab02b65da335350fa526659c
parent3fa5db4c04c5ea83ba2f374ddaea275b063a49a8 (diff)
downloadbcm5719-llvm-9780faaf8f86b80804ebdbcdf79a28352529f04c.tar.gz
bcm5719-llvm-9780faaf8f86b80804ebdbcdf79a28352529f04c.zip
[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
-rw-r--r--clang/lib/Driver/ToolChains/Gnu.cpp12
-rw-r--r--clang/test/Driver/openmp-offload.c8
2 files changed, 11 insertions, 9 deletions
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index 1a398fd8a77..d50f8e21f62 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -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.
diff --git a/clang/test/Driver/openmp-offload.c b/clang/test/Driver/openmp-offload.c
index 097dc7d17fa..39eb41e6ac0 100644
--- a/clang/test/Driver/openmp-offload.c
+++ b/clang/test/Driver/openmp-offload.c
@@ -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 = .);
OpenPOWER on IntegriCloud