aboutsummaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2024-06-02 12:17:03 +0200
committerDmitry Vyukov <dvyukov@google.com>2024-06-04 09:50:32 +0000
commit11f2afa5a3c8cc88e10b001d6eb8790c8a3b91a7 (patch)
treeaed911ddb145445af02d18db7c0e73699522c2ef /sys
parent06bf8101debe879447d0ef3a7a5b84cb11fa5acf (diff)
sys/targets: mark big-endian targets
Litte-endian is kind of default (except for s390). So instead of saying that each arch is litte-endian, mark only s390 as big-endian.
Diffstat (limited to 'sys')
-rw-r--r--sys/syz-sysgen/sysgen.go4
-rw-r--r--sys/targets/targets.go77
-rw-r--r--sys/test/test/align02
-rw-r--r--sys/test/test/align0_be2
-rw-r--r--sys/test/test/bf2
-rw-r--r--sys/test/test/bf22
-rw-r--r--sys/test/test/bf2_be2
-rw-r--r--sys/test/test/bf_be2
-rw-r--r--sys/test/test/expressions4
-rw-r--r--sys/test/test/nla2
-rw-r--r--sys/test/test/overlay2
-rw-r--r--sys/test/test/overlay_be2
12 files changed, 41 insertions, 62 deletions
diff --git a/sys/syz-sysgen/sysgen.go b/sys/syz-sysgen/sysgen.go
index 0022cea12..f03972a9f 100644
--- a/sys/syz-sysgen/sysgen.go
+++ b/sys/syz-sysgen/sysgen.go
@@ -251,11 +251,11 @@ func generate(target *targets.Target, prg *compiler.Prog, consts map[string]uint
fmt.Fprintf(out, "func init() {\n")
fmt.Fprintf(out, "\tRegisterTarget(&Target{"+
"OS: %q, Arch: %q, Revision: revision_%v, PtrSize: %v, PageSize: %v, "+
- "NumPages: %v, DataOffset: %v, LittleEndian: %v, "+
+ "NumPages: %v, DataOffset: %v, BigEndian: %v, "+
"Syscalls: syscalls_%v, Resources: resources_%v, Consts: consts_%v,"+
"Flags: flags_%v}, types_%v, InitTarget)\n}\n\n",
target.OS, target.Arch, target.Arch, target.PtrSize, target.PageSize,
- target.NumPages, target.DataOffset, target.LittleEndian,
+ target.NumPages, target.DataOffset, target.BigEndian,
target.Arch, target.Arch, target.Arch, target.Arch, target.Arch)
fmt.Fprintf(out, "var resources_%v = ", target.Arch)
diff --git a/sys/targets/targets.go b/sys/targets/targets.go
index 5483897a1..4e3e37e66 100644
--- a/sys/targets/targets.go
+++ b/sys/targets/targets.go
@@ -25,7 +25,7 @@ type Target struct {
NumPages uint64
DataOffset uint64
Int64Alignment uint64
- LittleEndian bool
+ BigEndian bool
CFlags []string
CxxFlags []string
Triple string
@@ -250,7 +250,6 @@ var List = map[string]map[string]*Target{
AMD64: {
PtrSize: 8,
PageSize: 4 << 10,
- LittleEndian: true,
CFlags: []string{"-m64"},
Triple: "x86_64-linux-gnu",
KernelArch: "x86_64",
@@ -266,7 +265,6 @@ var List = map[string]map[string]*Target{
PtrSize: 4,
PageSize: 4 << 10,
Int64Alignment: 4,
- LittleEndian: true,
CFlags: []string{"-m32"},
Triple: "x86_64-linux-gnu",
KernelArch: "i386",
@@ -275,7 +273,6 @@ var List = map[string]map[string]*Target{
ARM64: {
PtrSize: 8,
PageSize: 4 << 10,
- LittleEndian: true,
Triple: "aarch64-linux-gnu",
KernelArch: "arm64",
KernelHeaderArch: "arm64",
@@ -284,7 +281,6 @@ var List = map[string]map[string]*Target{
VMArch: ARM64,
PtrSize: 4,
PageSize: 4 << 10,
- LittleEndian: true,
CFlags: []string{"-D__LINUX_ARM_ARCH__=6", "-march=armv6"},
Triple: "arm-linux-gnueabi",
KernelArch: "arm",
@@ -293,7 +289,6 @@ var List = map[string]map[string]*Target{
MIPS64LE: {
PtrSize: 8,
PageSize: 4 << 10,
- LittleEndian: true,
CFlags: []string{"-march=mips64r2", "-mabi=64", "-EL"},
Triple: "mips64el-linux-gnuabi64",
KernelArch: "mips",
@@ -302,7 +297,6 @@ var List = map[string]map[string]*Target{
PPC64LE: {
PtrSize: 8,
PageSize: 64 << 10,
- LittleEndian: true,
CFlags: []string{"-D__powerpc64__"},
Triple: "powerpc64le-linux-gnu",
KernelArch: "powerpc",
@@ -313,7 +307,7 @@ var List = map[string]map[string]*Target{
PageSize: 4 << 10,
DataOffset: 0xfffff000,
CFlags: []string{"-fPIE"},
- LittleEndian: false,
+ BigEndian: true,
Triple: "s390x-linux-gnu",
KernelArch: "s390",
KernelHeaderArch: "s390",
@@ -328,7 +322,6 @@ var List = map[string]map[string]*Target{
RiscV64: {
PtrSize: 8,
PageSize: 4 << 10,
- LittleEndian: true,
Triple: "riscv64-linux-gnu",
KernelArch: "riscv",
KernelHeaderArch: "riscv",
@@ -336,22 +329,20 @@ var List = map[string]map[string]*Target{
},
FreeBSD: {
AMD64: {
- PtrSize: 8,
- PageSize: 4 << 10,
- LittleEndian: true,
- CCompiler: "clang",
- CFlags: []string{"-m64", "--target=x86_64-unknown-freebsd14.0"},
+ PtrSize: 8,
+ PageSize: 4 << 10,
+ CCompiler: "clang",
+ CFlags: []string{"-m64", "--target=x86_64-unknown-freebsd14.0"},
NeedSyscallDefine: func(nr uint64) bool {
// freebsd_12_shm_open, shm_open2, shm_rename, __realpathat, close_range, copy_file_range
return nr == 482 || nr >= 569
},
},
ARM64: {
- PtrSize: 8,
- PageSize: 4 << 10,
- LittleEndian: true,
- CCompiler: "clang",
- CFlags: []string{"-m64", "--target=aarch64-unknown-freebsd14.0"},
+ PtrSize: 8,
+ PageSize: 4 << 10,
+ CCompiler: "clang",
+ CFlags: []string{"-m64", "--target=aarch64-unknown-freebsd14.0"},
NeedSyscallDefine: func(nr uint64) bool {
// freebsd_12_shm_open, shm_open2, shm_rename, __realpathat, close_range, copy_file_range
return nr == 482 || nr >= 569
@@ -365,7 +356,6 @@ var List = map[string]map[string]*Target{
// FreeBSD and using ld.lld due to collisions.
DataOffset: 256 << 20,
Int64Alignment: 4,
- LittleEndian: true,
CCompiler: "clang",
CFlags: []string{"-m32", "--target=i386-unknown-freebsd14.0"},
NeedSyscallDefine: func(nr uint64) bool {
@@ -374,11 +364,10 @@ var List = map[string]map[string]*Target{
},
},
RiscV64: {
- PtrSize: 8,
- PageSize: 4 << 10,
- LittleEndian: true,
- CCompiler: "clang",
- CFlags: []string{"-m64", "--target=riscv64-unknown-freebsd14.0"},
+ PtrSize: 8,
+ PageSize: 4 << 10,
+ CCompiler: "clang",
+ CFlags: []string{"-m64", "--target=riscv64-unknown-freebsd14.0"},
NeedSyscallDefine: func(nr uint64) bool {
// freebsd_12_shm_open, shm_open2, shm_rename, __realpathat, close_range, copy_file_range
return nr == 482 || nr >= 569
@@ -387,11 +376,10 @@ var List = map[string]map[string]*Target{
},
Darwin: {
AMD64: {
- PtrSize: 8,
- PageSize: 4 << 10,
- DataOffset: 512 << 24,
- LittleEndian: true,
- CCompiler: "clang",
+ PtrSize: 8,
+ PageSize: 4 << 10,
+ DataOffset: 512 << 24,
+ CCompiler: "clang",
CFlags: []string{
"-m64",
"-I", sourceDirVar + "/san",
@@ -403,9 +391,8 @@ var List = map[string]map[string]*Target{
},
NetBSD: {
AMD64: {
- PtrSize: 8,
- PageSize: 4 << 10,
- LittleEndian: true,
+ PtrSize: 8,
+ PageSize: 4 << 10,
CFlags: []string{
"-m64",
"-static-pie",
@@ -416,10 +403,9 @@ var List = map[string]map[string]*Target{
},
OpenBSD: {
AMD64: {
- PtrSize: 8,
- PageSize: 4 << 10,
- LittleEndian: true,
- CCompiler: "c++",
+ PtrSize: 8,
+ PageSize: 4 << 10,
+ CCompiler: "c++",
// PIE is enabled on OpenBSD by default, so no need for -static-pie.
CFlags: []string{"-m64", "-static", "-lutil"},
NeedSyscallDefine: func(nr uint64) bool {
@@ -453,7 +439,6 @@ var List = map[string]map[string]*Target{
AMD64: {
PtrSize: 8,
PageSize: 4 << 10,
- LittleEndian: true,
KernelHeaderArch: "x64",
CCompiler: sourceDirVar + "/prebuilt/third_party/clang/linux-x64/bin/clang",
Objdump: sourceDirVar + "/prebuilt/third_party/clang/linux-x64/bin/llvm-objdump",
@@ -462,7 +447,6 @@ var List = map[string]map[string]*Target{
ARM64: {
PtrSize: 8,
PageSize: 4 << 10,
- LittleEndian: true,
KernelHeaderArch: ARM64,
CCompiler: sourceDirVar + "/prebuilt/third_party/clang/linux-x64/bin/clang",
Objdump: sourceDirVar + "/prebuilt/third_party/clang/linux-x64/bin/llvm-objdump",
@@ -473,15 +457,13 @@ var List = map[string]map[string]*Target{
AMD64: {
PtrSize: 8,
// TODO(dvyukov): what should we do about 4k vs 64k?
- PageSize: 4 << 10,
- LittleEndian: true,
+ PageSize: 4 << 10,
},
},
Trusty: {
ARM: {
PtrSize: 4,
PageSize: 4 << 10,
- LittleEndian: true,
NeedSyscallDefine: dontNeedSyscallDefine,
},
},
@@ -738,15 +720,12 @@ func initTarget(target *Target, OS, arch string) {
target.CFlags = append(target.CFlags, flags...)
}
if OS == TestOS {
- if runtime.GOARCH != S390x {
- target.LittleEndian = true
- } else {
- target.LittleEndian = false
+ if runtime.GOARCH == S390x {
+ target.BigEndian = true
}
}
- if target.LittleEndian {
- target.HostEndian = binary.LittleEndian
- } else {
+ target.HostEndian = binary.LittleEndian
+ if target.BigEndian {
target.HostEndian = binary.BigEndian
}
// Temporal hack.
diff --git a/sys/test/test/align0 b/sys/test/test/align0
index e2aaf61ee..fd78e5032 100644
--- a/sys/test/test/align0
+++ b/sys/test/test/align0
@@ -1,5 +1,5 @@
# 32 has 4-byte alignment for int64 and everything goes havoc.
-# requires: -arch=32 littleendian
+# requires: -arch=32 -bigendian
syz_compare(&AUTO="010000000200000003000400000000000500000000000000", 0x18, &AUTO=@align0={0x1, 0x2, 0x3, 0x4, 0x5}, AUTO)
syz_compare(&AUTO="", 0x18, &AUTO=@align0={0x0, 0x0, 0x0, 0x0, 0x0}, 0x17) # EBADF
diff --git a/sys/test/test/align0_be b/sys/test/test/align0_be
index f9072e841..26463e154 100644
--- a/sys/test/test/align0_be
+++ b/sys/test/test/align0_be
@@ -1,5 +1,5 @@
# 32 has 4-byte alignment for int64 and everything goes havoc.
-# requires: -arch=32 -littleendian
+# requires: -arch=32 bigendian
syz_compare(&AUTO="000100000000000203000004000000000000000000000005", 0x18, &AUTO=@align0={0x1, 0x2, 0x3, 0x4, 0x5}, AUTO)
syz_compare(&AUTO="", 0x18, &AUTO=@align0={0x0, 0x0, 0x0, 0x0, 0x0}, 0x17) # EBADF
diff --git a/sys/test/test/bf b/sys/test/test/bf
index 6d7bb6364..ddd329b5c 100644
--- a/sys/test/test/bf
+++ b/sys/test/test/bf
@@ -1,5 +1,5 @@
# 32 has 4-byte alignment for int64 and everything goes havoc.
-# requires: -arch=32 littleendian
+# requires: -arch=32 -bigendian
syz_compare(&AUTO="ab03000000000000cdcdcdcdcdcdcdcdebffff03ab0303abaa00000000000000", 0x20, &AUTO=@bf0={0xabab, 0xcdcdcdcdcdcdcdcd, 0xabab, 0xffff, 0xffffff, 0xabab, 0xabab, 0xaaa}, AUTO)
syz_compare(&AUTO="dcfcde563422f10e", 0x8, &AUTO=@bf2={0x0abc, 0x0bcd, 0xcdef, 0x123456, 0x78ef12}, AUTO)
diff --git a/sys/test/test/bf2 b/sys/test/test/bf2
index 82b9a0a1f..4ed1b7540 100644
--- a/sys/test/test/bf2
+++ b/sys/test/test/bf2
@@ -1,5 +1,5 @@
# 32 has 4-byte alignment for int64 and everything goes havoc.
-# requires: -arch=32 littleendian
+# requires: -arch=32 -bigendian
syz_compare(&AUTO="1200000034067800", AUTO, &AUTO=@bf4={0x12, {0x34, 0x56, 0x78}}, AUTO)
syz_compare(&AUTO="1200000034060000", AUTO, &AUTO=@bf5={0x12, {0x34, 0x56}}, AUTO)
diff --git a/sys/test/test/bf2_be b/sys/test/test/bf2_be
index 1c39a9f99..d3c715e86 100644
--- a/sys/test/test/bf2_be
+++ b/sys/test/test/bf2_be
@@ -1,5 +1,5 @@
# 32 has 4-byte alignment for int64 and everything goes havoc.
-# requires: -arch=32 -littleendian
+# requires: -arch=32 bigendian
syz_compare(&AUTO="1200000034607800", AUTO, &AUTO=@bf4={0x12, {0x34, 0x56, 0x78}}, AUTO)
syz_compare(&AUTO="1200000034600000", AUTO, &AUTO=@bf5={0x12, {0x34, 0x56}}, AUTO)
diff --git a/sys/test/test/bf_be b/sys/test/test/bf_be
index b03794e91..cd6f4a73b 100644
--- a/sys/test/test/bf_be
+++ b/sys/test/test/bf_be
@@ -1,5 +1,5 @@
# 32 has 4-byte alignment for int64 and everything goes havoc.
-# requires: -arch=32 -littleendian
+# requires: -arch=32 bigendian
syz_compare(&AUTO="eac0000000000000cdcdcdcdcdcdcdcd5fffffc075607560aa", 0x20, &AUTO=@bf0={0xabab, 0xcdcdcdcdcdcdcdcd, 0xabab, 0xffff, 0xffffff, 0xabab, 0xabab, 0xaaa}, AUTO)
syz_compare(&AUTO="ccddef23456ef120", 0x8, &AUTO=@bf2={0x0abc, 0x0bcd, 0xcdef, 0x123456, 0x78ef12}, AUTO)
diff --git a/sys/test/test/expressions b/sys/test/test/expressions
index 9ecaaf30c..63100c05c 100644
--- a/sys/test/test/expressions
+++ b/sys/test/test/expressions
@@ -1,4 +1,4 @@
-# requires: littleendian
+# requires: -bigendian
syz_compare(&AUTO="00000000", 0x4, &AUTO=@conditional={0x0, @void, @void}, AUTO)
syz_compare(&AUTO="02000000ffffffff", 0x8, &AUTO=@conditional={0x2, @value={AUTO}, @void}, AUTO)
@@ -7,4 +7,4 @@ syz_compare(&AUTO="06000000ffffffffaaaa000000000000", 0x10, &AUTO=@conditional={
syz_compare(&AUTO="00ff0000", 0x4, &AUTO=@conditional2={0x0, @void, 0xff}, AUTO)
syz_compare(&AUTO="0134120000ff0000", 0x8, &AUTO=@conditional2={0x1, @value=0x1234, 0xff}, AUTO)
syz_compare(&AUTO="1100220000330000", 0x8, &AUTO=@conditional3={0x11, {0x0, @void, 0x22}, 0x33}, AUTO)
-syz_compare(&AUTO="1101ddccbbaa220000330000", 0xc, &AUTO=@conditional3={0x11, {0x1, @value=0xaabbccdd, 0x22}, 0x33}, AUTO) \ No newline at end of file
+syz_compare(&AUTO="1101ddccbbaa220000330000", 0xc, &AUTO=@conditional3={0x11, {0x1, @value=0xaabbccdd, 0x22}, 0x33}, AUTO)
diff --git a/sys/test/test/nla b/sys/test/test/nla
index b2c5bf1a9..bb7c74275 100644
--- a/sys/test/test/nla
+++ b/sys/test/test/nla
@@ -1,4 +1,4 @@
-# requires: littleendian
+# requires: -bigendian
syz_compare(&AUTO="0500aa0055000000", AUTO, &AUTO=@nla=[@a0={AUTO, AUTO, 0x55, ''}], AUTO)
syz_compare(&AUTO="0600bb0055550000", AUTO, &AUTO=@nla=[@a1={AUTO, AUTO, 0x5555, ''}], AUTO)
diff --git a/sys/test/test/overlay b/sys/test/test/overlay
index e15d62b5e..0dbf49ed6 100644
--- a/sys/test/test/overlay
+++ b/sys/test/test/overlay
@@ -1,4 +1,4 @@
-# requires: littleendian
+# requires: -bigendian
syz_compare(&AUTO="1111111122222222", AUTO, &AUTO=@overlay0={0x11111111, 0x22222222, <r0=>0x0, <r1=>0x0}, AUTO)
syz_compare(&AUTO="11111111", AUTO, &AUTO=@overlayres=@res32=r0, AUTO)
diff --git a/sys/test/test/overlay_be b/sys/test/test/overlay_be
index b1eb65f8d..91f7c9f69 100644
--- a/sys/test/test/overlay_be
+++ b/sys/test/test/overlay_be
@@ -1,4 +1,4 @@
-# requires: -littleendian
+# requires: bigendian
syz_compare(&AUTO="1111111122222222", AUTO, &AUTO=@overlay0={0x11111111, 0x22222222, <r0=>0x0, <r1=>0x0}, AUTO)
syz_compare(&AUTO="11111111", AUTO, &AUTO=@overlayres=@res32=r0, AUTO)