FAQ
Reviewers: golang-dev_googlegroups.com,

Message:
Hello golang-dev@googlegroups.com,

I'd like you to review this change to
https://code.google.com/p/go


Description:
debug/elf: handle missing shstrndx in core files

Fixes issue 4481.

hello-world-core.gz was generated with a simple hello world c program
and core dumped as suggested in the issue.

Also: add support for gz compressed test fixtures.

Please review this at https://codereview.appspot.com/6936058/

Affected files:
M src/pkg/debug/elf/file.go
M src/pkg/debug/elf/file_test.go
A src/pkg/debug/elf/testdata/hello-world-core.gz


Index: src/pkg/debug/elf/file.go
===================================================================
--- a/src/pkg/debug/elf/file.go
+++ b/src/pkg/debug/elf/file.go
@@ -272,7 +272,7 @@
shnum = int(hdr.Shnum)
shstrndx = int(hdr.Shstrndx)
}
- if shstrndx < 0 || shstrndx >= shnum {
+ if shstrndx < 0 || shstrndx > shnum {
return nil, &FormatError{0, "invalid ELF shstrndx", shstrndx}
}

@@ -367,6 +367,10 @@
f.Sections[i] = s
}

+ if len(f.Sections) == 0 {
+ return f, nil
+ }
+
// Load section header string table.
shstrtab, err := f.Sections[shstrndx].Data()
if err != nil {
Index: src/pkg/debug/elf/file_test.go
===================================================================
--- a/src/pkg/debug/elf/file_test.go
+++ b/src/pkg/debug/elf/file_test.go
@@ -5,10 +5,14 @@
package elf

import (
+ "compress/gzip"
"debug/dwarf"
"encoding/binary"
+ "io"
+ "io/ioutil"
"net"
"os"
+ "path"
"reflect"
"runtime"
"testing"
@@ -121,15 +125,50 @@
},
[]string{"libc.so.6"},
},
+ {
+ "testdata/hello-world-core.gz",
+ FileHeader{ELFCLASS64, ELFDATA2LSB, EV_CURRENT, ELFOSABI_NONE, 0x0,
binary.LittleEndian, ET_CORE, EM_X86_64, 0x0},
+ []SectionHeader{},
+ []ProgHeader{
+ {Type: PT_NOTE, Flags: 0x0, Off: 0x3f8, Vaddr: 0x0, Paddr: 0x0, Filesz:
0x8ac, Memsz: 0x0, Align: 0x0},
+ {Type: PT_LOAD, Flags: PF_X + PF_R, Off: 0x1000, Vaddr: 0x400000,
Paddr: 0x0, Filesz: 0x0, Memsz: 0x1000, Align: 0x1000},
+ {Type: PT_LOAD, Flags: PF_R, Off: 0x1000, Vaddr: 0x401000, Paddr: 0x0,
Filesz: 0x1000, Memsz: 0x1000, Align: 0x1000},
+ {Type: PT_LOAD, Flags: PF_W + PF_R, Off: 0x2000, Vaddr: 0x402000,
Paddr: 0x0, Filesz: 0x1000, Memsz: 0x1000, Align: 0x1000},
+ {Type: PT_LOAD, Flags: PF_X + PF_R, Off: 0x3000, Vaddr: 0x7f54078b8000,
Paddr: 0x0, Filesz: 0x0, Memsz: 0x1b5000, Align: 0x1000},
+ {Type: PT_LOAD, Flags: 0x0, Off: 0x3000, Vaddr: 0x7f5407a6d000, Paddr:
0x0, Filesz: 0x0, Memsz: 0x1ff000, Align: 0x1000},
+ {Type: PT_LOAD, Flags: PF_R, Off: 0x3000, Vaddr: 0x7f5407c6c000, Paddr:
0x0, Filesz: 0x4000, Memsz: 0x4000, Align: 0x1000},
+ {Type: PT_LOAD, Flags: PF_W + PF_R, Off: 0x7000, Vaddr: 0x7f5407c70000,
Paddr: 0x0, Filesz: 0x2000, Memsz: 0x2000, Align: 0x1000},
+ {Type: PT_LOAD, Flags: PF_W + PF_R, Off: 0x9000, Vaddr: 0x7f5407c72000,
Paddr: 0x0, Filesz: 0x5000, Memsz: 0x5000, Align: 0x1000},
+ {Type: PT_LOAD, Flags: PF_X + PF_R, Off: 0xe000, Vaddr: 0x7f5407c77000,
Paddr: 0x0, Filesz: 0x0, Memsz: 0x22000, Align: 0x1000},
+ {Type: PT_LOAD, Flags: PF_W + PF_R, Off: 0xe000, Vaddr: 0x7f5407e81000,
Paddr: 0x0, Filesz: 0x3000, Memsz: 0x3000, Align: 0x1000},
+ {Type: PT_LOAD, Flags: PF_W + PF_R, Off: 0x11000, Vaddr:
0x7f5407e96000, Paddr: 0x0, Filesz: 0x3000, Memsz: 0x3000, Align: 0x1000},
+ {Type: PT_LOAD, Flags: PF_R, Off: 0x14000, Vaddr: 0x7f5407e99000,
Paddr: 0x0, Filesz: 0x1000, Memsz: 0x1000, Align: 0x1000},
+ {Type: PT_LOAD, Flags: PF_W + PF_R, Off: 0x15000, Vaddr:
0x7f5407e9a000, Paddr: 0x0, Filesz: 0x2000, Memsz: 0x2000, Align: 0x1000},
+ {Type: PT_LOAD, Flags: PF_W + PF_R, Off: 0x17000, Vaddr:
0x7fff79972000, Paddr: 0x0, Filesz: 0x23000, Memsz: 0x23000, Align: 0x1000},
+ {Type: PT_LOAD, Flags: PF_X + PF_R, Off: 0x3a000, Vaddr:
0x7fff799f8000, Paddr: 0x0, Filesz: 0x1000, Memsz: 0x1000, Align: 0x1000},
+ {Type: PT_LOAD, Flags: PF_X + PF_R, Off: 0x3b000, Vaddr:
0xffffffffff600000, Paddr: 0x0, Filesz: 0x1000, Memsz: 0x1000, Align:
0x1000},
+ },
+ nil,
+ },
}

func TestOpen(t *testing.T) {
for i := range fileTests {
tt := &fileTests[i]

- f, err := Open(tt.file)
+ file := tt.file
+ if path.Ext(file) == ".gz" {
+ var err error
+ file, err = decompress(file)
+ if err != nil {
+ t.Error(err)
+ continue
+ }
+ defer os.Remove(file)
+ }
+ f, err := Open(file)
if err != nil {
- t.Error(err)
+ t.Errorf("cannot open file %s: %v", file, err)
continue
}
if !reflect.DeepEqual(f.FileHeader, tt.hdr) {
@@ -175,6 +214,28 @@
}
}

+// elf.NewFile requires io.ReaderAt, which compress/gzip cannot
+// provide. Temporarily decompress the compressed file to a
+// temporary file and return the name of that file.
+func decompress(gz string) (string, error) {
+ in, err := os.Open(gz)
+ if err != nil {
+ return "", err
+ }
+ defer in.Close()
+ r, err := gzip.NewReader(in)
+ if err != nil {
+ return "", err
+ }
+ out, err := ioutil.TempFile("", "elftest")
+ if err != nil {
+ return "", err
+ }
+ defer out.Close()
+ _, err = io.Copy(out, r)
+ return out.Name(), err
+}
+
type relocationTestEntry struct {
entryNumber int
entry *dwarf.Entry
Index: src/pkg/debug/elf/testdata/hello-world-core.gz
===================================================================
new file mode 100644
index
0000000000000000000000000000000000000000..806af6edbc23bd0db45a9b1adfae9418ca6a969a
GIT binary patch
literal 12678
zc%1EcRZtvE)MXL^1PJg&a19bHKnMhf2_d+<GiV49+-(L)f<u7dG7#L|f(%a33GNbX
za2RZ0biaRh|EiVRec0!{FXy5A-tN;?efpkeiG6hMifUZ@9>H-gdGIp@)UcSNW32x_
zb?*XP{^-6d=C7reu#$NAK>v~PbBbo3raw+Dw!k7%a8#)3D=Y5x=<qB(ea)*XK}_vB
zB!$(fS5NRK8|f{{qYSoBGVfy9?#@1fW<I8COs7##1%dpo$ApDp<HC)NXW46mwlhNq
zK9XU4y0kpAX5p-)aMkC!UvGSNGo9E)NL2%0C`wtl7N%k-<;&6@T##Rbl487t?C#z{
zx$jsMix?PA;fcb82Q3ZzSA+B(Ssl6CTn|z0khz=6Xuz=Gn?JDYglR2(oizZTpmFh)
za7EdT*LiR%#6;n`&HuY=_4Fx3r*@4QDeRvL;^D2pKBhHM^NGM>wt4zs1s7yu!0~f0
zLorwB>T_XP&sMD`rIsq!{*v`<OL_XJuh|f)V8W(byRVndUu#Biwk7Hee5HgneWsO-
zJivdb*K}Zeh6-DSI9Vxn1*pqW&)$#SH$xt@4P$c&A+IARQO_$@#LMBNJ6E!YS}YH<
z7a%j)gC42Ba6~b+=nGmwnnmLaA?lJB!eQ4_486En+w4qzZCyrf2i*q1;Nm&=d$k09
zh2cHk#A+JY!0NW%5OQY0%w7=@Y<C{=j`}w|E-L;R3vM=4)V`UhFd$^nx6F^KlMzDc
zVih#?r<fP*$J<dodRkQhCA(b!eGafydo`<W?JKod%MRoRgRgM-h4{Z)tZ2Dx{eT|R
zfGKVh&gwTb){8XNJ3b$N?1frpJ$HQeQVa6pPtI*Mk7V$ZuUGs}38O!-<wB?{C-K+f
zc=)h6+cfeaqx1+IUtNr+FJ^xk0H)!2n3onqI{(v26BI{tAFBVEQSbU^_?k|F9?d%t
z<A~YgA`%7%&FcUYeu}5gK~bbP3XDcas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a2a|>!$x>>A_99ucRSsBFYe&vL*UvBUs&fpld1itfw
z;1QVE+CeAj>_>cx=bb{wCe5AxlXd8)L~6v{Hu0;1^m_rgKu)Zm7j7*F-2OrE5}^D_
z;__aiJ5EU)nj(DX{`xo=&5pTk<w@1KBpi%$yTU^W
zLImgJ&dWptq$vY__Y)Fr;*~COkVt9sjC(lfavBmZz4PMV5qV|-?%QX-fzE&L^$^_q
EFWf@282|tP

Search Discussions

  • Minux Ma at Dec 16, 2012 at 1:22 am
    do we really need to create a tmp file?

    i think just use bytes.Reader + bytes.Buffer and
    elf.NewFile is acceptable for this case (elf.Open
    is tested by others files and it merely open the
    file and then invokes NewFile).

    i'd like to avoid creating temporary files for this,
    what do you think?

    https://codereview.appspot.com/6936058/
  • Dave at Dec 16, 2012 at 1:33 am
  • Minux Ma at Dec 16, 2012 at 2:01 am
    https://codereview.appspot.com/6936058/diff/8001/src/pkg/debug/elf/file_test.go
    File src/pkg/debug/elf/file_test.go (right):

    https://codereview.appspot.com/6936058/diff/8001/src/pkg/debug/elf/file_test.go#newcode168
    src/pkg/debug/elf/file_test.go:168: f, err := os.Open(tt.file)
    well i mean we keep using elf.Open for normal files
    so that we still test elf.Open and only use elf.NewFile
    for gz compressed elf files.

    https://codereview.appspot.com/6936058/
  • Dave at Dec 16, 2012 at 2:23 am

    src/pkg/debug/elf/file_test.go:168: f, err := os.Open(tt.file)
    well i mean we keep using elf.Open for normal files
    so that we still test elf.Open and only use elf.NewFile
    for gz compressed elf files.
    Gotcha. Done.


    https://codereview.appspot.com/6936058/
  • Dave at Dec 16, 2012 at 2:25 am
    Hello golang-dev@googlegroups.com, minux.ma@gmail.com (cc:
    golang-dev@googlegroups.com),

    Please take another look.


    https://codereview.appspot.com/6936058/
  • Minux Ma at Dec 16, 2012 at 2:32 am
    https://codereview.appspot.com/6936058/diff/4005/src/pkg/debug/elf/file.go
    File src/pkg/debug/elf/file.go (right):

    https://codereview.appspot.com/6936058/diff/4005/src/pkg/debug/elf/file.go#newcode275
    src/pkg/debug/elf/file.go:275: if shstrndx < 0 || shstrndx > shnum {
    if shnum > 0 i think shstrndx should not be allowed to be
    equal to shnum.

    i think the correct condition is:
    if shstrndx < 0 || shstrndx != 0 && shstrndx >= shnum

    https://codereview.appspot.com/6936058/
  • Dave at Dec 16, 2012 at 4:57 am
    https://codereview.appspot.com/6936058/diff/4005/src/pkg/debug/elf/file.go
    File src/pkg/debug/elf/file.go (right):

    https://codereview.appspot.com/6936058/diff/4005/src/pkg/debug/elf/file.go#newcode275
    src/pkg/debug/elf/file.go:275: if shstrndx < 0 || shstrndx > shnum {
    On 2012/12/16 02:32:02, minux wrote:
    if shnum > 0 i think shstrndx should not be allowed to be
    equal to shnum.
    i think the correct condition is:
    if shstrndx < 0 || shstrndx != 0 && shstrndx >= shnum
    PTAL. According to the freebsd man page on elf,

    "If a file has no section header table, both the e_shnum and the e_shoff
    fields of the ELF header will be zero."

    https://codereview.appspot.com/6936058/

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedDec 16, '12 at 1:11a
activeDec 16, '12 at 4:57a
posts8
users2
websitegolang.org

2 users in discussion

Dave: 5 posts Minux Ma: 3 posts

People

Translate

site design / logo © 2022 Grokbase