aboutsummaryrefslogtreecommitdiffstats
path: root/sys/targets/targets.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2025-02-04 14:23:07 +0100
committerAleksandr Nogikh <nogikh@google.com>2025-02-04 18:03:08 +0000
commitf1930ee4ea9bed443a9fd13a790b9f9014d318b4 (patch)
tree26a55d9f624365e192aac2f949efa67711603ad3 /sys/targets/targets.go
parent4baca3d60668ee7d9867320db39d2db9c6d2724d (diff)
sys/targets: change the default DataOffset value
The current default value sometimes intersects with the addresses used by malloc, which causes executor memory corruptions. Closes #5674.
Diffstat (limited to 'sys/targets/targets.go')
-rw-r--r--sys/targets/targets.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/sys/targets/targets.go b/sys/targets/targets.go
index c571d1165..1d79f4f95 100644
--- a/sys/targets/targets.go
+++ b/sys/targets/targets.go
@@ -702,7 +702,7 @@ func initTarget(target *Target, OS, arch string) {
target.NeedSyscallDefine = needSyscallDefine
}
if target.DataOffset == 0 {
- target.DataOffset = 512 << 20
+ target.DataOffset = target.defaultDataOffset()
}
target.NumPages = (16 << 20) / target.PageSize
sourceDir := getSourceDir(target)
@@ -774,6 +774,15 @@ func initTarget(target *Target, OS, arch string) {
target.initAddr2Line()
}
+func (target *Target) defaultDataOffset() uint64 {
+ if target.PtrSize == 8 {
+ // An address from ASAN's 64-bit HighMem area.
+ return 0x200000000000
+ }
+ // From 32-bit HighMem area.
+ return 0x80000000
+}
+
func (target *Target) initAddr2Line() {
// Initialize addr2line lazily since lots of tests don't need it,
// but we invoke a number of external binaries during addr2line detection.