Documentation
¶
Index ¶
- Constants
- func CheckMagic(contents []byte, magic string) bool
- func ElfGetName(strTab []byte, offset uint32) string
- func ReadFile(ctx *Context, file *File)
- func ReadInputFiles(ctx *Context, remaining []string)
- type ArHdr
- type Context
- type ContextArgs
- type EHdr
- type File
- type FileType
- type InputFile
- type MachineType
- type MachineTypeStringer
- type ObjFile
- type SHdr
- type Sym
Constants ¶
View Source
const ArHdrSize = unsafe.Sizeof(ArHdr{})
archive file header size
View Source
const EhdrSize = unsafe.Sizeof(EHdr{})
elf header size
View Source
const ElfObjectMagicNumber = "\177ELF"
View Source
const ElfStaticLinkMagicNumber = "!<arch>\n"
View Source
const SHdrSize = unsafe.Sizeof(SHdr{})
section header size
View Source
const SymSize = unsafe.Sizeof(Sym{})
符号表结构的大小
Variables ¶
This section is empty.
Functions ¶
func ElfGetName ¶
根据在shstrtab这个sh中的偏移量,返回相应sh的名字的字符串
Types ¶
type ArHdr ¶
type Context ¶
type Context struct {
Args ContextArgs
Objs []*ObjFile
}
func NewContext ¶
func NewContext() *Context
type ContextArgs ¶
type ContextArgs struct {
Output string // 保存链接器最后生成的文件名字
Emulation MachineType // 哪种架构
LibraryPaths []string // 库文件的路径,这是个数组
}
type EHdr ¶
type EHdr struct {
Ident [16]uint8
Type uint16
Machine uint16
Version uint32
Entry uint64
PhOff uint64
ShOff uint64
Flags uint32
EhSize uint16
PhEntSize uint16
PhNum uint16
ShEntSize uint16
ShNum uint16
ShStrNdx uint16
}
elf header struct
type File ¶
func ReadArchiveMembers ¶
type InputFile ¶
type InputFile struct {
File *File
ElfSections []SHdr // section数组
ShStrtab []byte // 对象文件的strtab sh
FirstGlobal int64
ElfSyms []Sym // 符号表数组
SymbolStrtab []byte // 符号表的str table
}
链接文件的基类
func NewInputFile ¶
func (*InputFile) FindfSection ¶
在对象文件的sh数组中,找到相应类型的sh
func (*InputFile) GetBytesFromIdx ¶
根据section header在数组中的偏移,拿到section的内容
func (*InputFile) GetBytesFromShdr ¶
根据secion header拿到对应的section的内容
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
Click to show internal directories.
Click to hide internal directories.