[PATCH] D126950: [lld][WebAssembly] Retain data segments referenced via __start/__stop
Yuta Saito via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 3 10:06:53 PDT 2022
kateinoigakukun marked 2 inline comments as done and an inline comment as not done.
kateinoigakukun added inline comments.
================
Comment at: lld/wasm/MarkLive.cpp:121
+ if (symtab->find(("__start_" + name).str()) ||
+ symtab->find(("__stop_" + name).str())) {
+ enqueueWholeChunk(segment);
----------------
sbc100 wrote:
> So, does this mean that if I reference the symbol `__start_data`, then all the normal data segment in my whole program will be included (non will be GC'd)?
>
> Is this how ELF works? It seems like a shame to loose the ability to GC data segments just because i want to know where my data starts and/or stops. I suppose we have other symbols such as `_edata` which can be used to get the start/end of the static data region without disabling GC?
> So, does this mean that if I reference the symbol __start_data, then all the normal data segment in my whole program will be included (non will be GC'd)?
Yes, I agree that's unfortunate situation...
> Is this how ELF works?
To be precise, according to https://lld.llvm.org/ELF/start-stop-gc, whether `__start`/`__stop` symbols retain all input data segments is controlled by `-z start-stop-gc` / `-z nostart-stop-gc`.
The latest ELF lld defaults to `-z start-stop-gc`, but GNU ld defaults to `-z nostart-stop-gc` to be conservative.
So, how about adding the option in wasm-ld also? If it's reasonable, which behavior should be defaulted?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126950/new/
https://reviews.llvm.org/D126950
More information about the llvm-commits
mailing list