From 9c054f413751fdec62aa33df19ec1249426767ee Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Tue, 1 Jun 2021 19:16:33 -0400 Subject: [PATCH] [dev.typeparams] cmd/link: take function address in assembly in TestFuncAlign In TestFuncAlign we want to get the address of an assembly function. Take the address in assembly, so we get the actual function's address, not the wrapper's. Change-Id: Idc1fe2c8426562c70f8f7d6e489584ef059bc556 Reviewed-on: https://go-review.googlesource.com/c/go/+/324249 Trust: Cherry Mui Run-TryBot: Cherry Mui TryBot-Result: Go Bot Reviewed-by: Than McIntosh --- src/cmd/link/link_test.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cmd/link/link_test.go b/src/cmd/link/link_test.go index 4d6bc76aca..4a580991ef 100644 --- a/src/cmd/link/link_test.go +++ b/src/cmd/link/link_test.go @@ -524,14 +524,13 @@ const testFuncAlignSrc = ` package main import ( "fmt" - "reflect" ) func alignPc() +var alignPcFnAddr uintptr func main() { - addr := reflect.ValueOf(alignPc).Pointer() - if (addr % 512) != 0 { - fmt.Printf("expected 512 bytes alignment, got %v\n", addr) + if alignPcFnAddr % 512 != 0 { + fmt.Printf("expected 512 bytes alignment, got %v\n", alignPcFnAddr) } else { fmt.Printf("PASS") } @@ -546,6 +545,9 @@ TEXT ·alignPc(SB),NOSPLIT, $0-0 PCALIGN $512 MOVD $3, R1 RET + +GLOBL ·alignPcFnAddr(SB),RODATA,$8 +DATA ·alignPcFnAddr(SB)/8,$·alignPc(SB) ` // TestFuncAlign verifies that the address of a function can be aligned