diff options
Diffstat (limited to 'src/cmd/internal/obj')
| -rw-r--r-- | src/cmd/internal/obj/riscv/cpu.go | 5 | ||||
| -rw-r--r-- | src/cmd/internal/obj/riscv/obj.go | 9 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/cmd/internal/obj/riscv/cpu.go b/src/cmd/internal/obj/riscv/cpu.go index 69a8516696..2b75ed38a6 100644 --- a/src/cmd/internal/obj/riscv/cpu.go +++ b/src/cmd/internal/obj/riscv/cpu.go @@ -317,6 +317,11 @@ const ( // it is the first instruction in an AUIPC + S-type pair that needs a // R_RISCV_PCREL_STYPE relocation. NEED_PCREL_STYPE_RELOC + + // NEED_GOT_PCREL_ITYPE_RELOC is set on AUIPC instructions to indicate that + // it is the first instruction in an AUIPC + I-type pair that needs a + // R_RISCV_GOT_PCREL_ITYPE relocation. + NEED_GOT_PCREL_ITYPE_RELOC ) // RISC-V mnemonics, as defined in the "opcodes" and "opcodes-pseudo" files diff --git a/src/cmd/internal/obj/riscv/obj.go b/src/cmd/internal/obj/riscv/obj.go index 381dc08560..54c34af2f4 100644 --- a/src/cmd/internal/obj/riscv/obj.go +++ b/src/cmd/internal/obj/riscv/obj.go @@ -215,11 +215,15 @@ func markRelocs(p *obj.Prog) { switch p.From.Name { case obj.NAME_EXTERN, obj.NAME_STATIC: p.Mark |= NEED_PCREL_ITYPE_RELOC + case obj.NAME_GOTREF: + p.Mark |= NEED_GOT_PCREL_ITYPE_RELOC } case p.From.Type == obj.TYPE_MEM && p.To.Type == obj.TYPE_REG: switch p.From.Name { case obj.NAME_EXTERN, obj.NAME_STATIC: p.Mark |= NEED_PCREL_ITYPE_RELOC + case obj.NAME_GOTREF: + p.Mark |= NEED_GOT_PCREL_ITYPE_RELOC } case p.From.Type == obj.TYPE_REG && p.To.Type == obj.TYPE_MEM: switch p.To.Name { @@ -2203,7 +2207,7 @@ func instructionsForMOV(p *obj.Prog) []*instruction { // MOV c(Rs), Rd -> L $c, Rs, Rd inss = instructionsForLoad(p, movToLoad(p.As), addrToReg(p.From)) - case obj.NAME_EXTERN, obj.NAME_STATIC: + case obj.NAME_EXTERN, obj.NAME_STATIC, obj.NAME_GOTREF: if p.From.Sym.Type == objabi.STLSBSS { return instructionsForTLSLoad(p) } @@ -2631,6 +2635,9 @@ func assemble(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) { } else if p.Mark&NEED_PCREL_STYPE_RELOC == NEED_PCREL_STYPE_RELOC { rt = objabi.R_RISCV_PCREL_STYPE addr = &p.To + } else if p.Mark&NEED_GOT_PCREL_ITYPE_RELOC == NEED_GOT_PCREL_ITYPE_RELOC { + rt = objabi.R_RISCV_GOT_PCREL_ITYPE + addr = &p.From } else { break } |
