Skip to content

Commit

Permalink
fix CI tests by adding test ELF. fix README mbr link
Browse files Browse the repository at this point in the history
  • Loading branch information
soypat committed Oct 6, 2024
1 parent 2642653 commit 8052aa4
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 64 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ picobin
!cmd/picobin
!boot/picobin
!testdata/blink.elf
!testdata/helloc.elf
# IDE
.vscode/

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
63 changes: 0 additions & 63 deletions build/xelf/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file added testdata/helloc.elf
Binary file not shown.

0 comments on commit 8052aa4

Please sign in to comment.