]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: move ELF structure definitions into own files
authorTobias Klauser <tklauser@distanz.ch>
Wed, 14 Feb 2018 13:26:32 +0000 (14:26 +0100)
committerTobias Klauser <tobias.klauser@gmail.com>
Thu, 15 Feb 2018 16:15:19 +0000 (16:15 +0000)
Move the ELF32 and ELF64 structure definitions into their own files so
they can be reused when vDSO support is added for other architectures.

Change-Id: Id0171b4e5cea4add8635743c881e3bf3469597af
Reviewed-on: https://go-review.googlesource.com/93995
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
src/runtime/vdso_elf32.go [new file with mode: 0644]
src/runtime/vdso_elf64.go [new file with mode: 0644]
src/runtime/vdso_linux_386.go
src/runtime/vdso_linux_amd64.go

diff --git a/src/runtime/vdso_elf32.go b/src/runtime/vdso_elf32.go
new file mode 100644 (file)
index 0000000..e1a693d
--- /dev/null
@@ -0,0 +1,80 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build linux
+// +build 386
+
+package runtime
+
+// ELF32 structure definitions for use by the vDSO loader
+
+type elfSym struct {
+       st_name  uint32
+       st_value uint32
+       st_size  uint32
+       st_info  byte
+       st_other byte
+       st_shndx uint16
+}
+
+type elfVerdef struct {
+       vd_version uint16 /* Version revision */
+       vd_flags   uint16 /* Version information */
+       vd_ndx     uint16 /* Version Index */
+       vd_cnt     uint16 /* Number of associated aux entries */
+       vd_hash    uint32 /* Version name hash value */
+       vd_aux     uint32 /* Offset in bytes to verdaux array */
+       vd_next    uint32 /* Offset in bytes to next verdef entry */
+}
+
+type elfEhdr struct {
+       e_ident     [_EI_NIDENT]byte /* Magic number and other info */
+       e_type      uint16           /* Object file type */
+       e_machine   uint16           /* Architecture */
+       e_version   uint32           /* Object file version */
+       e_entry     uint32           /* Entry point virtual address */
+       e_phoff     uint32           /* Program header table file offset */
+       e_shoff     uint32           /* Section header table file offset */
+       e_flags     uint32           /* Processor-specific flags */
+       e_ehsize    uint16           /* ELF header size in bytes */
+       e_phentsize uint16           /* Program header table entry size */
+       e_phnum     uint16           /* Program header table entry count */
+       e_shentsize uint16           /* Section header table entry size */
+       e_shnum     uint16           /* Section header table entry count */
+       e_shstrndx  uint16           /* Section header string table index */
+}
+
+type elfPhdr struct {
+       p_type   uint32 /* Segment type */
+       p_offset uint32 /* Segment file offset */
+       p_vaddr  uint32 /* Segment virtual address */
+       p_paddr  uint32 /* Segment physical address */
+       p_filesz uint32 /* Segment size in file */
+       p_memsz  uint32 /* Segment size in memory */
+       p_flags  uint32 /* Segment flags */
+       p_align  uint32 /* Segment alignment */
+}
+
+type elfShdr struct {
+       sh_name      uint32 /* Section name (string tbl index) */
+       sh_type      uint32 /* Section type */
+       sh_flags     uint32 /* Section flags */
+       sh_addr      uint32 /* Section virtual addr at execution */
+       sh_offset    uint32 /* Section file offset */
+       sh_size      uint32 /* Section size in bytes */
+       sh_link      uint32 /* Link to another section */
+       sh_info      uint32 /* Additional section information */
+       sh_addralign uint32 /* Section alignment */
+       sh_entsize   uint32 /* Entry size if section holds table */
+}
+
+type elfDyn struct {
+       d_tag int32  /* Dynamic entry type */
+       d_val uint32 /* Integer value */
+}
+
+type elfVerdaux struct {
+       vda_name uint32 /* Version or dependency names */
+       vda_next uint32 /* Offset in bytes to next verdaux entry */
+}
diff --git a/src/runtime/vdso_elf64.go b/src/runtime/vdso_elf64.go
new file mode 100644 (file)
index 0000000..828714d
--- /dev/null
@@ -0,0 +1,80 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build linux
+// +build amd64
+
+package runtime
+
+// ELF64 structure definitions for use by the vDSO loader
+
+type elfSym struct {
+       st_name  uint32
+       st_info  byte
+       st_other byte
+       st_shndx uint16
+       st_value uint64
+       st_size  uint64
+}
+
+type elfVerdef struct {
+       vd_version uint16 /* Version revision */
+       vd_flags   uint16 /* Version information */
+       vd_ndx     uint16 /* Version Index */
+       vd_cnt     uint16 /* Number of associated aux entries */
+       vd_hash    uint32 /* Version name hash value */
+       vd_aux     uint32 /* Offset in bytes to verdaux array */
+       vd_next    uint32 /* Offset in bytes to next verdef entry */
+}
+
+type elfEhdr struct {
+       e_ident     [_EI_NIDENT]byte /* Magic number and other info */
+       e_type      uint16           /* Object file type */
+       e_machine   uint16           /* Architecture */
+       e_version   uint32           /* Object file version */
+       e_entry     uint64           /* Entry point virtual address */
+       e_phoff     uint64           /* Program header table file offset */
+       e_shoff     uint64           /* Section header table file offset */
+       e_flags     uint32           /* Processor-specific flags */
+       e_ehsize    uint16           /* ELF header size in bytes */
+       e_phentsize uint16           /* Program header table entry size */
+       e_phnum     uint16           /* Program header table entry count */
+       e_shentsize uint16           /* Section header table entry size */
+       e_shnum     uint16           /* Section header table entry count */
+       e_shstrndx  uint16           /* Section header string table index */
+}
+
+type elfPhdr struct {
+       p_type   uint32 /* Segment type */
+       p_flags  uint32 /* Segment flags */
+       p_offset uint64 /* Segment file offset */
+       p_vaddr  uint64 /* Segment virtual address */
+       p_paddr  uint64 /* Segment physical address */
+       p_filesz uint64 /* Segment size in file */
+       p_memsz  uint64 /* Segment size in memory */
+       p_align  uint64 /* Segment alignment */
+}
+
+type elfShdr struct {
+       sh_name      uint32 /* Section name (string tbl index) */
+       sh_type      uint32 /* Section type */
+       sh_flags     uint64 /* Section flags */
+       sh_addr      uint64 /* Section virtual addr at execution */
+       sh_offset    uint64 /* Section file offset */
+       sh_size      uint64 /* Section size in bytes */
+       sh_link      uint32 /* Link to another section */
+       sh_info      uint32 /* Additional section information */
+       sh_addralign uint64 /* Section alignment */
+       sh_entsize   uint64 /* Entry size if section holds table */
+}
+
+type elfDyn struct {
+       d_tag int64  /* Dynamic entry type */
+       d_val uint64 /* Integer value */
+}
+
+type elfVerdaux struct {
+       vda_name uint32 /* Version or dependency names */
+       vda_next uint32 /* Offset in bytes to next verdaux entry */
+}
index 74ad953469cae20a5d7d85bbe6642b59f6701a82..645563ebe0a00dde9d8a26f482685aba81352248 100644 (file)
@@ -4,78 +4,6 @@
 
 package runtime
 
-// ELF32 structure definitions for use by the Linux vDSO loader
-
-type elfSym struct {
-       st_name  uint32
-       st_value uint32
-       st_size  uint32
-       st_info  byte
-       st_other byte
-       st_shndx uint16
-}
-
-type elfVerdef struct {
-       vd_version uint16 /* Version revision */
-       vd_flags   uint16 /* Version information */
-       vd_ndx     uint16 /* Version Index */
-       vd_cnt     uint16 /* Number of associated aux entries */
-       vd_hash    uint32 /* Version name hash value */
-       vd_aux     uint32 /* Offset in bytes to verdaux array */
-       vd_next    uint32 /* Offset in bytes to next verdef entry */
-}
-
-type elfEhdr struct {
-       e_ident     [_EI_NIDENT]byte /* Magic number and other info */
-       e_type      uint16           /* Object file type */
-       e_machine   uint16           /* Architecture */
-       e_version   uint32           /* Object file version */
-       e_entry     uint32           /* Entry point virtual address */
-       e_phoff     uint32           /* Program header table file offset */
-       e_shoff     uint32           /* Section header table file offset */
-       e_flags     uint32           /* Processor-specific flags */
-       e_ehsize    uint16           /* ELF header size in bytes */
-       e_phentsize uint16           /* Program header table entry size */
-       e_phnum     uint16           /* Program header table entry count */
-       e_shentsize uint16           /* Section header table entry size */
-       e_shnum     uint16           /* Section header table entry count */
-       e_shstrndx  uint16           /* Section header string table index */
-}
-
-type elfPhdr struct {
-       p_type   uint32 /* Segment type */
-       p_offset uint32 /* Segment file offset */
-       p_vaddr  uint32 /* Segment virtual address */
-       p_paddr  uint32 /* Segment physical address */
-       p_filesz uint32 /* Segment size in file */
-       p_memsz  uint32 /* Segment size in memory */
-       p_flags  uint32 /* Segment flags */
-       p_align  uint32 /* Segment alignment */
-}
-
-type elfShdr struct {
-       sh_name      uint32 /* Section name (string tbl index) */
-       sh_type      uint32 /* Section type */
-       sh_flags     uint32 /* Section flags */
-       sh_addr      uint32 /* Section virtual addr at execution */
-       sh_offset    uint32 /* Section file offset */
-       sh_size      uint32 /* Section size in bytes */
-       sh_link      uint32 /* Link to another section */
-       sh_info      uint32 /* Additional section information */
-       sh_addralign uint32 /* Section alignment */
-       sh_entsize   uint32 /* Entry size if section holds table */
-}
-
-type elfDyn struct {
-       d_tag int32  /* Dynamic entry type */
-       d_val uint32 /* Integer value */
-}
-
-type elfVerdaux struct {
-       vda_name uint32 /* Version or dependency names */
-       vda_next uint32 /* Offset in bytes to next verdaux entry */
-}
-
 const (
        // vdsoArrayMax is the byte-size of a maximally sized array on this architecture.
        // See cmd/compile/internal/x86/galign.go arch.MAXWIDTH initialization, but must also
index 0bbe5c2e8f5fea970fec9e2b38a10d666e34c224..f971ba672b80d9ece977f0a0db2af3d9005b4c53 100644 (file)
@@ -4,78 +4,6 @@
 
 package runtime
 
-// ELF64 structure definitions for use by the Linux vDSO loader
-
-type elfSym struct {
-       st_name  uint32
-       st_info  byte
-       st_other byte
-       st_shndx uint16
-       st_value uint64
-       st_size  uint64
-}
-
-type elfVerdef struct {
-       vd_version uint16 /* Version revision */
-       vd_flags   uint16 /* Version information */
-       vd_ndx     uint16 /* Version Index */
-       vd_cnt     uint16 /* Number of associated aux entries */
-       vd_hash    uint32 /* Version name hash value */
-       vd_aux     uint32 /* Offset in bytes to verdaux array */
-       vd_next    uint32 /* Offset in bytes to next verdef entry */
-}
-
-type elfEhdr struct {
-       e_ident     [_EI_NIDENT]byte /* Magic number and other info */
-       e_type      uint16           /* Object file type */
-       e_machine   uint16           /* Architecture */
-       e_version   uint32           /* Object file version */
-       e_entry     uint64           /* Entry point virtual address */
-       e_phoff     uint64           /* Program header table file offset */
-       e_shoff     uint64           /* Section header table file offset */
-       e_flags     uint32           /* Processor-specific flags */
-       e_ehsize    uint16           /* ELF header size in bytes */
-       e_phentsize uint16           /* Program header table entry size */
-       e_phnum     uint16           /* Program header table entry count */
-       e_shentsize uint16           /* Section header table entry size */
-       e_shnum     uint16           /* Section header table entry count */
-       e_shstrndx  uint16           /* Section header string table index */
-}
-
-type elfPhdr struct {
-       p_type   uint32 /* Segment type */
-       p_flags  uint32 /* Segment flags */
-       p_offset uint64 /* Segment file offset */
-       p_vaddr  uint64 /* Segment virtual address */
-       p_paddr  uint64 /* Segment physical address */
-       p_filesz uint64 /* Segment size in file */
-       p_memsz  uint64 /* Segment size in memory */
-       p_align  uint64 /* Segment alignment */
-}
-
-type elfShdr struct {
-       sh_name      uint32 /* Section name (string tbl index) */
-       sh_type      uint32 /* Section type */
-       sh_flags     uint64 /* Section flags */
-       sh_addr      uint64 /* Section virtual addr at execution */
-       sh_offset    uint64 /* Section file offset */
-       sh_size      uint64 /* Section size in bytes */
-       sh_link      uint32 /* Link to another section */
-       sh_info      uint32 /* Additional section information */
-       sh_addralign uint64 /* Section alignment */
-       sh_entsize   uint64 /* Entry size if section holds table */
-}
-
-type elfDyn struct {
-       d_tag int64  /* Dynamic entry type */
-       d_val uint64 /* Integer value */
-}
-
-type elfVerdaux struct {
-       vda_name uint32 /* Version or dependency names */
-       vda_next uint32 /* Offset in bytes to next verdaux entry */
-}
-
 const (
        // vdsoArrayMax is the byte-size of a maximally sized array on this architecture.
        // See cmd/compile/internal/amd64/galign.go arch.MAXWIDTH initialization.