[llvm] [BOLT][DWARF] Fix handling .debug_str_offsets for type units (PR #75522)

Maksim Panchenko via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 14 14:02:29 PST 2023


================
@@ -851,35 +851,34 @@ std::string SimpleBinaryPatcher::patchBinary(StringRef BinaryContents) {
   return BinaryContentsStr;
 }
 
-void DebugStrOffsetsWriter::initialize(
-    const DWARFSection &StrOffsetsSection,
-    const std::optional<StrOffsetsContributionDescriptor> Contr) {
+void DebugStrOffsetsWriter::initialize(DWARFUnit &Unit) {
+  if (Unit.getVersion() < 5)
+    return;
+  const DWARFSection StrOffsetsSection = Unit.getStringOffsetSection();
+  const std::optional<StrOffsetsContributionDescriptor> Contr =
+      Unit.getStringOffsetsTableContribution();
   if (!Contr)
     return;
-
   const uint8_t DwarfOffsetByteSize = Contr->getDwarfOffsetByteSize();
   assert(DwarfOffsetByteSize == 4 &&
          "Dwarf String Offsets Byte Size is not supported.");
----------------
maksfb wrote:

Unrelated: this should be an error, not an assertion.

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


More information about the llvm-commits mailing list