]> Cypherpunks repositories - gostls13.git/commitdiff
debug/pe: move some code into section.go and symbol.go
authorAlex Brainman <alex.brainman@gmail.com>
Wed, 20 Apr 2016 03:02:41 +0000 (13:02 +1000)
committerAlex Brainman <alex.brainman@gmail.com>
Wed, 20 Apr 2016 04:46:59 +0000 (04:46 +0000)
Just moving code. No code changes.

Updates #15345

Change-Id: I89c257b7aae4fbd78ce59a42909ecb3ff493659d
Reviewed-on: https://go-review.googlesource.com/22300
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/debug/pe/file.go
src/debug/pe/pe.go
src/debug/pe/section.go [new file with mode: 0644]
src/debug/pe/symbol.go [new file with mode: 0644]

index f7b74e92a4a27afdade51207234b4a05da463264..3affd25185deb68378d07b45331dc79b10aa3747 100644 (file)
@@ -26,53 +26,6 @@ type File struct {
        closer io.Closer
 }
 
-type SectionHeader struct {
-       Name                 string
-       VirtualSize          uint32
-       VirtualAddress       uint32
-       Size                 uint32
-       Offset               uint32
-       PointerToRelocations uint32
-       PointerToLineNumbers uint32
-       NumberOfRelocations  uint16
-       NumberOfLineNumbers  uint16
-       Characteristics      uint32
-}
-
-type Section struct {
-       SectionHeader
-
-       // Embed ReaderAt for ReadAt method.
-       // Do not embed SectionReader directly
-       // to avoid having Read and Seek.
-       // If a client wants Read and Seek it must use
-       // Open() to avoid fighting over the seek offset
-       // with other clients.
-       io.ReaderAt
-       sr *io.SectionReader
-}
-
-type Symbol struct {
-       Name          string
-       Value         uint32
-       SectionNumber int16
-       Type          uint16
-       StorageClass  uint8
-}
-
-// Data reads and returns the contents of the PE section.
-func (s *Section) Data() ([]byte, error) {
-       dat := make([]byte, s.sr.Size())
-       n, err := s.sr.ReadAt(dat, 0)
-       if n == len(dat) {
-               err = nil
-       }
-       return dat[0:n], err
-}
-
-// Open returns a new ReadSeeker reading the PE section.
-func (s *Section) Open() io.ReadSeeker { return io.NewSectionReader(s.sr, 0, 1<<63-1) }
-
 // Open opens the named file using os.Open and prepares it for use as a PE binary.
 func Open(name string) (*File, error) {
        f, err := os.Open(name)
index 6af40e2c781fce26b717329b9904a1c0dc980884..8050d59c70dd4f2d060edec7bcb1d45275738930 100644 (file)
@@ -86,30 +86,6 @@ type OptionalHeader64 struct {
        DataDirectory               [16]DataDirectory
 }
 
-type SectionHeader32 struct {
-       Name                 [8]uint8
-       VirtualSize          uint32
-       VirtualAddress       uint32
-       SizeOfRawData        uint32
-       PointerToRawData     uint32
-       PointerToRelocations uint32
-       PointerToLineNumbers uint32
-       NumberOfRelocations  uint16
-       NumberOfLineNumbers  uint16
-       Characteristics      uint32
-}
-
-const COFFSymbolSize = 18
-
-type COFFSymbol struct {
-       Name               [8]uint8
-       Value              uint32
-       SectionNumber      int16
-       Type               uint16
-       StorageClass       uint8
-       NumberOfAuxSymbols uint8
-}
-
 const (
        IMAGE_FILE_MACHINE_UNKNOWN   = 0x0
        IMAGE_FILE_MACHINE_AM33      = 0x1d3
diff --git a/src/debug/pe/section.go b/src/debug/pe/section.go
new file mode 100644 (file)
index 0000000..31cff27
--- /dev/null
@@ -0,0 +1,61 @@
+// Copyright 2016 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.
+
+package pe
+
+import (
+       "io"
+)
+
+type SectionHeader32 struct {
+       Name                 [8]uint8
+       VirtualSize          uint32
+       VirtualAddress       uint32
+       SizeOfRawData        uint32
+       PointerToRawData     uint32
+       PointerToRelocations uint32
+       PointerToLineNumbers uint32
+       NumberOfRelocations  uint16
+       NumberOfLineNumbers  uint16
+       Characteristics      uint32
+}
+
+type SectionHeader struct {
+       Name                 string
+       VirtualSize          uint32
+       VirtualAddress       uint32
+       Size                 uint32
+       Offset               uint32
+       PointerToRelocations uint32
+       PointerToLineNumbers uint32
+       NumberOfRelocations  uint16
+       NumberOfLineNumbers  uint16
+       Characteristics      uint32
+}
+
+type Section struct {
+       SectionHeader
+
+       // Embed ReaderAt for ReadAt method.
+       // Do not embed SectionReader directly
+       // to avoid having Read and Seek.
+       // If a client wants Read and Seek it must use
+       // Open() to avoid fighting over the seek offset
+       // with other clients.
+       io.ReaderAt
+       sr *io.SectionReader
+}
+
+// Data reads and returns the contents of the PE section.
+func (s *Section) Data() ([]byte, error) {
+       dat := make([]byte, s.sr.Size())
+       n, err := s.sr.ReadAt(dat, 0)
+       if n == len(dat) {
+               err = nil
+       }
+       return dat[0:n], err
+}
+
+// Open returns a new ReadSeeker reading the PE section.
+func (s *Section) Open() io.ReadSeeker { return io.NewSectionReader(s.sr, 0, 1<<63-1) }
diff --git a/src/debug/pe/symbol.go b/src/debug/pe/symbol.go
new file mode 100644 (file)
index 0000000..5591748
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright 2016 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.
+
+package pe
+
+const COFFSymbolSize = 18
+
+type COFFSymbol struct {
+       Name               [8]uint8
+       Value              uint32
+       SectionNumber      int16
+       Type               uint16
+       StorageClass       uint8
+       NumberOfAuxSymbols uint8
+}
+
+type Symbol struct {
+       Name          string
+       Value         uint32
+       SectionNumber int16
+       Type          uint16
+       StorageClass  uint8
+}