[PATCH] D81359: [ELF] Add --[no-]relax for RISC-V

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 8 10:30:12 PDT 2020


MaskRay updated this revision to Diff 269281.
MaskRay edited the summary of this revision.
MaskRay removed subscribers: kito-cheng, shiva0217, rogfer01, rkruppe, Jim, sameer.abuasal.
MaskRay added a comment.

Add an x86-64 test


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81359/new/

https://reviews.llvm.org/D81359

Files:
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/Options.td
  lld/docs/ld.lld.1
  lld/test/ELF/x86-64-gotpc-relax.s


Index: lld/test/ELF/x86-64-gotpc-relax.s
===================================================================
--- lld/test/ELF/x86-64-gotpc-relax.s
+++ lld/test/ELF/x86-64-gotpc-relax.s
@@ -4,6 +4,12 @@
 # RUN: llvm-readobj -r %t1 | FileCheck --check-prefix=RELOC %s
 # RUN: llvm-objdump -d %t1 | FileCheck --check-prefix=DISASM %s
 
+## Accept but ignore --relax and --no-relax.
+# RUN: ld.lld --relax %t.o -o %t2
+# RUN: cmp %t1 %t2
+# RUN: ld.lld --no-relax %t.o -o %t3
+# RUN: cmp %t1 %t3
+
 ## There is no relocations.
 # RELOC:    Relocations [
 # RELOC:    ]
Index: lld/docs/ld.lld.1
===================================================================
--- lld/docs/ld.lld.1
+++ lld/docs/ld.lld.1
@@ -308,6 +308,8 @@
 Page align sections.
 .It Fl -no-omagic
 Do not set the text data sections to be writable, page align sections.
+.It Fl -no-relax
+Disable target-specific relaxations. This is currently a no-op.
 .It Fl -no-rosegment
 Do not put read-only non-executable sections in their own segment.
 .It Fl -no-undefined-version
Index: lld/ELF/Options.td
===================================================================
--- lld/ELF/Options.td
+++ lld/ELF/Options.td
@@ -337,6 +337,10 @@
 def print_map: F<"print-map">,
   HelpText<"Print a link map to the standard output">;
 
+defm relax: BB<"relax",
+  "Enable target-specific relaxations (default)",
+  "Disable target-specific relaxations">;
+
 defm reproduce: Eq<"reproduce", "Write a tar file containing input files and command line options to reproduce link">;
 
 defm rosegment: BB<"rosegment",
Index: lld/ELF/Driver.cpp
===================================================================
--- lld/ELF/Driver.cpp
+++ lld/ELF/Driver.cpp
@@ -974,6 +974,7 @@
   config->printArchiveStats = args.getLastArgValue(OPT_print_archive_stats);
   config->printSymbolOrder =
       args.getLastArgValue(OPT_print_symbol_order);
+  config->relax = args.hasFlag(OPT_relax, OPT_no_relax, true);
   config->rpath = getRpath(args);
   config->relocatable = args.hasArg(OPT_relocatable);
   config->saveTemps = args.hasArg(OPT_save_temps);
Index: lld/ELF/Config.h
===================================================================
--- lld/ELF/Config.h
+++ lld/ELF/Config.h
@@ -185,6 +185,7 @@
   bool pie;
   bool printGcSections;
   bool printIcfSections;
+  bool relax;
   bool relocatable;
   bool relrPackDynRelocs;
   bool saveTemps;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81359.269281.patch
Type: text/x-patch
Size: 2392 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200608/827fa768/attachment.bin>


More information about the llvm-commits mailing list