[PATCH] D140116: [MachOYAML] Improve section offset misalignment error message
Michael Buch via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 15 10:05:01 PST 2022
Michael137 created this revision.
Michael137 added a reviewer: aprantl.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Before:
wrote too much data somewhere, section offsets don't line up
After:
wrote too much data somewhere, section offsets in section __debug_str for segment __DWARF don't line up: [cursor=0x581], [fileStart=0x0], [sectionOffset=0x579]
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D140116
Files:
llvm/lib/ObjectYAML/MachOEmitter.cpp
llvm/test/ObjectYAML/MachO/sections.yaml
Index: llvm/test/ObjectYAML/MachO/sections.yaml
===================================================================
--- llvm/test/ObjectYAML/MachO/sections.yaml
+++ llvm/test/ObjectYAML/MachO/sections.yaml
@@ -291,7 +291,7 @@
# RUN: not yaml2obj --docnum=2 %s -o %t2.macho 2>&1 | FileCheck %s --check-prefix=OVERLAP
-# OVERLAP: yaml2obj: error: wrote too much data somewhere, section offsets don't line up
+# OVERLAP: yaml2obj: error: wrote too much data somewhere, section offsets in section __sec2 for segment __SEC don't line up: [cursor=0x121], [fileStart=0x0], [sectionOffset=0x1]
--- !mach-o
FileHeader:
Index: llvm/lib/ObjectYAML/MachOEmitter.cpp
===================================================================
--- llvm/lib/ObjectYAML/MachOEmitter.cpp
+++ llvm/lib/ObjectYAML/MachOEmitter.cpp
@@ -17,6 +17,7 @@
#include "llvm/ObjectYAML/yaml2obj.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Error.h"
+#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/YAMLTraits.h"
#include "llvm/Support/raw_ostream.h"
@@ -315,7 +316,12 @@
if (OS.tell() - fileStart > Sec.offset && Sec.offset != (uint32_t)0)
return createStringError(
errc::invalid_argument,
- "wrote too much data somewhere, section offsets don't line up");
+ llvm::formatv(
+ "wrote too much data somewhere, section offsets in "
+ "section {0} for segment {1} don't line up: "
+ "[cursor={2:x}], [fileStart={3:x}], [sectionOffset={4:x}]",
+ Sec.sectname, Sec.segname, OS.tell(), fileStart,
+ Sec.offset.value));
StringRef SectName(Sec.sectname,
strnlen(Sec.sectname, sizeof(Sec.sectname)));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140116.483221.patch
Type: text/x-patch
Size: 1814 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221215/73c370da/attachment.bin>
More information about the llvm-commits
mailing list