Home | History | Annotate | Download | only in runtime
      1 // Copyright 2012 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 runtime
      6 
      7 // ELF64 structure definitions for use by the Linux vDSO loader
      8 
      9 type elfSym struct {
     10 	st_name  uint32
     11 	st_info  byte
     12 	st_other byte
     13 	st_shndx uint16
     14 	st_value uint64
     15 	st_size  uint64
     16 }
     17 
     18 type elfVerdef struct {
     19 	vd_version uint16 /* Version revision */
     20 	vd_flags   uint16 /* Version information */
     21 	vd_ndx     uint16 /* Version Index */
     22 	vd_cnt     uint16 /* Number of associated aux entries */
     23 	vd_hash    uint32 /* Version name hash value */
     24 	vd_aux     uint32 /* Offset in bytes to verdaux array */
     25 	vd_next    uint32 /* Offset in bytes to next verdef entry */
     26 }
     27 
     28 type elfEhdr struct {
     29 	e_ident     [_EI_NIDENT]byte /* Magic number and other info */
     30 	e_type      uint16           /* Object file type */
     31 	e_machine   uint16           /* Architecture */
     32 	e_version   uint32           /* Object file version */
     33 	e_entry     uint64           /* Entry point virtual address */
     34 	e_phoff     uint64           /* Program header table file offset */
     35 	e_shoff     uint64           /* Section header table file offset */
     36 	e_flags     uint32           /* Processor-specific flags */
     37 	e_ehsize    uint16           /* ELF header size in bytes */
     38 	e_phentsize uint16           /* Program header table entry size */
     39 	e_phnum     uint16           /* Program header table entry count */
     40 	e_shentsize uint16           /* Section header table entry size */
     41 	e_shnum     uint16           /* Section header table entry count */
     42 	e_shstrndx  uint16           /* Section header string table index */
     43 }
     44 
     45 type elfPhdr struct {
     46 	p_type   uint32 /* Segment type */
     47 	p_flags  uint32 /* Segment flags */
     48 	p_offset uint64 /* Segment file offset */
     49 	p_vaddr  uint64 /* Segment virtual address */
     50 	p_paddr  uint64 /* Segment physical address */
     51 	p_filesz uint64 /* Segment size in file */
     52 	p_memsz  uint64 /* Segment size in memory */
     53 	p_align  uint64 /* Segment alignment */
     54 }
     55 
     56 type elfShdr struct {
     57 	sh_name      uint32 /* Section name (string tbl index) */
     58 	sh_type      uint32 /* Section type */
     59 	sh_flags     uint64 /* Section flags */
     60 	sh_addr      uint64 /* Section virtual addr at execution */
     61 	sh_offset    uint64 /* Section file offset */
     62 	sh_size      uint64 /* Section size in bytes */
     63 	sh_link      uint32 /* Link to another section */
     64 	sh_info      uint32 /* Additional section information */
     65 	sh_addralign uint64 /* Section alignment */
     66 	sh_entsize   uint64 /* Entry size if section holds table */
     67 }
     68 
     69 type elfDyn struct {
     70 	d_tag int64  /* Dynamic entry type */
     71 	d_val uint64 /* Integer value */
     72 }
     73 
     74 type elfVerdaux struct {
     75 	vda_name uint32 /* Version or dependency names */
     76 	vda_next uint32 /* Offset in bytes to next verdaux entry */
     77 }
     78 
     79 const (
     80 	// vdsoArrayMax is the byte-size of a maximally sized array on this architecture.
     81 	// See cmd/compile/internal/amd64/galign.go arch.MAXWIDTH initialization.
     82 	vdsoArrayMax = 1<<50 - 1
     83 )
     84 
     85 var sym_keys = []symbol_key{
     86 	{"__vdso_time", 0xa33c485, 0x821e8e0d, &__vdso_time_sym},
     87 	{"__vdso_gettimeofday", 0x315ca59, 0xb01bca00, &__vdso_gettimeofday_sym},
     88 	{"__vdso_clock_gettime", 0xd35ec75, 0x6e43a318, &__vdso_clock_gettime_sym},
     89 }
     90 
     91 // initialize with vsyscall fallbacks
     92 var (
     93 	__vdso_time_sym          uintptr = 0xffffffffff600400
     94 	__vdso_gettimeofday_sym  uintptr = 0xffffffffff600000
     95 	__vdso_clock_gettime_sym uintptr = 0
     96 )
     97