[PATCH] D57294: lld: elf: discard more specific .gnu.linkonce section

Nick Desaulniers via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 26 18:54:32 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL352302: lld: elf: discard more specific .gnu.linkonce section (authored by nickdesaulniers, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57294?vs=183742&id=183743#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57294

Files:
  lld/trunk/ELF/InputFiles.cpp
  lld/trunk/test/ELF/comdat-linkonce.s
  lld/trunk/test/ELF/no-discard-this_module.s


Index: lld/trunk/test/ELF/no-discard-this_module.s
===================================================================
--- lld/trunk/test/ELF/no-discard-this_module.s
+++ lld/trunk/test/ELF/no-discard-this_module.s
@@ -0,0 +1,41 @@
+// REQUIRES: x86
+// RUN: llvm-mc -filetype=obj -triple=x86_64-linux-gnu -save-temp-labels %s -o %t
+// RUN: ld.lld %t -o %t2
+// RUN: llvm-readobj -s -sd -t %t2 | FileCheck %s
+
+.global _start
+_start:
+
+// This section and symbol is used by Linux kernel modules. Ensure it's not
+// accidentally discarded.
+.section .gnu.linkonce.this_module:
+__this_module:
+.byte 0x00
+
+// CHECK: Section {
+// CHECK:    Index:
+// CHECK:    Name: .gnu.linkonce.this_module
+// CHECK-NEXT:    Type: SHT_PROGBITS
+// CHECK-NEXT:    Flags [
+// CHECK-NEXT:    ]
+// CHECK-NEXT:    Address:
+// CHECK-NEXT:    Offset:
+// CHECK-NEXT:    Size:
+// CHECK-NEXT:    Link:
+// CHECK-NEXT:    Info:
+// CHECK-NEXT:    AddressAlignment:
+// CHECK-NEXT:    EntrySize:
+// CHECK-NEXT:    SectionData (
+// CHECK-NEXT:      0000: 00                                   |.|
+// CHECK-NEXT:    )
+// CHECK-NEXT:  }
+
+// CHECK:  Symbol {
+// CHECK:    Name: __this_module
+// CHECK-NEXT:    Value:
+// CHECK-NEXT:    Size:
+// CHECK-NEXT:    Binding: Local
+// CHECK-NEXT:    Type: None
+// CHECK-NEXT:    Other:
+// CHECK-NEXT:    Section: .gnu.linkonce.this_module:
+// CHECK-NEXT:  }
Index: lld/trunk/test/ELF/comdat-linkonce.s
===================================================================
--- lld/trunk/test/ELF/comdat-linkonce.s
+++ lld/trunk/test/ELF/comdat-linkonce.s
@@ -4,7 +4,12 @@
 // RUN: ld.lld -shared %t.o %t2.o -o %t
 // RUN: ld.lld -shared %t2.o %t.o -o %t
 
-.section .gnu.linkonce.t.zed
+.section .gnu.linkonce.t.__x86.get_pc_thunk.bx
 .globl abc
 abc:
 nop
+
+.section .gnu.linkonce.t.__i686.get_pc_thunk.bx
+.globl def
+def:
+nop
Index: lld/trunk/ELF/InputFiles.cpp
===================================================================
--- lld/trunk/ELF/InputFiles.cpp
+++ lld/trunk/ELF/InputFiles.cpp
@@ -733,7 +733,8 @@
   // sections. Drop those sections to avoid duplicate symbol errors.
   // FIXME: This is glibc PR20543, we should remove this hack once that has been
   // fixed for a while.
-  if (Name.startswith(".gnu.linkonce."))
+  if (Name == ".gnu.linkonce.t.__x86.get_pc_thunk.bx" ||
+      Name == ".gnu.linkonce.t.__i686.get_pc_thunk.bx")
     return &InputSection::Discarded;
 
   // If we are creating a new .build-id section, strip existing .build-id


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57294.183743.patch
Type: text/x-patch
Size: 2504 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190127/968aceb9/attachment.bin>


More information about the llvm-commits mailing list