[Lldb-commits] [lldb] [LLDB] Impove ObjectFileELF's .dynamic parsing and usage. (PR #101237)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Wed Jul 31 05:04:30 PDT 2024


================
@@ -402,6 +413,29 @@ class ObjectFileELF : public lldb_private::ObjectFile {
   /// .gnu_debugdata section or \c nullptr if an error occured or if there's no
   /// section with that name.
   std::shared_ptr<ObjectFileELF> GetGnuDebugDataObjectFile();
+
+  /// Get the bytes that represent the .dynamic section.
+  ///
+  /// This function will fetch the data for the .dynamic section in an ELF file.
+  /// If the ELF file is loaded from a file on disk, it will use the PT_DYNAMIC
+  /// program header to extract the data and fall back to using the section
+  /// headers. If the ELF file is loaded from memory, it will use the PT_DYNAMIC
+  /// program header to get the information.
+  ///
+  /// \return The bytes that represent the string table data or \c std::nullopt
+  ///         if an error occured.
+  std::optional<lldb_private::DataExtractor> GetDynamicData();
----------------
labath wrote:

Do we need to distinguish between an empty dynamic header, and one that was not present (or there was some other error in retrieving it). I.e., what do you think about returning an empty DataExtractor in case of an error?

https://github.com/llvm/llvm-project/pull/101237


More information about the lldb-commits mailing list