[PATCH] D140788: [DWARFLinkerNext] add AddressesMap interface.

Alexey Lapshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 31 02:04:31 PST 2022


avl updated this revision to Diff 485755.
avl added a comment.

changed signature for isLiveVariable and isLiveSubprogram.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140788/new/

https://reviews.llvm.org/D140788

Files:
  llvm/include/llvm/DWARFLinkerNext/AddressesMap.h


Index: llvm/include/llvm/DWARFLinkerNext/AddressesMap.h
===================================================================
--- /dev/null
+++ llvm/include/llvm/DWARFLinkerNext/AddressesMap.h
@@ -0,0 +1,71 @@
+//===- AddressesMap.h -------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DWARFLINKERNEXT_ADDRESSESMAP_H
+#define LLVM_DWARFLINKERNEXT_ADDRESSESMAP_H
+
+#include "llvm/ADT/AddressRanges.h"
+#include "llvm/DebugInfo/DWARF/DWARFDie.h"
+#include <cstdint>
+
+namespace llvm {
+namespace dwarflinker {
+
+/// Mapped value in the address map is the offset to apply to the
+/// linked address.
+using RangesTy = AddressRangesMap<int64_t>;
+
+/// AddressesMap represents information about valid addresses used
+/// by debug information. Valid addresses are those which points to
+/// live code sections. i.e. relocations for these addresses point
+/// into sections which would be/are placed into resulting binary.
+class AddressesMap {
+public:
+  virtual ~AddressesMap() = default;
+
+  /// Checks that there are valid relocations against a .debug_info
+  /// section.
+  virtual bool hasValidRelocs() = 0;
+
+  /// Checks that the specified variable \p DIE references live code section
+  /// and returns variable address. Allowed kind of input die: DW_TAG_variable,
+  /// DW_TAG_constant.
+  /// \returns address value or std::nullopt if there is not corresponding live
+  /// address.
+  virtual std::optional<int64_t> getVariableAddress(const DWARFDie &DIE) = 0;
+
+  /// Checks that the specified subprogram \p DIE references live code section
+  /// and returns subprogram address. Allowed kind of input die:
+  /// DW_TAG_subprogram, DW_TAG_label.
+  /// \returns address value or std::nullopt if there is not corresponding live
+  /// address.
+  virtual std::optional<int64_t> getSubprogramAddress(const DWARFDie &DIE) = 0;
+
+  /// Apply the valid relocations to the buffer \p Data, taking into
+  /// account that Data is at \p BaseOffset in the .debug_info section.
+  ///
+  /// \returns true whether any reloc has been applied.
+  virtual bool applyValidRelocs(MutableArrayRef<char> Data, uint64_t BaseOffset,
+                                bool IsLittleEndian) = 0;
+
+  /// Relocate the given address offset if a valid relocation exists.
+  virtual llvm::Expected<uint64_t> relocateIndexedAddr(uint64_t StartOffset,
+                                                       uint64_t EndOffset) = 0;
+
+  /// Returns all valid functions address ranges(i.e., those ranges
+  /// which points to sections with code).
+  virtual RangesTy &getValidAddressRanges() = 0;
+
+  /// Erases all data.
+  virtual void clear() = 0;
+};
+
+} // end of namespace dwarflinker
+} // end namespace llvm
+
+#endif // LLVM_DWARFLINKERNEXT_ADDRESSESMAP_H


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140788.485755.patch
Type: text/x-patch
Size: 3072 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221231/6f1d8abe/attachment.bin>


More information about the llvm-commits mailing list