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 // ELF32 structure definitions for use by the Linux vDSO loader
      8 
      9 type elfSym struct {
     10 	st_name  uint32
     11 	st_value uint32
     12 	st_size  uint32
     13 	st_info  byte
     14 	st_other byte
     15 	st_shndx uint16
     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     uint32           /* Entry point virtual address */
     34 	e_phoff     uint32           /* Program header table file offset */
     35 	e_shoff     uint32           /* 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_offset uint32 /* Segment file offset */
     48 	p_vaddr  uint32 /* Segment virtual address */
     49 	p_paddr  uint32 /* Segment physical address */
     50 	p_filesz uint32 /* Segment size in file */
     51 	p_memsz  uint32 /* Segment size in memory */
     52 	p_flags  uint32 /* Segment flags */
     53 	p_align  uint32 /* 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     uint32 /* Section flags */
     60 	sh_addr      uint32 /* Section virtual addr at execution */
     61 	sh_offset    uint32 /* Section file offset */
     62 	sh_size      uint32 /* Section size in bytes */
     63 	sh_link      uint32 /* Link to another section */
     64 	sh_info      uint32 /* Additional section information */
     65 	sh_addralign uint32 /* Section alignment */
     66 	sh_entsize   uint32 /* Entry size if section holds table */
     67 }
     68 
     69 type elfDyn struct {
     70 	d_tag int32  /* Dynamic entry type */
     71 	d_val uint32 /* 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/x86/galign.go arch.MAXWIDTH initialization, but must also
     82 	// be constrained to max +ve int.
     83 	vdsoArrayMax = 1<<31 - 1
     84 )
     85 
     86 var sym_keys = []symbol_key{
     87 	{"__vdso_clock_gettime", 0xd35ec75, 0x6e43a318, &__vdso_clock_gettime_sym},
     88 }
     89 
     90 // initialize to fall back to syscall
     91 var (
     92 	__vdso_clock_gettime_sym uintptr = 0
     93 )
     94