elfwriter

package module
v0.0.0-...-ddd4f52 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2020 License: BSD-2-Clause Imports: 4 Imported by: 0

README

elfwriter [WIP]

A go library for writing ELF data using the built in elf/debug package.

Usage

elfwriter only has one public method, WriteElf:

// shrtrndx = section header table index of the entry associated with the section name string table
func WriteElf(f *elf.File, w io.WriteSeeker, programTableOffset, sectionTableOffset uint64, shstrndx uint16) error

It will write a complete ELF file to w with the given ELF data.

Documentation

Overview

A go library for writing ELF data using the built in [`elf/debug`](https://golang.org/pkg/debug/elf/) package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ELFFile

type ELFFile struct {
	FileHeader   FileHeader
	ProgramTable []ProgramSegment
	SectionTable []SectionHeader
}

func (*ELFFile) Write

func (f *ELFFile) Write(w io.WriteSeeker) error

WriteElf writes the given ELF info to the provided writer

type FileHeader

type FileHeader struct {
	// ident
	Class      elf.Class
	Endianness elf.Data
	ABI        elf.OSABI
	ABIVersion byte

	// Rest of struct
	Type elf.Type
	Arch elf.Machine

	// Change the following from uint64 to uint32 for 32 bit mode
	EntryPoint         uint64
	ProgramTableOffset uint64
	SectionTableOffset uint64

	Flags    uint32 // Not used
	Shstrndx uint16
}

type ProgramSegment

type ProgramSegment struct {
	Type         elf.ProgType
	Flags        elf.ProgFlag
	Offset       uint64 // File offset
	VirtualAddr  uint64 // Virtual memory starting address
	PhysicalAddr uint64 // Physical address (not relevant for most systems)
	FileSize     uint64
	MemSize      uint64
	Align        uint64
	Data         []byte
}

type SectionHeader

type SectionHeader struct{}

Jump to

Keyboard shortcuts

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