From 378221bd6e73bdc21884fed9e32f53e6672ca0cd Mon Sep 17 00:00:00 2001 From: Than McIntosh Date: Tue, 22 Mar 2022 08:49:52 -0400 Subject: debug/pe: add APIs for reading section def aux info Add hooks to support reading of section definition symbol aux data (including COMDAT information) from the aux symbols associated with section definition symbols. The COFF symbol array made available by "pe.File" includes entries for aux symbols, but doesn't expose their structure (since it varies depending on the type of aux symbol). This patch adds a function for returning a specific class of aux symbol ("type 5") that immediately follows a COFF symbol corresponding to a section definition. Updates #35006. Updates #51868. Change-Id: I21fcc057150f7a3c64f01a5961aabca0fa43399e Reviewed-on: https://go-review.googlesource.com/c/go/+/394534 Reviewed-by: Alex Brainman Reviewed-by: Cherry Mui Trust: Alex Brainman Trust: Than McIntosh Run-TryBot: Than McIntosh TryBot-Result: Gopher Robot --- src/debug/pe/section.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/debug/pe/section.go') diff --git a/src/debug/pe/section.go b/src/debug/pe/section.go index b641158ecc..ee59dedeb4 100644 --- a/src/debug/pe/section.go +++ b/src/debug/pe/section.go @@ -109,3 +109,15 @@ func (s *Section) Data() ([]byte, error) { func (s *Section) Open() io.ReadSeeker { return io.NewSectionReader(s.sr, 0, 1<<63-1) } + +// Section characteristics flags. +const ( + IMAGE_SCN_CNT_CODE = 0x00000020 + IMAGE_SCN_CNT_INITIALIZED_DATA = 0x00000040 + IMAGE_SCN_CNT_UNINITIALIZED_DATA = 0x00000080 + IMAGE_SCN_LNK_COMDAT = 0x00001000 + IMAGE_SCN_MEM_DISCARDABLE = 0x02000000 + IMAGE_SCN_MEM_EXECUTE = 0x20000000 + IMAGE_SCN_MEM_READ = 0x40000000 + IMAGE_SCN_MEM_WRITE = 0x80000000 +) -- cgit v1.3-5-g45d5