forked from OSchip/llvm-project
Teach llvm-lto to respect the given RelocModel.
Patch by Nick Tomlinson! llvm-svn: 206177
This commit is contained in:
parent
f434c4fa3f
commit
951e529f66
|
@ -79,7 +79,8 @@ typedef enum {
|
||||||
typedef enum {
|
typedef enum {
|
||||||
LTO_CODEGEN_PIC_MODEL_STATIC = 0,
|
LTO_CODEGEN_PIC_MODEL_STATIC = 0,
|
||||||
LTO_CODEGEN_PIC_MODEL_DYNAMIC = 1,
|
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;
|
} lto_codegen_model;
|
||||||
|
|
||||||
/** opaque reference to a loaded object module */
|
/** opaque reference to a loaded object module */
|
||||||
|
|
|
@ -65,7 +65,7 @@ const char* LTOCodeGenerator::getVersionString() {
|
||||||
LTOCodeGenerator::LTOCodeGenerator()
|
LTOCodeGenerator::LTOCodeGenerator()
|
||||||
: Context(getGlobalContext()), Linker(new Module("ld-temp.o", Context)),
|
: Context(getGlobalContext()), Linker(new Module("ld-temp.o", Context)),
|
||||||
TargetMach(NULL), EmitDwarfDebugInfo(false), ScopeRestrictionsDone(false),
|
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) {
|
DiagHandler(NULL), DiagContext(NULL) {
|
||||||
initializeLTOPasses();
|
initializeLTOPasses();
|
||||||
}
|
}
|
||||||
|
@ -161,6 +161,7 @@ void LTOCodeGenerator::setCodePICModel(lto_codegen_model model) {
|
||||||
case LTO_CODEGEN_PIC_MODEL_STATIC:
|
case LTO_CODEGEN_PIC_MODEL_STATIC:
|
||||||
case LTO_CODEGEN_PIC_MODEL_DYNAMIC:
|
case LTO_CODEGEN_PIC_MODEL_DYNAMIC:
|
||||||
case LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC:
|
case LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC:
|
||||||
|
case LTO_CODEGEN_PIC_MODEL_DEFAULT:
|
||||||
CodeModel = model;
|
CodeModel = model;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -295,6 +296,9 @@ bool LTOCodeGenerator::determineTarget(std::string &errMsg) {
|
||||||
case LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC:
|
case LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC:
|
||||||
RelocModel = Reloc::DynamicNoPIC;
|
RelocModel = Reloc::DynamicNoPIC;
|
||||||
break;
|
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
|
// construct LTOModule, hand over ownership of module and target
|
||||||
|
|
|
@ -83,7 +83,20 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
LTOCodeGenerator CodeGen;
|
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.setDebugInfo(LTO_DEBUG_MODEL_DWARF);
|
||||||
CodeGen.setTargetOptions(Options);
|
CodeGen.setTargetOptions(Options);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue