Can golang be decompiled?

青灯夜游
Release: 2022-12-28 11:14:14
Original
6037 people have browsed it

Golang cannot be decompiled. Reason: Golang is a compiled static language. Golang will generate binary files after compilation, and binary files are files containing data or program instructions written in ASCII and extended ASCII characters. These files contain special formats and computer codes, so Cannot be decompiled.

Can golang be decompiled?

The operating environment of this tutorial: Windows 7 system, GO version 1.18, Dell G3 computer.

Golang does not support decompilation.

Reason:

Go language is a compiled static language, so before running a Go language program, it must be compiled into a binary executable document.

Golang will generate binary files after compilation, and binary files are files containing data or program instructions written in ASCII and extended ASCII characters. These files contain special formats and computer codes, so they 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 binary files only require 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, so using binary Saving to a file is 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.

How to store 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
Copy after login

The ones listed here are what you see in UltraEdit (UE) thing. 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.

【Related recommendations:Go video tutorial,Programming teaching

The above is the detailed content of Can golang be decompiled?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!