diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2021-11-19 20:06:13 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2021-11-19 20:06:13 +0000 |
| commit | c0981da47d5696fe36474fcf86b4ce03ae3ff818 (patch) | |
| tree | f42add1021b9f2ac6a69ac7cf6c4499962739a45 /llvm/tools/llvm-objcopy/COFF/Writer.cpp | |
| parent | 344a3780b2e33f6ca763666c380202b18aab72a3 (diff) | |
Diffstat (limited to 'llvm/tools/llvm-objcopy/COFF/Writer.cpp')
| -rw-r--r-- | llvm/tools/llvm-objcopy/COFF/Writer.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/llvm/tools/llvm-objcopy/COFF/Writer.cpp b/llvm/tools/llvm-objcopy/COFF/Writer.cpp index e7be64faab65..cbd0e4261238 100644 --- a/llvm/tools/llvm-objcopy/COFF/Writer.cpp +++ b/llvm/tools/llvm-objcopy/COFF/Writer.cpp @@ -406,7 +406,7 @@ Expected<uint32_t> COFFWriter::virtualAddressToFileAddress(uint32_t RVA) { // the debug_directory structs in there, and set the PointerToRawData field // in all of them, according to their new physical location in the file. Error COFFWriter::patchDebugDirectory() { - if (Obj.DataDirectories.size() < DEBUG_DIRECTORY) + if (Obj.DataDirectories.size() <= DEBUG_DIRECTORY) return Error::success(); const data_directory *Dir = &Obj.DataDirectories[DEBUG_DIRECTORY]; if (Dir->Size <= 0) @@ -426,15 +426,13 @@ Error COFFWriter::patchDebugDirectory() { uint8_t *End = Ptr + Dir->Size; while (Ptr < End) { debug_directory *Debug = reinterpret_cast<debug_directory *>(Ptr); - if (!Debug->AddressOfRawData) - return createStringError(object_error::parse_failed, - "debug directory payload outside of " - "mapped sections not supported"); - if (Expected<uint32_t> FilePosOrErr = - virtualAddressToFileAddress(Debug->AddressOfRawData)) - Debug->PointerToRawData = *FilePosOrErr; - else - return FilePosOrErr.takeError(); + if (Debug->PointerToRawData) { + if (Expected<uint32_t> FilePosOrErr = + virtualAddressToFileAddress(Debug->AddressOfRawData)) + Debug->PointerToRawData = *FilePosOrErr; + else + return FilePosOrErr.takeError(); + } Ptr += sizeof(debug_directory); Offset += sizeof(debug_directory); } |
