func (cc *CoreConvert) makeRegInfo(regs []byte) { var phdr elf.Prog32 phdr.Type = uint32(elf.PT_NOTE) phdr.Off = 0 phdr.Vaddr = 0 phdr.Paddr = 0 phdr.Filesz = 0 phdr.Memsz = 0 phdr.Flags = 0 phdr.Align = 4 data := cc.makeRegData(regs) phdr.Filesz = uint32(len(data)) cc.phdrs = append(cc.phdrs, &phdr) cc.data = append(cc.data, data) }
func (cc *CoreConvert) makeProgHdr(off uint32, mem []byte) { var phdr elf.Prog32 memSz := uint32(len(mem)) phdr.Type = uint32(elf.PT_LOAD) phdr.Off = 0 /* offset of data in file */ phdr.Vaddr = off phdr.Paddr = 0 phdr.Filesz = memSz phdr.Memsz = memSz phdr.Flags = uint32(elf.PF_R) phdr.Align = 4 cc.phdrs = append(cc.phdrs, &phdr) if memSz%4 != 0 { pad := make([]byte, 4-memSz%4) mem = append(mem, pad...) } cc.data = append(cc.data, mem) }