How and where the function cmd/go/internal/lockedfile.(*File).Read autogenerated

87 views
Skip to first unread message

xiaodong liu

unread,
Oct 9, 2021, 6:23:54 PM10/9/21
to golan...@googlegroups.com
Hi,

I debugged the program on linux/loong64 when I rebased code, but I met a bug that R1 is clobbered, R1 is also as LINK Register on loong64. Here is the code:

cmd/go/internal/lockedfile.(*File).Read (b=..., n=<optimized out>, err=...) at <autogenerated>:1
1 <autogenerated>: No such file or directory.
7: x/10i $pc
=> 0x1ca938 <cmd/go/internal/lockedfile.(*File).Read>: ld.d $r1,$r3,8(0x8)  // r1 not saved for restore
   0x1ca93c <cmd/go/internal/lockedfile.(*File).Read+4>: ld.d $r1,$r1,0
   0x1ca940 <cmd/go/internal/lockedfile.(*File).Read+8>: addi.d $r4,$r3,0
   0x1ca944 <cmd/go/internal/lockedfile.(*File).Read+12>: st.d $r1,$r4,8(0x8)
   0x1ca948 <cmd/go/internal/lockedfile.(*File).Read+16>: b -944328(0xff19738) # 0xe4080 <os.(*File).Read>

Thanks!

Ian Lance Taylor

unread,
Oct 9, 2021, 7:41:23 PM10/9/21
to xiaodong liu, golang-nuts
In this case the auto-generated function is created by the compiler.
This is because lockedfile.File embeds osFile which embeds *os.File.
The Read method is being promoted from *os.File to lockedfile. This
is implemented by a little stub for lockedfile.Read that loads the
*os.File and calls the Read method on that value. That stbu is
generated by the compiler. Hope this helps.

Ian

xiaodong liu

unread,
Oct 10, 2021, 2:59:09 AM10/10/21
to Ian Lance Taylor, golang-nuts
Thanks for the tip! 
Reply all
Reply to author
Forward
0 new messages