From 2754118731b81baf0c812116a9b72b6153abf79d Mon Sep 17 00:00:00 2001 From: Pure White Date: Sun, 11 Aug 2019 05:37:29 +0000 Subject: [PATCH] doc/asm: document go_asm.h only works in the runtime package Fixes #33054 Change-Id: I687d45e092d721a6c22888cc7ddbe420c16a5af9 GitHub-Last-Rev: a7208c89a0d613a53ab057e0b4418ae4719cfcbd GitHub-Pull-Request: golang/go#33069 Reviewed-on: https://go-review.googlesource.com/c/go/+/185917 Reviewed-by: Rob Pike --- doc/asm.html | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/doc/asm.html b/doc/asm.html index 77defdbd28f..11033fe3c5f 100644 --- a/doc/asm.html +++ b/doc/asm.html @@ -590,27 +590,37 @@ Here follow some descriptions of key Go-specific details for the supported archi

The runtime pointer to the g structure is maintained through the value of an otherwise unused (as far as Go is concerned) register in the MMU. -A OS-dependent macro get_tls is defined for the assembler if the source includes -a special header, go_asm.h: +An OS-dependent macro get_tls is defined for the assembler if the source is +in the runtime package and includes a special header, go_tls.h:

-#include "go_asm.h"
+#include "go_tls.h"
 

Within the runtime, the get_tls macro loads its argument register with a pointer to the g pointer, and the g struct contains the m pointer. +There's another special header containing the offsets for each +element of g, called go_asm.h. The sequence to load g and m using CX looks like this:

+#include "go_tls.h"
+#include "go_asm.h"
+...
 get_tls(CX)
 MOVL	g(CX), AX     // Move g into AX.
 MOVL	g_m(AX), BX   // Move g.m into BX.
 
+

+Note: The code above works only in the runtime package, while go_tls.h also +applies to arm, amd64 and amd64p32, and go_asm.h applies to all architectures. +

+

Addressing modes: