diff options
| author | WANG Xuerui <git@xen0n.name> | 2022-12-03 21:16:49 +0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-04-10 15:50:11 +0000 |
| commit | a3dd95922913e51e7f0d4a20b8993fde710eb20e (patch) | |
| tree | 25b0f26e5320023a0ffd72745d38f1b9ea645156 /src/cmd/internal | |
| parent | 4bd77619b743c3c986742527236568e43db37c44 (diff) | |
| download | go-a3dd95922913e51e7f0d4a20b8993fde710eb20e.tar.xz | |
cmd/internal/obj/loong64, cmd/link/internal: switch to LoongArch ELF psABI v2 relocs
The LoongArch ELF psABI v2 [1] relocs are vastly simplified from the v1
which involved a stack machine for computing the reloc values, but the
details of PC-relative addressing are changed as well. Specifically, the
`pcaddu12i` instruction is substituted with the `pcalau12i`, which is
like arm64's `adrp` -- meaning the lower bits of a symbol's address now
have to be absolute and not PC-relative.
However, apart from the little bit of added complexity, the obvious
advantage is that only 1 reloc needs to be emitted for every kind of
external reloc we care about. This can mean substantial space savings
(each RELA reloc occupies 24 bytes), and no open-coded stack ops has to
remain any more.
While at it, update the preset value for the output ELF's flags to
indicate the psABI update.
Fixes #58784
[1]: https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html
Change-Id: I5c13bc710eaf58293a32e930dd33feff2ef14c28
Reviewed-on: https://go-review.googlesource.com/c/go/+/455017
Run-TryBot: Ben Shi <powerman1st@163.com>
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/cmd/internal')
| -rw-r--r-- | src/cmd/internal/obj/loong64/asm.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/cmd/internal/obj/loong64/asm.go b/src/cmd/internal/obj/loong64/asm.go index e23165a874..75b9302f24 100644 --- a/src/cmd/internal/obj/loong64/asm.go +++ b/src/cmd/internal/obj/loong64/asm.go @@ -1540,8 +1540,8 @@ func (c *ctxt0) asmout(p *obj.Prog, o *Optab, out []uint32) { o1 = c.oprrr(ABREAK) // relocation operations - case 50: // mov r,addr ==> pcaddu12i + sw - o1 = OP_IR(c.opir(APCADDU12I), uint32(0), uint32(REGTMP)) + case 50: // mov r,addr ==> pcalau12i + sw + o1 = OP_IR(c.opir(APCALAU12I), uint32(0), uint32(REGTMP)) rel := obj.Addrel(c.cursym) rel.Off = int32(c.pc) rel.Siz = 4 @@ -1557,8 +1557,8 @@ func (c *ctxt0) asmout(p *obj.Prog, o *Optab, out []uint32) { rel2.Add = p.To.Offset rel2.Type = objabi.R_ADDRLOONG64 - case 51: // mov addr,r ==> pcaddu12i + lw - o1 = OP_IR(c.opir(APCADDU12I), uint32(0), uint32(REGTMP)) + case 51: // mov addr,r ==> pcalau12i + lw + o1 = OP_IR(c.opir(APCALAU12I), uint32(0), uint32(REGTMP)) rel := obj.Addrel(c.cursym) rel.Off = int32(c.pc) rel.Siz = 4 @@ -1576,7 +1576,7 @@ func (c *ctxt0) asmout(p *obj.Prog, o *Optab, out []uint32) { case 52: // mov $lext, r // NOTE: this case does not use REGTMP. If it ever does, // remove the NOTUSETMP flag in optab. - o1 = OP_IR(c.opir(APCADDU12I), uint32(0), uint32(p.To.Reg)) + o1 = OP_IR(c.opir(APCALAU12I), uint32(0), uint32(p.To.Reg)) rel := obj.Addrel(c.cursym) rel.Off = int32(c.pc) rel.Siz = 4 |
