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:
Ayke van Laethem
2024-08-22 16:42:03 +02:00
committed by Ron Evans
parent 25abfff632
commit 73f519b589
5 changed files with 110 additions and 85 deletions
+11
View File
@@ -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
}
}