https://sourceware.org/bugzilla/show_bug.cgi?id=27491
--- Comment #3 from Fangrui Song <i at maskray dot me> --- (In reply to H.J. Lu from comment #2) > -z start-stop-gc is a bad idea. LLVM should use __gc_start/__gc_stop. I think the history is: * In 2006-10, [BZ3400](https://sourceware.org/bugzilla/show_bug.cgi?id=3400) reported that stdio flushing did not work with static linking && `--gc-sections`. * In 2010-01, the problem was re-raised and gold got the rule (<https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f1ec9ded5c740c22735843025e5d3a8ff4c4079e>). * [PR11133#c13](https://sourceware.org/bugzilla/show_bug.cgi?id=11133#c13) installed a rule for GNU ld, but it did not appear to work or did not work with other translation units. * In 2015-10, the rule was properly installed ([PR19161](https://sourceware.org/bugzilla/show_bug.cgi?id=19161) [PR19167](https://sourceware.org/bugzilla/show_bug.cgi?id=19167)). I don't know what happened to the 2010-01 patch. It likely did not let __start_ reference retain magic sections in other translation unit (in metadata section usage __start_/__stop_ references are always in a separate runtime file), so "__start_ retaining all magic sections" was not effective before 2015-10. Why do we need new start/stop symbols? The orphan __start_/__stop_ usage worked before 2015-10 and will work with -z start-stop-gc. (I think of the possibility enabling -z start-stop-gc by default because the rule was essentially invalid before 2015-10.) As is, all clang -fprofile-generate and -fprofile-instr-generate instrumented text sections cannot be GCed. (Fuchsia folks measured that GC can reduce binary size by 28%.). Below is the story: A function references its `__llvm_prf_cnts` and may reference its `__llvm_prf_data` if value profiling applies. The `__llvm_prf_data` references the text section, the associated `__llvm_prf_cnts` and the associated `__llvm_prf_vals`. If `__start_` references retain the `__llvm_prf_data` and the `__llvm_prf_cnts`, the text section will be retained as well. With GNU ld and gold all instrumented text sections cannot be discarded. Another example is https://clang.llvm.org/docs/SanitizerCoverage.html#pc-table: "Note: this instrumentation might be incompatible with dead code stripping (-Wl,-gc-sections) for linkers other than LLD, thus resulting in a significant binary size overhead. For more information, see Bug 34636." I envision new metadata section usage will appear and those sections will need a way for GC. If people are interested a longer analysis, please check out https://maskray.me/blog/2021-01-31-metadata-sections-comdat-and-shf-link-order -- You are receiving this mail because: You are on the CC list for the bug.