Method and system for simplifying executable files
A technology for executing files and compiling files, applied in the field of basic research of linux system, can solve the problems of wasting flash space and memory space, increasing the size of executable files, etc.
- Summary
- Abstract
- Description
- Claims
- Application Information
AI Technical Summary
Problems solved by technology
Method used
Image
Examples
Embodiment 1
[0036] This embodiment provides a method for streamlining an executable file, the method comprising the following steps:
[0037] Based on the functionality of the executable, determine the number and types of global variables that the executable needs to define.
[0038] During the coding phase, reduce the number of global variable initializations when defining global variables.
[0039] Optimize the makefile compilation file during the compilation phase, identify each function and / or symbol during compilation, and remove unnecessary functions and / or symbols based on the identification during linking.
[0040] A program is essentially composed of BSS segment, data segment, and text segment. This is a very important basic concept in current computer programming, and it is also very important in the design of embedded systems. It involves the allocation of memory size when the embedded system is running, and the size of the storage unit.
[0041] In this embodiment, by analyz...
Embodiment 2
[0049] As a better alternative, on the basis of Embodiment 1, this embodiment does not initialize a global variable first when defining a global variable, so as to reduce the number of global variable initializations when defining a global variable.
[0050] When defining a global variable, if the global variable is not initialized first, the system will automatically initialize the global variable.
[0051] Further, for the controllability of the coding stage, in this embodiment, when defining a global variable, the global variable is not initialized first, and the initialization value is assigned when the global variable is used, so as to reduce the initialization of the global variable when defining the global variable. quantity. For example, assign an initialization value of 0 to the global variable, so that the global variable is within a controllable range.
[0052] Because it is initialized in the definition, it belongs to the data segment; it is not initialized in the...
Embodiment 3
[0055] As a better alternative, on the basis of Example 1, when optimizing the makefile to compile files:
[0056] During compilation, use -ffunction-sections to create a corresponding section for each function function, and / or use -fdata-sections to create a corresponding section for each symbol data, and match the corresponding section name with function and / or The data name remains consistent;
[0057] During the linking phase, use -Wl,--gc-sections to remove unused sections to remove unneeded functions and / or symbols.
[0058] The link operation of GCC (GNU Compiler Suite, GNU Compiler Collection) uses section as the smallest processing unit. As long as a certain symbol is referenced in a section, the section will be added to the executable file. For example, if a function or symbol in a c source program is added to a section, if the program uses this function or symbol in the executable file generated by the c source program, all functions or symbols will be added to it,...
PUM
Login to View More Abstract
Description
Claims
Application Information
Login to View More 
