示例#1
0
文件: elf_auxv.go 项目: x56/usercorn
func SetupElfAuxv(u models.Usercorn) ([]byte, error) {
	var buf bytes.Buffer
	auxv, err := setupElfAuxv(u)
	if err != nil {
		return nil, err
	}
	if u.Bits() == 32 {
		var auxv32 Elf32Auxv
		for _, a := range auxv {
			auxv32.Type = uint32(a.Type)
			auxv32.Val = uint32(a.Val)
			if err := struc.PackWithOrder(&buf, &auxv32, u.ByteOrder()); err != nil {
				return nil, err
			}
		}
	} else {
		for _, a := range auxv {
			if err := struc.PackWithOrder(&buf, &a, u.ByteOrder()); err != nil {
				return nil, err
			}
		}
	}
	return buf.Bytes(), err
}
示例#2
0
func (s *StrucStream) Pack(i interface{}) error {
	return struc.PackWithOrder(s.Stream, i, s.Order)
}