blob: f373f8c6b930f4c5f30609765dd21f0c108ccca1 [file] [log] [blame]
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// TODO #include "../../cmd/ld/textflag.h"
#define NOSPLIT 4
// Functions that return details about our address space.
// They use the C-defined symbols like edata and also know
// a little about the heap and memory layout.
// From the linker. Well-known but might change.
// TODO: Is there a better way to know this?
#define ELFRESERVE 3072
#define INITTEXT ((1<<22)+ELFRESERVE)
// base of the address space.
TEXT ·base(SB), NOSPLIT, $0
MOVQ $INITTEXT, ret+0(FP)
RET
// end of the text segment.
TEXT ·etext(SB), NOSPLIT, $0
LEAQ etext+0(SB), BX
MOVQ BX, ret+0(FP)
RET
// end of the data segment.
TEXT ·edata(SB), NOSPLIT, $0
LEAQ edata+0(SB), BX
MOVQ BX, ret+0(FP)
RET
// end of the pre-defined address space.
TEXT ·end(SB), NOSPLIT, $0
LEAQ end+0(SB), BX
MOVQ BX, ret+0(FP)
RET
// These are offsets of critical fields of runtime.mheap.
// TODO: Very susceptible to change! They (or something equivalent) need to be published by runtime.
#define arena_start_offset 28840
#define arena_used_offset 28848
#define arena_end_offset 28856
// start of heap.
TEXT ·heapStart(SB), NOSPLIT, $0
MOVQ runtime·mheap+arena_start_offset(SB), BX
MOVQ BX, ret+0(FP)
RET
// end of active region of heap.
TEXT ·heapUsed(SB), NOSPLIT, $0
MOVQ runtime·mheap+arena_used_offset(SB), BX
MOVQ BX, ret+0(FP)
RET
// end of all of heap.
TEXT ·heapEnd(SB), NOSPLIT, $0
MOVQ runtime·mheap+arena_end_offset(SB), BX
MOVQ BX, ret+0(FP)
RET