<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, May 28, 2016 at 7:01 PM, Rafael Espindola via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: rafael<br>
Date: Sat May 28 21:01:14 2016<br>
New Revision: 271162<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=271162&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=271162&view=rev</a><br>
Log:<br>
Handle -Wa,--mrelax-relocations=[no|yes].<br>
<br>
Added:<br>
    cfe/trunk/test/CodeGen/relax.c<br>
    cfe/trunk/test/Driver/relax.c<br>
    cfe/trunk/test/Driver/relax.s<br>
Modified:<br>
    cfe/trunk/include/clang/Driver/CC1Options.td<br>
    cfe/trunk/include/clang/Frontend/CodeGenOptions.def<br>
    cfe/trunk/lib/CodeGen/BackendUtil.cpp<br>
    cfe/trunk/lib/Driver/Tools.cpp<br>
    cfe/trunk/lib/Frontend/CompilerInvocation.cpp<br>
    cfe/trunk/tools/driver/cc1as_main.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Driver/CC1Options.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=271162&r1=271161&r2=271162&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=271162&r1=271161&r2=271162&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)<br>
+++ cfe/trunk/include/clang/Driver/CC1Options.td Sat May 28 21:01:14 2016<br>
@@ -143,6 +143,8 @@ def mno_exec_stack : Flag<["-"], "mnoexe<br>
   HelpText<"Mark the file as not needing an executable stack">;<br>
 def massembler_fatal_warnings : Flag<["-"], "massembler-fatal-warnings">,<br>
   HelpText<"Make assembler warnings fatal">;<br>
+def mrelax_relocations : Flag<["--"], "mrelax-relocations">,<br>
+    HelpText<"Use relaxabel elf relocations">;<br></blockquote><div><br></div><div>relaxable?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
 def compress_debug_sections : Flag<["-"], "compress-debug-sections">,<br>
     HelpText<"Compress DWARF debug sections using zlib">;<br>
 def msave_temp_labels : Flag<["-"], "msave-temp-labels">,<br>
<br>
Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=271162&r1=271161&r2=271162&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=271162&r1=271161&r2=271162&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)<br>
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Sat May 28 21:01:14 2016<br>
@@ -30,6 +30,7 @@ CODEGENOPT(Name, Bits, Default)<br>
<br>
 CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as<br>
 CODEGENOPT(CompressDebugSections, 1, 0) ///< -Wa,-compress-debug-sections<br>
+CODEGENOPT(RelaxELFRelocations, 1, 0) ///< -Wa,--mrelax-relocations<br>
 CODEGENOPT(AsmVerbose        , 1, 0) ///< -dA, -fverbose-asm.<br>
 CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) operator new<br>
 CODEGENOPT(Autolink          , 1, 1) ///< -fno-autolink<br>
<br>
Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=271162&r1=271161&r2=271162&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=271162&r1=271161&r2=271162&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Sat May 28 21:01:14 2016<br>
@@ -593,6 +593,7 @@ TargetMachine *EmitAssemblyHelper::Creat<br>
   Options.UseInitArray = CodeGenOpts.UseInitArray;<br>
   Options.DisableIntegratedAS = CodeGenOpts.DisableIntegratedAS;<br>
   Options.CompressDebugSections = CodeGenOpts.CompressDebugSections;<br>
+  Options.RelaxELFRelocations = CodeGenOpts.RelaxELFRelocations;<br>
<br>
   // Set EABI version.<br>
   Options.EABIVersion = llvm::StringSwitch<llvm::EABI>(TargetOpts.EABIVersion)<br>
<br>
Modified: cfe/trunk/lib/Driver/Tools.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=271162&r1=271161&r2=271162&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=271162&r1=271161&r2=271162&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/Tools.cpp (original)<br>
+++ cfe/trunk/lib/Driver/Tools.cpp Sat May 28 21:01:14 2016<br>
@@ -2797,6 +2797,8 @@ static void CollectArgsForIntegratedAsse<br>
   // When using an integrated assembler, translate -Wa, and -Xassembler<br>
   // options.<br>
   bool CompressDebugSections = false;<br>
+<br>
+  bool UseRelaxRelocations = false;<br>
   const char *MipsTargetFeature = nullptr;<br>
   for (const Arg *A :<br>
        Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) {<br>
@@ -2872,6 +2874,12 @@ static void CollectArgsForIntegratedAsse<br>
       } else if (Value == "-nocompress-debug-sections" ||<br>
                  Value == "--nocompress-debug-sections") {<br>
         CompressDebugSections = false;<br>
+      } else if (Value == "-mrelax-relocations=yes" ||<br>
+                 Value == "--mrelax-relocations=yes") {<br>
+        UseRelaxRelocations = true;<br>
+      } else if (Value == "-mrelax-relocations=no" ||<br>
+                 Value == "--mrelax-relocations=no") {<br>
+        UseRelaxRelocations = false;<br>
       } else if (Value.startswith("-I")) {<br>
         CmdArgs.push_back(Value.data());<br>
         // We need to consume the next argument if the current arg is a plain<br>
@@ -2903,6 +2911,8 @@ static void CollectArgsForIntegratedAsse<br>
     else<br>
       D.Diag(diag::warn_debug_compression_unavailable);<br>
   }<br>
+  if (UseRelaxRelocations)<br>
+    CmdArgs.push_back("--mrelax-relocations");<br>
   if (MipsTargetFeature != nullptr) {<br>
     CmdArgs.push_back("-target-feature");<br>
     CmdArgs.push_back(MipsTargetFeature);<br>
<br>
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=271162&r1=271161&r2=271162&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=271162&r1=271161&r2=271162&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)<br>
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Sat May 28 21:01:14 2016<br>
@@ -683,6 +683,7 @@ static bool ParseCodeGenArgs(CodeGenOpti<br>
   Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);<br>
   Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);<br>
   Opts.CompressDebugSections = Args.hasArg(OPT_compress_debug_sections);<br>
+  Opts.RelaxELFRelocations = Args.hasArg(OPT_mrelax_relocations);<br>
   Opts.DebugCompilationDir = Args.getLastArgValue(OPT_fdebug_compilation_dir);<br>
   for (auto A : Args.filtered(OPT_mlink_bitcode_file, OPT_mlink_cuda_bitcode)) {<br>
     unsigned LinkFlags = llvm::Linker::Flags::None;<br>
<br>
Added: cfe/trunk/test/CodeGen/relax.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/relax.c?rev=271162&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/relax.c?rev=271162&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGen/relax.c (added)<br>
+++ cfe/trunk/test/CodeGen/relax.c Sat May 28 21:01:14 2016<br>
@@ -0,0 +1,9 @@<br>
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-obj --mrelax-relocations %s -mrelocation-model pic -o %t<br>
+// RUN: llvm-readobj -r %t | FileCheck  %s<br>
+<br>
+// CHECK: R_X86_64_REX_GOTPCRELX foo<br>
+<br>
+extern int foo;<br>
+int *f(void) {<br>
+  return &foo;<br>
+}<br>
<br>
Added: cfe/trunk/test/Driver/relax.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/relax.c?rev=271162&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/relax.c?rev=271162&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Driver/relax.c (added)<br>
+++ cfe/trunk/test/Driver/relax.c Sat May 28 21:01:14 2016<br>
@@ -0,0 +1,4 @@<br>
+// RUN: %clang -### -c -integrated-as -Wa,--mrelax-relocations=yes %s 2>&1 | FileCheck  %s<br>
+<br>
+// CHECK: "-cc1"<br>
+// CHECK: "--mrelax-relocations"<br>
<br>
Added: cfe/trunk/test/Driver/relax.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/relax.s?rev=271162&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/relax.s?rev=271162&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Driver/relax.s (added)<br>
+++ cfe/trunk/test/Driver/relax.s Sat May 28 21:01:14 2016<br>
@@ -0,0 +1,12 @@<br>
+// REQUIRES: x86-registered-target<br>
+// RUN: %clang -### -c -integrated-as -Wa,--mrelax-relocations=yes %s 2>&1 | FileCheck  %s<br>
+<br>
+// CHECK: "-cc1as"<br>
+// CHECK: "--mrelax-relocations"<br>
+<br>
+// RUN: %clang -cc1as -triple x86_64-pc-linux --mrelax-relocations %s -o %t  -filetype obj<br>
+// RUN: llvm-readobj -r %t | FileCheck --check-prefix=REL %s<br>
+<br>
+// REL: R_X86_64_REX_GOTPCRELX foo<br>
+<br>
+        movq   foo@GOTPCREL(%rip), %rax<br>
<br>
Modified: cfe/trunk/tools/driver/cc1as_main.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=271162&r1=271161&r2=271162&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=271162&r1=271161&r2=271162&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)<br>
+++ cfe/trunk/tools/driver/cc1as_main.cpp Sat May 28 21:01:14 2016<br>
@@ -88,6 +88,7 @@ struct AssemblerInvocation {<br>
   unsigned SaveTemporaryLabels : 1;<br>
   unsigned GenDwarfForAssembly : 1;<br>
   unsigned CompressDebugSections : 1;<br>
+  unsigned RelaxELFRelocations : 1;<br>
   unsigned DwarfVersion;<br>
   std::string DwarfDebugFlags;<br>
   std::string DwarfDebugProducer;<br>
@@ -200,6 +201,7 @@ bool AssemblerInvocation::CreateFromArgs<br>
   // Any DebugInfoKind implies GenDwarfForAssembly.<br>
   Opts.GenDwarfForAssembly = Args.hasArg(OPT_debug_info_kind_EQ);<br>
   Opts.CompressDebugSections = Args.hasArg(OPT_compress_debug_sections);<br>
+  Opts.RelaxELFRelocations = Args.hasArg(OPT_mrelax_relocations);<br>
   Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 2, Diags);<br>
   Opts.DwarfDebugFlags = Args.getLastArgValue(OPT_dwarf_debug_flags);<br>
   Opts.DwarfDebugProducer = Args.getLastArgValue(OPT_dwarf_debug_producer);<br>
@@ -315,6 +317,8 @@ static bool ExecuteAssembler(AssemblerIn<br>
   if (Opts.CompressDebugSections)<br>
     MAI->setCompressDebugSections(DebugCompressionType::DCT_ZlibGnu);<br>
<br>
+  MAI->setRelaxELFRelocations(Opts.RelaxELFRelocations);<br>
+<br>
   bool IsBinary = Opts.OutputType == AssemblerInvocation::FT_Obj;<br>
   std::unique_ptr<raw_fd_ostream> FDOS = getOutputStream(Opts, Diags, IsBinary);<br>
   if (!FDOS)<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>