[PATCH] D37718: [ELF] Handle references to garbage collected common symbols

ben via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 12 15:43:07 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL313086: [ELF] Handle references to garbage collected common symbols (authored by bd1976llvm).

Changed prior to commit:
  https://reviews.llvm.org/D37718?vs=114719&id=114928#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37718

Files:
  lld/trunk/ELF/Symbols.cpp
  lld/trunk/test/ELF/common-gc3.s


Index: lld/trunk/ELF/Symbols.cpp
===================================================================
--- lld/trunk/ELF/Symbols.cpp
+++ lld/trunk/ELF/Symbols.cpp
@@ -103,6 +103,8 @@
     if (!Config->DefineCommon)
       return 0;
     auto DC = cast<DefinedCommon>(Body);
+    if (!DC.Live)
+      return 0;
     return DC.Section->getParent()->Addr + DC.Section->OutSecOff;
   }
   case SymbolBody::SharedKind: {
Index: lld/trunk/test/ELF/common-gc3.s
===================================================================
--- lld/trunk/test/ELF/common-gc3.s
+++ lld/trunk/test/ELF/common-gc3.s
@@ -0,0 +1,18 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: ld.lld %t.o -o %t1 --gc-sections
+# RUN: llvm-objdump -s %t1 | FileCheck %s
+
+# CHECK:      Contents of section .noalloc:
+# 0000 00000000 00000000                    ........
+
+	.section	.text._start,"ax", at progbits
+	.globl	_start
+_start:
+	retq
+
+	.type	unused, at object
+	.comm	unused,4,4
+
+	.section	.noalloc,"", at progbits
+	.quad	unused


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37718.114928.patch
Type: text/x-patch
Size: 1049 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170912/02947a8a/attachment.bin>


More information about the llvm-commits mailing list