...

Source file src/cmd/link/internal/riscv64/obj.go

Documentation: cmd/link/internal/riscv64

     1  // Copyright 2019 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 riscv64
     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.ArchRISCV64
    15  
    16  	theArch := ld.Arch{
    17  		Funcalign:  funcAlign,
    18  		Maxalign:   maxAlign,
    19  		Minalign:   minAlign,
    20  		Dwarfregsp: dwarfRegSP,
    21  		Dwarfreglr: dwarfRegLR,
    22  
    23  		Adddynrel:        adddynrel,
    24  		Archinit:         archinit,
    25  		Archreloc:        archreloc,
    26  		Archrelocvariant: archrelocvariant,
    27  		Extreloc:         extreloc,
    28  
    29  		// TrampLimit is set such that we always run the trampoline
    30  		// generation code. This is necessary since calls to external
    31  		// symbols require the use of trampolines, regardless of the
    32  		// text size.
    33  		TrampLimit: 1,
    34  		Trampoline: trampoline,
    35  
    36  		Gentext:     gentext,
    37  		GenSymsLate: genSymsLate,
    38  		Machoreloc1: machoreloc1,
    39  
    40  		ELF: ld.ELFArch{
    41  			Linuxdynld: "/lib/ld.so.1",
    42  
    43  			Freebsddynld:   "/usr/libexec/ld-elf.so.1",
    44  			Netbsddynld:    "XXX",
    45  			Openbsddynld:   "/usr/libexec/ld.so",
    46  			Dragonflydynld: "XXX",
    47  			Solarisdynld:   "XXX",
    48  
    49  			Reloc1:    elfreloc1,
    50  			RelocSize: 24,
    51  			SetupPLT:  elfsetupplt,
    52  		},
    53  	}
    54  
    55  	return arch, theArch
    56  }
    57  
    58  func archinit(ctxt *ld.Link) {
    59  	switch ctxt.HeadType {
    60  	case objabi.Hlinux, objabi.Hfreebsd, objabi.Hopenbsd:
    61  		ld.Elfinit(ctxt)
    62  		ld.HEADR = ld.ELFRESERVE
    63  		if *ld.FlagRound == -1 {
    64  			*ld.FlagRound = 0x10000
    65  		}
    66  		if *ld.FlagTextAddr == -1 {
    67  			*ld.FlagTextAddr = ld.Rnd(0x10000, *ld.FlagRound) + int64(ld.HEADR)
    68  		}
    69  	default:
    70  		ld.Exitf("unknown -H option: %v", ctxt.HeadType)
    71  	}
    72  }
    73  

View as plain text