[PATCH] D17502: [ELF] - Fix of 22906, referencing __start or __stop should keep the section from GC.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 23 01:24:30 PST 2016


grimar added a comment.

In http://reviews.llvm.org/D17502#358468, @ed wrote:

> Unfortunately, this patch doesn't apply cleanly against LLD 3.8.0-rc2. If you generate a patch against that version of LLD, I'll perform a package build to see if it was fixing the issue I was running in to specifically. Thanks!


Yes, I tried to port it for LLD 3.8.0-rc2, but found that it is not that easy as seems. There are changes in logic of getOutputSectionName(), for example. In newer code it references linker script methods, in older - internal fields of Writer. So it does not looks possible to easy move this method from Writer class like was done in this patch.
So I am not sure it is worth to implement it for old code as there are too many code changes already, sorry.


================
Comment at: ELF/MarkLive.cpp:83
@@ +82,3 @@
+static bool isRetained(SymbolTable<ELFT> *Symtab, InputSectionBase<ELFT> *Sec) {
+  StringRef Name = Sec->getOutputSectionName();
+  if (!isValidCIdentifier(Name))
----------------
emaste wrote:
> Is the input->output section name mapping necessary? Those section names are not valid C identifiers anyhow.
I think it is. Thats mirrors logic of

```
void Writer<ELFT>::addStartStopSymbols(OutputSectionBase<ELFT> *Sec) {
  StringRef S = Sec->getName();
  if (!isValidCIdentifier(S))
    return;
...
```
which uses output section name to create start/stop identificator name. 
Also since we can use linker script to place sections to any output section, it seems to be correct for me.



http://reviews.llvm.org/D17502





More information about the llvm-commits mailing list