[llvm] [llvm-objcopy] Support SREC output format (PR #75874)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 26 00:36:38 PST 2024


================
@@ -2847,24 +2847,24 @@ void SRECSectionWriter::writeRecord(SRecord &Record, uint64_t Off) {
   memcpy(Out.getBufferStart() + Off, Data.data(), Data.size());
 }
 
-void SRECSectionWriter::writeRecords(uint32_t Entry) {
+void SRECSizeCalculator::writeRecords(uint32_t Entry) {
+  // The ELF header could contain an entry point outside of the sections we have
+  // seen that does not fit the current record Type.
   Type = std::max(Type, SRecord::getType(Entry));
   uint64_t Off = HeaderSize;
   for (SRecord &Record : Records) {
     Record.Type = Type;
-    writeRecord(Record, Off);
     Off += Record.getSize();
   }
   Offset = Off;
 }
 
-void SRECSectionWriterBase::writeRecords(uint32_t Entry) {
-  // The ELF header could contain an entry point outside of the sections we have
-  // seen that does not fit the current record Type.
+void SRECSectionWriter::writeRecords(uint32_t Entry) {
   Type = std::max(Type, SRecord::getType(Entry));
----------------
jh7370 wrote:

Could we move this function into the base class, and just make `writeRecord` the sub-class specific method (in the size calculation case, it does nothing)?

https://github.com/llvm/llvm-project/pull/75874


More information about the llvm-commits mailing list