Can Golang be decompiled?
Golang cannot be decompiled because Golang is compiled into a binary file, and a binary file is a file containing data or program instructions written in ASCII and extended ASCII characters. These files contain special formats and computer code, so it cannot be decompiled.
Benefits of Binary Files
Why use binary files. There are probably three reasons:
The first is that binary files save space, and there is no difference between the two when storing character data. However, when storing numbers, especially real numbers, binary is more space-saving. For example, storing Real*4 data: 3.1415927, a text file requires 9 bytes, and respectively stores: 3. 1 4 1 5 9 2 7 these 9 ASCII value, while the binary file only requires 4 bytes (DB 0F 49 40)
The second reason is that the data involved in calculations in the memory are stored in binary unformatted format, therefore, use binary to store it in the file It's faster. If stored as a text file, a conversion process is required. When the amount of data is large, there will be a significant speed difference between the two.
Third, for some relatively precise data, using binary storage will not cause the loss of valid bits.
Storage method of binary files
List a binary file as follows:
00000000h:0F 01 00 00 0F 03 00 00 12 53 21 45 58 62 35 34; .........S!EXb54
00000010h:41 42 43 44 45 46 47 48 49 47 4B 4C 4D 4E 4F 50; ABCDEFGHIGKLMNOP
List here What comes out is what you see in UltraEdit (UE). In fact, only the red part is the file content. The preceding one is the line number added by UE. What follows is a reference that UE attempts to interpret as a character.
This file is 32 bytes long. Displayed as two columns of 16 bytes each. In fact, this is just a display of UE. Real files don't have separate lines. Just knowing the contents of this file, if we don't have any explanation, we can't see any useful information.
I will stipulate an explanation below: We believe that the first 4 bytes are a 4-byte integer data (0F 01 00 00 hexadecimal: 10Fh decimal: 271). The 4 bytes after these 4 bytes are another 4 bytes of integer data (0F 03 00 00 hexadecimal: 30Fh decimal: 783). The following 4 bytes (12 53 21 45) represent a 4-byte real data: 2.5811919E 3. The following 4 bytes (58 62 35 34) represent another 4 bytes of execution data: 1.6892716E-7. And only the last 16 bytes (41 42 43 44 45 46 47 48 49 47 4B 4C 4D 4E 4F 50) we think are 16 bytes of string (ABCDEFGHIGKLMNOP)
Actually, the binary file It just stores data without specifying the data type. For example, the 9th byte to the 16th byte above (12 53 21 45 58 62 35 34), we just thought it was two 4-byte real types, but it can actually be Considered to be an 8-byte character type (S!EXb54). The following 16-byte string (ABCDEFGHIGKLMNOP) can also be considered as two 8-byte integers, or four 4-byte integers, or even two 8-byte real types, and four 4-byte real type, etc. etc.
Therefore, when facing a binary file, we cannot accurately know its meaning. We need a description of its data storage method. This description tells us what type of data is from which byte to which byte, and what is the meaning of the stored data. Otherwise, we can only guess or be helpless.
Recommended tutorial: "Go Tutorial"
The above is the detailed content of Can Golang be decompiled?. For more information, please follow other related articles on the PHP Chinese website!