[PATCH] D19996: New clang option -mpie-copy-relocationss to indicate support for linker copy relocations when linking as PIE
This revision was automatically updated to reflect the committed changes. Closed by commit rL284638: New clang option -mpie-copy-relocations to use copy relocations for PIE builds. (authored by tmsriram). Changed prior to commit: https://reviews.llvm.org/D19996?vs=75189&id=75212#toc Repository: rL LLVM https://reviews.llvm.org/D19996 Files: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/include/clang/Frontend/CodeGenOptions.def cfe/trunk/lib/CodeGen/BackendUtil.cpp cfe/trunk/lib/Driver/Tools.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp === --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp @@ -586,6 +586,8 @@ Opts.RelaxAll = Args.hasArg(OPT_mrelax_all); Opts.IncrementalLinkerCompatible = Args.hasArg(OPT_mincremental_linker_compatible); + Opts.PIECopyRelocations = + Args.hasArg(OPT_mpie_copy_relocations); Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer); Opts.SaveTempLabels = Args.hasArg(OPT_msave_temp_labels); Opts.NoDwarfDirectoryAsm = Args.hasArg(OPT_fno_dwarf_directory_asm); Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp === --- cfe/trunk/lib/CodeGen/BackendUtil.cpp +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp @@ -595,6 +595,8 @@ Options.MCOptions.MCNoExecStack = CodeGenOpts.NoExecStack; Options.MCOptions.MCIncrementalLinkerCompatible = CodeGenOpts.IncrementalLinkerCompatible; + Options.MCOptions.MCPIECopyRelocations = + CodeGenOpts.PIECopyRelocations; Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings; Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose; Options.MCOptions.PreserveAsmComments = CodeGenOpts.PreserveAsmComments; Index: cfe/trunk/lib/Driver/Tools.cpp === --- cfe/trunk/lib/Driver/Tools.cpp +++ cfe/trunk/lib/Driver/Tools.cpp @@ -4499,6 +4499,12 @@ CmdArgs.push_back("-mms-bitfields"); } + if (Args.hasFlag(options::OPT_mpie_copy_relocations, + options::OPT_mno_pie_copy_relocations, + false)) { +CmdArgs.push_back("-mpie-copy-relocations"); + } + // This is a coarse approximation of what llvm-gcc actually does, both // -fasynchronous-unwind-tables and -fnon-call-exceptions interact in more // complicated ways. Index: cfe/trunk/include/clang/Driver/Options.td === --- cfe/trunk/include/clang/Driver/Options.td +++ cfe/trunk/include/clang/Driver/Options.td @@ -1691,6 +1691,10 @@ def mimplicit_float : Flag<["-"], "mimplicit-float">, Group; def mrecip : Flag<["-"], "mrecip">, Group; def mrecip_EQ : CommaJoined<["-"], "mrecip=">, Group, Flags<[CC1Option]>; +def mpie_copy_relocations : Flag<["-"], "mpie-copy-relocations">, Group, + Flags<[CC1Option]>, + HelpText<"Use copy relocations support for PIE builds">; +def mno_pie_copy_relocations : Flag<["-"], "mno-pie-copy-relocations">, Group; def mx87 : Flag<["-"], "mx87">, Group; def m80387 : Flag<["-"], "m80387">, Alias; def msse2 : Flag<["-"], "msse2">, Group; Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def === --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def @@ -252,6 +252,9 @@ /// Whether to report the hotness of the code region for optimization remarks. CODEGENOPT(DiagnosticsWithHotness, 1, 0) +/// Whether copy relocations support is available when building as PIE. +CODEGENOPT(PIECopyRelocations, 1, 0) + #undef CODEGENOPT #undef ENUM_CODEGENOPT #undef VALUE_CODEGENOPT Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp === --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp @@ -586,6 +586,8 @@ Opts.RelaxAll = Args.hasArg(OPT_mrelax_all); Opts.IncrementalLinkerCompatible = Args.hasArg(OPT_mincremental_linker_compatible); + Opts.PIECopyRelocations = + Args.hasArg(OPT_mpie_copy_relocations); Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer); Opts.SaveTempLabels = Args.hasArg(OPT_msave_temp_labels); Opts.NoDwarfDirectoryAsm = Args.hasArg(OPT_fno_dwarf_directory_asm); Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp === --- cfe/trunk/lib/CodeGen/BackendUtil.cpp +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp @@ -595,6 +595,8 @@ Options.MCOptions.MCNoExecStack = CodeGenOpts.NoExecStack; Options.MCOptions.MCIncrementalLinkerCompatible = CodeGenOpts.IncrementalLinkerCompatible; + Options.MCOptions.MCPIECopyRelocations = + CodeGenOpts.PIECopyRelocation
[PATCH] D19996: New clang option -mpie-copy-relocationss to indicate support for linker copy relocations when linking as PIE
tmsriram updated this revision to Diff 75189. tmsriram added a comment. - Fix Help text. - Fix indentation. https://reviews.llvm.org/D19996 Files: include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.def lib/CodeGen/BackendUtil.cpp lib/Driver/Tools.cpp lib/Frontend/CompilerInvocation.cpp Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -586,6 +586,8 @@ Opts.RelaxAll = Args.hasArg(OPT_mrelax_all); Opts.IncrementalLinkerCompatible = Args.hasArg(OPT_mincremental_linker_compatible); + Opts.PIECopyRelocations = + Args.hasArg(OPT_mpie_copy_relocations); Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer); Opts.SaveTempLabels = Args.hasArg(OPT_msave_temp_labels); Opts.NoDwarfDirectoryAsm = Args.hasArg(OPT_fno_dwarf_directory_asm); Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -4499,6 +4499,12 @@ CmdArgs.push_back("-mms-bitfields"); } + if (Args.hasFlag(options::OPT_mpie_copy_relocations, + options::OPT_mno_pie_copy_relocations, + false)) { +CmdArgs.push_back("-mpie-copy-relocations"); + } + // This is a coarse approximation of what llvm-gcc actually does, both // -fasynchronous-unwind-tables and -fnon-call-exceptions interact in more // complicated ways. Index: lib/CodeGen/BackendUtil.cpp === --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -595,6 +595,8 @@ Options.MCOptions.MCNoExecStack = CodeGenOpts.NoExecStack; Options.MCOptions.MCIncrementalLinkerCompatible = CodeGenOpts.IncrementalLinkerCompatible; + Options.MCOptions.MCPIECopyRelocations = + CodeGenOpts.PIECopyRelocations; Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings; Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose; Options.MCOptions.PreserveAsmComments = CodeGenOpts.PreserveAsmComments; Index: include/clang/Frontend/CodeGenOptions.def === --- include/clang/Frontend/CodeGenOptions.def +++ include/clang/Frontend/CodeGenOptions.def @@ -252,6 +252,9 @@ /// Whether to report the hotness of the code region for optimization remarks. CODEGENOPT(DiagnosticsWithHotness, 1, 0) +/// Whether copy relocations support is available when building as PIE. +CODEGENOPT(PIECopyRelocations, 1, 0) + #undef CODEGENOPT #undef ENUM_CODEGENOPT #undef VALUE_CODEGENOPT Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1691,6 +1691,10 @@ def mimplicit_float : Flag<["-"], "mimplicit-float">, Group; def mrecip : Flag<["-"], "mrecip">, Group; def mrecip_EQ : CommaJoined<["-"], "mrecip=">, Group, Flags<[CC1Option]>; +def mpie_copy_relocations : Flag<["-"], "mpie-copy-relocations">, Group, + Flags<[CC1Option]>, + HelpText<"Use copy relocations support for PIE builds">; +def mno_pie_copy_relocations : Flag<["-"], "mno-pie-copy-relocations">, Group; def mx87 : Flag<["-"], "mx87">, Group; def m80387 : Flag<["-"], "m80387">, Alias; def msse2 : Flag<["-"], "msse2">, Group; Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -586,6 +586,8 @@ Opts.RelaxAll = Args.hasArg(OPT_mrelax_all); Opts.IncrementalLinkerCompatible = Args.hasArg(OPT_mincremental_linker_compatible); + Opts.PIECopyRelocations = + Args.hasArg(OPT_mpie_copy_relocations); Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer); Opts.SaveTempLabels = Args.hasArg(OPT_msave_temp_labels); Opts.NoDwarfDirectoryAsm = Args.hasArg(OPT_fno_dwarf_directory_asm); Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -4499,6 +4499,12 @@ CmdArgs.push_back("-mms-bitfields"); } + if (Args.hasFlag(options::OPT_mpie_copy_relocations, + options::OPT_mno_pie_copy_relocations, + false)) { +CmdArgs.push_back("-mpie-copy-relocations"); + } + // This is a coarse approximation of what llvm-gcc actually does, both // -fasynchronous-unwind-tables and -fnon-call-exceptions interact in more // complicated ways. Index: lib/CodeGen/BackendUtil.cpp === --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -595,6 +595,8 @@ Options.MCOptions.MCNoExecStack = CodeGenOpts.NoExecStack; Options.MCOptions.MCIncrementalLinkerCompat
[PATCH] D19996: New clang option -mpie-copy-relocationss to indicate support for linker copy relocations when linking as PIE
tmsriram added inline comments. Comment at: lib/Frontend/CompilerInvocation.cpp:589 Args.hasArg(OPT_mincremental_linker_compatible); + Opts.PIECopyRelocations = + Args.hasArg(OPT_mpie_copy_relocations); mgrang wrote: > You should also check for the negative flag here: > > Opts.PIECopyRelocations = Args.hasFlag(options::OPT_mpie_copy_relocations, > options::OPT_mno_pie_copy_relocations, false); mpie_copy_relocations is the only CC1 flag here and that is pushed into CC1 command after checking for the negative. https://reviews.llvm.org/D19996 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D19996: New clang option -mpie-copy-relocationss to indicate support for linker copy relocations when linking as PIE
mgrang added inline comments. Comment at: lib/Driver/Tools.cpp:4502 + if (Args.hasFlag(options::OPT_mpie_copy_relocations, options::OPT_mno_pie_copy_relocations, + false)) { Please fix indentation. Comment at: lib/Frontend/CompilerInvocation.cpp:589 Args.hasArg(OPT_mincremental_linker_compatible); + Opts.PIECopyRelocations = + Args.hasArg(OPT_mpie_copy_relocations); You should also check for the negative flag here: Opts.PIECopyRelocations = Args.hasFlag(options::OPT_mpie_copy_relocations, options::OPT_mno_pie_copy_relocations, false); https://reviews.llvm.org/D19996 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D19996: New clang option -mpie-copy-relocationss to indicate support for linker copy relocations when linking as PIE
rnk accepted this revision. rnk added a comment. This revision is now accepted and ready to land. lgtm Comment at: include/clang/Driver/Options.td:1696 + Flags<[CC1Option]>, + HelpText<"Copy Relocations support for PIE builds">; +def mno_pie_copy_relocations : Flag<["-"], "mno-pie-copy-relocations">, Group, rnk wrote: > I agree with Rafael, this needs a verb, like "Use copy relocations in PIE > builds" or something. I guess "avail" is a verb, but I've never seen anyone use it. I'd really rather use "use". :) https://reviews.llvm.org/D19996 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D19996: New clang option -mpie-copy-relocationss to indicate support for linker copy relocations when linking as PIE
tmsriram updated this revision to Diff 75179. tmsriram added a comment. - Changed help text to "Avail copy relocations support for PIE builds" - Removed mno-pie... as a CC1 option - Removed help text from mno-pie.. https://reviews.llvm.org/D19996 Files: include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.def lib/CodeGen/BackendUtil.cpp lib/Driver/Tools.cpp lib/Frontend/CompilerInvocation.cpp Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -586,6 +586,8 @@ Opts.RelaxAll = Args.hasArg(OPT_mrelax_all); Opts.IncrementalLinkerCompatible = Args.hasArg(OPT_mincremental_linker_compatible); + Opts.PIECopyRelocations = + Args.hasArg(OPT_mpie_copy_relocations); Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer); Opts.SaveTempLabels = Args.hasArg(OPT_msave_temp_labels); Opts.NoDwarfDirectoryAsm = Args.hasArg(OPT_fno_dwarf_directory_asm); Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -4499,6 +4499,11 @@ CmdArgs.push_back("-mms-bitfields"); } + if (Args.hasFlag(options::OPT_mpie_copy_relocations, options::OPT_mno_pie_copy_relocations, + false)) { +CmdArgs.push_back("-mpie-copy-relocations"); + } + // This is a coarse approximation of what llvm-gcc actually does, both // -fasynchronous-unwind-tables and -fnon-call-exceptions interact in more // complicated ways. Index: lib/CodeGen/BackendUtil.cpp === --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -595,6 +595,8 @@ Options.MCOptions.MCNoExecStack = CodeGenOpts.NoExecStack; Options.MCOptions.MCIncrementalLinkerCompatible = CodeGenOpts.IncrementalLinkerCompatible; + Options.MCOptions.MCPIECopyRelocations = + CodeGenOpts.PIECopyRelocations; Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings; Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose; Options.MCOptions.PreserveAsmComments = CodeGenOpts.PreserveAsmComments; Index: include/clang/Frontend/CodeGenOptions.def === --- include/clang/Frontend/CodeGenOptions.def +++ include/clang/Frontend/CodeGenOptions.def @@ -252,6 +252,9 @@ /// Whether to report the hotness of the code region for optimization remarks. CODEGENOPT(DiagnosticsWithHotness, 1, 0) +/// Whether copy relocations support is available when building as PIE. +CODEGENOPT(PIECopyRelocations, 1, 0) + #undef CODEGENOPT #undef ENUM_CODEGENOPT #undef VALUE_CODEGENOPT Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1691,6 +1691,10 @@ def mimplicit_float : Flag<["-"], "mimplicit-float">, Group; def mrecip : Flag<["-"], "mrecip">, Group; def mrecip_EQ : CommaJoined<["-"], "mrecip=">, Group, Flags<[CC1Option]>; +def mpie_copy_relocations : Flag<["-"], "mpie-copy-relocations">, Group, + Flags<[CC1Option]>, + HelpText<"Avail copy relocations support for PIE builds">; +def mno_pie_copy_relocations : Flag<["-"], "mno-pie-copy-relocations">, Group; def mx87 : Flag<["-"], "mx87">, Group; def m80387 : Flag<["-"], "m80387">, Alias; def msse2 : Flag<["-"], "msse2">, Group; Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -586,6 +586,8 @@ Opts.RelaxAll = Args.hasArg(OPT_mrelax_all); Opts.IncrementalLinkerCompatible = Args.hasArg(OPT_mincremental_linker_compatible); + Opts.PIECopyRelocations = + Args.hasArg(OPT_mpie_copy_relocations); Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer); Opts.SaveTempLabels = Args.hasArg(OPT_msave_temp_labels); Opts.NoDwarfDirectoryAsm = Args.hasArg(OPT_fno_dwarf_directory_asm); Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -4499,6 +4499,11 @@ CmdArgs.push_back("-mms-bitfields"); } + if (Args.hasFlag(options::OPT_mpie_copy_relocations, options::OPT_mno_pie_copy_relocations, + false)) { +CmdArgs.push_back("-mpie-copy-relocations"); + } + // This is a coarse approximation of what llvm-gcc actually does, both // -fasynchronous-unwind-tables and -fnon-call-exceptions interact in more // complicated ways. Index: lib/CodeGen/BackendUtil.cpp === --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -595,6 +595,8 @@ Options.MCOptions.MCNoExecStack = C
[PATCH] D19996: New clang option -mpie-copy-relocationss to indicate support for linker copy relocations when linking as PIE
rnk added a comment. In https://reviews.llvm.org/D19996#422906, @rafael wrote: > Is there a gcc option or they just assume they are targeting the > linker that was around when gcc was built? IIRC there's no GCC option. They base their decision on the configure-time check like you suggested. Comment at: include/clang/Driver/Options.td:1696 + Flags<[CC1Option]>, + HelpText<"Copy Relocations support for PIE builds">; +def mno_pie_copy_relocations : Flag<["-"], "mno-pie-copy-relocations">, Group, I agree with Rafael, this needs a verb, like "Use copy relocations in PIE builds" or something. Comment at: include/clang/Driver/Options.td:1698 +def mno_pie_copy_relocations : Flag<["-"], "mno-pie-copy-relocations">, Group, + Flags<[CC1Option]>, + HelpText<"No Copy Relocations support for PIE builds">; The "no" option variants don't need to be CC1 options. Comment at: include/clang/Driver/Options.td:1699 + Flags<[CC1Option]>, + HelpText<"No Copy Relocations support for PIE builds">; def mx87 : Flag<["-"], "mx87">, Group; I don't think we need help text for the "no" variant. I think we add help text to "no" flags when the flag is on by default, for example `-fno-exceptions`. https://reviews.llvm.org/D19996 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D19996: New clang option -mpie-copy-relocationss to indicate support for linker copy relocations when linking as PIE
tmsriram retitled this revision from "New clang option -mpiecopyrelocs to indicate support for linker copy relocations when linking as PIE" to "New clang option -mpie-copy-relocationss to indicate support for linker copy relocations when linking as PIE". tmsriram updated the summary for this revision. tmsriram added a reviewer: davide. tmsriram updated this revision to Diff 74757. tmsriram added a comment. - Option name changed to -mpie-copy-relocations - Option sets MCPIECopyRelocations in MCOptions https://reviews.llvm.org/D19996 Files: include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.def lib/CodeGen/BackendUtil.cpp lib/Driver/Tools.cpp lib/Frontend/CompilerInvocation.cpp Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -586,6 +586,8 @@ Opts.RelaxAll = Args.hasArg(OPT_mrelax_all); Opts.IncrementalLinkerCompatible = Args.hasArg(OPT_mincremental_linker_compatible); + Opts.PIECopyRelocations = + Args.hasArg(OPT_mpie_copy_relocations); Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer); Opts.SaveTempLabels = Args.hasArg(OPT_msave_temp_labels); Opts.NoDwarfDirectoryAsm = Args.hasArg(OPT_fno_dwarf_directory_asm); Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -4499,6 +4499,11 @@ CmdArgs.push_back("-mms-bitfields"); } + if (Args.hasFlag(options::OPT_mpie_copy_relocations, options::OPT_mno_pie_copy_relocations, + false)) { +CmdArgs.push_back("-mpie-copy-relocations"); + } + // This is a coarse approximation of what llvm-gcc actually does, both // -fasynchronous-unwind-tables and -fnon-call-exceptions interact in more // complicated ways. Index: lib/CodeGen/BackendUtil.cpp === --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -595,6 +595,8 @@ Options.MCOptions.MCNoExecStack = CodeGenOpts.NoExecStack; Options.MCOptions.MCIncrementalLinkerCompatible = CodeGenOpts.IncrementalLinkerCompatible; + Options.MCOptions.MCPIECopyRelocations = + CodeGenOpts.PIECopyRelocations; Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings; Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose; Options.MCOptions.PreserveAsmComments = CodeGenOpts.PreserveAsmComments; Index: include/clang/Frontend/CodeGenOptions.def === --- include/clang/Frontend/CodeGenOptions.def +++ include/clang/Frontend/CodeGenOptions.def @@ -252,6 +252,9 @@ /// Whether to report the hotness of the code region for optimization remarks. CODEGENOPT(DiagnosticsWithHotness, 1, 0) +/// Whether copy relocations support is available when building as PIE. +CODEGENOPT(PIECopyRelocations, 1, 0) + #undef CODEGENOPT #undef ENUM_CODEGENOPT #undef VALUE_CODEGENOPT Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1691,6 +1691,12 @@ def mimplicit_float : Flag<["-"], "mimplicit-float">, Group; def mrecip : Flag<["-"], "mrecip">, Group; def mrecip_EQ : CommaJoined<["-"], "mrecip=">, Group, Flags<[CC1Option]>; +def mpie_copy_relocations : Flag<["-"], "mpie-copy-relocations">, Group, + Flags<[CC1Option]>, + HelpText<"Copy Relocations support for PIE builds">; +def mno_pie_copy_relocations : Flag<["-"], "mno-pie-copy-relocations">, Group, + Flags<[CC1Option]>, + HelpText<"No Copy Relocations support for PIE builds">; def mx87 : Flag<["-"], "mx87">, Group; def m80387 : Flag<["-"], "m80387">, Alias; def msse2 : Flag<["-"], "msse2">, Group; Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -586,6 +586,8 @@ Opts.RelaxAll = Args.hasArg(OPT_mrelax_all); Opts.IncrementalLinkerCompatible = Args.hasArg(OPT_mincremental_linker_compatible); + Opts.PIECopyRelocations = + Args.hasArg(OPT_mpie_copy_relocations); Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer); Opts.SaveTempLabels = Args.hasArg(OPT_msave_temp_labels); Opts.NoDwarfDirectoryAsm = Args.hasArg(OPT_fno_dwarf_directory_asm); Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -4499,6 +4499,11 @@ CmdArgs.push_back("-mms-bitfields"); } + if (Args.hasFlag(options::OPT_mpie_copy_relocations, options::OPT_mno_pie_copy_relocations, + false)) { +CmdArgs.push_back("-mpie-copy-relocations"); + } + // This is a coarse approxi