summaryrefslogtreecommitdiff
path: root/simpleperf/read_elf.h
diff options
context:
space:
mode:
Diffstat (limited to 'simpleperf/read_elf.h')
-rw-r--r--simpleperf/read_elf.h23
1 files changed, 20 insertions, 3 deletions
diff --git a/simpleperf/read_elf.h b/simpleperf/read_elf.h
index 1ab9a1f3..f289ee17 100644
--- a/simpleperf/read_elf.h
+++ b/simpleperf/read_elf.h
@@ -84,11 +84,28 @@ ElfStatus ReadMinExecutableVirtualAddressFromEmbeddedElfFile(const std::string&
ElfStatus ReadSectionFromElfFile(const std::string& filename, const std::string& section_name,
std::string* content);
-// Expose the following functions for unit tests.
+namespace llvm {
+class MemoryBuffer;
+}
+
+namespace simpleperf {
+
+class ElfFile {
+ public:
+ static std::unique_ptr<ElfFile> Open(const std::string& filename, ElfStatus* status);
+ virtual ~ElfFile() {}
+
+ virtual llvm::MemoryBuffer* GetMemoryBuffer() = 0;
+
+ protected:
+ ElfFile() {}
+};
+
+} // namespace simpleperf
+
bool IsArmMappingSymbol(const char* name);
-ElfStatus IsValidElfFile(int fd);
+ElfStatus IsValidElfFile(int fd, uint64_t file_offset = 0);
bool IsValidElfFileMagic(const char* buf, size_t buf_size);
-ElfStatus IsValidElfPath(const std::string& filename);
bool GetBuildIdFromNoteSection(const char* section, size_t section_size, BuildId* build_id);
#endif // SIMPLE_PERF_READ_ELF_H_