| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710 |
- // Copyright 2022 The Gc Authors. All rights reserved.
- // Use of this source code is governed by a BSD-style
- // license that can be found in the LICENSE file.
- package gc // import "modernc.org/gc/v3"
- import (
- "encoding/binary"
- "fmt"
- )
- var (
- byteOrders = map[string]binary.ByteOrder{
- "386": binary.LittleEndian,
- "amd64": binary.LittleEndian,
- "arm": binary.LittleEndian,
- "arm64": binary.LittleEndian,
- "loong64": binary.LittleEndian,
- "ppc64le": binary.LittleEndian,
- "riscv64": binary.LittleEndian,
- "s390x": binary.BigEndian,
- }
- abiTypes = map[[2]string]map[Kind]ABIType{
- // go1.19.1
- {"freebsd", "386"}: {
- Bool: {1, 1, 1},
- Chan: {4, 4, 4},
- Complex128: {16, 4, 4},
- Complex64: {8, 4, 4},
- Float32: {4, 4, 4},
- Float64: {8, 4, 4},
- Function: {4, 4, 4},
- Int: {4, 4, 4},
- Int16: {2, 2, 2},
- Int32: {4, 4, 4},
- Int64: {8, 4, 4},
- Int8: {1, 1, 1},
- Interface: {8, 4, 4},
- Map: {4, 4, 4},
- Pointer: {4, 4, 4},
- Slice: {12, 4, 4},
- String: {8, 4, 4},
- Uint: {4, 4, 4},
- Uint16: {2, 2, 2},
- Uint32: {4, 4, 4},
- Uint64: {8, 4, 4},
- Uint8: {1, 1, 1},
- Uintptr: {4, 4, 4},
- UnsafePointer: {4, 4, 4},
- },
- // go1.19.1
- {"freebsd", "amd64"}: {
- Bool: {1, 1, 1},
- Chan: {8, 8, 8},
- Complex128: {16, 8, 8},
- Complex64: {8, 4, 4},
- Float32: {4, 4, 4},
- Float64: {8, 8, 8},
- Function: {8, 8, 8},
- Int: {8, 8, 8},
- Int16: {2, 2, 2},
- Int32: {4, 4, 4},
- Int64: {8, 8, 8},
- Int8: {1, 1, 1},
- Interface: {16, 8, 8},
- Map: {8, 8, 8},
- Pointer: {8, 8, 8},
- Slice: {24, 8, 8},
- String: {16, 8, 8},
- Uint: {8, 8, 8},
- Uint16: {2, 2, 2},
- Uint32: {4, 4, 4},
- Uint64: {8, 8, 8},
- Uint8: {1, 1, 1},
- Uintptr: {8, 8, 8},
- UnsafePointer: {8, 8, 8},
- },
- // go1.18.5
- {"freebsd", "arm"}: {
- Bool: {1, 1, 1},
- Chan: {4, 4, 4},
- Complex128: {16, 4, 4},
- Complex64: {8, 4, 4},
- Float32: {4, 4, 4},
- Float64: {8, 4, 4},
- Function: {4, 4, 4},
- Int: {4, 4, 4},
- Int16: {2, 2, 2},
- Int32: {4, 4, 4},
- Int64: {8, 4, 4},
- Int8: {1, 1, 1},
- Interface: {8, 4, 4},
- Map: {4, 4, 4},
- Pointer: {4, 4, 4},
- Slice: {12, 4, 4},
- String: {8, 4, 4},
- Uint: {4, 4, 4},
- Uint16: {2, 2, 2},
- Uint32: {4, 4, 4},
- Uint64: {8, 4, 4},
- Uint8: {1, 1, 1},
- Uintptr: {4, 4, 4},
- UnsafePointer: {4, 4, 4},
- },
- // go1.19
- {"freebsd", "arm64"}: {
- Bool: {1, 1, 1},
- Chan: {8, 8, 8},
- Complex128: {16, 8, 8},
- Complex64: {8, 4, 4},
- Float32: {4, 4, 4},
- Float64: {8, 8, 8},
- Function: {8, 8, 8},
- Int: {8, 8, 8},
- Int16: {2, 2, 2},
- Int32: {4, 4, 4},
- Int64: {8, 8, 8},
- Int8: {1, 1, 1},
- Interface: {16, 8, 8},
- Map: {8, 8, 8},
- Pointer: {8, 8, 8},
- Slice: {24, 8, 8},
- String: {16, 8, 8},
- Uint: {8, 8, 8},
- Uint16: {2, 2, 2},
- Uint32: {4, 4, 4},
- Uint64: {8, 8, 8},
- Uint8: {1, 1, 1},
- Uintptr: {8, 8, 8},
- UnsafePointer: {8, 8, 8},
- },
- // go1.19.1
- {"darwin", "amd64"}: {
- Bool: {1, 1, 1},
- Chan: {8, 8, 8},
- Complex128: {16, 8, 8},
- Complex64: {8, 4, 4},
- Float32: {4, 4, 4},
- Float64: {8, 8, 8},
- Function: {8, 8, 8},
- Int: {8, 8, 8},
- Int16: {2, 2, 2},
- Int32: {4, 4, 4},
- Int64: {8, 8, 8},
- Int8: {1, 1, 1},
- Interface: {16, 8, 8},
- Map: {8, 8, 8},
- Pointer: {8, 8, 8},
- Slice: {24, 8, 8},
- String: {16, 8, 8},
- Uint: {8, 8, 8},
- Uint16: {2, 2, 2},
- Uint32: {4, 4, 4},
- Uint64: {8, 8, 8},
- Uint8: {1, 1, 1},
- Uintptr: {8, 8, 8},
- UnsafePointer: {8, 8, 8},
- },
- // go1.19.1
- {"darwin", "arm64"}: {
- Bool: {1, 1, 1},
- Chan: {8, 8, 8},
- Complex128: {16, 8, 8},
- Complex64: {8, 4, 4},
- Float32: {4, 4, 4},
- Float64: {8, 8, 8},
- Function: {8, 8, 8},
- Int: {8, 8, 8},
- Int16: {2, 2, 2},
- Int32: {4, 4, 4},
- Int64: {8, 8, 8},
- Int8: {1, 1, 1},
- Interface: {16, 8, 8},
- Map: {8, 8, 8},
- Pointer: {8, 8, 8},
- Slice: {24, 8, 8},
- String: {16, 8, 8},
- Uint: {8, 8, 8},
- Uint16: {2, 2, 2},
- Uint32: {4, 4, 4},
- Uint64: {8, 8, 8},
- Uint8: {1, 1, 1},
- Uintptr: {8, 8, 8},
- UnsafePointer: {8, 8, 8},
- },
- // go1.19.1
- {"linux", "386"}: {
- Bool: {1, 1, 1},
- Chan: {4, 4, 4},
- Complex128: {16, 4, 4},
- Complex64: {8, 4, 4},
- Float32: {4, 4, 4},
- Float64: {8, 4, 4},
- Function: {4, 4, 4},
- Int: {4, 4, 4},
- Int16: {2, 2, 2},
- Int32: {4, 4, 4},
- Int64: {8, 4, 4},
- Int8: {1, 1, 1},
- Interface: {8, 4, 4},
- Map: {4, 4, 4},
- Pointer: {4, 4, 4},
- Slice: {12, 4, 4},
- String: {8, 4, 4},
- Uint: {4, 4, 4},
- Uint16: {2, 2, 2},
- Uint32: {4, 4, 4},
- Uint64: {8, 4, 4},
- Uint8: {1, 1, 1},
- Uintptr: {4, 4, 4},
- UnsafePointer: {4, 4, 4},
- },
- // go1.19.1
- {"linux", "amd64"}: {
- Bool: {1, 1, 1},
- Chan: {8, 8, 8},
- Complex128: {16, 8, 8},
- Complex64: {8, 4, 4},
- Float32: {4, 4, 4},
- Float64: {8, 8, 8},
- Function: {8, 8, 8},
- Int: {8, 8, 8},
- Int16: {2, 2, 2},
- Int32: {4, 4, 4},
- Int64: {8, 8, 8},
- Int8: {1, 1, 1},
- Interface: {16, 8, 8},
- Map: {8, 8, 8},
- Pointer: {8, 8, 8},
- Slice: {24, 8, 8},
- String: {16, 8, 8},
- Uint: {8, 8, 8},
- Uint16: {2, 2, 2},
- Uint32: {4, 4, 4},
- Uint64: {8, 8, 8},
- Uint8: {1, 1, 1},
- Uintptr: {8, 8, 8},
- UnsafePointer: {8, 8, 8},
- },
- // go1.19.1
- {"linux", "arm"}: {
- Bool: {1, 1, 1},
- Chan: {4, 4, 4},
- Complex128: {16, 4, 4},
- Complex64: {8, 4, 4},
- Float32: {4, 4, 4},
- Float64: {8, 4, 4},
- Function: {4, 4, 4},
- Int: {4, 4, 4},
- Int16: {2, 2, 2},
- Int32: {4, 4, 4},
- Int64: {8, 4, 4},
- Int8: {1, 1, 1},
- Interface: {8, 4, 4},
- Map: {4, 4, 4},
- Pointer: {4, 4, 4},
- Slice: {12, 4, 4},
- String: {8, 4, 4},
- Uint: {4, 4, 4},
- Uint16: {2, 2, 2},
- Uint32: {4, 4, 4},
- Uint64: {8, 4, 4},
- Uint8: {1, 1, 1},
- Uintptr: {4, 4, 4},
- UnsafePointer: {4, 4, 4},
- },
- // go1.19.1
- {"linux", "arm64"}: {
- Bool: {1, 1, 1},
- Chan: {8, 8, 8},
- Complex128: {16, 8, 8},
- Complex64: {8, 4, 4},
- Float32: {4, 4, 4},
- Float64: {8, 8, 8},
- Function: {8, 8, 8},
- Int: {8, 8, 8},
- Int16: {2, 2, 2},
- Int32: {4, 4, 4},
- Int64: {8, 8, 8},
- Int8: {1, 1, 1},
- Interface: {16, 8, 8},
- Map: {8, 8, 8},
- Pointer: {8, 8, 8},
- Slice: {24, 8, 8},
- String: {16, 8, 8},
- Uint: {8, 8, 8},
- Uint16: {2, 2, 2},
- Uint32: {4, 4, 4},
- Uint64: {8, 8, 8},
- Uint8: {1, 1, 1},
- Uintptr: {8, 8, 8},
- UnsafePointer: {8, 8, 8},
- },
- // go1.19.1
- {"linux", "s390x"}: {
- Bool: {1, 1, 1},
- Chan: {8, 8, 8},
- Complex128: {16, 8, 8},
- Complex64: {8, 4, 4},
- Float32: {4, 4, 4},
- Float64: {8, 8, 8},
- Function: {8, 8, 8},
- Int: {8, 8, 8},
- Int16: {2, 2, 2},
- Int32: {4, 4, 4},
- Int64: {8, 8, 8},
- Int8: {1, 1, 1},
- Interface: {16, 8, 8},
- Map: {8, 8, 8},
- Pointer: {8, 8, 8},
- Slice: {24, 8, 8},
- String: {16, 8, 8},
- Uint: {8, 8, 8},
- Uint16: {2, 2, 2},
- Uint32: {4, 4, 4},
- Uint64: {8, 8, 8},
- Uint8: {1, 1, 1},
- Uintptr: {8, 8, 8},
- UnsafePointer: {8, 8, 8},
- },
- // go1.19.1
- {"linux", "ppc64le"}: {
- Bool: {1, 1, 1},
- Chan: {8, 8, 8},
- Complex128: {16, 8, 8},
- Complex64: {8, 4, 4},
- Float32: {4, 4, 4},
- Float64: {8, 8, 8},
- Function: {8, 8, 8},
- Int: {8, 8, 8},
- Int16: {2, 2, 2},
- Int32: {4, 4, 4},
- Int64: {8, 8, 8},
- Int8: {1, 1, 1},
- Interface: {16, 8, 8},
- Map: {8, 8, 8},
- Pointer: {8, 8, 8},
- Slice: {24, 8, 8},
- String: {16, 8, 8},
- Uint: {8, 8, 8},
- Uint16: {2, 2, 2},
- Uint32: {4, 4, 4},
- Uint64: {8, 8, 8},
- Uint8: {1, 1, 1},
- Uintptr: {8, 8, 8},
- UnsafePointer: {8, 8, 8},
- },
- // go1.19.1
- {"linux", "riscv64"}: {
- Bool: {1, 1, 1},
- Chan: {8, 8, 8},
- Complex128: {16, 8, 8},
- Complex64: {8, 4, 4},
- Float32: {4, 4, 4},
- Float64: {8, 8, 8},
- Function: {8, 8, 8},
- Int: {8, 8, 8},
- Int16: {2, 2, 2},
- Int32: {4, 4, 4},
- Int64: {8, 8, 8},
- Int8: {1, 1, 1},
- Interface: {16, 8, 8},
- Map: {8, 8, 8},
- Pointer: {8, 8, 8},
- Slice: {24, 8, 8},
- String: {16, 8, 8},
- Uint: {8, 8, 8},
- Uint16: {2, 2, 2},
- Uint32: {4, 4, 4},
- Uint64: {8, 8, 8},
- Uint8: {1, 1, 1},
- Uintptr: {8, 8, 8},
- UnsafePointer: {8, 8, 8},
- },
- // go1.21.5
- {"linux", "loong64"}: {
- Bool: {1, 1, 1},
- Chan: {8, 8, 8},
- Complex128: {16, 8, 8},
- Complex64: {8, 4, 4},
- Float32: {4, 4, 4},
- Float64: {8, 8, 8},
- Function: {8, 8, 8},
- Int: {8, 8, 8},
- Int16: {2, 2, 2},
- Int32: {4, 4, 4},
- Int64: {8, 8, 8},
- Int8: {1, 1, 1},
- Interface: {16, 8, 8},
- Map: {8, 8, 8},
- Pointer: {8, 8, 8},
- Slice: {24, 8, 8},
- String: {16, 8, 8},
- Uint: {8, 8, 8},
- Uint16: {2, 2, 2},
- Uint32: {4, 4, 4},
- Uint64: {8, 8, 8},
- Uint8: {1, 1, 1},
- Uintptr: {8, 8, 8},
- UnsafePointer: {8, 8, 8},
- },
- // go1.18.3
- {"netbsd", "386"}: {
- Bool: {1, 1, 1},
- Chan: {4, 4, 4},
- Complex128: {16, 4, 4},
- Complex64: {8, 4, 4},
- Float32: {4, 4, 4},
- Float64: {8, 4, 4},
- Function: {4, 4, 4},
- Int: {4, 4, 4},
- Int16: {2, 2, 2},
- Int32: {4, 4, 4},
- Int64: {8, 4, 4},
- Int8: {1, 1, 1},
- Interface: {8, 4, 4},
- Map: {4, 4, 4},
- Pointer: {4, 4, 4},
- Slice: {12, 4, 4},
- String: {8, 4, 4},
- Uint: {4, 4, 4},
- Uint16: {2, 2, 2},
- Uint32: {4, 4, 4},
- Uint64: {8, 4, 4},
- Uint8: {1, 1, 1},
- Uintptr: {4, 4, 4},
- UnsafePointer: {4, 4, 4},
- },
- // go1.18.3
- {"netbsd", "amd64"}: {
- Bool: {1, 1, 1},
- Chan: {8, 8, 8},
- Complex128: {16, 8, 8},
- Complex64: {8, 4, 4},
- Float32: {4, 4, 4},
- Float64: {8, 8, 8},
- Function: {8, 8, 8},
- Int: {8, 8, 8},
- Int16: {2, 2, 2},
- Int32: {4, 4, 4},
- Int64: {8, 8, 8},
- Int8: {1, 1, 1},
- Interface: {16, 8, 8},
- Map: {8, 8, 8},
- Pointer: {8, 8, 8},
- Slice: {24, 8, 8},
- String: {16, 8, 8},
- Uint: {8, 8, 8},
- Uint16: {2, 2, 2},
- Uint32: {4, 4, 4},
- Uint64: {8, 8, 8},
- Uint8: {1, 1, 1},
- Uintptr: {8, 8, 8},
- UnsafePointer: {8, 8, 8},
- },
- // go1.18.3
- {"netbsd", "arm"}: {
- Bool: {1, 1, 1},
- Chan: {4, 4, 4},
- Complex128: {16, 4, 4},
- Complex64: {8, 4, 4},
- Float32: {4, 4, 4},
- Float64: {8, 4, 4},
- Function: {4, 4, 4},
- Int: {4, 4, 4},
- Int16: {2, 2, 2},
- Int32: {4, 4, 4},
- Int64: {8, 4, 4},
- Int8: {1, 1, 1},
- Interface: {8, 4, 4},
- Map: {4, 4, 4},
- Pointer: {4, 4, 4},
- Slice: {12, 4, 4},
- String: {8, 4, 4},
- Uint: {4, 4, 4},
- Uint16: {2, 2, 2},
- Uint32: {4, 4, 4},
- Uint64: {8, 4, 4},
- Uint8: {1, 1, 1},
- Uintptr: {4, 4, 4},
- UnsafePointer: {4, 4, 4},
- },
- // go1.19
- {"openbsd", "amd64"}: {
- Bool: {1, 1, 1},
- Chan: {8, 8, 8},
- Complex128: {16, 8, 8},
- Complex64: {8, 4, 4},
- Float32: {4, 4, 4},
- Float64: {8, 8, 8},
- Function: {8, 8, 8},
- Int: {8, 8, 8},
- Int16: {2, 2, 2},
- Int32: {4, 4, 4},
- Int64: {8, 8, 8},
- Int8: {1, 1, 1},
- Interface: {16, 8, 8},
- Map: {8, 8, 8},
- Pointer: {8, 8, 8},
- Slice: {24, 8, 8},
- String: {16, 8, 8},
- Uint: {8, 8, 8},
- Uint16: {2, 2, 2},
- Uint32: {4, 4, 4},
- Uint64: {8, 8, 8},
- Uint8: {1, 1, 1},
- Uintptr: {8, 8, 8},
- UnsafePointer: {8, 8, 8},
- },
- // go1.19
- {"openbsd", "arm64"}: {
- Bool: {1, 1, 1},
- Chan: {8, 8, 8},
- Complex128: {16, 8, 8},
- Complex64: {8, 4, 4},
- Float32: {4, 4, 4},
- Float64: {8, 8, 8},
- Function: {8, 8, 8},
- Int: {8, 8, 8},
- Int16: {2, 2, 2},
- Int32: {4, 4, 4},
- Int64: {8, 8, 8},
- Int8: {1, 1, 1},
- Interface: {16, 8, 8},
- Map: {8, 8, 8},
- Pointer: {8, 8, 8},
- Slice: {24, 8, 8},
- String: {16, 8, 8},
- Uint: {8, 8, 8},
- Uint16: {2, 2, 2},
- Uint32: {4, 4, 4},
- Uint64: {8, 8, 8},
- Uint8: {1, 1, 1},
- Uintptr: {8, 8, 8},
- UnsafePointer: {8, 8, 8},
- },
- // go1.19
- {"openbsd", "386"}: {
- Bool: {1, 1, 1},
- Chan: {4, 4, 4},
- Complex128: {16, 4, 4},
- Complex64: {8, 4, 4},
- Float32: {4, 4, 4},
- Float64: {8, 4, 4},
- Function: {4, 4, 4},
- Int: {4, 4, 4},
- Int16: {2, 2, 2},
- Int32: {4, 4, 4},
- Int64: {8, 4, 4},
- Int8: {1, 1, 1},
- Interface: {8, 4, 4},
- Map: {4, 4, 4},
- Pointer: {4, 4, 4},
- Slice: {12, 4, 4},
- String: {8, 4, 4},
- Uint: {4, 4, 4},
- Uint16: {2, 2, 2},
- Uint32: {4, 4, 4},
- Uint64: {8, 4, 4},
- Uint8: {1, 1, 1},
- Uintptr: {4, 4, 4},
- UnsafePointer: {4, 4, 4},
- },
- // go1.19.1
- {"windows", "386"}: {
- Bool: {1, 1, 1},
- Chan: {4, 4, 4},
- Complex128: {16, 4, 4},
- Complex64: {8, 4, 4},
- Float32: {4, 4, 4},
- Float64: {8, 4, 4},
- Function: {4, 4, 4},
- Int: {4, 4, 4},
- Int16: {2, 2, 2},
- Int32: {4, 4, 4},
- Int64: {8, 4, 4},
- Int8: {1, 1, 1},
- Interface: {8, 4, 4},
- Map: {4, 4, 4},
- Pointer: {4, 4, 4},
- Slice: {12, 4, 4},
- String: {8, 4, 4},
- Uint: {4, 4, 4},
- Uint16: {2, 2, 2},
- Uint32: {4, 4, 4},
- Uint64: {8, 4, 4},
- Uint8: {1, 1, 1},
- Uintptr: {4, 4, 4},
- UnsafePointer: {4, 4, 4},
- },
- // go1.19.1
- {"windows", "amd64"}: {
- Bool: {1, 1, 1},
- Chan: {8, 8, 8},
- Complex128: {16, 8, 8},
- Complex64: {8, 4, 4},
- Float32: {4, 4, 4},
- Float64: {8, 8, 8},
- Function: {8, 8, 8},
- Int: {8, 8, 8},
- Int16: {2, 2, 2},
- Int32: {4, 4, 4},
- Int64: {8, 8, 8},
- Int8: {1, 1, 1},
- Interface: {16, 8, 8},
- Map: {8, 8, 8},
- Pointer: {8, 8, 8},
- Slice: {24, 8, 8},
- String: {16, 8, 8},
- Uint: {8, 8, 8},
- Uint16: {2, 2, 2},
- Uint32: {4, 4, 4},
- Uint64: {8, 8, 8},
- Uint8: {1, 1, 1},
- Uintptr: {8, 8, 8},
- UnsafePointer: {8, 8, 8},
- },
- // go1.19.1
- {"windows", "arm64"}: {
- Bool: {1, 1, 1},
- Chan: {8, 8, 8},
- Complex128: {16, 8, 8},
- Complex64: {8, 4, 4},
- Float32: {4, 4, 4},
- Float64: {8, 8, 8},
- Function: {8, 8, 8},
- Int: {8, 8, 8},
- Int16: {2, 2, 2},
- Int32: {4, 4, 4},
- Int64: {8, 8, 8},
- Int8: {1, 1, 1},
- Interface: {16, 8, 8},
- Map: {8, 8, 8},
- Pointer: {8, 8, 8},
- Slice: {24, 8, 8},
- String: {16, 8, 8},
- Uint: {8, 8, 8},
- Uint16: {2, 2, 2},
- Uint32: {4, 4, 4},
- Uint64: {8, 8, 8},
- Uint8: {1, 1, 1},
- Uintptr: {8, 8, 8},
- UnsafePointer: {8, 8, 8},
- },
- // go1.19.3
- {"illumos", "amd64"}: {
- Bool: {1, 1, 1},
- Chan: {8, 8, 8},
- Complex128: {16, 8, 8},
- Complex64: {8, 4, 4},
- Float32: {4, 4, 4},
- Float64: {8, 8, 8},
- Function: {8, 8, 8},
- Int: {8, 8, 8},
- Int16: {2, 2, 2},
- Int32: {4, 4, 4},
- Int64: {8, 8, 8},
- Int8: {1, 1, 1},
- Interface: {16, 8, 8},
- Map: {8, 8, 8},
- Pointer: {8, 8, 8},
- Slice: {24, 8, 8},
- String: {16, 8, 8},
- Uint: {8, 8, 8},
- Uint16: {2, 2, 2},
- Uint32: {4, 4, 4},
- Uint64: {8, 8, 8},
- Uint8: {1, 1, 1},
- Uintptr: {8, 8, 8},
- UnsafePointer: {8, 8, 8},
- },
- }
- )
- // ABI describes selected parts of the Application Binary Interface.
- type ABI struct {
- ByteOrder binary.ByteOrder
- goarch string
- goos string
- Types map[Kind]ABIType
- }
- type ABIType struct {
- Size int64
- Align int64
- FieldAlign int64
- }
- // NewABI creates an ABI based on the os+arch pair.
- func NewABI(os, arch string) (*ABI, error) {
- byteOrder, ok := byteOrders[arch]
- if !ok {
- return nil, fmt.Errorf("unsupported arch: %s", arch)
- }
- types0, ok := abiTypes[[2]string{os, arch}]
- if !ok {
- return nil, fmt.Errorf("unsupported os/arch: %s/%s", os, arch)
- }
- types := make(map[Kind]ABIType, len(types0))
- for k, v := range types0 {
- types[k] = v
- }
- return &ABI{
- ByteOrder: byteOrder,
- Types: types,
- }, nil
- }
|