diff options
author | James Molloy <james.molloy@arm.com> | 2014-04-14 13:54:16 +0000 |
---|---|---|
committer | James Molloy <james.molloy@arm.com> | 2014-04-14 13:54:16 +0000 |
commit | 555f97f2bc7cc9215734edbdc0c180a341fc3748 (patch) | |
tree | a04d1b1263f42166f78a033a7e5c2b445da1125f | |
parent | f86c5472c00b89ddb8980ae17c6568e9619aaf54 (diff) | |
download | llvm-555f97f2bc7cc9215734edbdc0c180a341fc3748.tar.gz llvm-555f97f2bc7cc9215734edbdc0c180a341fc3748.tar.bz2 llvm-555f97f2bc7cc9215734edbdc0c180a341fc3748.tar.xz |
Teach llvm-lto to respect the given RelocModel.
Patch by Nick Tomlinson!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206177 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm-c/lto.h | 3 | ||||
-rw-r--r-- | lib/LTO/LTOCodeGenerator.cpp | 6 | ||||
-rw-r--r-- | tools/llvm-lto/llvm-lto.cpp | 15 |
3 files changed, 21 insertions, 3 deletions
diff --git a/include/llvm-c/lto.h b/include/llvm-c/lto.h index 049c4d7517..808de03318 100644 --- a/include/llvm-c/lto.h +++ b/include/llvm-c/lto.h @@ -79,7 +79,8 @@ typedef enum { typedef enum { LTO_CODEGEN_PIC_MODEL_STATIC = 0, LTO_CODEGEN_PIC_MODEL_DYNAMIC = 1, - LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC = 2 + LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC = 2, + LTO_CODEGEN_PIC_MODEL_DEFAULT = 3 } lto_codegen_model; /** opaque reference to a loaded object module */ diff --git a/lib/LTO/LTOCodeGenerator.cpp b/lib/LTO/LTOCodeGenerator.cpp index 7fe143bd5d..2ba90fad84 100644 --- a/lib/LTO/LTOCodeGenerator.cpp +++ b/lib/LTO/LTOCodeGenerator.cpp @@ -65,7 +65,7 @@ const char* LTOCodeGenerator::getVersionString() { LTOCodeGenerator::LTOCodeGenerator() : Context(getGlobalContext()), Linker(new Module("ld-temp.o", Context)), TargetMach(NULL), EmitDwarfDebugInfo(false), ScopeRestrictionsDone(false), - CodeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC), NativeObjectFile(NULL), + CodeModel(LTO_CODEGEN_PIC_MODEL_DEFAULT), NativeObjectFile(NULL), DiagHandler(NULL), DiagContext(NULL) { initializeLTOPasses(); } @@ -161,6 +161,7 @@ void LTOCodeGenerator::setCodePICModel(lto_codegen_model model) { case LTO_CODEGEN_PIC_MODEL_STATIC: case LTO_CODEGEN_PIC_MODEL_DYNAMIC: case LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC: + case LTO_CODEGEN_PIC_MODEL_DEFAULT: CodeModel = model; return; } @@ -295,6 +296,9 @@ bool LTOCodeGenerator::determineTarget(std::string &errMsg) { case LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC: RelocModel = Reloc::DynamicNoPIC; break; + case LTO_CODEGEN_PIC_MODEL_DEFAULT: + // RelocModel is already the default, so leave it that way. + break; } // construct LTOModule, hand over ownership of module and target diff --git a/tools/llvm-lto/llvm-lto.cpp b/tools/llvm-lto/llvm-lto.cpp index ec3f0fa233..05ffbf3191 100644 --- a/tools/llvm-lto/llvm-lto.cpp +++ b/tools/llvm-lto/llvm-lto.cpp @@ -83,7 +83,20 @@ int main(int argc, char **argv) { LTOCodeGenerator CodeGen; - CodeGen.setCodePICModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC); + switch (RelocModel) { + case Reloc::Static: + CodeGen.setCodePICModel(LTO_CODEGEN_PIC_MODEL_STATIC); + break; + case Reloc::PIC_: + CodeGen.setCodePICModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC); + break; + case Reloc::DynamicNoPIC: + CodeGen.setCodePICModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC); + break; + default: + CodeGen.setCodePICModel(LTO_CODEGEN_PIC_MODEL_DEFAULT); + } + CodeGen.setDebugInfo(LTO_DEBUG_MODEL_DWARF); CodeGen.setTargetOptions(Options); |