diff options
| author | Alexander Egorenkov <Alexander.Egorenkov@ibm.com> | 2020-06-23 17:46:15 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-06-23 21:24:30 +0200 |
| commit | bbad15ae75da01150f3b1fed1a3837f5f5bedc89 (patch) | |
| tree | fac55cc631521270f128cbf8292b9d55330fbc9e /sys/syz-extract | |
| parent | 6930bbef3b671ae21f74007f9e59efb9b236b93f (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')
| -rw-r--r-- | sys/syz-extract/akaros.go | 1 | ||||
| -rw-r--r-- | sys/syz-extract/fetch.go | 7 | ||||
| -rw-r--r-- | sys/syz-extract/freebsd.go | 1 | ||||
| -rw-r--r-- | sys/syz-extract/fuchsia.go | 1 | ||||
| -rw-r--r-- | sys/syz-extract/linux.go | 1 | ||||
| -rw-r--r-- | sys/syz-extract/netbsd.go | 3 | ||||
| -rw-r--r-- | sys/syz-extract/openbsd.go | 3 | ||||
| -rw-r--r-- | sys/syz-extract/trusty.go | 1 | ||||
| -rw-r--r-- | sys/syz-extract/windows.go | 1 |
9 files changed, 14 insertions, 5 deletions
diff --git a/sys/syz-extract/akaros.go b/sys/syz-extract/akaros.go index e587cabef..368f77f87 100644 --- a/sys/syz-extract/akaros.go +++ b/sys/syz-extract/akaros.go @@ -43,6 +43,7 @@ func (*akaros) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]uin } params := &extractParams{ DeclarePrintf: true, + TargetEndian: arch.target.HostEndian, } return extract(info, "gcc", args, params) } 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 diff --git a/sys/syz-extract/freebsd.go b/sys/syz-extract/freebsd.go index 846e019a7..0c3e8fd8d 100644 --- a/sys/syz-extract/freebsd.go +++ b/sys/syz-extract/freebsd.go @@ -59,6 +59,7 @@ func (*freebsd) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]ui params := &extractParams{ AddSource: "#include <sys/syscall.h>", DeclarePrintf: true, + TargetEndian: arch.target.HostEndian, } return extract(info, "gcc", args, params) } diff --git a/sys/syz-extract/fuchsia.go b/sys/syz-extract/fuchsia.go index b768b81b5..8e802b5e5 100644 --- a/sys/syz-extract/fuchsia.go +++ b/sys/syz-extract/fuchsia.go @@ -44,6 +44,7 @@ func (*fuchsia) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]ui params := &extractParams{ DeclarePrintf: true, DefineGlibcUse: true, + TargetEndian: arch.target.HostEndian, } return extract(info, cc, args, params) } diff --git a/sys/syz-extract/linux.go b/sys/syz-extract/linux.go index 7760bcb0f..ef3a9c6d3 100644 --- a/sys/syz-extract/linux.go +++ b/sys/syz-extract/linux.go @@ -179,6 +179,7 @@ func (*linux) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]uint params := &extractParams{ AddSource: "#include <asm/unistd.h>", ExtractFromELF: true, + TargetEndian: arch.target.HostEndian, } cc := arch.target.CCompiler res, undeclared, err := extract(info, cc, args, params) diff --git a/sys/syz-extract/netbsd.go b/sys/syz-extract/netbsd.go index 336111444..27ebe3ec3 100644 --- a/sys/syz-extract/netbsd.go +++ b/sys/syz-extract/netbsd.go @@ -92,7 +92,8 @@ func (*netbsd) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]uin } } params := &extractParams{ - AddSource: "#include <sys/syscall.h>", + AddSource: "#include <sys/syscall.h>", + TargetEndian: arch.target.HostEndian, } res, undeclared, err := extract(info, "gcc", args, params) for orig, compats := range compatNames { diff --git a/sys/syz-extract/openbsd.go b/sys/syz-extract/openbsd.go index bcac28299..0e322fb27 100644 --- a/sys/syz-extract/openbsd.go +++ b/sys/syz-extract/openbsd.go @@ -82,7 +82,8 @@ func (*openbsd) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]ui } } params := &extractParams{ - AddSource: "#include <sys/syscall.h>", + AddSource: "#include <sys/syscall.h>", + TargetEndian: arch.target.HostEndian, } res, undeclared, err := extract(info, "cc", args, params) for orig, compats := range compatNames { diff --git a/sys/syz-extract/trusty.go b/sys/syz-extract/trusty.go index 55943088a..0022d86ff 100644 --- a/sys/syz-extract/trusty.go +++ b/sys/syz-extract/trusty.go @@ -41,6 +41,7 @@ func (*trusty) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]uin } params := &extractParams{ DeclarePrintf: true, + TargetEndian: arch.target.HostEndian, } return extract(info, "gcc", args, params) } diff --git a/sys/syz-extract/windows.go b/sys/syz-extract/windows.go index 1b9b13937..d0cda310e 100644 --- a/sys/syz-extract/windows.go +++ b/sys/syz-extract/windows.go @@ -20,6 +20,7 @@ func (*windows) prepareArch(arch *Arch) error { func (*windows) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]uint64, map[string]bool, error) { params := &extractParams{ DeclarePrintf: true, + TargetEndian: arch.target.HostEndian, } return extract(info, "cl", nil, params) } |
