// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // -*- mode: C++ -*- // // Copyright 2022 Google LLC // // Licensed under the Apache License v2.0 with LLVM Exceptions (the // "License"); you may not use this file except in compliance with the // License. You may obtain a copy of the License at // // https://llvm.org/LICENSE.txt // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Author: Aleksei Vetrov #ifndef STG_ELF_READER_H_ #define STG_ELF_READER_H_ #include #include #include #include #include #include #include #include "elf_dwarf_handle.h" #include "elf_loader.h" #include "filter.h" #include "graph.h" #include "reader_options.h" #include "runtime.h" namespace stg { namespace elf { Id Read(Runtime& runtime, Graph& graph, ElfDwarfHandle& elf_dwarf_handle, ReadOptions options, const std::unique_ptr& file_filter); // For unit tests only namespace internal { using SymbolTable = std::vector; using SymbolNameList = std::unordered_set; using CRCValuesMap = std::unordered_map; using NamespacesMap = std::unordered_map; using AddressMap = std::unordered_map; ElfSymbol::SymbolType ConvertSymbolType( SymbolTableEntry::SymbolType symbol_type); SymbolNameList GetKsymtabSymbols(const SymbolTable& symbols); CRCValuesMap GetCRCValuesMap(const SymbolTable& symbols, const ElfLoader& elf); NamespacesMap GetNamespacesMap(const SymbolTable& symbols, const ElfLoader& elf); AddressMap GetCFIAddressMap(const SymbolTable& symbols, const ElfLoader& elf); bool IsPublicFunctionOrVariable(const SymbolTableEntry& symbol); bool IsLinuxKernelFunctionOrVariable(const SymbolNameList& ksymtab, const SymbolTableEntry& symbol); } // namespace internal } // namespace elf } // namespace stg #endif // STG_ELF_READER_H_