From 38eab876714e3b7e1e3969e629ff173024043ecd Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Tue, 29 Aug 2017 16:53:24 +0000 Subject: [PATCH] Add -no-eh-frame-hdr which negates -eh-frame-hdr. Note that ld.bfd and ld.gold have the option. llvm-svn: 312010 --- lld/ELF/Driver.cpp | 3 ++- lld/ELF/Options.td | 3 +++ lld/test/ELF/eh-frame-hdr.s | 12 ++++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index efb62b43288e..8ae7ee92eb59 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -633,7 +633,8 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) { Config->DisableVerify = Args.hasArg(OPT_disable_verify); Config->Discard = getDiscard(Args); Config->DynamicLinker = getDynamicLinker(Args); - Config->EhFrameHdr = Args.hasArg(OPT_eh_frame_hdr); + Config->EhFrameHdr = + getArg(Args, OPT_eh_frame_hdr, OPT_no_eh_frame_hdr, false); Config->EmitRelocs = Args.hasArg(OPT_emit_relocs); Config->EnableNewDtags = !Args.hasArg(OPT_disable_new_dtags); Config->Entry = Args.getLastArgValue(OPT_entry); diff --git a/lld/ELF/Options.td b/lld/ELF/Options.td index 1345038ec20b..f89ca7007fa8 100644 --- a/lld/ELF/Options.td +++ b/lld/ELF/Options.td @@ -176,6 +176,9 @@ def no_demangle: F<"no-demangle">, def no_dynamic_linker: F<"no-dynamic-linker">, HelpText<"Inhibit output of .interp section">; +def no_eh_frame_hdr: F<"no-eh-frame-hdr">, + HelpText<"Do not create .eh_frame_hdr section">; + def no_export_dynamic: F<"no-export-dynamic">; def no_fatal_warnings: F<"no-fatal-warnings">; diff --git a/lld/test/ELF/eh-frame-hdr.s b/lld/test/ELF/eh-frame-hdr.s index 35c14a4b65dd..4498d7d30eaa 100644 --- a/lld/test/ELF/eh-frame-hdr.s +++ b/lld/test/ELF/eh-frame-hdr.s @@ -1,9 +1,17 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o + // RUN: ld.lld %t.o -o %t -// RUN: llvm-readobj -file-headers -s -section-data -program-headers -symbols %t | FileCheck %s --check-prefix=NOHDR +// RUN: llvm-readobj -file-headers -s -section-data -program-headers -symbols %t \ +// RUN: | FileCheck %s --check-prefix=NOHDR + +// RUN: ld.lld -eh-frame-hdr -no-eh-frame-hdr %t.o -o %t +// RUN: llvm-readobj -file-headers -s -section-data -program-headers -symbols %t \ +// RUN: | FileCheck %s --check-prefix=NOHDR + // RUN: ld.lld --eh-frame-hdr %t.o -o %t -// RUN: llvm-readobj -file-headers -s -section-data -program-headers -symbols %t | FileCheck %s --check-prefix=HDR +// RUN: llvm-readobj -file-headers -s -section-data -program-headers -symbols %t \ +// RUN: | FileCheck %s --check-prefix=HDR // RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=HDRDISASM .section foo,"ax",@progbits