llvm.org GIT mirror llvm / 555f97f
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 James Molloy 5 years ago
3 changed file(s) with 21 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
7878 typedef enum {
7979 LTO_CODEGEN_PIC_MODEL_STATIC = 0,
8080 LTO_CODEGEN_PIC_MODEL_DYNAMIC = 1,
81 LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC = 2
81 LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC = 2,
82 LTO_CODEGEN_PIC_MODEL_DEFAULT = 3
8283 } lto_codegen_model;
8384
8485 /** opaque reference to a loaded object module */
6464 LTOCodeGenerator::LTOCodeGenerator()
6565 : Context(getGlobalContext()), Linker(new Module("ld-temp.o", Context)),
6666 TargetMach(NULL), EmitDwarfDebugInfo(false), ScopeRestrictionsDone(false),
67 CodeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC), NativeObjectFile(NULL),
67 CodeModel(LTO_CODEGEN_PIC_MODEL_DEFAULT), NativeObjectFile(NULL),
6868 DiagHandler(NULL), DiagContext(NULL) {
6969 initializeLTOPasses();
7070 }
160160 case LTO_CODEGEN_PIC_MODEL_STATIC:
161161 case LTO_CODEGEN_PIC_MODEL_DYNAMIC:
162162 case LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC:
163 case LTO_CODEGEN_PIC_MODEL_DEFAULT:
163164 CodeModel = model;
164165 return;
165166 }
293294 break;
294295 case LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC:
295296 RelocModel = Reloc::DynamicNoPIC;
297 break;
298 case LTO_CODEGEN_PIC_MODEL_DEFAULT:
299 // RelocModel is already the default, so leave it that way.
296300 break;
297301 }
298302
8282
8383 LTOCodeGenerator CodeGen;
8484
85 CodeGen.setCodePICModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC);
85 switch (RelocModel) {
86 case Reloc::Static:
87 CodeGen.setCodePICModel(LTO_CODEGEN_PIC_MODEL_STATIC);
88 break;
89 case Reloc::PIC_:
90 CodeGen.setCodePICModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC);
91 break;
92 case Reloc::DynamicNoPIC:
93 CodeGen.setCodePICModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC);
94 break;
95 default:
96 CodeGen.setCodePICModel(LTO_CODEGEN_PIC_MODEL_DEFAULT);
97 }
98
8699 CodeGen.setDebugInfo(LTO_DEBUG_MODEL_DWARF);
87100 CodeGen.setTargetOptions(Options);
88101