Last active
September 21, 2018 14:57
-
-
Save grantseltzer/35642d262f18a2c26588facc8e1d488d to your computer and use it in GitHub Desktop.
Empty symbols in Go binaries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"debug/elf" | |
"fmt" | |
"log" | |
"os" | |
) | |
func main() { | |
pathToELF := os.Args[1] | |
// open the ELF binary | |
elfFile, err := elf.Open(pathToELF) | |
if err != nil { | |
log.Fatalf("error while opening ELF file %s: %+s", pathToELF, err.Error()) | |
} | |
// // extract the symbol table | |
symbolTable, err := elfFile.Symbols() | |
if err != nil { | |
log.Fatalf("could not extract symbol table: %s", err.Error()) | |
} | |
// traverse through the symbol table | |
for _, symbol := range symbolTable { | |
// empty symbols | |
if symbol.Size == 0 { | |
fmt.Printf("%+v\n", symbol) | |
} | |
} | |
} | |
``` | |
[*] go run main.go test 1 ↵ | |
{Name:go.go Info:4 Other:0 Section:SHN_ABS Value:0 Size:0} | |
{Name:runtime.text Info:2 Other:0 Section:SHN_UNDEF+1 Value:4198400 Size:0} | |
{Name:runtime.etext Info:2 Other:0 Section:SHN_UNDEF+1 Value:4790063 Size:0} | |
{Name:runtime.itablink Info:1 Other:0 Section:SHN_UNDEF+5 Value:5080056 Size:0} | |
{Name:runtime.eitablink Info:1 Other:0 Section:SHN_UNDEF+5 Value:5080144 Size:0} | |
{Name:runtime.rodata Info:1 Other:0 Section:SHN_UNDEF+2 Value:4792320 Size:0} | |
{Name:runtime.erodata Info:1 Other:0 Section:SHN_UNDEF+2 Value:5076716 Size:0} | |
{Name:runtime.types Info:1 Other:0 Section:SHN_UNDEF+2 Value:4792320 Size:0} | |
{Name:runtime.etypes Info:1 Other:0 Section:SHN_UNDEF+2 Value:5076716 Size:0} | |
{Name:runtime.noptrdata Info:1 Other:0 Section:SHN_UNDEF+8 Value:5427200 Size:0} | |
{Name:runtime.enoptrdata Info:1 Other:0 Section:SHN_UNDEF+8 Value:5479516 Size:0} | |
{Name:runtime.data Info:1 Other:0 Section:SHN_UNDEF+9 Value:5479520 Size:0} | |
{Name:runtime.edata Info:1 Other:0 Section:SHN_UNDEF+9 Value:5507376 Size:0} | |
{Name:runtime.bss Info:1 Other:0 Section:SHN_UNDEF+10 Value:5507392 Size:0} | |
{Name:runtime.ebss Info:1 Other:0 Section:SHN_UNDEF+10 Value:5623944 Size:0} | |
{Name:runtime.noptrbss Info:1 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:runtime.enoptrbss Info:1 Other:0 Section:SHN_UNDEF+11 Value:5633944 Size:0} | |
{Name:runtime.end Info:1 Other:0 Section:SHN_UNDEF+11 Value:5633944 Size:0} | |
{Name:runtime.epclntab Info:1 Other:0 Section:SHN_UNDEF+7 Value:5425883 Size:0} | |
{Name:runtime.esymtab Info:1 Other:0 Section:SHN_UNDEF+6 Value:5080144 Size:0} | |
{Name:runtime.egcdata Info:1 Other:0 Section:SHN_UNDEF+2 Value:5069236 Size:0} | |
{Name:runtime.egcbss Info:1 Other:0 Section:SHN_UNDEF+2 Value:5068744 Size:0} | |
{Name:go.string.* Info:1 Other:0 Section:SHN_UNDEF+2 Value:4996176 Size:0} | |
{Name:go.func.* Info:1 Other:0 Section:SHN_UNDEF+2 Value:5024980 Size:0} | |
{Name:runtime.gcbits.* Info:1 Other:0 Section:SHN_UNDEF+2 Value:5065208 Size:0} | |
{Name:runtime.symtab Info:1 Other:0 Section:SHN_UNDEF+6 Value:5080144 Size:0} | |
{Name:internal/poll.statictmp_7 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_97 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_100 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_103 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_111 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_119 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_126 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_131 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_142 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_145 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_148 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_160 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_163 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_168 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_173 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_176 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_179 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_189 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_192 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_209 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_217 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_223 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_226 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_231 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_241 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_246 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_249 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_260 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_263 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_268 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_271 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_274 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_281 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_284 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_287 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_292 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_295 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_298 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_301 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_304 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_310 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_313 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_318 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_323 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_328 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_335 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_338 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_341 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_344 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_347 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_350 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_353 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_358 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_361 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_364 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_367 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_370 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_375 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_378 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_389 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_392 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_395 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_398 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_404 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_407 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_426 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_431 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_444 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_447 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_452 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_457 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:unicode.statictmp_525 Info:17 Other:0 Section:SHN_UNDEF+11 Value:5623968 Size:0} | |
{Name:type.* Info:17 Other:0 Section:SHN_UNDEF+2 Value:4792320 Size:0} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment