| 1 |
// Copyright 2022 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
package loong64 |
| 6 |
|
| 7 |
import ( |
| 8 |
"cmd/internal/objabi" |
| 9 |
"cmd/internal/sys" |
| 10 |
"cmd/link/internal/ld" |
| 11 |
) |
| 12 |
|
| 13 |
func Init() (*sys.Arch, ld.Arch) { |
| 14 |
arch := sys.ArchLoong64 |
| 15 |
|
| 16 |
theArch := ld.Arch{ |
| 17 |
Funcalign: funcAlign, |
| 18 |
Maxalign: maxAlign, |
| 19 |
Minalign: minAlign, |
| 20 |
Dwarfregsp: dwarfRegSP, |
| 21 |
Dwarfreglr: dwarfRegLR, |
| 22 |
TrampLimit: 0x7c00000, // 26-bit signed offset * 4, leave room for PLT etc. |
| 23 |
CodePad: []byte{0x00, 0x00, 0x2a, 0x00}, // BREAK 0 |
| 24 |
Adddynrel: adddynrel, |
| 25 |
Archinit: archinit, |
| 26 |
Archreloc: archreloc, |
| 27 |
Archrelocvariant: archrelocvariant, |
| 28 |
Extreloc: extreloc, |
| 29 |
Machoreloc1: machoreloc1, |
| 30 |
Gentext: gentext, |
| 31 |
Trampoline: trampoline, |
| 32 |
|
| 33 |
ELF: ld.ELFArch{ |
| 34 |
Linuxdynld: "/lib64/ld-linux-loongarch-lp64d.so.1", |
| 35 |
LinuxdynldMusl: "/lib/ld-musl-loongarch64.so.1", |
| 36 |
Freebsddynld: "XXX", |
| 37 |
Openbsddynld: "XXX", |
| 38 |
Netbsddynld: "XXX", |
| 39 |
Dragonflydynld: "XXX", |
| 40 |
Solarisdynld: "XXX", |
| 41 |
|
| 42 |
Reloc1: elfreloc1, |
| 43 |
RelocSize: 24, |
| 44 |
SetupPLT: elfsetupplt, |
| 45 |
}, |
| 46 |
} |
| 47 |
|
| 48 |
return arch, theArch |
| 49 |
} |
| 50 |
|
| 51 |
func archinit(ctxt *ld.Link) { |
| 52 |
switch ctxt.HeadType { |
| 53 |
default: |
| 54 |
ld.Exitf("unknown -H option: %v", ctxt.HeadType) |
| 55 |
case objabi.Hlinux: /* loong64 elf */ |
| 56 |
ld.Elfinit(ctxt) |
| 57 |
ld.HEADR = ld.ELFRESERVE |
| 58 |
if *ld.FlagRound == -1 { |
| 59 |
*ld.FlagRound = 0x10000 |
| 60 |
} |
| 61 |
if *ld.FlagTextAddr == -1 { |
| 62 |
*ld.FlagTextAddr = ld.Rnd(0x10000, *ld.FlagRound) + int64(ld.HEADR) |
| 63 |
} |
| 64 |
} |
| 65 |
} |