...

Source file src/cmd/internal/objabi/util.go

Documentation: cmd/internal/objabi

     1  // Copyright 2015 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 objabi
     6  
     7  import (
     8  	"fmt"
     9  	"strings"
    10  
    11  	"internal/buildcfg"
    12  )
    13  
    14  const (
    15  	ElfRelocOffset   = 256
    16  	MachoRelocOffset = 2048    // reserve enough space for ELF relocations
    17  	GlobalDictPrefix = ".dict" // prefix for names of global dictionaries
    18  )
    19  
    20  // HeaderString returns the toolchain configuration string written in
    21  // Go object headers. This string ensures we don't attempt to import
    22  // or link object files that are incompatible with each other. This
    23  // string always starts with "go object ".
    24  func HeaderString() string {
    25  	archExtra := ""
    26  	if k, v := buildcfg.GOGOARCH(); k != "" && v != "" {
    27  		archExtra = " " + k + "=" + v
    28  	}
    29  	return fmt.Sprintf("go object %s %s %s%s X:%s\n",
    30  		buildcfg.GOOS, buildcfg.GOARCH,
    31  		buildcfg.Version, archExtra,
    32  		strings.Join(buildcfg.Experiment.Enabled(), ","))
    33  }
    34  

View as plain text