diff options
author | Amir Ayupov <aaupov@fb.com> | 2022-04-09 07:07:27 +0300 |
---|---|---|
committer | Amir Ayupov <aaupov@fb.com> | 2022-04-09 07:08:39 +0300 |
commit | 9b02dc631d71ded18bf62ea332b68bd873cc23b6 (patch) | |
tree | ac3b5839c865209760c1ab7ab94e99f990b74f6f /bolt | |
parent | 82dcf3063697eba96b825e91f11a8e74c4c95cb1 (diff) |
[BOLT] Check MCContext errors
Abort on emission errors to prevent a malformed binary being written.
Example:
```
<unknown>:0: error: Undefined temporary symbol .Ltmp26310
<unknown>:0: error: Undefined temporary symbol .Ltmp26311
<unknown>:0: error: Undefined temporary symbol .Ltmp26312
<unknown>:0: error: Undefined temporary symbol .Ltmp26313
<unknown>:0: error: Undefined temporary symbol .Ltmp26314
<unknown>:0: error: Undefined temporary symbol .Ltmp26315
BOLT-ERROR: Emission failed.
```
Reviewed By: yota9
Differential Revision: https://reviews.llvm.org/D123263
Diffstat (limited to 'bolt')
-rw-r--r-- | bolt/lib/Rewrite/RewriteInstance.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp index 1db7bd92a4a0..2cac9d74b83e 100644 --- a/bolt/lib/Rewrite/RewriteInstance.cpp +++ b/bolt/lib/Rewrite/RewriteInstance.cpp @@ -3108,6 +3108,10 @@ void RewriteInstance::emitAndLink() { emitBinaryContext(*Streamer, *BC, getOrgSecPrefix()); Streamer->Finish(); + if (Streamer->getContext().hadError()) { + errs() << "BOLT-ERROR: Emission failed.\n"; + exit(1); + } ////////////////////////////////////////////////////////////////////////////// // Assign addresses to new sections. @@ -3137,7 +3141,7 @@ void RewriteInstance::emitAndLink() { RTDyld->finalizeWithMemoryManagerLocking(); if (RTDyld->hasError()) { - outs() << "BOLT-ERROR: RTDyld failed: " << RTDyld->getErrorString() << "\n"; + errs() << "BOLT-ERROR: RTDyld failed: " << RTDyld->getErrorString() << "\n"; exit(1); } |