Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | //===- DWARFObject.h --------------------------------------------*- C++ -*-===// |
| 2 | // |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 6 | // |
| 7 | //===-----------------------------------------------------------------------===/ |
| 8 | |
| 9 | #ifndef LLVM_DEBUGINFO_DWARF_DWARFOBJECT_H |
| 10 | #define LLVM_DEBUGINFO_DWARF_DWARFOBJECT_H |
| 11 | |
| 12 | #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h" |
| 13 | #include "llvm/DebugInfo/DWARF/DWARFSection.h" |
| 14 | #include "llvm/Object/ObjectFile.h" |
| 15 | |
| 16 | namespace llvm { |
| 17 | // This is responsible for low level access to the object file. It |
| 18 | // knows how to find the required sections and compute relocated |
| 19 | // values. |
| 20 | // The default implementations of the get<Section> methods return dummy values. |
| 21 | // This is to allow clients that only need some of those to implement just the |
| 22 | // ones they need. We can't use unreachable for as many cases because the parser |
| 23 | // implementation is eager and will call some of these methods even if the |
| 24 | // result is not used. |
| 25 | class DWARFObject { |
| 26 | DWARFSection Dummy; |
| 27 | |
| 28 | public: |
| 29 | virtual ~DWARFObject() = default; |
| 30 | virtual StringRef getFileName() const { llvm_unreachable("unimplemented"); } |
| 31 | virtual const object::ObjectFile *getFile() const { return nullptr; } |
| 32 | virtual ArrayRef<SectionName> getSectionNames() const { return {}; } |
| 33 | virtual bool isLittleEndian() const = 0; |
| 34 | virtual uint8_t getAddressSize() const { llvm_unreachable("unimplemented"); } |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 35 | virtual void |
| 36 | forEachInfoSections(function_ref<void(const DWARFSection &)> F) const {} |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 37 | virtual void |
| 38 | forEachTypesSections(function_ref<void(const DWARFSection &)> F) const {} |
| 39 | virtual StringRef getAbbrevSection() const { return ""; } |
| 40 | virtual const DWARFSection &getLocSection() const { return Dummy; } |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 41 | virtual const DWARFSection &getLoclistsSection() const { return Dummy; } |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 42 | virtual StringRef getArangesSection() const { return ""; } |
| 43 | virtual const DWARFSection &getFrameSection() const { return Dummy; } |
| 44 | virtual const DWARFSection &getEHFrameSection() const { return Dummy; } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 45 | virtual const DWARFSection &getLineSection() const { return Dummy; } |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 46 | virtual StringRef getLineStrSection() const { return ""; } |
| 47 | virtual StringRef getStrSection() const { return ""; } |
| 48 | virtual const DWARFSection &getRangesSection() const { return Dummy; } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 49 | virtual const DWARFSection &getRnglistsSection() const { return Dummy; } |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 50 | virtual const DWARFSection &getMacroSection() const { return Dummy; } |
| 51 | virtual StringRef getMacroDWOSection() const { return ""; } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 52 | virtual StringRef getMacinfoSection() const { return ""; } |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 53 | virtual StringRef getMacinfoDWOSection() const { return ""; } |
| 54 | virtual const DWARFSection &getPubnamesSection() const { return Dummy; } |
| 55 | virtual const DWARFSection &getPubtypesSection() const { return Dummy; } |
| 56 | virtual const DWARFSection &getGnuPubnamesSection() const { return Dummy; } |
| 57 | virtual const DWARFSection &getGnuPubtypesSection() const { return Dummy; } |
| 58 | virtual const DWARFSection &getStrOffsetsSection() const { return Dummy; } |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 59 | virtual void |
| 60 | forEachInfoDWOSections(function_ref<void(const DWARFSection &)> F) const {} |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 61 | virtual void |
| 62 | forEachTypesDWOSections(function_ref<void(const DWARFSection &)> F) const {} |
| 63 | virtual StringRef getAbbrevDWOSection() const { return ""; } |
| 64 | virtual const DWARFSection &getLineDWOSection() const { return Dummy; } |
| 65 | virtual const DWARFSection &getLocDWOSection() const { return Dummy; } |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 66 | virtual const DWARFSection &getLoclistsDWOSection() const { return Dummy; } |
| 67 | virtual StringRef getStrDWOSection() const { return ""; } |
| 68 | virtual const DWARFSection &getStrOffsetsDWOSection() const { |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 69 | return Dummy; |
| 70 | } |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 71 | virtual const DWARFSection &getRangesDWOSection() const { return Dummy; } |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 72 | virtual const DWARFSection &getRnglistsDWOSection() const { return Dummy; } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 73 | virtual const DWARFSection &getAddrSection() const { return Dummy; } |
| 74 | virtual const DWARFSection &getAppleNamesSection() const { return Dummy; } |
| 75 | virtual const DWARFSection &getAppleTypesSection() const { return Dummy; } |
| 76 | virtual const DWARFSection &getAppleNamespacesSection() const { |
| 77 | return Dummy; |
| 78 | } |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 79 | virtual const DWARFSection &getNamesSection() const { return Dummy; } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 80 | virtual const DWARFSection &getAppleObjCSection() const { return Dummy; } |
| 81 | virtual StringRef getCUIndexSection() const { return ""; } |
| 82 | virtual StringRef getGdbIndexSection() const { return ""; } |
| 83 | virtual StringRef getTUIndexSection() const { return ""; } |
| 84 | virtual Optional<RelocAddrEntry> find(const DWARFSection &Sec, |
| 85 | uint64_t Pos) const = 0; |
| 86 | }; |
| 87 | |
| 88 | } // namespace llvm |
| 89 | #endif |