aboutsummaryrefslogtreecommitdiffstats
path: root/main/gcc/0044-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch
blob: 474847badd2559d40381e1daa737da2d1adefb3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
From 61fc6a52f3fc5fe6c66dc2dd0fa222ba1349d7e5 Mon Sep 17 00:00:00 2001
From: "A. Wilcox" <AWilcox@Wilcox-Tech.com>
Date: Sun, 30 Aug 2020 18:33:49 +0200
Subject: [PATCH] gcc-go: Use int64 type as offset argument for mmap
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Without this patch, Go run-time memory allocation fails on 32-bit architectures:

	fatal error: runtime: cannot allocate memory
	runtime stack:
	runtime.dopanic__m
		:0
	runtime.throw
		:0
		:0
		:0
	runtime.systemstack
		:0
	runtime.addrRanges.init
		:0
	runtime.pageAlloc.init
		:0
	runtime.mheap.init
		:0
	runtime.schedinit
		:0
		:0
		:0

Taken from Adélie Linux [1].

[1]: https://git.adelielinux.org/adelie/packages/-/commit/63b5fb12c3d75e460799c672bbbdd5d29c3cc33c
---
 libgo/go/runtime/mem_gccgo.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libgo/go/runtime/mem_gccgo.go b/libgo/go/runtime/mem_gccgo.go
index fa3389d857e..57bed97c710 100644
--- a/libgo/go/runtime/mem_gccgo.go
+++ b/libgo/go/runtime/mem_gccgo.go
@@ -15,7 +15,7 @@ import (
 //go:linkname sysFree
 
 //extern mmap
-func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) unsafe.Pointer
+func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) unsafe.Pointer
 
 //extern munmap
 func munmap(addr unsafe.Pointer, length uintptr) int32
@@ -37,7 +37,7 @@ func init() {
 	}
 }
 
-func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) (unsafe.Pointer, int) {
+func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) (unsafe.Pointer, int) {
 	p := sysMmap(addr, n, prot, flags, fd, off)
 	if uintptr(p) == _MAP_FAILED {
 		return nil, errno()
-- 
2.34.1