[PATCH] D107273: [llvm-objcopy] IHexELFBuilder::addDataSections - fix evaluation ordering static analyzer warning
Simon Pilgrim via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 3 04:28:27 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG43ff058e78d9: [llvm-objcopy] IHexELFBuilder::addDataSections - fix evaluation ordering static… (authored by RKSimon).
Changed prior to commit:
https://reviews.llvm.org/D107273?vs=363532&id=363688#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D107273/new/
https://reviews.llvm.org/D107273
Files:
llvm/tools/llvm-objcopy/ELF/Object.cpp
Index: llvm/tools/llvm-objcopy/ELF/Object.cpp
===================================================================
--- llvm/tools/llvm-objcopy/ELF/Object.cpp
+++ llvm/tools/llvm-objcopy/ELF/Object.cpp
@@ -1342,13 +1342,16 @@
if (R.HexData.empty())
continue;
RecAddr = R.Addr + SegmentAddr + BaseAddr;
- if (!Section || Section->Addr + Section->Size != RecAddr)
+ if (!Section || Section->Addr + Section->Size != RecAddr) {
// OriginalOffset field is only used to sort section properly, so
- // instead of keeping track of real offset in IHEX file, we use
- // section number.
+ // instead of keeping track of real offset in IHEX file, and as
+ // Object::sortSections() uses llvm::stable_sort(), we can just set to a
+ // constant (zero).
Section = &Obj->addSection<OwnedDataSection>(
- ".sec" + std::to_string(SecNo++), RecAddr,
- ELF::SHF_ALLOC | ELF::SHF_WRITE, SecNo);
+ ".sec" + std::to_string(SecNo), RecAddr,
+ ELF::SHF_ALLOC | ELF::SHF_WRITE, 0);
+ SecNo++;
+ }
Section->appendHexData(R.HexData);
break;
case IHexRecord::EndOfFile:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107273.363688.patch
Type: text/x-patch
Size: 1200 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210803/a136bb55/attachment-0001.bin>
More information about the llvm-commits
mailing list