[lld] r301710 - Eliminate .debug_gnu_pub{names, types} if -gdb-index is given.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 28 15:46:56 PDT 2017


Author: ruiu
Date: Fri Apr 28 17:46:55 2017
New Revision: 301710

URL: http://llvm.org/viewvc/llvm-project?rev=301710&view=rev
Log:
Eliminate .debug_gnu_pub{names,types} if -gdb-index is given.

This patch is to ignore .debug_gnu_pub{names,types} sections if the
-gdb-index option was given.

Differential Revision: https://reviews.llvm.org/D32662

Added:
    lld/trunk/test/ELF/debug-gnu-pubnames.s
Modified:
    lld/trunk/ELF/InputFiles.cpp

Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=301710&r1=301709&r2=301710&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Fri Apr 28 17:46:55 2017
@@ -461,6 +461,15 @@ elf::ObjectFile<ELFT>::createInputSectio
   if (Config->Strip != StripPolicy::None && Name.startswith(".debug"))
     return &InputSection::Discarded;
 
+  // If -gdb-index is given, LLD creates .gdb_index section, and that
+  // section serves the same purpose as .debug_gnu_pub{names,types} sections.
+  // If that's the case, we want to eliminate .debug_gnu_pub{names,types}
+  // because they are redundant and can waste large amount of disk space
+  // (for example, they are about 400 MiB in total for a clang debug build.)
+  if (Config->GdbIndex &&
+      (Name == ".debug_gnu_pubnames" || Name == ".debug_gnu_pubtypes"))
+    return &InputSection::Discarded;
+
   // The linkonce feature is a sort of proto-comdat. Some glibc i386 object
   // files contain definitions of symbol "__x86.get_pc_thunk.bx" in linkonce
   // sections. Drop those sections to avoid duplicate symbol errors.

Added: lld/trunk/test/ELF/debug-gnu-pubnames.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/debug-gnu-pubnames.s?rev=301710&view=auto
==============================================================================
--- lld/trunk/test/ELF/debug-gnu-pubnames.s (added)
+++ lld/trunk/test/ELF/debug-gnu-pubnames.s Fri Apr 28 17:46:55 2017
@@ -0,0 +1,10 @@
+# REQUIRES: x86
+# RUN: ld.lld -e main %p/Inputs/gdb-index-a.elf %p/Inputs/gdb-index-b.elf -o %t1.exe
+# RUN: llvm-readobj -sections %t1.exe | FileCheck -check-prefix=CHECK1 %s
+# CHECK1: Name: .debug_gnu_pubnames
+# CHECK1: Name: .debug_gnu_pubtypes
+
+# RUN: ld.lld -gdb-index -e main %p/Inputs/gdb-index-a.elf %p/Inputs/gdb-index-b.elf -o %t2.exe
+# RUN: llvm-readobj -sections %t2.exe | FileCheck -check-prefix=CHECK2 %s
+# CHECK2-NOT: Name: .debug_gnu_pubnames
+# CHECK2-NOT: Name: .debug_gnu_pubtypes




More information about the llvm-commits mailing list