================ @@ -7922,6 +7928,59 @@ void LLVMELFDumper<ELFT>::printBBAddrMaps(bool PrettyPGOAnalysis) { } } +template <class ELFT> void LLVMELFDumper<ELFT>::printFuncMaps() { + bool IsRelocatable = this->Obj.getHeader().e_type == ELF::ET_REL; + using Elf_Shdr = typename ELFT::Shdr; + auto IsMatch = [](const Elf_Shdr &Sec) -> bool { + return Sec.sh_type == ELF::SHT_LLVM_FUNC_MAP; + }; + Expected<MapVector<const Elf_Shdr *, const Elf_Shdr *>> SecRelocMapOrErr = + this->Obj.getSectionAndRelocations(IsMatch); + if (!SecRelocMapOrErr) { + this->reportUniqueWarning("failed to get SHT_LLVM_FUNC_MAP section(s): " + + toString(SecRelocMapOrErr.takeError())); + return; + } + + for (auto const &[Sec, RelocSec] : *SecRelocMapOrErr) { + std::optional<const Elf_Shdr *> FunctionSec; + if (IsRelocatable) + FunctionSec = + unwrapOrError(this->FileName, this->Obj.getSection(Sec->sh_link)); ---------------- jh7370 wrote:
Do not use `unwrapOrError` in new code. The dumper should be tolerant of slightly dodgy looking object files, as the dumper is often the only way of finding out what's gone wrong (short of decoding the bytes be hand). A warning is fine here and you can then either continue as if the relocation section didn't exist or bail out. See my comments elsewhere about the requirement for a relocation section. https://github.com/llvm/llvm-project/pull/124333 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits