[llvm] [llvm-objcopy] Support SREC output format (PR #75874)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 16 14:36:39 PST 2024
================
@@ -390,6 +392,104 @@ class IHexWriter : public Writer {
IHexWriter(Object &Obj, raw_ostream &Out) : Writer(Obj, Out) {}
};
+using SRecLineData = SmallVector<char, 64>;
+struct SRecord {
+ uint8_t Type;
+ uint32_t Address;
+ ArrayRef<uint8_t> Data;
+ SRecLineData toString() const;
+ uint8_t getCount() const;
+ // get address size in characters
+ uint8_t getAddressSize() const;
+ uint8_t getChecksum() const;
+ size_t getSize() const;
+ static SRecord getHeader(StringRef FileName);
+ static uint8_t getType(uint32_t Address);
+ enum Type : uint8_t {
+ // Vendor specific text comment
+ S0 = 0,
+ // Data that starts at a 16 bit address
+ S1 = 1,
+ // Data that starts at a 24 bit address
+ S2 = 2,
+ // Data that starts at a 32 bit address
+ S3 = 3,
+ // Reserved
+ S4 = 4,
+ // 16 bit count of S1/S2/S3 records (optional)
+ S5 = 5,
+ // 32 bit count of S1/S2/S3 records (optional)
+ S6 = 6,
+ // Terminates a series of S3 records
+ S7 = 7,
+ // Terminates a series of S2 records
+ S8 = 8,
+ // Terminates a series of S1 records
+ S9 = 9
+ };
+};
+
+/// The real writer
+class SRECWriter : public Writer {
+ StringRef OutputFileName;
+ size_t TotalSize = 0;
+ std::vector<const SectionBase *> Sections;
+
+ size_t writeHeader(uint8_t *Buf);
+ size_t writeTerminator(uint8_t *Buf, uint8_t Type);
+ Error checkSection(const SectionBase &S) const;
+
+public:
+ ~SRECWriter() = default;
----------------
quic-areg wrote:
No. Removed.
https://github.com/llvm/llvm-project/pull/75874
More information about the llvm-commits
mailing list