Handle copy relocations in symbol assignments.

When a linker script has "foo = bar" and bar is the result of a copy
relocation foo should point to the same location in .bss.

This is part of a growing evidence that copy relocations should be
implemented by using replaceSymbol to replace the SharedSymbol with a
Defined.

llvm-svn: 319449
This commit is contained in:
Rafael Espindola
2017-11-30 17:51:10 +00:00
parent fc473dee98
commit de38b3d22f
4 changed files with 51 additions and 2 deletions

View File

@@ -976,8 +976,13 @@ ExprValue LinkerScript::getSymbolValue(StringRef Name, const Twine &Loc) {
return 0;
}
if (auto *Sym = dyn_cast_or_null<Defined>(Symtab->find(Name)))
return {Sym->Section, false, Sym->Value, Loc};
if (Symbol *Sym = Symtab->find(Name)) {
if (auto *DS = dyn_cast<Defined>(Sym))
return {DS->Section, false, DS->Value, Loc};
if (auto *SS = dyn_cast<SharedSymbol>(Sym))
if (!ErrorOnMissingSection || SS->CopyRelSec)
return {SS->CopyRelSec, false, 0, Loc};
}
error(Loc + ": symbol not found: " + Name);
return 0;