From abc717f203060f7ab16d36f2afe681d838b46801 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 22 Nov 2020 17:28:11 -0700 Subject: modernize the PIE patch for the latest master branch This is the part of #3960 that has to be rewritten to apply to latest master branch code. --- src/stage1/codegen.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/stage1/codegen.cpp') diff --git a/src/stage1/codegen.cpp b/src/stage1/codegen.cpp index 26fe00228e..d0bb9b4411 100644 --- a/src/stage1/codegen.cpp +++ b/src/stage1/codegen.cpp @@ -9043,6 +9043,7 @@ Buf *codegen_generate_builtin_source(CodeGen *g) { buf_appendf(contents, "pub const have_error_return_tracing = %s;\n", bool_to_str(g->have_err_ret_tracing)); buf_appendf(contents, "pub const valgrind_support = false;\n"); buf_appendf(contents, "pub const position_independent_code = %s;\n", bool_to_str(g->have_pic)); + buf_appendf(contents, "pub const position_independent_executable = %s;\n", bool_to_str(g->have_pie)); buf_appendf(contents, "pub const strip_debug_info = %s;\n", bool_to_str(g->strip_debug_symbols)); buf_appendf(contents, "pub const code_model = CodeModel.default;\n"); @@ -9170,6 +9171,14 @@ static void init(CodeGen *g) { reloc_mode = LLVMRelocStatic; } + if (g->have_pic) { + ZigLLVMSetModulePICLevel(g->module); + } + + if (g->have_pie) { + ZigLLVMSetModulePIELevel(g->module); + } + const char *target_specific_cpu_args = ""; const char *target_specific_features = ""; -- cgit v1.2.3