[PATCH] D91291: [ELF] Don't consider SHF_ALLOC ".debug*" sections debug sections

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 12 09:59:58 PST 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG8df4e60945fa: [ELF] Don't consider SHF_ALLOC ".debug*" sections debug sections (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91291/new/

https://reviews.llvm.org/D91291

Files:
  lld/ELF/InputSection.h
  lld/test/ELF/gc-sections-strip-debug.s


Index: lld/test/ELF/gc-sections-strip-debug.s
===================================================================
--- /dev/null
+++ lld/test/ELF/gc-sections-strip-debug.s
@@ -0,0 +1,17 @@
+# REQUIRES: x86
+## Test that we don't strip SHF_ALLOC .debug* or crash (PR48071
+## mark liveness of a merge section which has not been split).
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
+# RUN: ld.lld %t.o --gc-sections --strip-debug -o %t
+# RUN: llvm-readelf -S %t | FileCheck %s
+
+# CHECK: .debug_gdb_scripts
+
+.globl _start
+_start:
+  leaq .L.str(%rip), %rax
+
+.section .debug_gdb_scripts,"aMS", at progbits,1
+.L.str:
+  .asciz "Rust uses SHF_ALLOC .debug_gdb_scripts"
Index: lld/ELF/InputSection.h
===================================================================
--- lld/ELF/InputSection.h
+++ lld/ELF/InputSection.h
@@ -397,7 +397,8 @@
 #endif
 
 inline bool isDebugSection(const InputSectionBase &sec) {
-  return sec.name.startswith(".debug") || sec.name.startswith(".zdebug");
+  return (sec.flags & llvm::ELF::SHF_ALLOC) == 0 &&
+         (sec.name.startswith(".debug") || sec.name.startswith(".zdebug"));
 }
 
 // The list of all input sections.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91291.304882.patch
Type: text/x-patch
Size: 1168 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201112/170a0e42/attachment.bin>


More information about the llvm-commits mailing list