[llvm-commits] CVS: llvm/lib/Linker/LinkModules.cpp
Anton Korobeynikov
asl at math.spbu.ru
Sun Apr 29 13:57:18 PDT 2007
Changes in directory llvm/lib/Linker:
LinkModules.cpp updated: 1.139 -> 1.140
---
Log message:
Implement visibility checking during linking. Also implement protected
visibility support for bitcode.
---
Diffs of the changes: (+14 -1)
LinkModules.cpp | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletion(-)
Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.139 llvm/lib/Linker/LinkModules.cpp:1.140
--- llvm/lib/Linker/LinkModules.cpp:1.139 Thu Apr 12 13:32:50 2007
+++ llvm/lib/Linker/LinkModules.cpp Sun Apr 29 15:56:48 2007
@@ -365,7 +365,9 @@
/// the result will look like in the destination module. In particular, it
/// computes the resultant linkage type, computes whether the global in the
/// source should be copied over to the destination (replacing the existing
-/// one), and computes whether this linkage is an error or not.
+/// one), and computes whether this linkage is an error or not. It also performs
+/// visibility checks: we cannot link together two symbols with different
+/// visibilities.
static bool GetLinkageResult(GlobalValue *Dest, GlobalValue *Src,
GlobalValue::LinkageTypes <, bool &LinkFromSrc,
std::string *Err) {
@@ -435,6 +437,11 @@
return Error(Err, "Linking globals named '" + Src->getName() +
"': symbol multiply defined!");
}
+
+ // Check visibility
+ if (Dest && Src->getVisibility() != Dest->getVisibility())
+ return Error(Err, "Linking globals named '" + Src->getName() +
+ "': symbols have different visibilities!");
return false;
}
@@ -617,6 +624,12 @@
RecursiveResolveTypes(SF->getType(), DF->getType(),
&Dest->getTypeSymbolTable(), "");
}
+
+ // Check visibility
+ if (DF && !DF->hasInternalLinkage() &&
+ SF->getVisibility() != DF->getVisibility())
+ return Error(Err, "Linking functions named '" + SF->getName() +
+ "': symbols have different visibilities!");
if (DF && DF->getType() != SF->getType()) {
if (DF->isDeclaration() && !SF->isDeclaration()) {
More information about the llvm-commits
mailing list