mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-14 07:53:40 +00:00
interp: support big-endian targets
The interp package was assuming that all targets were little-endian. But that's not true: we now have a big-endian target (GOARCH=mips). This fixes the interp package to use the appropriate byte order for a given target.
This commit is contained in:
committed by
Ron Evans
parent
25abfff632
commit
73f519b589
@@ -8,6 +8,7 @@
|
||||
package llvmutil
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -216,3 +217,13 @@ func Version() int {
|
||||
}
|
||||
return major
|
||||
}
|
||||
|
||||
// Return the byte order for the given target triple. Most targets are little
|
||||
// endian, but for example MIPS can be big-endian.
|
||||
func ByteOrder(target string) binary.ByteOrder {
|
||||
if strings.HasPrefix(target, "mips-") {
|
||||
return binary.BigEndian
|
||||
} else {
|
||||
return binary.LittleEndian
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user