diff options
author | Anton Korobeynikov <asl@math.spbu.ru> | 2007-04-29 20:56:48 +0000 |
---|---|---|
committer | Anton Korobeynikov <asl@math.spbu.ru> | 2007-04-29 20:56:48 +0000 |
commit | 9cd3ccf5065a8a139e458d016c88a8512471598b (patch) | |
tree | 915835b6f8a0a2ac5d1915c39a9dcf5ffd8acf14 /lib/Linker | |
parent | 4238d474b4f8443371a52a4f1fca278170ff2c0e (diff) | |
download | external_llvm-9cd3ccf5065a8a139e458d016c88a8512471598b.zip external_llvm-9cd3ccf5065a8a139e458d016c88a8512471598b.tar.gz external_llvm-9cd3ccf5065a8a139e458d016c88a8512471598b.tar.bz2 |
Implement visibility checking during linking. Also implement protected
visibility support for bitcode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36577 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Linker')
-rw-r--r-- | lib/Linker/LinkModules.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index 0d4479b..cf9f777 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -365,7 +365,9 @@ static void CopyGVAttributes(GlobalValue *DestGV, const GlobalValue *SrcGV) { /// 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 @@ static bool GetLinkageResult(GlobalValue *Dest, GlobalValue *Src, 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 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src, 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()) { |