Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Unified Diff: src/IceGlobalInits.h

Issue 1774383002: PNaCl Dynamic Linking: Force __pnacl_pso_root to be an external declaration. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@fixes
Patch Set: Updated external declaration test Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/PNaClTranslator.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceGlobalInits.h
diff --git a/src/IceGlobalInits.h b/src/IceGlobalInits.h
index 419702d9cc867fc960fb66efa1b8fd0cae15c78c..276180ccbbd9dfbab3f2a0cd8afeb55453b2d663 100644
--- a/src/IceGlobalInits.h
+++ b/src/IceGlobalInits.h
@@ -71,6 +71,10 @@ public:
return Linkage == llvm::GlobalValue::InternalLinkage;
}
llvm::GlobalValue::LinkageTypes getLinkage() const { return Linkage; }
+ void setLinkage(llvm::GlobalValue::LinkageTypes L) {
+ assert(!hasName());
+ Linkage = L;
+ }
bool isExternal() const {
return Linkage == llvm::GlobalValue::ExternalLinkage;
}
@@ -90,6 +94,10 @@ public:
return isInternal() ? "internal" : "external";
}
+ /// Returns true if the name of this GlobalDeclaration indicates that it
+ /// should have ExternalLinkage (as a special case).
+ virtual bool isPNaClABIExternalName(const IceString &Name) const = 0;
+
protected:
GlobalDeclaration(GlobalDeclarationKind Kind,
llvm::GlobalValue::LinkageTypes Linkage)
@@ -109,7 +117,7 @@ protected:
}
const GlobalDeclarationKind Kind;
- const llvm::GlobalValue::LinkageTypes Linkage;
+ llvm::GlobalValue::LinkageTypes Linkage;
IceString Name;
};
@@ -142,9 +150,11 @@ public:
/// Returns true if linkage is correct for the function declaration.
bool verifyLinkageCorrect(const GlobalContext *Ctx) const {
- if (isPNaClABIExternalName() || isIntrinsicName(Ctx))
+ if (isPNaClABIExternalName(getName()) || isIntrinsicName(Ctx)) {
return Linkage == llvm::GlobalValue::ExternalLinkage;
- return verifyLinkageDefault(Ctx);
+ } else {
+ return verifyLinkageDefault(Ctx);
+ }
}
/// Validates that the type signature of the function is correct. Returns true
@@ -184,9 +194,8 @@ private:
: GlobalDeclaration(FunctionDeclarationKind, Linkage),
Signature(Signature), CallingConv(CallingConv), IsProto(IsProto) {}
- bool isPNaClABIExternalName() const {
- const char *Name = getName().c_str();
- return strcmp(Name, "_start") == 0 || strcmp(Name, "__pnacl_pso_root") == 0;
+ bool isPNaClABIExternalName(const IceString &Name) const override {
+ return Name == "_start";
}
bool isIntrinsicName(const GlobalContext *Ctx) const {
@@ -414,10 +423,13 @@ public:
/// Prints out the definition of the global variable declaration (including
/// initialization).
- virtual void dump(Ostream &Stream) const;
+ virtual void dump(Ostream &Stream) const override;
/// Returns true if linkage is correct for the variable declaration.
bool verifyLinkageCorrect(const GlobalContext *Ctx) const {
+ if (isPNaClABIExternalName(getName())) {
+ return Linkage == llvm::GlobalValue::ExternalLinkage;
+ }
return verifyLinkageDefault(Ctx);
}
@@ -433,6 +445,10 @@ public:
void discardInitializers() { Initializers = nullptr; }
+ bool isPNaClABIExternalName(const IceString &Name) const override {
+ return Name == "__pnacl_pso_root";
+ }
+
private:
/// List of initializers for the declared variable.
std::unique_ptr<InitializerListType> Initializers;
« no previous file with comments | « no previous file | src/PNaClTranslator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698