-
-
Save ubogdan/bfd515e8c91d5ac89a2372cf1b7aeb26 to your computer and use it in GitHub Desktop.
Revisions
-
itaysk created this gist
Apr 29, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ build: go build -o _main objcopy --add-section myfile=myfile _main main This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ package main import ( "debug/elf" "fmt" "os" ) func main() { selfPath, _ := os.Executable() selfFile, _ := os.Open(selfPath) selfElf, _ := elf.NewFile(selfFile) var data []byte for _, s := range selfElf.Sections { if s.Name == "myfile" { data, _ = s.Data() } } fmt.Println(string(data)) }