1
0
mirror of https://github.com/golang/go synced 2024-11-23 06:40:05 -07:00

[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 <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
Cherry Mui 2021-06-01 19:16:33 -04:00
parent 95c618e99a
commit 9c054f4137

View File

@ -524,14 +524,13 @@ const testFuncAlignSrc = `
package main package main
import ( import (
"fmt" "fmt"
"reflect"
) )
func alignPc() func alignPc()
var alignPcFnAddr uintptr
func main() { func main() {
addr := reflect.ValueOf(alignPc).Pointer() if alignPcFnAddr % 512 != 0 {
if (addr % 512) != 0 { fmt.Printf("expected 512 bytes alignment, got %v\n", alignPcFnAddr)
fmt.Printf("expected 512 bytes alignment, got %v\n", addr)
} else { } else {
fmt.Printf("PASS") fmt.Printf("PASS")
} }
@ -546,6 +545,9 @@ TEXT ·alignPc(SB),NOSPLIT, $0-0
PCALIGN $512 PCALIGN $512
MOVD $3, R1 MOVD $3, R1
RET RET
GLOBL ·alignPcFnAddr(SB),RODATA,$8
DATA ·alignPcFnAddr(SB)/8,$·alignPc(SB)
` `
// TestFuncAlign verifies that the address of a function can be aligned // TestFuncAlign verifies that the address of a function can be aligned