[PATCH] D37580: Add Position Independent Pages (PIP) relocation model
Stephen Crane via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 2 16:20:50 PDT 2018
rinon updated this revision to Diff 140703.
rinon added a comment.
Rebase
Repository:
rL LLVM
https://reviews.llvm.org/D37580
Files:
include/llvm/CodeGen/CommandFlags.def
include/llvm/Support/CodeGen.h
include/llvm/Target/TargetMachine.h
lib/Target/TargetMachine.cpp
tools/gold/gold-plugin.cpp
Index: tools/gold/gold-plugin.cpp
===================================================================
--- tools/gold/gold-plugin.cpp
+++ tools/gold/gold-plugin.cpp
@@ -258,6 +258,8 @@
sample_profile= opt.substr(strlen("sample-profile="));
} else if (opt == "new-pass-manager") {
new_pass_manager = true;
+ } else if (opt == "pagerando") {
+ RelocationModel = Reloc::PIP;
} else {
// Save this option to pass to the code generator.
// ParseCommandLineOptions() expects argv[0] to be program name. Lazily
@@ -307,15 +309,15 @@
break;
case LDPO_DYN: // .so
IsExecutable = false;
- RelocationModel = Reloc::PIC_;
+ RelocationModel = RelocationModel ? RelocationModel : Reloc::PIC_;
break;
case LDPO_PIE: // position independent executable
IsExecutable = true;
- RelocationModel = Reloc::PIC_;
+ RelocationModel = RelocationModel ? RelocationModel : Reloc::PIC_;
break;
case LDPO_EXEC: // .exe
IsExecutable = true;
- RelocationModel = Reloc::Static;
+ RelocationModel = RelocationModel ? RelocationModel : Reloc::Static;
break;
default:
message(LDPL_ERROR, "Unknown output file type %d", tv->tv_u.tv_val);
Index: lib/Target/TargetMachine.cpp
===================================================================
--- lib/Target/TargetMachine.cpp
+++ lib/Target/TargetMachine.cpp
@@ -48,7 +48,8 @@
}
bool TargetMachine::isPositionIndependent() const {
- return getRelocationModel() == Reloc::PIC_;
+ return getRelocationModel() == Reloc::PIC_ ||
+ getRelocationModel() == Reloc::PIP;
}
/// \brief Reset the target options based on the function's attributes.
@@ -207,7 +208,7 @@
TLSModel::Model TargetMachine::getTLSModel(const GlobalValue *GV) const {
bool IsPIE = GV->getParent()->getPIELevel() != PIELevel::Default;
Reloc::Model RM = getRelocationModel();
- bool IsSharedLibrary = RM == Reloc::PIC_ && !IsPIE;
+ bool IsSharedLibrary = (RM == Reloc::PIC_ || RM == Reloc::PIP) && !IsPIE;
bool IsLocal = shouldAssumeDSOLocal(*GV->getParent(), GV);
TLSModel::Model Model;
Index: include/llvm/Target/TargetMachine.h
===================================================================
--- include/llvm/Target/TargetMachine.h
+++ include/llvm/Target/TargetMachine.h
@@ -219,6 +219,9 @@
return Options.FunctionSections;
}
+ /// Return true if Pagerando is enabled on this target.
+ bool isPagerando() const { return getRelocationModel() == Reloc::PIP; }
+
/// \brief Get a \c TargetIRAnalysis appropriate for the target.
///
/// This is used to construct the new pass manager's target IR analysis pass,
Index: include/llvm/Support/CodeGen.h
===================================================================
--- include/llvm/Support/CodeGen.h
+++ include/llvm/Support/CodeGen.h
@@ -19,7 +19,7 @@
// Relocation model types.
namespace Reloc {
- enum Model { Static, PIC_, DynamicNoPIC, ROPI, RWPI, ROPI_RWPI };
+ enum Model { Static, PIC_, DynamicNoPIC, ROPI, RWPI, ROPI_RWPI, PIP };
}
// Code model types.
Index: include/llvm/CodeGen/CommandFlags.def
===================================================================
--- include/llvm/CodeGen/CommandFlags.def
+++ include/llvm/CodeGen/CommandFlags.def
@@ -55,7 +55,9 @@
Reloc::RWPI, "rwpi",
"Read-write data relocatable, accessed relative to static base"),
clEnumValN(Reloc::ROPI_RWPI, "ropi-rwpi",
- "Combination of ropi and rwpi")));
+ "Combination of ropi and rwpi"),
+ clEnumValN(Reloc::PIP, "pip",
+ "Position independent pages for Pagerando")));
LLVM_ATTRIBUTE_UNUSED static Optional<Reloc::Model> getRelocModel() {
if (RelocModel.getNumOccurrences()) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37580.140703.patch
Type: text/x-patch
Size: 3860 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180402/4dc68fc7/attachment.bin>
More information about the llvm-commits
mailing list