]> Cypherpunks repositories - gostls13.git/commitdiff
debug/elf: Expose entry point from Header in File struct.
authorMatthew Horsnell <matthew.horsnell@gmail.com>
Tue, 22 May 2012 03:29:30 +0000 (23:29 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 22 May 2012 03:29:30 +0000 (23:29 -0400)
Fixes #3470.

R=rsc, golang-dev
CC=golang-dev
https://golang.org/cl/6195074

src/pkg/debug/elf/file.go
src/pkg/debug/elf/file_test.go

index 184ca8375b548e1f474f1392d4aa074b29f037cf..241430e5c6534483fab5ef6724b283ec63447c0e 100644 (file)
@@ -31,6 +31,7 @@ type FileHeader struct {
        ByteOrder  binary.ByteOrder
        Type       Type
        Machine    Machine
+       Entry      uint64
 }
 
 // A File represents an open ELF file.
@@ -240,6 +241,7 @@ func NewFile(r io.ReaderAt) (*File, error) {
                }
                f.Type = Type(hdr.Type)
                f.Machine = Machine(hdr.Machine)
+               f.Entry = uint64(hdr.Entry)
                if v := Version(hdr.Version); v != f.Version {
                        return nil, &FormatError{0, "mismatched ELF version", v}
                }
@@ -258,6 +260,7 @@ func NewFile(r io.ReaderAt) (*File, error) {
                }
                f.Type = Type(hdr.Type)
                f.Machine = Machine(hdr.Machine)
+               f.Entry = uint64(hdr.Entry)
                if v := Version(hdr.Version); v != f.Version {
                        return nil, &FormatError{0, "mismatched ELF version", v}
                }
index 98f2723c86e6e1d3f3108254ed5e6bde2c7700c7..6ec5f4f62cb7bf63d9a79a94c7ccbb3a042b45f3 100644 (file)
@@ -24,7 +24,7 @@ type fileTest struct {
 var fileTests = []fileTest{
        {
                "testdata/gcc-386-freebsd-exec",
-               FileHeader{ELFCLASS32, ELFDATA2LSB, EV_CURRENT, ELFOSABI_FREEBSD, 0, binary.LittleEndian, ET_EXEC, EM_386},
+               FileHeader{ELFCLASS32, ELFDATA2LSB, EV_CURRENT, ELFOSABI_FREEBSD, 0, binary.LittleEndian, ET_EXEC, EM_386, 0x80483cc},
                []SectionHeader{
                        {"", SHT_NULL, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
                        {".interp", SHT_PROGBITS, SHF_ALLOC, 0x80480d4, 0xd4, 0x15, 0x0, 0x0, 0x1, 0x0},
@@ -67,7 +67,7 @@ var fileTests = []fileTest{
        },
        {
                "testdata/gcc-amd64-linux-exec",
-               FileHeader{ELFCLASS64, ELFDATA2LSB, EV_CURRENT, ELFOSABI_NONE, 0, binary.LittleEndian, ET_EXEC, EM_X86_64},
+               FileHeader{ELFCLASS64, ELFDATA2LSB, EV_CURRENT, ELFOSABI_NONE, 0, binary.LittleEndian, ET_EXEC, EM_X86_64, 0x4003e0},
                []SectionHeader{
                        {"", SHT_NULL, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
                        {".interp", SHT_PROGBITS, SHF_ALLOC, 0x400200, 0x200, 0x1c, 0x0, 0x0, 0x1, 0x0},