[ELF] Adding accessor method for getting Note Desc as StringRef
authorDineshkumar Bhaskaran <dineshkumar.bhaskaran@amd.com>
Mon, 8 Jun 2020 09:42:02 +0000 (09:42 +0000)
committerSaiyedul Islam <Saiyedul.Islam@amd.com>
Mon, 8 Jun 2020 09:44:00 +0000 (09:44 +0000)
Summary: One more way to access note desc.

Reviewers: arsenm, scott.linder, saiislam

Reviewed By: scott.linder

Subscribers: wdng, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D81185

llvm/include/llvm/Object/ELFTypes.h

index 32ad1e4..d0909f5 100644 (file)
@@ -615,6 +615,12 @@ public:
         Nhdr.n_descsz);
   }
 
+  /// Get the note's descriptor as StringRef
+  StringRef getDescAsStringRef() const {
+    auto &Desc = getDesc();
+    return StringRef(reinterpret_cast<const char *>(Desc.data()), Desc.size());
+  }
+
   /// Get the note's type.
   Elf_Word getType() const { return Nhdr.n_type; }
 };