]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/compile: use exact constant in go_asm.h
authorIan Lance Taylor <iant@golang.org>
Mon, 10 Jan 2022 04:20:43 +0000 (20:20 -0800)
committerIan Lance Taylor <iant@golang.org>
Mon, 10 Jan 2022 21:27:19 +0000 (21:27 +0000)
Fixes #50523

Change-Id: Idab1b44d106250e9301d90ee6571f0ea51242dd9
Reviewed-on: https://go-review.googlesource.com/c/go/+/377074
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Liz Fong-Jones <lizf@honeycomb.io>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/gc/export.go
test/asmhdr.dir/main.go
test/asmhdr.dir/main.s

index eed438705ade0f20a18451eb8a0a0f5cfc8e24c2..c9acfc1710f4fb14f17dc27c26b8ffdd9a23de91 100644 (file)
@@ -31,7 +31,7 @@ func dumpasmhdr() {
                        if t == constant.Float || t == constant.Complex {
                                break
                        }
-                       fmt.Fprintf(b, "#define const_%s %v\n", n.Sym().Name, n.Val())
+                       fmt.Fprintf(b, "#define const_%s %v\n", n.Sym().Name, n.Val().ExactString())
 
                case ir.OTYPE:
                        t := n.Type()
index 808b5de7bb31577340413d46e3870e57962c1103..4e1813d2edf4ab46e72035bc58acfdf5808f32bd 100644 (file)
@@ -16,12 +16,15 @@ const (
        bigInt = 0xffffffffffffffff
 
        stringVal = "test"
+
+       longStringVal = "this_is_a_string_constant_longer_than_seventy_characters_which_used_to_fail_see_issue_50253"
 )
 
 var (
-       smallIntAsm int64
-       bigIntAsm   uint64
-       stringAsm   [len(stringVal)]byte
+       smallIntAsm   int64
+       bigIntAsm     uint64
+       stringAsm     [len(stringVal)]byte
+       longStringAsm [len(longStringVal)]byte
 )
 
 type typ struct {
@@ -46,6 +49,9 @@ func main() {
        if stringVal != string(stringAsm[:]) {
                println("stringVal", stringVal, "!=", string(stringAsm[:]))
        }
+       if longStringVal != string(longStringAsm[:]) {
+               println("longStringVal", longStringVal, "!=", string(longStringAsm[:]))
+       }
 
        // We also include boolean consts in go_asm.h, but they're
        // defined to be "true" or "false", and it's not clear how to
index 7e2d8e7abd71c21a3a2baa2cb346f91e85295857..bc2aa99b0b3be55e3587a9f6c7773d04db0d4467 100644 (file)
@@ -14,6 +14,9 @@ GLOBL ·bigIntAsm(SB),RODATA,$8
 DATA ·stringAsm(SB)/4, $const_stringVal
 GLOBL ·stringAsm(SB),RODATA,$4
 
+DATA ·longStringAsm(SB)/91, $const_longStringVal
+GLOBL ·longStringAsm(SB),RODATA,$91
+
 DATA ·typSize(SB)/8, $typ__size
 GLOBL ·typSize(SB),RODATA,$8