Imports #
"bytes"
"cmd/internal/bio"
"cmd/internal/objabi"
"cmd/internal/sys"
"cmd/link/internal/loader"
"cmd/link/internal/sym"
"debug/elf"
"encoding/binary"
"fmt"
"io"
"log"
"strings"
"bytes"
"cmd/internal/bio"
"cmd/internal/objabi"
"cmd/internal/sys"
"cmd/link/internal/loader"
"cmd/link/internal/sym"
"debug/elf"
"encoding/binary"
"fmt"
"io"
"log"
"strings"
const SHT_ARM_ATTRIBUTES = 0x70000003
const TagABIVFPArgs = 28
const TagAlsoCompatibleWith = 65
const TagCPUName = 4
const TagCPURawName = 5
const TagCompatibility = 32
const TagFile = 1
const TagNoDefaults = 64
type ElfObj struct {
f *bio.Reader
base int64
length int64
is64 int
name string
e binary.ByteOrder
sect []ElfSect
nsect uint
nsymtab int
symtab *ElfSect
symstr *ElfSect
type_ uint32
machine uint32
version uint32
entry uint64
phoff uint64
shoff uint64
flags uint32
ehsize uint32
phentsize uint32
phnum uint32
shentsize uint32
shnum uint32
shstrndx uint32
}
type ElfSect struct {
name string
nameoff uint32
type_ elf.SectionType
flags elf.SectionFlag
addr uint64
off uint64
size uint64
link uint32
info uint32
align uint64
entsize uint64
base []byte
readOnlyMem bool
sym loader.Sym
}
type ElfSym struct {
name string
value uint64
size uint64
bind elf.SymBind
type_ elf.SymType
other uint8
shndx elf.SectionIndex
sym loader.Sym
}
type elfAttribute struct {
tag uint64
sval string
ival uint64
}
type elfAttributeList struct {
data []byte
err error
}
Load loads the ELF file pn from f. Symbols are installed into the loader, and a slice of the text symbols is returned. On ARM systems, Load will attempt to determine what ELF header flags to emit by scanning the attributes in the ELF file being loaded. The parameter initEhdrFlags contains the current header flags for the output object, and the returned ehdrFlags contains what this Load function computes. TODO: find a better place for this logic.
func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, f *bio.Reader, pkg string, length int64, pn string, initEhdrFlags uint32) (textp []loader.Sym, ehdrFlags uint32, err error)
Read an elfAttribute from the list following the rules used on ARM systems.
func (a *elfAttributeList) armAttr() elfAttribute
func cstring(x []byte) string
func (a *elfAttributeList) done() bool
func elfmap(elfobj *ElfObj, sect *ElfSect) (err error)
Look for the attribute that indicates the object uses the hard-float ABI (a file-level attribute with tag Tag_VFP_arch and value 1). Unfortunately the format used means that we have to parse all of the file-level attributes to find the one we are looking for. This format is slightly documented in "ELF for the ARM Architecture" but mostly this is derived from reading the source to gold and readelf.
func parseArmAttributes(e binary.ByteOrder, data []byte) (found bool, ehdrFlags uint32, err error)
func readelfsym(l *loader.Loader, arch *sys.Arch, elfobj *ElfObj, i int, elfsym *ElfSym, needSym int, localSymVersion int) (err error)
Return the size of the relocated field, and the size of the addend as the first and second values. Note, the addend may be larger than the relocation field in some cases when a relocated value is split across multiple relocations.
func relSize(arch *sys.Arch, pn string, elftype uint32) (uint8, uint8, error)
func section(elfobj *ElfObj, name string) *ElfSect
func (a *elfAttributeList) string() string
func (a *elfAttributeList) uleb128() uint64
Generated with Arrow