Method and device for detecting bit displacement of key function code segment of relay protection device

By processing and detecting key functions in the code compilation stage of the relay protection device, the problem of increasing costs and complexity in the prior art is solved, and the bit displacement of the key code segment is effectively detected without increasing hardware costs, which improves the reliability and fault tolerance of the relay protection device.

CN119988179AActive Publication Date: 2025-05-13BEIJING SIFANG JIBAO ENG TECH +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411984604.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-05-13
Estimated Expiration
2044-12-31

AI Technical Summary

Technical Problem

In the prior art, the use of dual or redundant storage systems to improve the reliability and fault tolerance of relay protection devices will usually increase cost and complexity, and it is difficult to detect the situation of abnormal displacement of continuous multiple access at the same time.

Method used

By creating a compilation directory during the code compilation stage of the relay protection device, the first and second types of functions in the key functions are processed, the initial executable and linkable format files are generated, the function information files are parsed, and the code script is called to generate a secondary link script, and the target executable and linkable format files are finally generated, and the file is executed to detect the bit displacement of the second type of functions of the relay protection device.

Benefits of technology

Without adding additional hardware costs, the bit displacement of the key code segment is effectively detected, which improves the reliability and fault tolerance of the relay protection device and reduces system cost and complexity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119988179A_ABST
    Figure CN119988179A_ABST
Patent Text Reader

Abstract

The invention provides a method and device for detecting bit displacement of a key function code segment of a relay protection device, and relates to the technical field of relay protection, and the method comprises the steps: creating a compiling directory in a code compiling stage of the relay protection device; processing a first-class source file where a first-class function is located and a second-class source file where a second-class function is located in the key functions in the compiling directory to generate an initial executable and linkable format file; analyzing the initial executable and linkable format file to obtain a function information file; calling the compiled code script to generate a secondary link script; generating a target executable and linkable format file according to the function information file, the first type of target file and the second type of target file; and executing the target executable and linkable format file to obtain a key function code segment bit displacement detection result. According to the technical scheme, under the condition that extra hardware cost is not increased, bit displacement of the key function code segment can be effectively detected in the operation process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of relay protection, and in particular to a method and device for detecting bit displacement of a key function code segment of a relay protection device. Background Art

[0002] Relay protection devices are an important component for protecting the reliable operation of power systems. Due to the importance and complexity of relay protection devices, the reliability and safety of their storage systems are very critical.

[0003] At present, in the prior art, some technical solutions have been proposed for detecting abnormal or fault problems in the storage system of relay protection devices. For example, the use of error correction code (ECC) technology can effectively solve the problem of soft errors caused by bit flipping in memory and Nand Flash devices. Another technical solution is to use a dual or redundant storage system to improve the reliability and fault tolerance of the relay protection device. However, the above technical solutions also have some shortcomings. The use of ECC technology cannot realize the detection and recovery of abnormal bit changes of continuous multiple addresses (multiple units) at the same time. The use of a dual or redundant storage system to improve the reliability and fault tolerance of the relay protection device usually increases the cost and complexity. Summary of the invention

[0004] The present invention provides a method and device for detecting bit displacement of a key function code segment of a relay protection device, so as to solve the defect in the prior art that the use of a duplicated or redundant storage system to improve the reliability and fault tolerance of a relay protection device usually increases cost and complexity, and achieves effective detection of the bit displacement of the key code segment without increasing additional hardware costs, thereby obtaining the bit displacement detection result of the key function code segment of the relay protection device.

[0005] The present invention provides a method for detecting bit displacement of a key function code segment of a relay protection device, comprising the following steps.

[0006] During the code compilation phase of the relay protection device, a compilation directory is created.

[0007] In the compilation directory, the first-category source files where the first-category functions in the key functions are located and the second-category source files where the second-category functions are located are processed to generate initial executable and linkable format files; wherein the first-category functions are key functions that do not require cyclic redundancy check verification, and the second-category functions are key functions that require cyclic redundancy check verification; and the second-category functions contain at least one key function.

[0008] The initial executable and linkable format file is parsed to obtain a function information file; wherein the function information file includes a structure variable corresponding to each function in the initial executable and linkable format file, and the structure variable includes a cyclic redundancy check value and a function length corresponding to a second type of function that needs to check a cyclic redundancy check.

[0009] Calling a code compilation script to generate a secondary link script; wherein the code compilation script is a pre-compiled link script file.

[0010] Generate target executable and linkable format files according to the function information file, the first type target file and the second type target file.

[0011] The target executable and linkable format file is executed, and the code segment bit shift detection is performed on the second type of function of the relay protection device to obtain the key function code segment bit shift detection result of the relay protection device.

[0012] According to a method for detecting bit shifts in a code segment of a key function of a relay protection device provided by the present invention, a first-category source file where a first-category function in the key function is located and a second-category source file where a second-category function is located are processed in a compilation directory to generate an initial executable and linkable format file, including: compiling the first-category source file where the first-category function in the key function is located in the compilation directory to obtain a first-category target file corresponding to the compiled first-category source file, compiling the second-category source file where the second-category function in the key function is located to obtain a second-category target file corresponding to the compiled second-category source file; linking the first-category target file and the second-category target file to generate an initial executable and linkable format file.

[0013] According to a method for detecting bit displacement of a key function code segment of a relay protection device provided by the present invention, a target executable and linkable format file is generated according to a function information file, a first-category target file, a second-category target file and a secondary link script, comprising: compiling the function information file to generate a function target file; linking the first-category target file, the second-category target file and the function target file according to the secondary link script to generate a target executable and linkable format file.

[0014] According to a method for detecting bit displacement of a code segment of a key function of a relay protection device provided by the present invention, a target executable and linkable format file is executed, and a code segment bit displacement detection is performed on a second type of function of the relay protection device to obtain a detection result of the code segment bit displacement of the key function of the relay protection device, comprising: executing a stub function in the target executable and linkable format file, and recalculating a target cyclic redundancy check value corresponding to the second type of function according to a starting address and a function length corresponding to the second type of function; and detecting a code segment bit displacement of the second type of function of the relay protection device according to the cyclic redundancy check value and the target cyclic redundancy check value to obtain a detection result of the code segment bit displacement of the key function of the relay protection device.

[0015] According to a method for detecting bit displacement of a code segment of a key function of a relay protection device provided by the present invention, a code segment bit displacement detection is performed on a second type of function of the relay protection device according to a cyclic redundancy check value and a target cyclic redundancy check value to obtain a detection result of bit displacement of the code segment of the key function of the relay protection device, including: detecting bit displacement of the code segment of the second type of function of the relay protection device according to the cyclic redundancy check value and the target cyclic redundancy check value to determine whether the cyclic redundancy check value and the target cyclic redundancy check value are the same; when the cyclic redundancy check value and the target cyclic redundancy check value are the same, determining that the result of the bit displacement detection of the code segment of the key function is normal, and continuing to execute the remaining code of the second type of function of the relay protection device; when the cyclic redundancy check value and the target cyclic redundancy check value are different, determining that the result of the bit displacement detection of the code segment of the key function is abnormal, and obtaining an error log; wherein the error log is used to indicate that the cyclic redundancy check value and the target cyclic redundancy check value are different.

[0016] According to a method for detecting bit shifts in a key function code segment of a relay protection device provided by the present invention, before creating a compilation directory, the method further includes: obtaining a directory detection command; determining whether a compilation directory exists based on a target detection command; and continuing to execute the step of creating a compilation directory if no compilation directory exists.

[0017] The present invention also provides a device for detecting bit shifts of key function code segments of a relay protection device, comprising the following modules.

[0018] The directory creation module is used to create a compilation directory during the code compilation stage of the relay protection device.

[0019] The file processing module is used to process the first-category source files where the first-category functions in the key functions are located and the second-category source files where the second-category functions are located in the compilation directory to generate initial executable and linkable format files; wherein the first-category functions are key functions that do not need to check the cyclic redundancy check, and the second-category functions are key functions that need to check the cyclic redundancy check; the second-category functions contain at least one key function.

[0020] The file parsing module is used to parse the initial executable and linkable format file to obtain a function information file; wherein the function information file includes a structure variable corresponding to each function in the initial executable and linkable format file, and the structure variable includes a cyclic redundancy check value and a function length corresponding to a second type of function that needs to check the cyclic redundancy check.

[0021] The script generation module is used to call the code compilation script to generate a secondary link script; wherein the code compilation script is a link script file that has been compiled in advance.

[0022] The file generation module is used to generate target executable and linkable format files according to the function information file, the first type target file, the second type target file and the secondary link script.

[0023] The bit shift detection module is used to execute the target executable and linkable format file, detect the bit shift of the code segment of the second type of function of the relay protection device, and obtain the bit shift detection result of the key function code segment of the relay protection device.

[0024] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, a method for detecting bit shifts in a key function code segment of any of the above-mentioned relay protection devices is implemented.

[0025] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method for detecting bit shifts in a key function code segment of any of the above-mentioned relay protection devices is implemented.

[0026] The present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements any of the above-mentioned methods for detecting bit shifts in a key function code segment of a relay protection device.

[0027] The present invention provides a method and device for detecting bit shifts in a code segment of a key function of a relay protection device. The method and device create a compilation directory in the code compilation stage of the relay protection device; process the first-category source files where the first-category functions in the key functions are located and the second-category source files where the second-category functions are located in the compilation directory to generate an initial executable and linkable format file; wherein the first-category functions are key functions that do not require cyclic redundancy check verification, and the second-category functions are key functions that require cyclic redundancy check verification; the second-category functions contain at least one key function; the initial executable and linkable format file is parsed to obtain a function information file; wherein the function information file contains The invention includes a structure variable corresponding to each function in the initial executable and linkable format file, and the structure variable includes a cyclic redundancy check value and a function length corresponding to the second type of function that needs to check the cyclic redundancy check; calling the code compilation script to generate a secondary link script; wherein the code compilation script is to call the pre-compiled link script file; generating a target executable and linkable format file according to the function information file, the first type of target file, the second type of target file and the secondary link script; executing the target executable and linkable format file, detecting the code segment bit displacement of the second type of function of the relay protection device, and obtaining the key function code segment bit displacement detection result of the relay protection device. The technical solution of the present invention is used to solve the defect that the use of a dual or redundant storage system in the prior art to improve the reliability and fault tolerance of the relay protection device usually increases the cost and complexity, and realizes the effective detection of the key code segment bit displacement without increasing the additional hardware cost, and obtains the key function code segment bit displacement detection result of the relay protection device. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0029] Figure 1 It is one of the flow charts of the method for detecting bit displacement of a key function code segment of a relay protection device provided by the present invention.

[0030] Figure 2 It is a schematic diagram of the initial link script provided by the present invention.

[0031] Figure 3 It is a schematic diagram of the secondary link script provided by the present invention.

[0032] Figure 4This is the second flow chart of the method for detecting bit shift of a key function code segment of a relay protection device provided by the present invention.

[0033] Figure 5 It is a structural schematic diagram of a device for detecting bit shifts of a key function code segment of a relay protection device provided by the present invention.

[0034] Figure 6 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0035] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0036] Combine the following Figure 1-Figure 4 The present invention describes a method for detecting bit displacement of a key function code segment of a relay protection device provided by the present invention. The method for detecting bit displacement of a key function code segment of a relay protection device provided by the present invention can be applicable to detecting bit displacement of a key function code segment of a relay protection device. The executor of the method can be an electronic device or a device for detecting bit displacement of a key function code segment of a relay protection device arranged in the electronic device. The device for detecting bit displacement of a key function code segment of a relay protection device can be implemented by software, hardware or a combination of both. Figure 1 It is one of the flow charts of the method for detecting bit shift of key function code segment of relay protection device provided by the present invention, such as Figure 1 As shown, the method includes the following steps 101, 102, 103, 104, 105 and 106.

[0037] Step 101: During the code compilation phase of the relay protection device, a compilation directory is created.

[0038] In this step, the relay protection device is an important part of protecting the reliable operation of the power system. It can detect faults or abnormal conditions in the power system and remove the faulty components from the power system by tripping the circuit breaker or sending a signal to ensure that other fault-free parts quickly resume normal operation. Due to the importance and complexity of the relay protection device, the reliability and safety of its storage system are very critical.

[0039] In a specific implementation, before creating the compilation directory, the method further includes: obtaining a directory detection command; determining whether the compilation directory exists based on the target detection command; and continuing to execute the step of creating the compilation directory if the compilation directory does not exist.

[0040] In this step, the target detection command refers to the command used to determine whether the compilation directory exists during the code compilation phase of the relay protection device. For example, it can be @test -d $(BUILD_DIR) || mkdir -p $(BUILD_DIR). @test -d $(BUILD_DIR) || mkdir -p $(BUILD_DIR) is a conditional statement, usually used to ensure that a directory exists and create it if it does not exist. BUILD_DIR is a variable that should contain the path of the directory you want to check or create. The @ symbol is used to suppress the output of the command execution result in some contexts. test -d $(BUILD_DIR) is a test condition that checks whether the directory specified by $(BUILD_DIR) exists. The -d option is used to test whether a file exists and is a directory. BUILD_DIR refers to the build directory, mkdir is a command for creating directories, and the -p parameter tells mkdir to create the directory when needed and not to report an error if the directory already exists. This is a very useful option because it allows the script to run safely without knowing whether the directory already exists. $(BUILD_DIR) is a reference to the variable BUILD_DIR, which is not limited in this embodiment.

[0041] Specifically, during the code compilation stage of the relay protection device, a target detection command is used to determine whether a compilation directory exists for the protection program of the relay protection device. If it is determined that no compilation directory exists for the protection program of the relay protection device, a compilation directory is created for the protection program of the relay protection device.

[0042] Step 102: Process the first source files where the first type of functions in the key functions are located and the second source files where the second type of functions are located in the compilation directory to generate initial executable and linkable format files.

[0043] In this step, the key functions in the protection program of the relay protection device are divided into functions that need to perform cyclic redundancy check (CRC) and functions that do not need to check CRC. Functions that need to check CRC and functions that do not need to check CRC need to be placed in different C source files. The source files that need to check CRC and the source files that do not need to check CRC only need to be distinguished in the MAKEFILE file (a file that describes compilation rules) and do not need to be marked in the source code.

[0044] In this step, the initial executable and linkable format file is an executable and linkable format file (ELF).

[0045] Among them, the first type of function is a key function that does not need to check the cyclic redundancy check, and the second type of function is a key function that needs to check the cyclic redundancy check; the second type of function contains at least one key function.

[0046] Specifically, in the compilation directory, the first-category source files where the first-category functions in the key functions are located and the second-category source files where the second-category functions are located are compiled, and the compiled first-category source files and the compiled second-category source files are connected through a linker according to the initial link script, and finally the initial executable and linkable format files are generated.

[0047] In a specific implementation, the first-category source files where the first-category functions in the key functions are located and the second-category source files where the second-category functions are located are processed in a compilation directory to generate initial executable and linkable format files, including: compiling the first-category source files where the first-category functions in the key functions are located in the compilation directory to obtain first-category target files corresponding to the compiled first-category source files, compiling the second-category source files where the second-category functions in the key functions are located to obtain second-category target files corresponding to the compiled second-category source files; linking the first-category target files and the second-category target files to generate initial executable and linkable format files.

[0048] In this step, the first type of function is a key function that does not need to check the cyclic redundancy check, and the second type of function is a key function that needs to check the cyclic redundancy check; the first type of function and the second type of function contain at least one key function.

[0049] Specifically, after creating a compilation directory, compile the first-category source files where the first-category functions in the key functions are located in the compilation directory to obtain the first-category target files corresponding to the compiled first-category source files, and compile the second-category source files where the second-category functions in the key functions are located to obtain the second-category target files corresponding to the compiled second-category source files, and then use a linker to connect the first-category target files and the second-category target files according to the initial link script to generate initial executable and linkable format files.

[0050] The advantage of this setting is that it allows flexible compilation. By classifying and compiling functions that need to be checked for CRC and functions that do not need to be checked during the compilation phase, it is beneficial for the subsequently generated function information files to automatically manage structure variables and link scripts, greatly simplifying the operation process and improving development efficiency.

[0051] In this step, the linker may be, for example, an ld linker, which is mainly used to link multiple compiled target files together to generate an executable file or a shared library. It is an important tool in the programming and software development process, completing the last step of the compilation process.

[0052] Further, compile and need to verify the second class source file of CRC function, this compilation process will use gcc compile option "-finstrument-functions", use this compile option, gcc compiler will automatically insert piles for each function compiled, when entering this function execution, the first step will first call pile function, after executing pile function, just execute original function remaining code, present embodiment does not limit this.

[0053] The advantage of this setting is that there is no need to add additional hardware. Through the combination of compiler instrumentation technology and CRC verification, storage anomalies can be detected, saving hardware resources and reducing system costs.

[0054] For example, Figure 2 is a schematic diagram of the initial link script provided by the present invention, such as Figure 2 The initial linker script is shown. Figure 2 0x6E400000, 0x6DA00000, 0x68600000 and 0x68000000 are all storage addresses, which are not limited in this embodiment. Figure 2 The initial link script in connects the first-class target files and the second-class target files. The .bss section* (.bss) represents the storage of uninitialized global variables of the first-class target files and the second-class target files. The .data section* (.data) represents the storage of global variables of the first-class target files and the second-class target files. The .text section* (.text) represents the storage of code segments and compiled codes of the first-class target files and the second-class target files. Then, the initial executable and linkable format files after linking are generated based on the .bss section* (.bss), .data section* (.data) and .text section* (.text).

[0055] Step 103: parse the initial executable and linkable format file to obtain a function information file.

[0056] In this step, the function information file includes a structure variable corresponding to each function in the initial executable and linkable format file, and the structure variable includes a cyclic redundancy check value and a function length corresponding to the second type of function that needs to check the cyclic redundancy check.

[0057] Specifically, after obtaining the initial executable and linkable format file, use the command line tool and call the prepared secondary link script to export all function start addresses, lengths and function names from the symbol table of the initial executable and linkable format file and save them to obtain the function information file.

[0058] In a specific implementation, after the initial executable and linkable format file is obtained, the sixteen contents of the test segment are simultaneously exported and saved in the obtained function code segment binary file.

[0059] Exemplarily, the command line tool may be, for example, the readelf tool with the "-s –wide" parameter to export the symbol table in the initial executable and linkable format file, the grep tool is used to filter the "FUNC" field in the symbol table, and awk '{print $$2 " " $$3 " " $$8}' is used to output the corresponding column of the filtered content to the dump.data file, and the dump.data file is used to generate a function information file through the secondary link script (python script). The readelf tool with the "-s .text" parameter is used to export the test segment (text segment) in the initial executable and linkable format file, and the awk '{print $$2 $$3 $$4 $$5}' tool is used to output the filtered content to the dump.hex file. The Python script uses the dump.data file and the dump.hex file, and calls the CRC calculation tool through the secondary link script (python script) to calculate the CRC value of each function code segment, and finally fills the CRC value into the initial value position of the structure variable corresponding to the function information file. Furthermore, a secondary link script (python script) is used to generate a new function code segment binary file, namely the function code segment binary file. The function code segment binary file specifies the link position for each function in the text segment. The link position of the structure variable corresponding to the function information file generated in the fifth step of compilation is specified in front of each function position, which is used to obtain the CRC value and length of its own code segment when the function is executed.

[0060] For example, Figure 3 is a schematic diagram of the secondary link script provided by the present invention, such as Figure 3 As shown, it indicates the secondary link script. Figure 30x6E400000, 0x6DA00000, 0x68600000 and 0x68000000 are all storage addresses, which are not limited in this embodiment. The .bss segment is used to store global variables that are not initialized during the definition process, the .data segment is used to store global variables that are initialized during the definition process, and the .text segment is used to store the binary code of functions that do not require CRC verification. Immediately below the .text segment are the code segments of each function that requires CRC verification and the data structures used for verification, such as: .text.fuc1 stores the code segment of the CRC verification function, and .header.fuc1 stores the data structure used by the CRC verification function (the data structure includes crc and the code segment length len), which is not performed in this embodiment. The numbers on the left are the storage space specified for each segment in the secondary link script, such as the .data segment is stored in the address space of 0x68600000~0x6DA00000. During the linking phase, the linker will place the code segments, uninitialized global variables, and initialized global variables in the compiled target file in the segments specified by the link script, and then relocate the global variables and function calls used in the text segment, and finally link them into a target executable and linkable format file that can run on the processor.

[0061] Step 104: Call the code compilation script to generate a secondary link script.

[0062] In this step, the code script is compiled by calling a pre-compiled link script file; the code script can be, for example, a python (a widely used high-level programming language) script, which is not limited in this embodiment.

[0063] Specifically, after the initial link script of step 102 is obtained, the pre-compiled code compilation script is called to generate a secondary link script.

[0064] Step 105: Generate a target executable and linkable format file according to the function information file, the first type target file, the second type target file and the secondary link script.

[0065] Specifically, after the function information file is obtained, a target executable and linkable format file is generated according to the function information file, the first type of target file, the second type of target file and the secondary link script.

[0066] In a specific implementation, a target executable and linkable format file is generated based on a function information file, a first-category target file, a second-category target file, and a secondary linking script, including: compiling the function information file to generate a function target file; linking the first-category target file, the second-category target file, and the function target file according to the secondary linking script to generate a target executable and linkable format file.

[0067] In this step, the target executable and linkable format file is also an ELF file.

[0068] Specifically, after obtaining the function information file and the secondary link script, the function information file is compiled to generate a function target file, and then the function target file, the first type of target file and the second type of target file are linked again through the secondary link script to finally obtain the target executable and linkable format file.

[0069] Step 106: execute the target executable and linkable format file, perform code segment bit shift detection on the second type of function of the relay protection device, and obtain the code segment bit shift detection result of the key function of the relay protection device.

[0070] Specifically, after obtaining the target executable and linkable format file, the target executable and linkable format file is executed, and the code segment bit shift detection is performed on the second type of function of the relay protection device based on the function code segment binary file and the target executable and linkable format file to obtain the key function code segment bit shift detection result of the relay protection device.

[0071] In a specific implementation, a target executable and linkable format file is executed, and a code segment bit shift detection is performed on a second type of function of a relay protection device to obtain a code segment bit shift detection result of a key function of the relay protection device, including: executing a stub function in the target executable and linkable format file, and recalculating a target cyclic redundancy check value corresponding to the second type of function according to a starting address and a function length corresponding to the second type of function; and detecting a code segment bit shift of the second type of function of the relay protection device according to the cyclic redundancy check value and the target cyclic redundancy check value to obtain a code segment bit shift detection result of a key function of the relay protection device.

[0072] In this step, realize the function self code segment CRC check function in the pile function.This pile function first reads and is stored in the code segment CRC and the code segment length that are formed in the compiling stage next to the verified function position.Then calculate the CRC of this function again and compare with the CRC value that reads.If more inconsistent, then illustrate that single bit or multi-bit displacement has occurred in the code segment of this function, after the pile function record error log, jump to the abnormal interrupt handling function.If the pile function verification CRC is identical, then continue the normal execution and be verified function code.

[0073] Specifically, the stub function in the target executable and linkable format file is executed, and the function length of the function formed in the compilation stage is found from 8 bytes above the starting address of the second-class function according to the function code segment binary file, and the target cyclic redundancy check value corresponding to the second-class function is recalculated according to the starting address and the function length; the code segment bit displacement detection of the second-class function of the relay protection device is performed according to the cyclic redundancy check value and the target cyclic redundancy check value, and the key function code segment bit displacement detection result of the relay protection device is obtained.

[0074] The advantage of this setting is that the real-time performance of the relay protection device will not be affected by the way that the stub function verifies the key function, and it is suitable for relay protection devices with high real-time requirements.

[0075] In a specific embodiment, a code segment bit shift detection is performed on the second type of function of the relay protection device according to a cyclic redundancy check value and a target cyclic redundancy check value to obtain a key function code segment bit shift detection result of the relay protection device, including: performing a code segment bit shift detection on the second type of function of the relay protection device according to the cyclic redundancy check value and the target cyclic redundancy check value to determine whether the cyclic redundancy check value and the target cyclic redundancy check value are the same; when the cyclic redundancy check value and the target cyclic redundancy check value are the same, determining that the key function code segment bit shift detection result is normal, and continuing to execute the remaining code of the second type of function of the relay protection device; when the cyclic redundancy check value and the target cyclic redundancy check value are different, determining that the key function code segment bit shift detection result is abnormal, and obtaining an error log; wherein the error log is used to indicate that the cyclic redundancy check value and the target cyclic redundancy check value are different.

[0076] In this step, the error log is used to indicate that the cyclic redundancy check value is different from the target cyclic redundancy check value.

[0077] Specifically, the code segment bit shift detection of the second type function of the relay protection device is performed according to the cyclic redundancy check value and the target cyclic redundancy check value to determine whether the cyclic redundancy check value and the target cyclic redundancy check value are the same; when the cyclic redundancy check value and the target cyclic redundancy check value are the same, the key function code segment bit shift detection result is determined to be normal, and the remaining code of the second type function of the relay protection device continues to be executed; when the cyclic redundancy check value and the target cyclic redundancy check value are different, the key function code segment bit shift detection result is determined to be abnormal, and an error log is obtained, and the error log indicates that the cyclic redundancy check value and the target cyclic redundancy check value are different. After recording the error log, the relay protection device restart state is set, and then jumps to the abnormal code processing entry to restart the relay protection device.

[0078] The advantage of this setting is that it can accurately locate the specific function where the abnormality occurs, facilitate fault analysis and location, and improve the fault recovery capability of the relay protection device.

[0079] In a specific embodiment, Figure 4 This is a second flow chart of the method for detecting bit shift of a key function code segment of a relay protection device provided by the present invention, such as Figure 4 As shown, the generation of target executable and linkable format files specifically includes the following steps.

[0080] Step 401: During the code compilation phase of the relay protection device, a compilation directory is created.

[0081] Step 402: compile the first type of source files to obtain the first type of target files, and compile the second type of source files to obtain the second type of target files.

[0082] Specifically, in the compilation directory, the first type of source files where the first type of functions in the key functions are located are compiled to obtain the first type of target files corresponding to the compilation of the first type of source files, and the second type of source files where the second type of functions in the key functions are located are compiled to obtain the second type of target files corresponding to the compilation of the second type of source files.

[0083] Step 403: Link the first type target file and the second type target file according to the initial link script to generate an initial executable and linkable format file.

[0084] Step 404: parse the initial executable and linkable format file to obtain a function information file.

[0085] Step 405: Call the code compilation script to generate a secondary link script.

[0086] Specifically, after the initial link script is obtained, a pre-compiled code compilation script is called to generate a secondary link script.

[0087] Step 406: compile the function information file to generate a function target file.

[0088] Step 407: Link the first-category target file, the second-category target file, and the function target file according to the secondary link script to generate a target executable and linkable format file.

[0089] Specifically, the first type target file, the second type target file and the function target file are linked according to the secondary link script to generate target executable and linkable format files. After the target executable and linkable format files are generated, the automatic compilation ends.

[0090] The present invention provides a method for detecting bit shifts in a code segment of a key function of a relay protection device. The method comprises the following steps: creating a compilation directory in the code compilation stage of the relay protection device; processing a first-category source file where a first-category function in the key function is located and a second-category source file where a second-category function is located in the compilation directory to generate an initial executable and linkable format file; wherein the first-category function is a key function that does not require a cyclic redundancy check, and the second-category function is a key function that requires a cyclic redundancy check; the second-category function contains at least one key function; parsing the initial executable and linkable format file to obtain a function information file; wherein the function information file includes the initial executable and linkable format files. The structure variables corresponding to each function in the format file are connected, and the structure variables include the cyclic redundancy check value and function length corresponding to the second type of function that needs to check the cyclic redundancy check; call the code compilation script to generate a secondary link script; wherein the code compilation script is to call the pre-compiled link script file; generate a target executable and linkable format file according to the function information file, the first type of target file, the second type of target file and the secondary link script; execute the target executable and linkable format file, and perform a key function relay protection device key function code segment bit shift detection on the second type of function of the relay protection device, and obtain the key function code segment bit shift detection result of the relay protection device. The technical solution of the present invention is used to solve the defect that the use of a dual or redundant storage system in the prior art to improve the reliability and fault tolerance of the relay protection device usually increases the cost and complexity, and realizes the effective detection of the key code segment bit shift situation without increasing the additional hardware cost, and obtains the key function code segment bit shift detection result of the relay protection device.

[0091] The following is a description of the detection device for bit displacement of a key function code segment of a relay protection device provided by the present invention. The detection device for bit displacement of a key function code segment of a relay protection device described below and the detection method for bit displacement of a key function code segment of a relay protection device described above can be referenced to each other.

[0092] Figure 5 It is a schematic diagram of the structure of the detection device for bit shift of the key function code segment of the relay protection device provided by the present invention, referring to Figure 5 As shown, the device 500 for detecting bit displacement of a key function code segment of a relay protection device includes: a directory creation module 501, a file processing module 502, a file parsing module 503, a script generation module 504, a file generation module 505 and a displacement detection module 506.

[0093] The directory creation module 501 is used to create a compilation directory during the code compilation stage of the relay protection device.

[0094] The file processing module 502 is used to process the first-category source files where the first-category functions in the key functions are located and the second-category source files where the second-category functions are located in the compilation directory to generate initial executable and linkable format files; wherein the first-category functions are key functions that do not need to be checked for cyclic redundancy checks, and the second-category functions are key functions that need to be checked for cyclic redundancy checks; and the second-category functions contain at least one key function.

[0095] The file parsing module 503 is used to parse the initial executable and linkable format file to obtain a function information file; wherein the function information file includes structure variables corresponding to each function in the initial executable and linkable format file, and the structure variables include a cyclic redundancy check value and a function length corresponding to a second type of function that needs to verify a cyclic redundancy check.

[0096] The script generation module 504 is used to call the code compilation script to generate a secondary link script; wherein the code compilation script is a link script file compiled in advance.

[0097] The file generation module 505 is used to generate a target executable and linkable format file according to the function information file, the first type target file, the second type target file and the secondary link script.

[0098] The displacement detection module 506 is used to execute the target executable and linkable format file, detect the bit displacement of the key function code segment of the second type function of the relay protection device, and obtain the bit displacement detection result of the key function code segment of the relay protection device.

[0099] In an example embodiment, the file processing module 502 is specifically used to: compile the first type of source files where the first type of functions in the key functions are located in the compilation directory to obtain the first type of target files corresponding to the compiled first type of source files, compile the second type of source files where the second type of functions in the key functions are located to obtain the second type of target files corresponding to the compiled second type of source files; link the first type of target files and the second type of target files to generate initial executable and linkable format files.

[0100] In an exemplary embodiment, the file generation module 505 is specifically used to: compile the function information file to generate a function target file; link the first type target file, the second type target file and the function target file according to the secondary link script to generate a target executable and linkable format file.

[0101] In an exemplary embodiment, the displacement detection module 506 is specifically used to: execute the stub function in the target executable and linkable format file, and recalculate the target cyclic redundancy check value corresponding to the second type of function according to the starting address and function length corresponding to the second type of function; detect the code segment bit displacement of the second type of function of the relay protection device according to the cyclic redundancy check value and the target cyclic redundancy check value, and obtain the key function code segment bit displacement detection result of the relay protection device.

[0102] In an exemplary embodiment, the displacement detection module 505 detects the code segment bit displacement of the second type of function of the relay protection device according to the cyclic redundancy check value and the target cyclic redundancy check value, and obtains the key function code segment bit displacement detection result of the relay protection device, which is specifically used for: detecting the code segment bit displacement of the second type of function of the relay protection device according to the cyclic redundancy check value and the target cyclic redundancy check value, and determining whether the cyclic redundancy check value and the target cyclic redundancy check value are the same; when the cyclic redundancy check value and the target cyclic redundancy check value are the same, determining that the key function code segment bit displacement detection result is normal, and continuing to execute the remaining code of the second type of function of the relay protection device; when the cyclic redundancy check value and the target cyclic redundancy check value are different, determining that the key function code segment bit displacement detection result is abnormal, and obtaining an error log; wherein the error log is used to indicate that the cyclic redundancy check value and the target cyclic redundancy check value are different.

[0103] In an exemplary embodiment, the device further includes: a directory determination module. The directory determination module is used to: before creating a compilation directory, obtain a directory detection command; determine whether a compilation directory exists based on the target detection command; if the compilation directory does not exist, continue to execute the step of creating the compilation directory.

[0104] The device of this embodiment can be used to execute the method of any embodiment in the embodiment of the method for detecting bit shift of the key function code segment of the relay protection device. Its specific implementation process and technical effects are similar to those in the embodiment of the method for detecting bit shift of the key function code segment of the relay protection device. For details, please refer to the detailed introduction in the embodiment of the method for detecting bit shift of the key function code segment of the relay protection device, which will not be repeated here.

[0105] Figure 6 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 6 As shown, the electronic device may include: a processor 610, a communication interface 620, a memory 630 and a communication bus 640, wherein the processor 610, the communication interface 620 and the memory 630 communicate with each other through the communication bus 640. The processor 610 may call the logic instructions in the memory 630 to execute a method for detecting bit shifts in a key function code segment of a relay protection device, the method comprising: creating a compilation directory in the code compilation stage of the relay protection device; processing the first type of source files where the first type of functions in the key functions are located and the second type of source files where the second type of functions are located in the compilation directory to generate an initial executable and linkable format file; wherein the first type of function is a key function that does not require a cyclic redundancy check, and the second type of function is a key function that requires a cyclic redundancy check; the second type of function contains at least one key function; parsing the initial executable and linkable format file to obtain function information information file; wherein the function information file includes the structure variables corresponding to each function in the initial executable and linkable format file, and the structure variables include the cyclic redundancy check value and function length corresponding to the second type of function that needs to check the cyclic redundancy check; calling the code compilation script to generate a secondary link script; generating a target executable and linkable format file according to the function information file, the first type of target file, the second type of target file and the secondary link script; executing the target executable and linkable format file, performing a key function code segment bit shift detection on the second type of function of the relay protection device, and obtaining the key function code segment bit shift detection result of the relay protection device.

[0106] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0107] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the detection method for the bit displacement of the key function code segment of the relay protection device provided by the above methods. The method includes: in the code compilation stage of the relay protection device, creating a compilation directory; processing the first type of source files where the first type of functions in the key functions are located and the second type of source files where the second type of functions are located in the compilation directory to generate an initial executable and linkable format file; wherein the first type of function is a key function that does not require a cyclic redundancy check, and the second type of function is a key function that requires a cyclic redundancy check; the second type of function contains up to Less one key function; parsing the initial executable and linkable format file to obtain a function information file; wherein the function information file includes structure variables corresponding to each function in the initial executable and linkable format file, and the structure variables include a cyclic redundancy check value and a function length corresponding to a second type of function that needs to verify the cyclic redundancy check; calling the code compilation script to generate a secondary link script; generating a target executable and linkable format file according to the function information file, the first type of target file, the second type of target file and the secondary link script; executing the target executable and linkable format file, performing a key function code segment bit shift detection on the second type of function of the relay protection device, and obtaining a key function code segment bit shift detection result of the relay protection device.

[0108] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a method for detecting bit shifts in a key function code segment of a relay protection device provided by the above-mentioned methods, the method comprising: creating a compilation directory in the code compilation stage of the relay protection device; processing the first-class source files where the first-class functions in the key functions are located and the second-class source files where the second-class functions are located in the compilation directory to generate initial executable and linkable format files; wherein the first-class functions are key functions that do not require cyclic redundancy check verification, and the second-class functions are key functions that require cyclic redundancy check verification; the second-class functions contain at least one key function; and processing the initial executable The function information file is obtained by parsing the executable and linkable format file; wherein the function information file includes the structure variables corresponding to each function in the initial executable and linkable format file, and the structure variables include the cyclic redundancy check value and function length corresponding to the second type of function that needs to check the cyclic redundancy check; calling the code compilation script to generate a secondary link script; generating a target executable and linkable format file according to the function information file, the first type of target file, the second type of target file and the secondary link script; executing the target executable and linkable format file, detecting the bit displacement of the key function code segment of the second type of function of the relay protection device, and obtaining the bit displacement detection result of the key function code segment of the relay protection device.

[0109] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0110] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0111] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for detecting bit shift of a key function code segment of a relay protection device, characterized in that: include: During the code compilation phase of the relay protection device, a compilation directory is created; Processing the first type source files where the first type functions in the key functions are located and the second type source files where the second type functions are located in the compilation directory to generate initial executable and linkable format files; wherein the first type functions are key functions that do not require cyclic redundancy check verification, and the second type functions are key functions that require cyclic redundancy check verification; and the second type functions contain at least one key function; Parsing the initial executable and linkable format file to obtain a function information file; wherein the function information file includes a structure variable corresponding to each function in the initial executable and linkable format file, and the structure variable includes a cyclic redundancy check value and a function length corresponding to the second type of function that needs to check the cyclic redundancy check; Calling a code compilation script to generate a secondary link script; wherein the code compilation script is a pre-compiled link script file; Generate a target executable and linkable format file according to the function information file, the first type of target file, the second type of target file and the secondary link script; The target executable and linkable format file is executed, and the code segment bit shift detection is performed on the second type of function of the relay protection device to obtain the key function code segment bit shift detection result of the relay protection device.

2. The method for detecting bit displacement of a key function code segment of a relay protection device according to claim 1, characterized in that: The processing of the first source file where the first type of function in the key function is located and the second source file where the second type of function is located in the compilation directory to generate an initial executable and linkable format file includes: Compile the first type of source files where the first type of functions in the key functions are located in the compilation directory to obtain the first type of target files corresponding to the compiled first type of source files, and compile the second type of source files where the second type of functions in the key functions are located to obtain the second type of target files corresponding to the compiled second type of source files; The first type of target file and the second type of target file are linked to generate the initial executable and linkable format file.

3. The method for detecting bit displacement of a key function code segment of a relay protection device according to claim 1, characterized in that: The generating of the target executable and linkable format file according to the function information file, the first type of target file, the second type of target file and the secondary link script comprises: Compiling the function information file to generate a function target file; The first type of target file, the second type of target file, and the function target file are linked according to the secondary link script to generate the target executable and linkable format file.

4. The method for detecting bit displacement of a code segment of a key function of a relay protection device according to claim 1, wherein the target executable and linkable format file is executed, and the code segment bit displacement detection is performed on the second type of function of the relay protection device to obtain the key function code segment bit displacement detection result of the relay protection device, including: Execute the stub function in the executable and linkable format file of the target, and recalculate the target cyclic redundancy check value corresponding to the second class function according to the corresponding starting address and the function length of the second class function; The code segment bit shift detection of the second type of function of the relay protection device is performed according to the cyclic redundancy check value and the target cyclic redundancy check value to obtain the code segment bit shift detection result of the key function of the relay protection device.

5. The method for detecting bit displacement of a key function code segment of a relay protection device according to claim 4, wherein the detection of code segment bit displacement of the second type function of the relay protection device is performed according to the cyclic redundancy check value and the target cyclic redundancy check value to obtain the key function code segment bit displacement detection result of the relay protection device, comprising: Performing code segment bit shift detection on the second type function of the relay protection device according to the cyclic redundancy check value and the target cyclic redundancy check value to determine whether the cyclic redundancy check value and the target cyclic redundancy check value are the same; When the cyclic redundancy check value is the same as the target cyclic redundancy check value, determining that the bit shift detection result of the key function code segment is normal, and continuing to execute the remaining code of the second type function of the relay protection device; When the cyclic redundancy check value and the target cyclic redundancy check value are different, it is determined that the bit shift detection result of the key function code segment is abnormal, and an error log is obtained; wherein the error log is used to indicate that the cyclic redundancy check value and the target cyclic redundancy check value are different.

6. The method for detecting bit shift of a key function code segment of a relay protection device according to claim 1, characterized in that: Before creating the compilation directory, it also includes: Get the directory detection command; Determining whether the compilation directory exists based on the target detection command; If the compilation directory does not exist, continue to execute the step of creating the compilation directory.

7. A device for detecting bit shift of a key function code segment of a relay protection device, characterized in that: include: A directory creation module is used to create a compilation directory during the code compilation stage of the relay protection device; A file processing module is used to process the first type source files where the first type functions in the key functions are located and the second type source files where the second type functions are located in the compilation directory to generate initial executable and linkable format files; wherein the first type functions are key functions that do not require cyclic redundancy check verification, and the second type functions are key functions that require cyclic redundancy check verification; and the second type functions contain at least one key function; A file parsing module, used for parsing the initial executable and linkable format file to obtain a function information file; wherein the function information file includes a structure variable corresponding to each function in the initial executable and linkable format file, and the structure variable includes a cyclic redundancy check value and a function length corresponding to the second type of function that needs to check the cyclic redundancy check; A script generation module, used for calling a code compilation script to generate a secondary link script; wherein the code compilation script is a link script file compiled in advance; A file generation module, used for generating a target executable and linkable format file according to the function information file, the first type of target file, the second type of target file and the secondary link script; The bit shift detection module is used to execute the target executable and linkable format file, detect the bit shift of the code segment of the second type function of the relay protection device, and obtain the bit shift detection result of the key function code segment of the relay protection device.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the method for detecting bit shifts in a key function code segment of a relay protection device as described in any one of claims 1 to 6 is implemented.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for detecting bit shifts in a key function code segment of a relay protection device as described in any one of claims 1 to 6 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method for detecting bit shifts in a key function code segment of a relay protection device as described in any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Method and device for locating programming language errors and electronic equipment

    CN118331878A

  • Source code instrumentation method and device and storage medium

    CN118733426A

  • Method and system for detecting and recovering memory bit flipping in secondary power equipment

    WO2021208341A1