From 700b1f8a56ca2de891bbc8ae99aa47228dc0881d Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Wed, 1 Nov 2017 02:04:43 +0000 Subject: [PATCH] Add --no-omagic and --no-print-gc-sections. llvm-svn: 317068 --- lld/ELF/Driver.cpp | 5 +++-- lld/ELF/Options.td | 6 ++++++ lld/test/ELF/gc-sections-print.s | 6 ++++++ lld/test/ELF/segments.s | 5 +++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index ce7d4a3..8176a37 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -668,14 +668,15 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) { Config->NoinhibitExec = Args.hasArg(OPT_noinhibit_exec); Config->Nostdlib = Args.hasArg(OPT_nostdlib); Config->OFormatBinary = isOutputFormatBinary(Args); - Config->Omagic = Args.hasArg(OPT_omagic); + Config->Omagic = Args.hasFlag(OPT_omagic, OPT_no_omagic, false); Config->OptRemarksFilename = Args.getLastArgValue(OPT_opt_remarks_filename); Config->OptRemarksWithHotness = Args.hasArg(OPT_opt_remarks_with_hotness); Config->Optimize = getInteger(Args, OPT_O, 1); Config->OrphanHandling = getOrphanHandling(Args); Config->OutputFile = Args.getLastArgValue(OPT_o); Config->Pie = Args.hasFlag(OPT_pie, OPT_nopie, false); - Config->PrintGcSections = Args.hasArg(OPT_print_gc_sections); + Config->PrintGcSections = + Args.hasFlag(OPT_print_gc_sections, OPT_no_print_gc_sections, false); 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 index d3f6c5e..e326f5b 100644 --- a/lld/ELF/Options.td +++ b/lld/ELF/Options.td @@ -201,6 +201,12 @@ def noinhibit_exec: F<"noinhibit-exec">, def nopie: F<"nopie">, HelpText<"Do not create a position independent executable">; +def no_omagic: Flag<["--"], "no-omagic">, MetaVarName<"">, + HelpText<"Do not set the text data sections to be writable">; + +def no_print_gc_sections: F<"no-print-gc-sections">, + HelpText<"Do not list removed unused sections">; + def no_rosegment: F<"no-rosegment">, HelpText<"Do not put read-only non-executable sections in their own segment">; diff --git a/lld/test/ELF/gc-sections-print.s b/lld/test/ELF/gc-sections-print.s index 59177a6..e058241 100644 --- a/lld/test/ELF/gc-sections-print.s +++ b/lld/test/ELF/gc-sections-print.s @@ -5,6 +5,12 @@ # PRINT: removing unused section from '.text.x' in file # PRINT-NEXT: removing unused section from '.text.y' in file +# RUN: ld.lld %t --gc-sections --print-gc-sections --no-print-gc-sections -o %t2 >& %t.log +# RUN: echo >> %t.log +# RUN: FileCheck -check-prefix=NOPRINT %s < %t.log + +# NOPRINT-NOT: removing + .globl _start .protected a, x, y _start: diff --git a/lld/test/ELF/segments.s b/lld/test/ELF/segments.s index 9307ba3..4648ba9 100644 --- a/lld/test/ELF/segments.s +++ b/lld/test/ELF/segments.s @@ -1,7 +1,10 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t + # RUN: ld.lld %t -o %t1 # RUN: llvm-readobj --program-headers %t1 | FileCheck --check-prefix=ROSEGMENT %s +# RUN: ld.lld --omagic --no-omagic %t -o %t1 +# RUN: llvm-readobj --program-headers %t1 | FileCheck --check-prefix=ROSEGMENT %s # ROSEGMENT: ProgramHeader { # ROSEGMENT: Type: PT_LOAD @@ -76,6 +79,8 @@ # RUN: ld.lld -N %t -o %t3 # RUN: llvm-readobj --program-headers %t3 | FileCheck --check-prefix=OMAGIC %s +# RUN: ld.lld --omagic %t -o %t3 +# RUN: llvm-readobj --program-headers %t3 | FileCheck --check-prefix=OMAGIC %s # OMAGIC: ProgramHeader { # OMAGIC: Type: PT_LOAD -- 2.7.4