Commit 875f34fd authored by Matthew Horsnell's avatar Matthew Horsnell Committed by Russ Cox

debug/elf: Expose entry point from Header in File struct.

Fixes #3470.

R=rsc, golang-dev
CC=golang-dev
https://golang.org/cl/6195074
parent 7648f61c
...@@ -31,6 +31,7 @@ type FileHeader struct { ...@@ -31,6 +31,7 @@ type FileHeader struct {
ByteOrder binary.ByteOrder ByteOrder binary.ByteOrder
Type Type Type Type
Machine Machine Machine Machine
Entry uint64
} }
// A File represents an open ELF file. // A File represents an open ELF file.
...@@ -240,6 +241,7 @@ func NewFile(r io.ReaderAt) (*File, error) { ...@@ -240,6 +241,7 @@ func NewFile(r io.ReaderAt) (*File, error) {
} }
f.Type = Type(hdr.Type) f.Type = Type(hdr.Type)
f.Machine = Machine(hdr.Machine) f.Machine = Machine(hdr.Machine)
f.Entry = uint64(hdr.Entry)
if v := Version(hdr.Version); v != f.Version { if v := Version(hdr.Version); v != f.Version {
return nil, &FormatError{0, "mismatched ELF version", v} return nil, &FormatError{0, "mismatched ELF version", v}
} }
...@@ -258,6 +260,7 @@ func NewFile(r io.ReaderAt) (*File, error) { ...@@ -258,6 +260,7 @@ func NewFile(r io.ReaderAt) (*File, error) {
} }
f.Type = Type(hdr.Type) f.Type = Type(hdr.Type)
f.Machine = Machine(hdr.Machine) f.Machine = Machine(hdr.Machine)
f.Entry = uint64(hdr.Entry)
if v := Version(hdr.Version); v != f.Version { if v := Version(hdr.Version); v != f.Version {
return nil, &FormatError{0, "mismatched ELF version", v} return nil, &FormatError{0, "mismatched ELF version", v}
} }
......
...@@ -24,7 +24,7 @@ type fileTest struct { ...@@ -24,7 +24,7 @@ type fileTest struct {
var fileTests = []fileTest{ var fileTests = []fileTest{
{ {
"testdata/gcc-386-freebsd-exec", "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{ []SectionHeader{
{"", SHT_NULL, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, {"", SHT_NULL, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
{".interp", SHT_PROGBITS, SHF_ALLOC, 0x80480d4, 0xd4, 0x15, 0x0, 0x0, 0x1, 0x0}, {".interp", SHT_PROGBITS, SHF_ALLOC, 0x80480d4, 0xd4, 0x15, 0x0, 0x0, 0x1, 0x0},
...@@ -67,7 +67,7 @@ var fileTests = []fileTest{ ...@@ -67,7 +67,7 @@ var fileTests = []fileTest{
}, },
{ {
"testdata/gcc-amd64-linux-exec", "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{ []SectionHeader{
{"", SHT_NULL, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, {"", SHT_NULL, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
{".interp", SHT_PROGBITS, SHF_ALLOC, 0x400200, 0x200, 0x1c, 0x0, 0x0, 0x1, 0x0}, {".interp", SHT_PROGBITS, SHF_ALLOC, 0x400200, 0x200, 0x1c, 0x0, 0x0, 0x1, 0x0},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment