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

Unified Diff: src/IceGlobalInits.h

Issue 1740033002: Force __pnacl_pso_root to be an external declaration. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Relocated location of forcing external. Made isPNaClABIExternalName public. Created 4 years, 10 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') | src/PNaClTranslator.cpp » ('J')
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 a11153648fb0d4c9a716d773e38947d15d84c9fb..72f2663a2977b02b5f349cbce254ea65fc50063a 100644
--- a/src/IceGlobalInits.h
+++ b/src/IceGlobalInits.h
@@ -102,6 +102,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 = 0;
+
protected:
GlobalDeclaration(GlobalDeclarationKind Kind,
llvm::GlobalValue::LinkageTypes Linkage)
@@ -154,9 +158,12 @@ public:
/// Returns true if linkage is correct for the function declaration.
bool verifyLinkageCorrect(const GlobalContext *Ctx) const {
- if (isPNaClABIExternalName() || isIntrinsicName(Ctx))
+ if (isIntrinsicName(Ctx))
return Linkage == llvm::GlobalValue::ExternalLinkage;
- return verifyLinkageDefault(Ctx);
+ else if (Linkage == llvm::GlobalValue::ExternalLinkage)
+ return isPNaClABIExternalName();
+ else
+ return verifyLinkageDefault(Ctx);
}
/// Validates that the type signature of the function is correct. Returns true
@@ -196,9 +203,9 @@ 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 override {
+ static constexpr char Start[] = "_start";
John 2016/02/26 19:48:37 thanks! :)
+ return getName() == Start;
}
bool isIntrinsicName(const GlobalContext *Ctx) const {
@@ -416,6 +423,9 @@ public:
/// Returns true if linkage is correct for the variable declaration.
bool verifyLinkageCorrect(const GlobalContext *Ctx) const {
+ if (isPNaClABIExternalName()) {
+ return Linkage == llvm::GlobalValue::ExternalLinkage;
+ }
return verifyLinkageDefault(Ctx);
}
@@ -433,6 +443,11 @@ public:
void discardInitializers() { Initializers = nullptr; }
+ bool isPNaClABIExternalName() const override {
+ static constexpr char PnaclPsoRoot[] = "__pnacl_pso_root";
+ return getName() == PnaclPsoRoot;
+ }
+
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') | src/PNaClTranslator.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698