Open from objcopy
June 18, 2017 22:30:47
Objcopy is not so much a conversion tool as a simple compiler. It can be understood in this way,
What should I do if I want to embed an image into a program? Use WinHex to get all the bytes of the image, and then
It is copied to the Code, compiled, and handled. Very regular, very primitive. To write a program, you must be a hacker and find its essence.
Here, objCopy can be understood as a compiler. Its input can be anything. Although the compilation input we know is code, this tool extends the concept of compilation, it can compile any file. o. Note: This activity was previously done by the compiler. Now, it's a shortcut. At the same time, it can output some variables, which is more conscientious and more like a compiler.
The usage is as follows:
Objcopy-I binary-O elf32-i386-B I ?foo.jpg foo. o
Convert foo.jpg to a. o file and export the following variables:
Extern char _ binary_foo_jpg_start [];
Extern char _ binary_foo_jpg_end [];
Extern char _ binary_foo_jpg_size [];
The tool is finished, but it does not seem to be clear yet. The essence of writing a program is to change the code. o, and then generate executable files, so with. o, you can link it .. O sources generally consider the output of the compiler. Is there anything else besides the compiler that can output the. o file? Objcopy is one. You can manually write one according to the. o file format. This is like a Java. class file, not only can be generated in Java, as long as it complies with the. class file format, any language, such as Python can generate such a file.
Learning can be too difficult to learn and use.