-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Add --dump-offload-bundle option to llvm-objcopy #143347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0f0030c
bc29780
1447801
a454551
78faec5
e493a07
448bfce
79b6ace
47dbdbd
f88b75e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -161,7 +161,7 @@ struct OffloadBundleURI { | |
| OffsetStr.getAsInteger(10, O); | ||
| Str = Str.drop_front(OffsetStr.size()); | ||
|
|
||
| if (Str.consume_front("&size=")) | ||
| if (!Str.consume_front("&size=")) | ||
| return createStringError(object_error::parse_failed, | ||
| "Reading 'size' in URI"); | ||
|
|
||
|
|
@@ -188,8 +188,8 @@ LLVM_ABI Error extractOffloadBundleFatBinary( | |
|
|
||
| /// Extract code object memory from the given \p Source object file at \p Offset | ||
| /// and of \p Size, and copy into \p OutputFileName. | ||
| LLVM_ABI Error extractCodeObject(const ObjectFile &Source, int64_t Offset, | ||
| int64_t Size, StringRef OutputFileName); | ||
| LLVM_ABI Error extractCodeObject(const ObjectFile &Source, size_t Offset, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering if the fixes in this file should be spun off into a separate PR? |
||
| size_t Size, StringRef OutputFileName); | ||
|
|
||
| /// Extracts an Offload Bundle Entry given by URI | ||
| LLVM_ABI Error extractOffloadBundleByURI(StringRef URIstr); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -199,8 +199,8 @@ Error object::extractOffloadBundleFatBinary( | |
| return Error::success(); | ||
| } | ||
|
|
||
| Error object::extractCodeObject(const ObjectFile &Source, int64_t Offset, | ||
| int64_t Size, StringRef OutputFileName) { | ||
| Error object::extractCodeObject(const ObjectFile &Source, size_t Offset, | ||
| size_t Size, StringRef OutputFileName) { | ||
| Expected<std::unique_ptr<FileOutputBuffer>> BufferOrErr = | ||
| FileOutputBuffer::create(OutputFileName, Size); | ||
|
|
||
|
|
@@ -211,12 +211,23 @@ Error object::extractCodeObject(const ObjectFile &Source, int64_t Offset, | |
| if (Error Err = InputBuffOrErr.takeError()) | ||
| return Err; | ||
|
|
||
| if (Size > InputBuffOrErr->getBufferSize()) | ||
| return createStringError(inconvertibleErrorCode(), | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a |
||
| "size in URI is larger than source"); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The LLVM style guide says that error messages should include additional relevant context. In this case, it could be something like the source size. Similar comments apply below. |
||
| if (Offset > InputBuffOrErr->getBufferSize()) | ||
| return createStringError(inconvertibleErrorCode(), | ||
| "offset in URI is beyond the size of the source"); | ||
| if (Offset + Size > InputBuffOrErr->getBufferSize()) | ||
| return createStringError( | ||
| inconvertibleErrorCode(), | ||
| "offset + size in URI is beyond the size of the source"); | ||
|
|
||
| std::unique_ptr<FileOutputBuffer> Buf = std::move(*BufferOrErr); | ||
| std::copy(InputBuffOrErr->getBufferStart() + Offset, | ||
| InputBuffOrErr->getBufferStart() + Offset + Size, | ||
| Buf->getBufferStart()); | ||
| if (Error E = Buf->commit()) | ||
| return E; | ||
| return createFileError(OutputFileName, std::move(E)); | ||
|
|
||
| return Error::success(); | ||
| } | ||
|
|
@@ -238,7 +249,7 @@ Error object::extractOffloadBundleByURI(StringRef URIstr) { | |
| // Create an ObjectFile object from uri.file_uri | ||
| auto ObjOrErr = ObjectFile::createObjectFile(Uri.FileName); | ||
| if (!ObjOrErr) | ||
| return ObjOrErr.takeError(); | ||
| return createFileError(Uri.FileName, ObjOrErr.takeError()); | ||
|
|
||
| auto Obj = ObjOrErr->getBinary(); | ||
| if (Error Err = | ||
|
|
||
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.