aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Linker
diff options
context:
space:
mode:
authorLauro Ramos Venancio <lauro.venancio@gmail.com>2007-06-06 22:01:12 +0000
committerLauro Ramos Venancio <lauro.venancio@gmail.com>2007-06-06 22:01:12 +0000
commit9613e871d26f123789d98c61879b4dbe944a6d31 (patch)
tree0f9f577d3e0454f637120445925b27a1589f996f /lib/Linker
parent682f683669d01f208c647ebce8d41a2580ef7707 (diff)
downloadexternal_llvm-9613e871d26f123789d98c61879b4dbe944a6d31.zip
external_llvm-9613e871d26f123789d98c61879b4dbe944a6d31.tar.gz
external_llvm-9613e871d26f123789d98c61879b4dbe944a6d31.tar.bz2
Propagate alignment, section name and visibility when linking "appending
global values". Fix noinline linkage. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37482 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Linker')
-rw-r--r--lib/Linker/LinkModules.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp
index cf9f777..88bf621 100644
--- a/lib/Linker/LinkModules.cpp
+++ b/lib/Linker/LinkModules.cpp
@@ -827,6 +827,18 @@ static bool LinkAppendingVars(Module *M,
return Error(ErrorMsg,
"Appending variables linked with different const'ness!");
+ if (G1->getAlignment() != G2->getAlignment())
+ return Error(ErrorMsg,
+ "Appending variables with different alignment need to be linked!");
+
+ if (G1->getVisibility() != G2->getVisibility())
+ return Error(ErrorMsg,
+ "Appending variables with different visibility need to be linked!");
+
+ if (G1->getSection() != G2->getSection())
+ return Error(ErrorMsg,
+ "Appending variables with different section name need to be linked!");
+
unsigned NewSize = T1->getNumElements() + T2->getNumElements();
ArrayType *NewType = ArrayType::get(T1->getElementType(), NewSize);
@@ -837,6 +849,9 @@ static bool LinkAppendingVars(Module *M,
new GlobalVariable(NewType, G1->isConstant(), G1->getLinkage(),
/*init*/0, First->first, M, G1->isThreadLocal());
+ // Propagate alignment, visibility and section info.
+ CopyGVAttributes(NG, G1);
+
// Merge the initializer...
Inits.reserve(NewSize);
if (ConstantArray *I = dyn_cast<ConstantArray>(G1->getInitializer())) {