]> Cypherpunks repositories - gostls13.git/commit
debug/elf: suport files with >= 65280 (0xff00) sections
authorZeke Lu <lvzecai@gmail.com>
Mon, 26 Sep 2022 20:46:24 +0000 (20:46 +0000)
committerGopher Robot <gobot@golang.org>
Tue, 27 Sep 2022 16:50:30 +0000 (16:50 +0000)
commit7d157fd0eb637a4c58f629421dd8d028022391d2
treefebd37a653ad736a87ac41dd6429829ece5416b3
parent1e4989c33674bf9570c99250a081a448c3cded65
debug/elf: suport files with >= 65280 (0xff00) sections

The spec https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.eheader.html
states:

1. e_shnum: If the number of sections is greater than or equal to
SHN_LORESERVE (0xff00), this member has the value zero and the actual
number of section header table entries is contained in the sh_size
field of the section header at index 0.

2. e_shstrndx: If the section name string table section index is
greater than or equal to SHN_LORESERVE (0xff00), this member has the
value SHN_XINDEX (0xffff) and the actual index of the section name
string table section is contained in the sh_link field of the section
header at index 0.

This CL makes these changes to support files with >= 0xff00 sections:

1. if shoff > 0 && shnum == 0, read sh_size from the initial section
header entry as shnum.
2. if shstrndx == SHN_XINDEX, read sh_link from the initial section
header entry as shstrndx.

It returns an error if the type of the initial section is not SHT_NULL.

A file with >= 0xff00 sections is too big to include in the repository,
so the test case constructs one on the fly, with some of the sections
zeroed out.

While here, remove the unnecessary use of reflect.DeepEqual in the test.

Fixes #55294.

Change-Id: I15ec43612c7cce6e8decfe4e81da3a5b16de47f7
GitHub-Last-Rev: 797c16480bc76524ff1a7c01ed09b759fcd7d45b
GitHub-Pull-Request: golang/go#55295
Reviewed-on: https://go-review.googlesource.com/c/go/+/432255
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
src/cmd/internal/buildid/note.go
src/debug/elf/file.go
src/debug/elf/file_test.go