[PATCH] D52241: Eliminate .{, z}debug_gnu_pub{names, types} sections as early as possible.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 18 11:12:41 PDT 2018
ruiu created this revision.
ruiu added a reviewer: dblaikie.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.
Previously, if --gdb-index is not given, we copy .debug_gnu_pub{names,types}
sections to an output file, which is just a waste of disk space.
If the input sections are compressed, doing it also wastes CPU and memory
because, in order to copy them, we need to uncompress them first.
https://reviews.llvm.org/D52241
Files:
lld/ELF/InputFiles.cpp
lld/test/ELF/debug-gnu-pubnames.s
Index: lld/test/ELF/debug-gnu-pubnames.s
===================================================================
--- lld/test/ELF/debug-gnu-pubnames.s
+++ lld/test/ELF/debug-gnu-pubnames.s
@@ -3,13 +3,12 @@
# RUN: ld.lld %t.o -o %t1.exe
# RUN: llvm-readobj -sections %t1.exe | FileCheck %s
-# CHECK: .debug_gnu_pubnames
-# CHECK: .debug_gnu_pubtypes
# RUN: ld.lld -gdb-index %t.o -o %t2.exe
-# RUN: llvm-readobj -sections %t2.exe | FileCheck %s --check-prefix=GDB
-# GDB-NOT: .debug_gnu_pubnames
-# GDB-NOT: .debug_gnu_pubtypes
+# RUN: llvm-readobj -sections %t2.exe | FileCheck %s
+
+# CHECK-NOT: .debug_gnu_pubnames
+# CHECK-NOT: .debug_gnu_pubtypes
.section .debug_gnu_pubnames,"", at progbits
.long 0
Index: lld/ELF/InputFiles.cpp
===================================================================
--- lld/ELF/InputFiles.cpp
+++ lld/ELF/InputFiles.cpp
@@ -729,6 +729,13 @@
if (Name.startswith(".gnu.linkonce."))
return &InputSection::Discarded;
+ // We create a .gdb_index section from .debug_gnu_pub{names,types}.
+ // If --gdb-index is not given, they are useless. So eliminate them early.
+ if (!Config->GdbIndex &&
+ (Name == ".debug_gnu_pubnames" || Name == ".zdebug_gnu_pubnames" ||
+ Name == ".debug_gnu_pubtypes" || Name == ".zdebug_gnu_pubtypes"))
+ return &InputSection::Discarded;
+
// If we are creating a new .build-id section, strip existing .build-id
// sections so that the output won't have more than one .build-id.
// This is not usually a problem because input object files normally don't
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52241.166006.patch
Type: text/x-patch
Size: 1553 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180918/d4024480/attachment.bin>
More information about the llvm-commits
mailing list