Index: ELF/OutputSections.cpp =================================================================== --- ELF/OutputSections.cpp +++ ELF/OutputSections.cpp @@ -172,9 +172,9 @@ if (IsRela) { if (Body) Addend += getSymVA(cast>(*Body)); - else - Addend += getLocalSymVA( - Obj.getRelocationSymbol(&RI, File.getSymbolTable()), File); + else if (const auto *Sym = + Obj.getRelocationSymbol(&RI, File.getSymbolTable())) + Addend += getLocalSymVA(Sym, File); } P->setSymbolAndType(0, Target->getRelativeReloc(), IsMips64EL); } Index: test/elf2/Inputs/shared-ppc64.s =================================================================== --- test/elf2/Inputs/shared-ppc64.s +++ test/elf2/Inputs/shared-ppc64.s @@ -1,8 +1,7 @@ .section ".opd","aw" .global bar bar: -# FIXME: This should be: .quad .Lbar,.TOC.@tocbase,0 -# But we can't handle .TOC.@tocbase for shared libraries yet +.quad .Lbar,.TOC.@tocbase,0 .quad .Lbar,0,0 .text