From cbed0e615b3658add66600d89e1d47c80a99a22d Mon Sep 17 00:00:00 2001 From: George Rimar Date: Fri, 3 Nov 2017 08:13:16 +0000 Subject: [PATCH] [ELF] - Teach LLD to strip .zdebug_* sections when --strip-debug/--strip-all is specified. Currently we do not strip .zdebug_*, what looks wrong. Also this simplifies the testcase we have for this options. Differential revision: https://reviews.llvm.org/D39552 llvm-svn: 317306 --- lld/ELF/InputFiles.cpp | 3 ++- lld/test/ELF/strip-debug.s | 27 ++++++++------------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 98329cdc0cde3..1210666e42c33 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -537,7 +537,8 @@ InputSectionBase *ObjFile::createInputSection(const Elf_Shdr &Sec) { return &InputSection::Discarded; } - if (Config->Strip != StripPolicy::None && Name.startswith(".debug")) + if (Config->Strip != StripPolicy::None && + (Name.startswith(".debug") || Name.startswith(".zdebug"))) return &InputSection::Discarded; // The linkonce feature is a sort of proto-comdat. Some glibc i386 object diff --git a/lld/test/ELF/strip-debug.s b/lld/test/ELF/strip-debug.s index 81f7572aa7c58..8005cfacee6cd 100644 --- a/lld/test/ELF/strip-debug.s +++ b/lld/test/ELF/strip-debug.s @@ -1,25 +1,14 @@ # REQUIRES: x86 - -# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux -g %s -o %t -# RUN: ld.lld %t -o %t2 -# RUN: llvm-readobj -sections -symbols %t2 | FileCheck -check-prefix=DEFAULT %s +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t # RUN: ld.lld %t -o %t2 --strip-debug -# RUN: llvm-readobj -sections -symbols %t2 | FileCheck -check-prefix=STRIP %s +# RUN: llvm-readobj -sections %t2 | FileCheck %s # RUN: ld.lld %t -o %t2 -S -# RUN: llvm-readobj -sections -symbols %t2 | FileCheck -check-prefix=STRIP %s +# RUN: llvm-readobj -sections %t2 | FileCheck %s # RUN: ld.lld %t -o %t2 --strip-all -# RUN: llvm-readobj -sections -symbols %t2 | FileCheck -check-prefix=STRIP %s - -# DEFAULT: Name: .debug_info -# DEFAULT: Name: .debug_abbrev -# DEFAULT: Name: .debug_aranges -# DEFAULT: Name: .debug_line +# RUN: llvm-readobj -sections %t2 | FileCheck %s -# STRIP-NOT: Name: .debug_info -# STRIP-NOT: Name: .debug_abbrev -# STRIP-NOT: Name: .debug_aranges -# STRIP-NOT: Name: .debug_line +# CHECK-NOT: Foo +# CHECK-NOT: Bar -.globl _start -_start: - ret +.section .debug_Foo,"",@progbits +.section .zdebug_Bar,"",@progbits