Spacecraft on-orbit maintenance injection code generation method based on same-platform combined compilation
Technical Field
The invention belongs to the field of on-orbit maintenance of spacecrafts, and relates to a method for generating an on-orbit maintenance injection code of spacecraft software based on a spark system architecture.
Background
The on-orbit maintenance capability of spacecraft software is an indispensable means for ensuring the long service life of the spacecraft, and compared with the redundant backup of hardware, the method is more economical and flexible. Methods for improving the long life and high reliability of on-orbit operation of spacecraft through software on-orbit maintenance are increasingly gaining attention.
At present, the main body of the processor platform for on-orbit operation of the spacecraft in China is a spark series system architecture, particularly a spark V7 system architecture and a spark V8 system architecture. The main means of the on-orbit operation maintenance of the spacecraft is to implement the on-orbit maintenance of software. The maintenance of the on-orbit software of the spacecraft is mainly based on a hook function method, namely, a section of on-orbit maintenance injection code is injected in a writable storage injection area, when the on-orbit maintenance is enabled, the hook function jumps to the injection area to be executed through a specified address, and the on-orbit software returns to the original on-orbit software to be continuously executed after the execution is finished. In the application scenario, the generation of the on-orbit maintenance injection code is a key link of the on-orbit maintenance of the software, and is also a relatively difficult work. As the processor platform of the spark V8 architecture adopts an RCC (RTEMS Cross Compilation System) Cross compiler, the object file generated by the RCC compiler is in an ELF format and supports Compilation linking based on a "section" attribute, so that the initial address of an injection area is conveniently set through the "section" attribute, and the generation of on-track maintenance injection codes is realized by utilizing a secondary linking mode (applied patent: a spacecraft on-track maintenance injection code generation method based on the secondary linking, 201710476446.5). The processor platform with the sparc V7 architecture generally adopts the ERC32 cross compiler, the target file generated by the compiler system is in an a.out format, and does not support compilation link based on "section" attribute, and the generation of on-track maintenance injection code cannot be realized directly in a secondary link mode. In the prior art, for spacecraft software adopting an ERC32 cross compiler, the in-orbit maintenance injection code is generated mainly by analyzing the original in-orbit software and the in-orbit maintenance software compiling result file, combing all information needing to be relocated in the in-orbit maintenance instruction code, and completing relocation. The process is relatively complex, on one hand, the format of a compiling result file is required to be mastered, and all repositioning information can be combed; on the other hand, the instruction rule set is required to be deeply known, and the relocation of the on-track maintenance instruction codes can be realized.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: the defects of the prior art are overcome, and the method for generating the on-orbit maintenance injection code of the spacecraft based on the same-platform combination compiling is provided.
The technical solution of the invention is as follows: a spacecraft on-orbit maintenance injection code generation method based on same-platform combined compilation is realized by the following modes:
(1) an ERC32 compiling system is adopted to restore the state of the on-orbit operation software of the spacecraft, and an on-orbit state target file in a format of a.out is generated through one-time linking;
(2) writing in an on-orbit maintenance source code, preprocessing and compiling the on-orbit maintenance source code by using an ERC32 compiling system to generate a corresponding assembly code target file;
(3) assembling the assembly code target file generated in the step (2) by using an RCC (Rich client computer) compiling system to generate an intermediate target file to be uploaded;
(4) converting the on-track state target file in the a.out format generated in the step (1) into an on-track state intermediate target file in an ELF format through target file format conversion;
(5) simplifying the on-track state intermediate target file in the ELF format generated in the step (4) and removing information irrelevant to the link relocation process;
(6) creating a link script file;
(7) based on the link script file established in the step (6), using an RCC compiling system to carry out secondary link on the simplified on-orbit state intermediate target file, the intermediate target file to be uploaded and the corresponding static library file in the step (5) so as to generate a new executable target file;
(8) and (3) converting the new executable target file generated in the step (7) into a link instruction file or a BIN file through an RCC compiling system, and directly extracting an injection code instruction of a specified initial address from the link instruction file or the BIN file, thereby completing the generation of the on-orbit maintenance injection code of the spacecraft.
Further, in the step (1), the original in-orbit software source file directory is compiled and linked by using a spark platform ERC32 compiling system which is the same as the original in-orbit software of the spacecraft, and an a.out format on-orbit state target file is generated.
Furthermore, the in-track maintenance source code storage path is in an injection code source file of in-track maintenance newly built under a source file directory of original in-track software of the aircraft.
Further, the RCC compiling system and the ERC32 compiling system are the same as those under the spark platform, and the ERC32Instruction set phi generated by compiling system compiling
ERC32Is an instruction set phi generated by the compiling of an RCC compiling system
RCCA subset of (1), i.e.
Further, the step (4) converts the on-track state object file in the a.out format generated in the step (1) into an on-track state intermediate object file in an ELF format by using an object file format conversion tool carried by the RCC compiling system.
Further, in the step (5), the in-track state intermediate target file in the ELF format generated in the step (4) is reduced by using a file clip tool strip of the RCC compiling system, and information irrelevant to the link relocation process is removed.
Further, the step (6) of creating a link script file specifically includes: in the section of sectons of script file, a first output section space is newly created according to the address setting of the output section of the original on-track software, the start address of the newly created first output section space is set as the start address of the output section of the original on-track software, the input section element of the newly created first output section space is set as a simplified on-track state intermediate target file generated after the file format is simplified in the step (5) after being linked once, then a second output section space is newly created according to the preset injection area start address, the start address of the second output section space is set as the preset injection area start address, and the input section element of the second output section space is set as an intermediate target file to be uploaded generated after the on-track maintenance software is compiled by combining with the same platform.
Further, the on-track state target file is an executable target file in an a.out file format, and the on-track state intermediate target file, the reduced on-track state intermediate target file, the to-be-uploaded intermediate target file and the new executable target file are all in an ELF file format.
Further, by the RCC compiling system, the new executable object file a.out in the ELF format generated in step (7) is converted into a link instruction file with an extension of.lst using an objdump command, or the new executable object file a.out in the ELF format generated in step (7) is converted into a BIN file with an extension of.bin using an objcopy command.
Furthermore, the on-orbit operation software of the spacecraft and the on-orbit maintenance source code are written by using C language.
Compared with the prior art, the invention has the beneficial effects that:
(1) according to the spacecraft on-orbit maintenance injection code generation method based on the same-platform combined compilation, the combined compilation is carried out by comprehensively utilizing the spark platform ERC32 and the RCC, on the premise that the consistency of the instruction set and the symbol information of the generated target file is ensured, the address information relocation of the on-orbit maintenance software injection code relative to the original on-orbit software can be realized, and the efficiency and the accuracy of the on-orbit maintenance injection code generation are greatly improved.
(2) The method for generating the on-orbit maintenance injection code of the spacecraft based on the same-platform combined compilation mainly aims at the on-orbit spacecraft software adopting the spark platform ERC32 compilation system to generate the on-orbit maintenance injection code, eliminates the on-orbit maintenance code compiling limitation requirements in various aspects such as newly-added global variables, newly-added library function calls and the like compared with the method for generating the injection code in the original file analysis mode, and greatly improves the implementation efficiency of the on-orbit maintenance source code.
(3) According to the method for generating the on-orbit maintenance injection code of the spacecraft based on the combined compilation with the same platform, the information irrelevant to the link relocation process is removed by cutting the on-orbit state intermediate target file in the ELF format, the lightweight target file in the link relocation process is realized, and the effective address space of the on-orbit maintenance relocation of the spacecraft software in the secondary link mode is expanded.
(4) The method is applied to the on-orbit maintenance realization of a plurality of on-orbit spacecraft software adopting a spark platform ERC32 compiling system, the feasibility and the effectiveness of the method are verified through engineering practice, the maintainability of the on-orbit spacecraft software is improved, and a new on-orbit maintenance realization method is provided for the development of follow-up spacecraft software.
Drawings
FIG. 1 is a flow chart of the present invention.
Detailed Description
The invention is described in detail below with reference to the figures and examples.
The invention relates to a spacecraft on-orbit maintenance injection code generation method based on same-platform combined compilation, which is mainly oriented to but not limited to on-orbit spacecraft software adopting a spark platform ERC32 compilation system. The content comprises the following steps: according to the on-orbit maintenance task requirement of spacecraft software, writing a corresponding on-orbit maintenance source code (C language), and utilizing two compiler systems under the same sparc platform: and the ERC32 compiling system and the RCC compiling system are used for performing combined compiling on the on-orbit maintenance source codes to generate an intermediate target file to be uploaded, and the intermediate target file is secondarily linked with an executable target file obtained after the compiling and linking of the original on-orbit software, so that the generation of the on-orbit maintenance injection codes of the spacecraft is completed.
The realization method of the invention is as follows:
(1) an ERC32 compiling system is adopted to restore the state of the on-orbit operation software of the spacecraft, and an on-orbit state target file in a format of a.out is generated through one-time linking;
the method specifically comprises the following steps: compiling the source file directory of the spacecraft in-orbit software by using a spark platform ERC32 compiling system and realizing one-time linkage, wherein the ERC32 compiling system and the source file directory of the spacecraft in-orbit software are consistent with the state of the spacecraft in-orbit software executable code during generation.
(2) Writing an on-track maintenance source code;
the method specifically comprises the following steps: and (c) establishing an in-orbit maintenance code source file with the extension name of c under the source file directory of the spacecraft in-orbit software, and writing corresponding in-orbit maintenance source codes and required header files according to the requirement of the spacecraft software in-orbit maintenance task.
(3) Performing independent preprocessing and compiling on the on-orbit maintenance source code compiled in the step (2) by using an ERC32 compiling system to generate a corresponding assembly code target file, wherein the assembly code target file takes S or S as an extension name;
(4) assembling the assembly code target file generated in the step (3) by using an RCC (Rich client computer) compiling system to generate an intermediate target file to be uploaded, wherein the intermediate target file to be uploaded is in an ELF (element object file) format with the extension name of o;
(5) converting the a.out format on-track state target file generated in the step (1) into an ELF format on-track state intermediate target file through target file format conversion, wherein the target file format conversion tool can be realized by adopting a target file format conversion tool objcopy carried by an RCC compiling system;
(6) cutting the target file in the ELF format generated in the step (5) in the middle of the track state, and removing symbol information, debugging information, character string information and the like which are irrelevant to the link relocation process so as to realize the light-weight target file in the link process and better expand the address space of the effective injection area, wherein the cutting of the target file in the middle of the track state can be realized by adopting a strip tool of an RCC compiling system;
(7) creating a link script file;
the method specifically comprises the following steps: a new link script file is newly created, and in the SECTIONS section of the new link script file, setting an address of an output section of original on-orbit software of the spacecraft to newly build a first output section space, setting a starting address of the newly built first output section space as a starting address of the output section of the original on-orbit software of the spacecraft, setting an input section element of the newly built first output section space as a simplified on-orbit state intermediate target file generated after cutting the file in the step (6) after one-time linkage, then setting a second output section space according to a preset injection area starting address, setting the starting address of the second output section space as a preset injection area starting address, and setting the input section element of the second output section space as an intermediate target file to be uploaded generated after the on-orbit maintenance software is compiled by combining with a same platform.
(8) Based on the link script file established in the step (7), performing secondary link on the simplified on-track state intermediate target file, the intermediate target file to be uploaded and the corresponding static library file by using an RCC (remote control center) compiling system to generate a new executable target file a.out in an ELF (executable file format);
(9) and (3) converting the new executable target file a.out in the ELF format generated in the step (8) into a link instruction file with an extension of.lst by using an objdump command or converting the new executable target file a.out in the ELF format generated in the step (8) into a BIN file with an extension of.bin by using an objcopy command through an RCC compiling system, and directly extracting an injection code instruction with a specified starting address from the generated link instruction file or BIN file, thereby completing the generation of the on-track maintenance injection code of the spacecraft.
Example (b):
(1) on the premise of ensuring that the states of an ERC32 compiling system and a source file compiling directory of the spacecraft in-orbit software are consistent with the states of the spacecraft in-orbit software executable codes during generation, the ERC32 compiler spark-tries-gcc is used for compiling and linking the source file compiling directory of the spacecraft in-orbit software through a makefile to generate an executable target file a.out in an a.out file format.
(2) In the source file directory of the on-track software of the spacecraft, an injection code source file task _ inject.c for on-track maintenance is newly created, and on-track maintenance source codes are written in the task _ inject.c source file, as shown in table 1:
table 1 on-track maintenance source code example
(3) And (3) independently preprocessing and compiling the on-track maintenance source code task _ inject.c by using an ERC32 compiler spark-tries-gcc to generate a corresponding assembly code object file task _ inject.s.
(4) Assembling the assembled and coded target file task _ inject.s generated in the step (3) by using an RCC compiler spark-rtems-gcc to generate an intermediate target file task _ inject.o to be uploaded;
(5) and (3) converting the executable object file a.out in the a.out file format generated in the step (1) into an ELF-format on-track state intermediate object file a.o by using an RCC compiler object file format conversion tool spark-tries-objcopy.
(6) And (3) cutting the ELF-format in-track state intermediate target file a.o generated in the step (5) by using an RCC compiler file cutting tool spark-tries-strip, removing symbol information, debugging information and character string information which are irrelevant to the link relocation process, and generating a simplified in-track state intermediate target file a.o.
(7) The link script file linkobsm is newly created as a new link script file, as shown in table 2:
TABLE 2 Secondary Link script File example
(8) Based on a new link script file linkobsm, using an RCC compiler spark-tries-gcc to link static library files such as a simplified on-track state intermediate target file a.o, an intermediate target file to be uploaded task _ inject.o, a mathematical library and the like to generate a new linked ELF format executable target file a.out;
(9) and (3) converting the new linked ELF format executable target file a.out generated in the step (8) into a link instruction file boot.lst with an extension name of.lst by using a spark-rtems-objdump command of the RCC compiling system, or converting the new linked ELF format executable target file a.out generated in the step (8) into a BIN file boot.bin with an extension name of.bin by using a spark-rtems-objcopy command of the RCC compiling system. And directly extracting an injection code instruction with the starting address of 0x21a0000 from the generated file boot.lst or boot.bin file, thereby completing the generation of the on-orbit maintenance injection code of the spacecraft.
The technical scheme of the embodiment is that two compiling systems of a spark platform are adopted: the ERC32 compiling system and the RCC compiling system are used for performing combined compiling on the on-orbit maintenance source codes, automatically realizing the address information relocation of the on-orbit maintenance software injection codes relative to the original on-orbit software by performing secondary linking on the on-orbit maintenance source codes and the executable object file compiled by the original on-orbit software, and greatly improving the efficiency and the accuracy of the on-orbit maintenance injection code generation.
The invention has not been described in detail in part of the common general knowledge of those skilled in the art.