diff --git a/.gitignore b/.gitignore index 3b9d416..9c65660 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ picobin !cmd/picobin !boot/picobin !testdata/blink.elf +!testdata/helloc.elf # IDE .vscode/ diff --git a/README.md b/README.md index 4caf22d..c91e4f9 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ go mod download github.com/soypat/tinyboot@latest ## Package layout There are two main top level packages: - [`boot`](./boot): Concerns storage formats for booting a computer such as MBT, GPT and Raspberry Pi's picobin format. - - [`boot/mbt`](./boot/mbt): Master Boot Record Partition Table interfacing. + - [`boot/mbr`](./boot/mbr): Master Boot Record Partition Table interfacing. - [`boot/gpt`](./boot/gpt): GUID Partition Table interfacing. - [`boot/picobin`](./boot/picobin): Raspberry Pi's bootable format for RP2350 and RP2040. diff --git a/build/xelf/file.go b/build/xelf/file.go index 654db98..900126c 100644 --- a/build/xelf/file.go +++ b/build/xelf/file.go @@ -154,69 +154,6 @@ func (f *File) Read(r io.ReaderAt) error { return nil } -func (f *File) WriteTo(w io.Writer) (n int64, err error) { - return n, errors.ErrUnsupported - b := f.buf[:] - err = f.hdr.Validate() - if err != nil { - return 0, err - } - - nput, err := f.hdr.Put(b) - if err != nil { - return n, err - } - nw, err := w.Write(b[:nput]) - n += int64(nw) - if err != nil { - return n, err - } else if nw != nput { - return n, io.ErrShortWrite - } - if err != nil { - return 0, err - } - // We define our ELF layout here. - phtotsize := int64(f.hdr.Phentsize) * int64(f.hdr.Phnum) - shtotsize := int64(f.hdr.Shentsize) * int64(f.hdr.Shnum) - - phOff := n - shOff := phOff + phtotsize - _ = shtotsize - _ = shOff - // And now we consolidate - bo := f.hdr.ByteOrder() - for i := range f.progs { - p := &f.progs[i] - nput, err = p.ProgHeader.Put(b, f.hdr.Class, bo) - if err != nil { - return n, err - } - nw, err := w.Write(b[:nput]) - n += int64(nw) - if err != nil { - return n, err - } else if nw != nput { - return n, io.ErrShortWrite - } - } - for i := range f.sections { - s := &f.sections[i] - nput, err = s.SectionHeader.Put(b, f.hdr.Class, bo) - if err != nil { - return n, err - } - nw, err := w.Write(b[:nput]) - n += int64(nw) - if err != nil { - return n, err - } else if nw != nput { - return n, io.ErrShortWrite - } - } - return 0, nil -} - // Header returns the ELF header. func (f *File) Header() Header { return f.hdr diff --git a/testdata/helloc.elf b/testdata/helloc.elf new file mode 100755 index 0000000..af70347 Binary files /dev/null and b/testdata/helloc.elf differ