Skip to content

Commit

Permalink
sys/targets: change the default DataOffset value
Browse files Browse the repository at this point in the history
The current default value sometimes intersects with the addresses used
by malloc, which causes executor memory corruptions.

Closes #5674.
  • Loading branch information
a-nogikh committed Feb 4, 2025
1 parent 44c0159 commit fa78f9e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion sys/targets/targets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit fa78f9e

Please sign in to comment.