elfwriter

package
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package elfwriter is a package to write ELF files without having their entire contents in memory at any one time.

Original work started from https://github.com/go-delve/delve/blob/master/pkg/elfwriter/writer.go and additional functionality added on top.

This package does not provide completeness guarantees. Some of the missing features: - Consistency and soundness of relocations - Consistency and preservation of linked sections (when target removed (sh_link)) - partially supported - Consistency and existence of overlapping segments when a section removed (offset, range check)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregatingWriter

type AggregatingWriter struct {
	Writer
}

AggregatingWriter is a wrapper around Writer that aggregates all given the sections, and programs. Then write them to underlying io.WriteSeeker.

func NewFromHeader

func NewFromHeader(dst io.WriteSeeker, header *elf.FileHeader, opts ...Option) (*AggregatingWriter, error)

NewFromHeader creates a new Aggregating using given header.

func (*AggregatingWriter) AddHeaderOnlySections

func (w *AggregatingWriter) AddHeaderOnlySections(headers ...elf.SectionHeader)

AddHeaderOnlySections add header only sections to the buffer.

func (*AggregatingWriter) AddPrograms

func (w *AggregatingWriter) AddPrograms(progs ...*elf.Prog)

AddPrograms adds programs to the buffer.

func (*AggregatingWriter) AddSections

func (w *AggregatingWriter) AddSections(secs ...*elf.Section)

AddSections add sections to the buffer. If sections have links to other sections, the order of the given sections is important.

type FilteringWriter

type FilteringWriter struct {
	Writer
	// contains filtered or unexported fields
}

FilteringWriter is a wrapper around Writer that allows to filter out sections, and programs from the source. Then write them to underlying io.WriteSeeker.

func NewFromSource

func NewFromSource(dst io.WriteSeeker, src SeekReaderAt, opts ...Option) (*FilteringWriter, error)

NewFromSource creates a new Writer using given source.

func (*FilteringWriter) FilterHeaderOnlySections

func (w *FilteringWriter) FilterHeaderOnlySections(predicates ...func(*elf.Section) bool)

FilterHeaderOnlySections filters out header only sections from the source.

func (*FilteringWriter) FilterPrograms

func (w *FilteringWriter) FilterPrograms(predicates ...func(*elf.Prog) bool)

FilterPrograms filters out programs from the source.

func (*FilteringWriter) FilterSections

func (w *FilteringWriter) FilterSections(predicates ...func(*elf.Section) bool)

FilterSections filters out sections from the source. If sections have links to other sections, the referred sections are also be carried over to the destination.

func (*FilteringWriter) Flush

func (w *FilteringWriter) Flush() error

type Note

type Note struct {
	Type elf.NType
	Name string
	Data []byte
}

type Option

type Option func(w *Writer)

func WithDebugCompressionEnabled

func WithDebugCompressionEnabled(b bool) Option

type SeekReaderAt

type SeekReaderAt interface {
	io.ReaderAt
	io.Seeker
}

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer writes ELF files.

func (*Writer) AddNotes

func (w *Writer) AddNotes(additionalNotes ...Note)

AddNotes adds additional notes to write to in the underlying io.WriterSeeker.

func (*Writer) Flush

func (w *Writer) Flush() error

Flush writes any buffered data to the underlying io.WriterSeeker.

func (*Writer) Reset

func (w *Writer) Reset(ws io.WriteSeeker)

Reset discards any unflushed buffered data, clears any error, and resets data to write its output to dst.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL