Documentation
¶
Index ¶
- Constants
- func BinSections(ctx *Context)
- func CheckFileCompatibility(ctx *Context, file *File)
- func CheckMagic(contents []byte) bool
- func ComputeMergedSectionSizes(ctx *Context)
- func ComputeSectionSizes(ctx *Context)
- func CreateSyntheticSections(ctx *Context)
- func ElfGetName(strTab []byte, offset uint32) string
- func GetOutputName(name string, flags uint64) string
- func MarkLiveObjects(ctx *Context)
- func ReadFile(ctx *Context, file *File)
- func ReadInputFiles(ctx *Context, remaining []string)
- func RegisterSectionPieces(ctx *Context)
- func ResolveSymbols(ctx *Context)
- func ScanRelocations(ctx *Context)
- func SetOutputSectionOffsets(ctx *Context) uint64
- func SortOutputSections(ctx *Context)
- func WriteMagic(contents []byte)
- type ArHdr
- type Chunk
- type Chunker
- type Context
- type ContextArgs
- type Ehdr
- type File
- type FileType
- type GotEntry
- type GotSection
- type InputFile
- type InputSection
- func (i *InputSection) ApplyRelocAlloc(ctx *Context, base []byte)
- func (i *InputSection) CopyContents(buf []byte)
- func (i *InputSection) GetAddr() uint64
- func (i *InputSection) GetRels() []Rela
- func (i *InputSection) Name() string
- func (i *InputSection) ScanRelocations()
- func (i *InputSection) Shdr() *Shdr
- func (i *InputSection) WriteTo(ctx *Context, buf []byte)
- type MachineType
- type MachineTypeStringer
- type MergeableSection
- type MergedSection
- type ObjectFile
- func (o *ObjectFile) ClearSymbols()
- func (o *ObjectFile) FillUpSymtabShndxSec(s *Shdr)
- func (o *ObjectFile) GetSection(esym *Sym, idx int) *InputSection
- func (o *ObjectFile) GetShndx(esym *Sym, idx int) int64
- func (o *ObjectFile) InitializeMergeableSections(ctx *Context)
- func (o *ObjectFile) InitializeSections(ctx *Context)
- func (o *ObjectFile) InitializeSymbols(ctx *Context)
- func (o *ObjectFile) MarkLiveObjects(feeder func(*ObjectFile))
- func (o *ObjectFile) Parse(ctx *Context)
- func (o *ObjectFile) RegisterSectionPieces()
- func (o *ObjectFile) ResolveSymbols()
- func (o *ObjectFile) ScanRelocations()
- func (o *ObjectFile) SkipEhframeSections()
- type OutputEhdr
- type OutputPhdr
- type OutputSection
- type OutputShdr
- type Phdr
- type Rela
- type SectionFragment
- type Shdr
- type Sym
- type Symbol
Constants ¶
View Source
const ArHdrSize = int(unsafe.Sizeof(ArHdr{}))
View Source
const EF_RISCV_RVC uint32 = 1
View Source
const EhdrSize = int(unsafe.Sizeof(Ehdr{}))
View Source
const IMAGE_BASE uint64 = 0x200000
View Source
const (
NeedsGotTp uint32 = 1 << 0
)
View Source
const PageSize = 4096
View Source
const PhdrSize = int(unsafe.Sizeof(Phdr{}))
View Source
const RelaSize = int(unsafe.Sizeof(Rela{}))
View Source
const ShdrSize = int(unsafe.Sizeof(Shdr{}))
View Source
const SymSize = int(unsafe.Sizeof(Sym{}))
Variables ¶
This section is empty.
Functions ¶
func BinSections ¶
func BinSections(ctx *Context)
func CheckFileCompatibility ¶
func CheckMagic ¶
func ComputeMergedSectionSizes ¶
func ComputeMergedSectionSizes(ctx *Context)
func ComputeSectionSizes ¶
func ComputeSectionSizes(ctx *Context)
func CreateSyntheticSections ¶
func CreateSyntheticSections(ctx *Context)
func ElfGetName ¶
func GetOutputName ¶
func MarkLiveObjects ¶
func MarkLiveObjects(ctx *Context)
func ReadInputFiles ¶
func RegisterSectionPieces ¶
func RegisterSectionPieces(ctx *Context)
func ResolveSymbols ¶
func ResolveSymbols(ctx *Context)
func ScanRelocations ¶
func ScanRelocations(ctx *Context)
func SetOutputSectionOffsets ¶
func SortOutputSections ¶
func SortOutputSections(ctx *Context)
func WriteMagic ¶
func WriteMagic(contents []byte)
Types ¶
type ArHdr ¶
type Chunk ¶
func (*Chunk) UpdateShdr ¶
type Chunker ¶
type Chunker interface {
GetName() string
GetShdr() *Shdr
UpdateShdr(ctx *Context)
CopyBuf(ctx *Context)
}
func CollectOutputSections ¶
type Context ¶
type Context struct {
Args ContextArgs
Buf []byte
Ehdr *OutputEhdr
Shdr *OutputShdr
Phdr *OutputPhdr
Got *GotSection
TpAddr uint64
OutputSections []*OutputSection
Chunks []Chunker
Objs []*ObjectFile
SymbolMap map[string]*Symbol
MergedSections []*MergedSection
}
func NewContext ¶
func NewContext() *Context
type ContextArgs ¶
type ContextArgs struct {
Output string
Emulation MachineType
LibraryPaths []string
}
type GotSection ¶
func NewGotSection ¶
func NewGotSection() *GotSection
func (*GotSection) AddGotTpSymbol ¶
func (g *GotSection) AddGotTpSymbol(sym *Symbol)
func (*GotSection) CopyBuf ¶
func (g *GotSection) CopyBuf(ctx *Context)
func (*GotSection) GetEntries ¶
func (g *GotSection) GetEntries(ctx *Context) []GotEntry
type InputFile ¶
type InputFile struct {
File *File
ElfSections []Shdr
ElfSyms []Sym
FirstGlobal int
ShStrtab []byte
SymbolStrtab []byte
IsAlive bool
Symbols []*Symbol
LocalSymbols []Symbol
}
func NewInputFile ¶
func (*InputFile) FillUpElfSyms ¶
func (*InputFile) FindSection ¶
func (*InputFile) GetBytesFromIdx ¶
func (*InputFile) GetBytesFromShdr ¶
type InputSection ¶
type InputSection struct {
File *ObjectFile
Contents []byte
Shndx uint32
ShSize uint32
IsAlive bool
P2Align uint8
Offset uint32
OutputSection *OutputSection
RelsecIdx uint32
Rels []Rela
}
func NewInputSection ¶
func NewInputSection(ctx *Context, name string, file *ObjectFile, shndx uint32) *InputSection
func (*InputSection) ApplyRelocAlloc ¶
func (i *InputSection) ApplyRelocAlloc(ctx *Context, base []byte)
func (*InputSection) CopyContents ¶
func (i *InputSection) CopyContents(buf []byte)
func (*InputSection) GetAddr ¶
func (i *InputSection) GetAddr() uint64
func (*InputSection) GetRels ¶
func (i *InputSection) GetRels() []Rela
func (*InputSection) Name ¶
func (i *InputSection) Name() string
func (*InputSection) ScanRelocations ¶
func (i *InputSection) ScanRelocations()
func (*InputSection) Shdr ¶
func (i *InputSection) Shdr() *Shdr
func (*InputSection) WriteTo ¶
func (i *InputSection) WriteTo(ctx *Context, buf []byte)
type MachineType ¶
type MachineType = uint8
const ( MachineTypeNone MachineType = iota MachineTypeRISCV64 MachineType = iota )
func GetMachineTypeFromContents ¶
func GetMachineTypeFromContents(contents []byte) MachineType
type MachineTypeStringer ¶
type MachineTypeStringer struct {
MachineType
}
func (MachineTypeStringer) String ¶
func (m MachineTypeStringer) String() string
type MergeableSection ¶
type MergeableSection struct {
Parent *MergedSection
P2Align uint8
Strs []string
FragOffsets []uint32
Fragments []*SectionFragment
}
func (*MergeableSection) GetFragment ¶
func (m *MergeableSection) GetFragment(offset uint32) (*SectionFragment, uint32)
type MergedSection ¶
type MergedSection struct {
Chunk
Map map[string]*SectionFragment
}
func GetMergedSectionInstance ¶
func GetMergedSectionInstance( ctx *Context, name string, typ uint32, flags uint64) *MergedSection
func NewMergedSection ¶
func NewMergedSection( name string, flags uint64, typ uint32) *MergedSection
func (*MergedSection) AssignOffsets ¶
func (m *MergedSection) AssignOffsets()
func (*MergedSection) CopyBuf ¶
func (m *MergedSection) CopyBuf(ctx *Context)
func (*MergedSection) Insert ¶
func (m *MergedSection) Insert( key string, p2align uint32) *SectionFragment
type ObjectFile ¶
type ObjectFile struct {
InputFile
SymtabSec *Shdr
SymtabShndxSec []uint32
Sections []*InputSection
MergeableSections []*MergeableSection
}
func CreateObjectFile ¶
func CreateObjectFile(ctx *Context, file *File, inLib bool) *ObjectFile
func NewObjectFile ¶
func NewObjectFile(file *File, isAlive bool) *ObjectFile
func (*ObjectFile) ClearSymbols ¶
func (o *ObjectFile) ClearSymbols()
func (*ObjectFile) FillUpSymtabShndxSec ¶
func (o *ObjectFile) FillUpSymtabShndxSec(s *Shdr)
func (*ObjectFile) GetSection ¶
func (o *ObjectFile) GetSection(esym *Sym, idx int) *InputSection
func (*ObjectFile) InitializeMergeableSections ¶
func (o *ObjectFile) InitializeMergeableSections(ctx *Context)
func (*ObjectFile) InitializeSections ¶
func (o *ObjectFile) InitializeSections(ctx *Context)
func (*ObjectFile) InitializeSymbols ¶
func (o *ObjectFile) InitializeSymbols(ctx *Context)
func (*ObjectFile) MarkLiveObjects ¶
func (o *ObjectFile) MarkLiveObjects(feeder func(*ObjectFile))
func (*ObjectFile) Parse ¶
func (o *ObjectFile) Parse(ctx *Context)
func (*ObjectFile) RegisterSectionPieces ¶
func (o *ObjectFile) RegisterSectionPieces()
func (*ObjectFile) ResolveSymbols ¶
func (o *ObjectFile) ResolveSymbols()
func (*ObjectFile) ScanRelocations ¶
func (o *ObjectFile) ScanRelocations()
func (*ObjectFile) SkipEhframeSections ¶
func (o *ObjectFile) SkipEhframeSections()
type OutputEhdr ¶
type OutputEhdr struct {
Chunk
}
func NewOutputEhdr ¶
func NewOutputEhdr() *OutputEhdr
func (*OutputEhdr) CopyBuf ¶
func (o *OutputEhdr) CopyBuf(ctx *Context)
type OutputPhdr ¶
func NewOutputPhdr ¶
func NewOutputPhdr() *OutputPhdr
func (*OutputPhdr) CopyBuf ¶
func (o *OutputPhdr) CopyBuf(ctx *Context)
func (*OutputPhdr) UpdateShdr ¶
func (o *OutputPhdr) UpdateShdr(ctx *Context)
type OutputSection ¶
type OutputSection struct {
Chunk
Members []*InputSection
Idx uint32
}
func GetOutputSection ¶
func GetOutputSection( ctx *Context, name string, typ, flags uint64) *OutputSection
func NewOutputSection ¶
func NewOutputSection( name string, typ uint32, flags uint64, idx uint32) *OutputSection
func (*OutputSection) CopyBuf ¶
func (o *OutputSection) CopyBuf(ctx *Context)
type OutputShdr ¶
type OutputShdr struct {
Chunk
}
func NewOutputShdr ¶
func NewOutputShdr() *OutputShdr
func (*OutputShdr) CopyBuf ¶
func (o *OutputShdr) CopyBuf(ctx *Context)
func (*OutputShdr) UpdateShdr ¶
func (o *OutputShdr) UpdateShdr(ctx *Context)
type SectionFragment ¶
type SectionFragment struct {
OutputSection *MergedSection
Offset uint32
P2Align uint32
IsAlive bool
}
func NewSectionFragment ¶
func NewSectionFragment(m *MergedSection) *SectionFragment
func (*SectionFragment) GetAddr ¶
func (s *SectionFragment) GetAddr() uint64
type Symbol ¶
type Symbol struct {
File *ObjectFile
Name string
Value uint64
SymIdx int
GotTpIdx int32
InputSection *InputSection
SectionFragment *SectionFragment
Flags uint32
}
func GetSymbolByName ¶
func (*Symbol) GetGotTpAddr ¶
func (*Symbol) SetInputSection ¶
func (s *Symbol) SetInputSection(isec *InputSection)
func (*Symbol) SetSectionFragment ¶
func (s *Symbol) SetSectionFragment(frag *SectionFragment)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.