[PATCH] D96753: [lld][ELF] Don't consider C identifier-named sections as GC roots

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 16 19:21:01 PST 2021


MaskRay added a comment.

Code LG. I hope in the future we can entirely drop the code.

  else if (isValidCIdentifier(sec->name) && !sec->nextInSectionGroup) {
    cNamedSections[saver.save("__start_" + sec->name)].push_back(sec);
    cNamedSections[saver.save("__stop_" + sec->name)].push_back(sec);
  }

I'll check how to make `__attribute__((used))` set SHF_GNU_RETAIN.

---

GC semantics are unfortunate. We have a special rule for SHT_NOTE, which has confused FreeBSD folks a bit:
(See the code touched by D70146 <https://reviews.llvm.org/D70146>)

  +  case SHT_NOTE:
  +    // SHT_NOTE sections in a group are subject to garbage collection.
  +    return !sec->nextInSectionGroup;



================
Comment at: lld/test/ELF/gc-sections-group-startstop.s:1
+# REQUIRES: x86
+## Check that group members are retained or discarded as a unit, and
----------------
The test can be written in gc-sections-metadata-startstop.s


================
Comment at: lld/test/ELF/gc-sections-group-startstop.s:32
+
+.section .text.aaa,"ax", at progbits
+aaa:
----------------
bbb and ccc are not needed.

You can rename `startstop-gccollect.s` to `gc-sections-*` and add a section group case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96753



More information about the llvm-commits mailing list