[PATCH] D84131: [ELF] Support -r --gc-sections

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 20 08:41:47 PDT 2020


MaskRay added a comment.

In D84131#2161527 <https://reviews.llvm.org/D84131#2161527>, @psmith wrote:

> I guess if the use case for -r is a kernel module then garbage collection can make sense as the "object" is not relinked. What happens when there is no GC root? I think it will be worth detecting that and turning GC off as otherwise everything will get removed which is unlikely to be what was wanted.


GNU ld has a diagnostic `gc-sections requires either an entry or an undefined symbol` (the resolution to https://sourceware.org/bugzilla/show_bug.cgi?id=26265 added `--init` and `--fini`).
We have other GC roots like SHT_INIT_ARRAY and C identifier sections. I don't know whether we want such a diagnostic. Users of the feature usually come from GNU ld. Failing to set a GC root can get pretty obvious broken output. I don't thing the diagnostic is very necessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84131





More information about the llvm-commits mailing list