aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/obj/textflag.go
diff options
context:
space:
mode:
authorfanzha02 <fannie.zhang@arm.com>2019-12-19 08:15:06 +0000
committerKeith Randall <khr@golang.org>2020-03-31 02:37:05 +0000
commit71d477469c5529b56779cdb3bc235d0a87fe9877 (patch)
tree00461b1597290e4e2e0e2f1fb0cdf45aea2ed83c /src/cmd/internal/obj/textflag.go
parentfde6868ac3f3f049247084f2c76efec3555a2395 (diff)
downloadgo-71d477469c5529b56779cdb3bc235d0a87fe9877.tar.gz
go-71d477469c5529b56779cdb3bc235d0a87fe9877.zip
cmd/asm: align an instruction or a function's address
Recently, the gVisor project needs an instruction's address with 128 bytes alignment and a function's start address with 2K bytes alignment to fit the architecture requirement for interrupt table. This patch allows aligning the address of an instruction to be aligned to a specific value (2^n and not higher than 2048) and the address of a function to be 2048 bytes. The main changes include: 1. Adds ALIGN2048 flag to align a function's address with 2048 bytes. e.g. "TEXT ·Add(SB),NOSPLIT|ALIGN2048" indicates that the address of Add function should be aligned to 2048 bytes. 2. Adds a new element in the FuncInfo structure defined in cmd/internal/obj/link.go file to record the alignment information. 3. Adds a new element in the Func structure defined in cmd/internal/goobj/read.go file to read the alignment information. 4. Because go introduces a new object file format, also add a new element in the FuncInfo structure defined in cmd/internal/goobj2/funcinfo.go to record the alignment information. 5. Adds the assembler support to align an intruction's offset with a specific value (2^n and not higher than 2048). e.g. "PCALIGN $256" indicates that the next instruction should be aligned to 256 bytes. This CL also adds a test. Change-Id: I31cfa6fb5bc35dee2c44bf65913e90cddfcb492a Reviewed-on: https://go-review.googlesource.com/c/go/+/212767 Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/cmd/internal/obj/textflag.go')
-rw-r--r--src/cmd/internal/obj/textflag.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/cmd/internal/obj/textflag.go b/src/cmd/internal/obj/textflag.go
index d2cec734b1..3681a3b67b 100644
--- a/src/cmd/internal/obj/textflag.go
+++ b/src/cmd/internal/obj/textflag.go
@@ -51,4 +51,9 @@ const (
// Function is the top of the call stack. Call stack unwinders should stop
// at this function.
TOPFRAME = 2048
+
+ // ALIGN2048 means that the address of the function must be aligned to a
+ // 2048 bytes boundary.
+ // Only works on arm64 at present.
+ ALIGN2048 = 4096
)