[PATCH] D107398: [llvm-readobj][XCOFF] Warn about invalid offset

Esme Yi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 4 01:18:55 PDT 2021


Esme updated this revision to Diff 363994.
Esme added a comment.

The warning output would be:

  StringTable {
  llvm-readobj: warning: '[[FILE]]': offset (0x4) is past the end of the contents size (0x0)
  }


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107398/new/

https://reviews.llvm.org/D107398

Files:
  llvm/tools/llvm-readobj/ObjDumper.cpp


Index: llvm/tools/llvm-readobj/ObjDumper.cpp
===================================================================
--- llvm/tools/llvm-readobj/ObjDumper.cpp
+++ llvm/tools/llvm-readobj/ObjDumper.cpp
@@ -55,9 +55,12 @@
 void ObjDumper::printAsStringList(StringRef StringContent,
                                   size_t StringDataOffset) {
   if (StringContent.size() < StringDataOffset) {
-    reportUniqueWarning("error: offset is out of string contents");
+    reportUniqueWarning("offset (0x" + Twine::utohexstr(StringDataOffset) +
+                        ") is past the end of the contents size (0x" +
+                        Twine::utohexstr(StringContent.size()) + ")");
     return;
   }
+
   const uint8_t *StrContent = StringContent.bytes_begin();
   // Some formats contain additional metadata at the start which should not be
   // interpreted as strings. Skip these bytes, but account for them in the


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107398.363994.patch
Type: text/x-patch
Size: 914 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210804/35ad096c/attachment.bin>


More information about the llvm-commits mailing list