[PATCH] D36579: [ELF] - Do not fail when set versions for linkerscript's symbol aliases

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 8 02:38:29 PDT 2017


grimar added inline comments.


================
Comment at: ELF/Driver.cpp:1021
 
+  // Add symbols defined in linker scripts early because otherwise version
+  // scripts referring script-synthesized symbols wouldn't work due to
----------------
ruiu wrote:
> Add symbols -> Add dummy symbols
Done.


================
Comment at: ELF/Driver.cpp:1027
+    if (SymbolAssignment *Cmd = dyn_cast<SymbolAssignment>(Base))
+      if (Cmd->Name != "." && !Symtab->find(Cmd->Name) && !Cmd->Provide)
+        Symtab->addAbsolute<ELFT>(Cmd->Name, STV_DEFAULT, STB_WEAK);
----------------
ruiu wrote:
> What is `!Cmd->Provide` for?
symbols.s has next testcase:
(testcase was innaccurate before today, I fixed it in rL312779).

```
# The symbol is not referenced. Don't provide it.
# RUN: echo "SECTIONS { PROVIDE(newsym = 1);}" > %t.script
# RUN: ld.lld -o %t1 --script %t.script %t
# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=DONTPROVIDE %s
# DONTPROVIDE-NOT: newsym
```

If we have no `!Cmd->Provide` condition here it will fail, 
because we should not provide `newsym` always, but only when it is referenced.




================
Comment at: ELF/Driver.cpp:1028
+      if (Cmd->Name != "." && !Symtab->find(Cmd->Name) && !Cmd->Provide)
+        Symtab->addAbsolute<ELFT>(Cmd->Name, STV_DEFAULT, STB_WEAK);
+
----------------
ruiu wrote:
> Is there any reason to create symbols as STB_WEAK?
Yes, please refer to my comment above:
https://reviews.llvm.org/D36579#861990


https://reviews.llvm.org/D36579





More information about the llvm-commits mailing list