aboutsummaryrefslogtreecommitdiffstats
path: root/sys/syz-extract/fetch.go
diff options
context:
space:
mode:
authorAlexander Egorenkov <Alexander.Egorenkov@ibm.com>2020-06-23 17:46:15 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-06-23 21:24:30 +0200
commitbbad15ae75da01150f3b1fed1a3837f5f5bedc89 (patch)
treefac55cc631521270f128cbf8292b9d55330fbc9e /sys/syz-extract/fetch.go
parent6930bbef3b671ae21f74007f9e59efb9b236b93f (diff)
target: support of big-endian architectures
* Introduce the new target flag 'LittleEndian' which specifies of which endianness the target is. * Introduce the new requires flag 'littleendian' for tests to selectively enable/disable tests on either little-endian architectures or big-endian ones. * Disable KD unit test on s390x architecture because the test works only on little-endian architecture. Signed-off-by: Alexander Egorenkov <Alexander.Egorenkov@ibm.com>
Diffstat (limited to 'sys/syz-extract/fetch.go')
-rw-r--r--sys/syz-extract/fetch.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/syz-extract/fetch.go b/sys/syz-extract/fetch.go
index 129385b7e..dd0c6aeb3 100644
--- a/sys/syz-extract/fetch.go
+++ b/sys/syz-extract/fetch.go
@@ -24,6 +24,7 @@ type extractParams struct {
DeclarePrintf bool
DefineGlibcUse bool // workaround for incorrect flags to clang for fuchsia.
ExtractFromELF bool
+ TargetEndian binary.ByteOrder
}
func extract(info *compiler.ConstInfo, cc string, args []string, params *extractParams) (
@@ -76,7 +77,7 @@ func extract(info *compiler.ConstInfo, cc string, args []string, params *extract
var flagVals []uint64
if data.ExtractFromELF {
- flagVals, err = extractFromELF(bin)
+ flagVals, err = extractFromELF(bin, params.TargetEndian)
} else {
flagVals, err = extractFromExecutable(bin)
}
@@ -146,7 +147,7 @@ func extractFromExecutable(binFile string) ([]uint64, error) {
return vals, nil
}
-func extractFromELF(binFile string) ([]uint64, error) {
+func extractFromELF(binFile string, targetEndian binary.ByteOrder) ([]uint64, error) {
f, err := os.Open(binFile)
if err != nil {
return nil, err
@@ -164,7 +165,7 @@ func extractFromELF(binFile string) ([]uint64, error) {
return nil, err
}
vals := make([]uint64, len(data)/8)
- if err := binary.Read(bytes.NewReader(data), binary.LittleEndian, &vals); err != nil {
+ if err := binary.Read(bytes.NewReader(data), targetEndian, &vals); err != nil {
return nil, err
}
return vals, nil