Skip to content

Commit 8e2bd26

Browse files
ianlancetaylorgopherbot
authored andcommitted
cmd/link: add comments for SymKind values
Change-Id: Ie297a19a59362e0f32eae20e511e298a0a87ab6b Reviewed-on: https://go-review.googlesource.com/c/go/+/715540 Reviewed-by: Than McIntosh <thanm@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com>
1 parent 16705b9 commit 8e2bd26

File tree

1 file changed

+77
-72
lines changed

1 file changed

+77
-72
lines changed

src/cmd/link/internal/sym/symkind.go

Lines changed: 77 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -41,31 +41,32 @@ type SymKind uint8
4141
//
4242
//go:generate stringer -type=SymKind
4343
const (
44+
// An otherwise invalid zero value for the type.
4445
Sxxx SymKind = iota
45-
STEXT
46-
STEXTFIPSSTART
47-
STEXTFIPS
48-
STEXTFIPSEND
49-
STEXTEND
50-
SELFRXSECT
51-
SMACHOPLT
52-
53-
// Read-only sections.
54-
STYPE
55-
SSTRING
56-
SGOSTRING
57-
SGOFUNC
58-
SGCBITS
59-
SRODATA
60-
SRODATAFIPSSTART
61-
SRODATAFIPS
62-
SRODATAFIPSEND
63-
SRODATAEND
64-
SFUNCTAB
65-
66-
SELFROSECT
67-
68-
// Read-only sections with relocations.
46+
// The text segment, containing executable instructions.
47+
STEXT // General executable code.
48+
STEXTFIPSSTART // Start of FIPS text section.
49+
STEXTFIPS // Instructions hashed for FIPS checks.
50+
STEXTFIPSEND // End of FIPS text section.
51+
STEXTEND // End of text section.
52+
SELFRXSECT // Executable PLT; PPC64 .glink.
53+
SMACHOPLT // Mach-O PLT.
54+
55+
// Read-only, non-executable, segment.
56+
STYPE // Type descriptors.
57+
SSTRING // Used only for XCOFF runtime.rodata symbol?
58+
SGOSTRING // Go string constants.
59+
SGOFUNC // Function descriptors and funcdata symbols.
60+
SGCBITS // GC bit masks and programs.
61+
SRODATA // General read-only data.
62+
SRODATAFIPSSTART // Start of FIPS read-only data.
63+
SRODATAFIPS // FIPS read-only data.
64+
SRODATAFIPSEND // End of FIPS read-only data.
65+
SRODATAEND // End of read-only data.
66+
SFUNCTAB // Appears to be unused, except for runtime.etypes.
67+
SELFROSECT // ELF read-only data: relocs, dynamic linking info.
68+
69+
// Read-only, non-executable, dynamically relocatable segment.
6970
//
7071
// Types STYPE-SFUNCTAB above are written to the .rodata section by default.
7172
// When linking a shared object, some conceptually "read only" types need to
@@ -84,55 +85,59 @@ const (
8485
SGCBITSRELRO
8586
SRODATARELRO
8687
SFUNCTABRELRO
87-
SELFRELROSECT
88-
SMACHORELROSECT
8988

90-
// Part of .data.rel.ro if it exists, otherwise part of .rodata.
91-
STYPELINK
92-
SITABLINK
93-
SSYMTAB
94-
SPCLNTAB
89+
SELFRELROSECT // ELF-specific read-only relocatable: PLT, etc.
90+
SMACHORELROSECT // Mach-O specific read-only relocatable.
9591

96-
// Writable sections.
92+
STYPELINK // Type links.
93+
SITABLINK // Itab links.
94+
SSYMTAB // Used for runtime.symtab, which is always empty.
95+
SPCLNTAB // Pclntab data.
96+
97+
// Allocated writable segment.
9798
SFirstWritable
98-
SBUILDINFO
99-
SFIPSINFO
100-
SELFSECT
101-
SMACHO
102-
SMACHOGOT
103-
SWINDOWS
104-
SELFGOT
105-
SNOPTRDATA
106-
SNOPTRDATAFIPSSTART
107-
SNOPTRDATAFIPS
108-
SNOPTRDATAFIPSEND
109-
SNOPTRDATAEND
110-
SINITARR
111-
SDATA
112-
SDATAFIPSSTART
113-
SDATAFIPS
114-
SDATAFIPSEND
115-
SDATAEND
116-
SXCOFFTOC
117-
SBSS
118-
SNOPTRBSS
119-
SLIBFUZZER_8BIT_COUNTER
120-
SCOVERAGE_COUNTER
121-
SCOVERAGE_AUXVAR
122-
STLSBSS
123-
SXREF
124-
SMACHOSYMSTR
125-
SMACHOSYMTAB
126-
SMACHOINDIRECTPLT
127-
SMACHOINDIRECTGOT
128-
SFILEPATH
129-
SDYNIMPORT
130-
SHOSTOBJ
131-
SUNDEFEXT // Undefined symbol for resolution by external linker
132-
133-
// Sections for debugging information
99+
SBUILDINFO // debug/buildinfo data (why is this writable?).
100+
SFIPSINFO // go:fipsinfo aka crypto/internal/fips140/check.Linkinfo (why is this writable)?
101+
SELFSECT // .got.plt, .plt, .dynamic where appropriate.
102+
SMACHO // Used only for .llvmasm?
103+
SMACHOGOT // Mach-O GOT.
104+
SWINDOWS // Windows dynamic symbols.
105+
SELFGOT // Writable ELF GOT section.
106+
SNOPTRDATA // Data with no heap pointers.
107+
SNOPTRDATAFIPSSTART // Start of FIPS non-pointer writable data.
108+
SNOPTRDATAFIPS // FIPS non-pointer writable data.
109+
SNOPTRDATAFIPSEND // End of FIPS non-pointer writable data.
110+
SNOPTRDATAEND // End of data with no heap pointers.
111+
SINITARR // ELF .init_array section.
112+
SDATA // Data that may have heap pointers.
113+
SDATAFIPSSTART // Start of FIPS writable data.
114+
SDATAFIPS // FIPS writable data.
115+
SDATAFIPSEND // End of FIPS writable data.
116+
SDATAEND // End of data that may have heap pointers.
117+
SXCOFFTOC // AIX TOC entries.
118+
119+
// Allocated zero-initialized segment.
120+
SBSS // Zeroed data that may have heap pointers.
121+
SNOPTRBSS // Zeroed data with no heap pointers.
122+
SLIBFUZZER_8BIT_COUNTER // Fuzzer counters.
123+
SCOVERAGE_COUNTER // Coverage counters.
124+
SCOVERAGE_AUXVAR // Compiler generated coverage symbols.
125+
STLSBSS // Thread-local zeroed data.
126+
127+
// Unallocated segment.
128+
SXREF // Reference from non-Go object file.
129+
SMACHOSYMSTR // Mach-O string table.
130+
SMACHOSYMTAB // Mach-O symbol table.
131+
SMACHOINDIRECTPLT // Mach-O indirect PLT.
132+
SMACHOINDIRECTGOT // Mach-O indirect GOT.
133+
SFILEPATH // Unused?
134+
SDYNIMPORT // Reference to symbol defined in shared library.
135+
SHOSTOBJ // Symbol defined in non-Go object file.
136+
SUNDEFEXT // Undefined symbol for resolution by external linker.
137+
138+
// Unallocated DWARF debugging segment.
134139
SDWARFSECT
135-
// DWARF symbol types
140+
// DWARF symbol types created by compiler or linker.
136141
SDWARFCUINFO
137142
SDWARFCONST
138143
SDWARFFCN
@@ -144,9 +149,9 @@ const (
144149
SDWARFLINES
145150
SDWARFADDR
146151

147-
// SEH symbol types
148-
SSEHUNWINDINFO
149-
SSEHSECT
152+
// SEH symbol types. These are probably allocated at run time.
153+
SSEHUNWINDINFO // Compiler generated Windows SEH info.
154+
SSEHSECT // Windows SEH data.
150155
)
151156

152157
// AbiSymKindToSymKind maps values read from object files (which are

0 commit comments

Comments
 (0)