aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/ModuleUtils.cpp
diff options
context:
space:
mode:
authorJoseph Huber <jhuber6@vols.utk.edu>2022-02-24 10:24:39 -0500
committerJoseph Huber <jhuber6@vols.utk.edu>2022-02-24 10:57:09 -0500
commit7aef8b3754a28e0856a8300980786a45bf7b4cd4 (patch)
treecdf07795a381de23bb395c629f41ac20b0a270cf /llvm/lib/Transforms/Utils/ModuleUtils.cpp
parent5379f76e6328ecfa2e15b3c7ab32c4a053f4a663 (diff)
downloadllvm-7aef8b3754a28e0856a8300980786a45bf7b4cd4.zip
llvm-7aef8b3754a28e0856a8300980786a45bf7b4cd4.tar.gz
llvm-7aef8b3754a28e0856a8300980786a45bf7b4cd4.tar.bz2
[OpenMP] Make section variable external to prevent collisions
Summary: We use a section to embed offloading code into the host for later linking. This is normally unique to the translation unit as it is thrown away during linking. However, if the user performs a relocatable link the sections will be merged and we won't be able to access the files stored inside. This patch changes the section variables to have external linkage and a name defined by the section name, so if two sections are combined during linking we get an error.
Diffstat (limited to 'llvm/lib/Transforms/Utils/ModuleUtils.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/ModuleUtils.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/ModuleUtils.cpp b/llvm/lib/Transforms/Utils/ModuleUtils.cpp
index 61cf42d..032ea80 100644
--- a/llvm/lib/Transforms/Utils/ModuleUtils.cpp
+++ b/llvm/lib/Transforms/Utils/ModuleUtils.cpp
@@ -271,9 +271,10 @@ void llvm::embedBufferInModule(Module &M, MemoryBufferRef Buf,
Constant *ModuleConstant = ConstantDataArray::get(
M.getContext(), makeArrayRef(Buf.getBufferStart(), Buf.getBufferSize()));
GlobalVariable *GV = new GlobalVariable(
- M, ModuleConstant->getType(), true, GlobalValue::PrivateLinkage,
- ModuleConstant, "llvm.embedded.object");
+ M, ModuleConstant->getType(), true, GlobalValue::ExternalLinkage,
+ ModuleConstant, SectionName.drop_front());
GV->setSection(SectionName);
+ GV->setVisibility(GlobalValue::HiddenVisibility);
appendToCompilerUsed(M, GV);
}