[PATCH] D76935: [COFF] Don't treat DWARF sections as GC roots

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 27 10:55:37 PDT 2020


MaskRay added a comment.

I don't know how `SHF_ALLOC` concept transforms to COFF. In ELF, gc is for sections which are part of the load image so non-SHF_ALLOC sections are generally not discarded. This patch captures the intent as COFF/MarkLive.cpp is still really simple currently.



================
Comment at: lld/test/COFF/gc-dwarf.s:5
+# RUN: lld-link -lldmap:%t.map -out:%t.exe -opt:ref -entry:main %t.obj -verbose 2>&1 | FileCheck %s
+# RUN: cat %t.map | FileCheck %s --check-prefix=MAP
+
----------------
This can be `--input-file=%t.map` to avoid a cat.


================
Comment at: lld/test/COFF/gc-dwarf.s:8
+# CHECK: Discarded unused1
+# CHECK: Discarded unused2
+
----------------
`-NEXT:`


================
Comment at: lld/test/COFF/gc-dwarf.s:10
+
+# MAP: main
+# MAP: used
----------------
It will be better to prepend `# MAP: Symbol` to make clear it is the `MAP` column.

In not-so-rare circumstances the absolute path of `%t.obj` may contain `main`.
`main{{$}}` can prevent this pattern from matching a path component.


================
Comment at: lld/test/COFF/gc-dwarf.s:22
+	callq used
+	xorl	%eax, %eax
+	retq
----------------
Optional: in ELF we tend to omit unneeded details like `xorl %eax, %eax; retq`.
But we will keep `retq` because an empty section and a non-empty section make a difference for GNU linkers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76935





More information about the llvm-commits mailing list