diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h --- a/lld/ELF/Config.h +++ b/lld/ELF/Config.h @@ -185,6 +185,7 @@ bool pie; bool printGcSections; bool printIcfSections; + bool relax; bool relocatable; bool relrPackDynRelocs; bool saveTemps; diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp --- a/lld/ELF/Driver.cpp +++ b/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); diff --git a/lld/ELF/Options.td b/lld/ELF/Options.td --- a/lld/ELF/Options.td +++ b/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", diff --git a/lld/docs/ld.lld.1 b/lld/docs/ld.lld.1 --- a/lld/docs/ld.lld.1 +++ b/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 diff --git a/lld/test/ELF/x86-64-gotpc-relax.s b/lld/test/ELF/x86-64-gotpc-relax.s --- a/lld/test/ELF/x86-64-gotpc-relax.s +++ b/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: ]