Last active
December 24, 2018 22:42
-
-
Save mmcloughlin/340d530e3c97afbf71a6e1acdc0945fa to your computer and use it in GitHub Desktop.
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 characters
| #include "textflag.h" | |
| DATA b<>+0(SB)/8, $0x0011223344556677 | |
| DATA b<>+8(SB)/8, $"strconst" | |
| DATA b<>+16(SB)/8, $3.141592 | |
| DATA b<>+24(SB)/4, $3.141592 | |
| // 28-31: empty | |
| DATA b<>+32(SB)/4, $0x00112233 | |
| DATA b<>+36(SB)/2, $0x4455 | |
| DATA b<>+38(SB)/1, $0x66 | |
| DATA b<>+39(SB)/1, $0x77 | |
| // 40-42: empty | |
| DATA b<>+43(SB)/4, $"hey" | |
| // 47: empty | |
| GLOBL b<>(SB), RODATA, $48 | |
| TEXT ·DataAt(SB),0,$0-9 | |
| MOVQ i+0(FP), AX | |
| LEAQ b<>+0x00(SB), BX | |
| MOVB 0(BX)(AX*1), CL | |
| MOVB CL, ret+8(FP) | |
| RET |
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 characters
| package main | |
| import ( | |
| "encoding/hex" | |
| "fmt" | |
| ) | |
| const Size = 48 | |
| func DataAt(i int) byte | |
| func ReadDataSection() []byte { | |
| b := make([]byte, Size) | |
| for i := 0; i < Size; i++ { | |
| b[i] = DataAt(i) | |
| } | |
| return b | |
| } | |
| func main() { | |
| b := ReadDataSection() | |
| fmt.Print(hex.Dump(b)) | |
| } |
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 characters
| 00000000 77 66 55 44 33 22 11 00 73 74 72 63 6f 6e 73 74 |wfUD3"..strconst| | |
| 00000010 7a 00 8b fc fa 21 09 40 d8 0f 49 40 00 00 00 00 |z....!.@..I@....| | |
| 00000020 33 22 11 00 55 44 66 77 00 00 00 68 65 79 00 00 |3"..UDfw...hey..| |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Experiment with
DATAsections in Go assembly. Confirms that: