[llvm] [Object] Beginnings of SFrame parser and dumper (PR #147294)

Pavel Labath via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 16 01:39:10 PDT 2025


================
@@ -6428,6 +6432,62 @@ template <typename ELFT> void ELFDumper<ELFT>::printMemtag() {
   printMemtag(DynamicEntries, AndroidNoteDesc, GlobalDescriptors);
 }
 
+template <typename ELFT>
+void ELFDumper<ELFT>::printSectionsAsSFrame(ArrayRef<std::string> Sections) {
+  constexpr endianness E = ELFT::Endianness;
+  for (object::SectionRef Section :
+       getSectionRefsByNameOrIndex(ObjF, Sections)) {
+    StringRef SectionName;
+    if (Error Err = Section.getName().moveInto(SectionName)) {
+      SectionName = "<error>";
+      reportWarning(std::move(Err), FileName);
+    }
+
+    DictScope SectionScope(W,
+                           formatv("SFrame section '{0}'", SectionName).str());
+
+    StringRef SectionContent;
+    if (Error Err = Section.getContents().moveInto(SectionContent)) {
+      reportWarning(std::move(Err), FileName);
----------------
labath wrote:

I think these two can only happen with a corrupted ELF file. I'll see if I can produce something like that.

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


More information about the llvm-commits mailing list