[PATCH] D27276: [ELF] Allow defined symbols to be assigned from linker script

Meador Inge via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 6 11:12:33 PST 2017


meadori added inline comments.


================
Comment at: ELF/LinkerScript.cpp:62
   uint8_t Visibility = Cmd->Hidden ? STV_HIDDEN : STV_DEFAULT;
-  Symbol *Sym = Symtab<ELFT>::X->addRegular(Cmd->Name, Visibility, STT_NOTYPE,
-                                            0, 0, STB_GLOBAL, nullptr, nullptr);
-  Cmd->Sym = Sym->body();
 
+  if (Sym) {
----------------
ruiu wrote:
> It is probably easier to add a dummy symbol and then replace that unconditionally like this.
> 
>   Symbol *Sym = Symtab<ELFT>::X->addUndefined(Cmd->Name);
>   replaceBody<DefinedRegular<ELFT>>(Sym, Cmd->Name, ...);
>   return Sym->body();
> 
> You can remove `Symbol *Sym` from the parameter list of this function.
Much better.  Thanks!


https://reviews.llvm.org/D27276





More information about the llvm-commits mailing list