[PATCH] D106420: [yaml2obj] Do not write the string table if there is no string entry.

Esme Yi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 20 22:08:22 PDT 2021


Esme created this revision.
Esme added reviewers: jhenderson, shchenz, Higuoxing, PowerPC.
Herald added a subscriber: hiraditya.
Esme requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This is a minor patch from James's comments in D105522 <https://reviews.llvm.org/D105522>.
I will add a test for this after "llvm-readobj --string-table" supports printing the size of string tables.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106420

Files:
  llvm/lib/ObjectYAML/XCOFFEmitter.cpp


Index: llvm/lib/ObjectYAML/XCOFFEmitter.cpp
===================================================================
--- llvm/lib/ObjectYAML/XCOFFEmitter.cpp
+++ llvm/lib/ObjectYAML/XCOFFEmitter.cpp
@@ -317,12 +317,11 @@
     if (!writeRelocations())
       return false;
   }
-  if (!Obj.Symbols.empty()) {
-    if (!writeSymbols())
-      return false;
-    // Write the string table.
+  if (!Obj.Symbols.empty() && !writeSymbols())
+    return false;
+  // Write the string table.
+  if (Strings.getSize() > 4)
     Strings.write(W.OS);
-  }
   return true;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106420.360356.patch
Type: text/x-patch
Size: 561 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210721/e333aed0/attachment.bin>


More information about the llvm-commits mailing list