CN101271408A - Method for analyzing stack use in embedded system - Google Patents
Method for analyzing stack use in embedded system Download PDFInfo
- Publication number
- CN101271408A CN101271408A CNA2008100615782A CN200810061578A CN101271408A CN 101271408 A CN101271408 A CN 101271408A CN A2008100615782 A CNA2008100615782 A CN A2008100615782A CN 200810061578 A CN200810061578 A CN 200810061578A CN 101271408 A CN101271408 A CN 101271408A
- Authority
- CN
- China
- Prior art keywords
- function
- storehouse
- information
- interrupt
- code
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 38
- 238000004458 analytical method Methods 0.000 claims abstract description 21
- 230000003068 static effect Effects 0.000 claims abstract description 6
- 239000000284 extract Substances 0.000 claims description 4
- GNFTZDOKVXKIBK-UHFFFAOYSA-N 3-(2-methoxyethoxy)benzohydrazide Chemical compound COCCOC1=CC=CC(C(=O)NN)=C1 GNFTZDOKVXKIBK-UHFFFAOYSA-N 0.000 claims description 3
- FGUUSXIOTUKUDN-IBGZPJMESA-N C1(=CC=CC=C1)N1C2=C(NC([C@H](C1)NC=1OC(=NN=1)C1=CC=CC=C1)=O)C=CC=C2 Chemical compound C1(=CC=CC=C1)N1C2=C(NC([C@H](C1)NC=1OC(=NN=1)C1=CC=CC=C1)=O)C=CC=C2 FGUUSXIOTUKUDN-IBGZPJMESA-N 0.000 claims description 3
- 230000000694 effects Effects 0.000 description 1
- 238000011156 evaluation Methods 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Landscapes
- Debugging And Monitoring (AREA)
Abstract
The invention discloses a method for analyzing stack use in an embedded system, which includes the following steps: a) decompiling executive files to get assembly codes; b) counting the stack use of each base block; c) calculating the stack use of each function; d) producing a function calling chart from the assembly codes; e) calculating the stack use of each thread combined with the results of step c and step d; f) conducting the interruptive stack use analysis of a processing function; g) conducting the stack use analysis of the whole system according to the situation of an interrupt switch of the system. In addition to the static analysis of the stack use under the worst operation of the program, the method of analyzing stack use provided by the invention also provides the interruptive stack use analysis of the processing function and the stack use analysis of the whole system according to the situation of the interrupt switch of the system. Through the estimation of the stack use of the thread, the method leads to more efficient and safer operation of the system.
Description
Technical field
The present invention relates to a kind of method that storehouse uses of in embedded system, analyzing.
Background technology
In recent years, in the computer realm of fast development, embedded technology became one of them more and more important aspect, increased gradually in relevant application, also obtained significant progress.Particularly on the wireless sensor node, the primary processor that adopts is some simple microcontrollers usually, when exploitation multithread programs on these nodes, is a big problem for each thread distributing independent storehouse becomes efficiently at embedded device.
Under existing conditions, in order to distribute Limited resources efficiently, when each thread creation, the storehouse that takies when each thread operation need be provided uses information, this has brought all inconvenience just for procedure development person, if simultaneously wrong estimation the employed storehouse size of thread, the mistake in the time of then can causing the waste of resource or program run.
Summary of the invention
The purpose of this invention is to provide a kind of method that storehouse uses of in embedded system, analyzing, to running on the evaluation method that the required storehouse of the single thread of program uses in the embedded system, especially be applied in the middle of the resource-constrained embedded system, by thread being used the estimation of storehouse, make the more efficient and safe operation of system.The present invention also analyzes the storehouse use of Interrupt Process function and the storehouse of total system uses information.
The step of the technical solution used in the present invention is as follows:
A) analyzed executable file is carried out dis-assembling, obtain the assembly code of analyzed executable file;
B) be that unit divides with the fundamental block with resulting assembly code in the step a), at the assembly code in each fundamental block, the storehouse of adding up this fundamental block uses information;
C) storehouse of analyzing each function uses, and uses the storehouse of the fundamental block of adding up in the step b) to use information, and the storehouse use information of the fundamental block that each function contained is added up, and the storehouse that obtains this function uses information;
D) taking-up function call code from assembly code and function return code according to the position relation of function call correlative code, obtain the function call figure of whole application program;
E) use the analysis result that obtains in step c) and the step d), be starting point with program entry function and thread creation function respectively, according to function call figure, the storehouse of stack related function uses information, and the storehouse that calculates under the worst case of each thread uses information;
F) storehouse of analyzing the Interrupt Process function uses information, on the avr platform, extracts all with _ function that vector_N begins, and relatively the storehouse of these functions uses the information size, finds out maximal value wherein, uses information as the maximum storehouse of Interrupt Process function;
G) storehouse of analyzing total system uses information, from function call source of graph function, if there is interrupt switch instruction, with can not interrupt function in the function from interrupting that out code begins to be labeled as to the function that interrupts being called the OPEN, but otherwise be labeled as interrupt function; If but the function of the bottommost layer that the storehouse under the worst case that step e is calculated uses is an interrupt function, to use be exactly that the maximum storehouse that calculated of step e uses and the storehouse use addition gained of the Interrupt Process function that step f calculates to the maximum storehouse of system so; If the function of the bottommost layer that the storehouse under the worst case that step e calculated uses is can not interrupt function, to use be exactly step e result calculated to the maximum storehouse of system so; After step g was finished, the storehouse of whole application program used the static analysis process of information to finish, and obtains the system stack size of using under the worst case of analyzed application program.
The present invention compares with background technology, has useful effect to be:
Owing to adopted technique scheme, the storehouse operational analysis method that the present invention proposes, except having the function of the storehouse use information under the static analyzer worst case, also provide the storehouse operational analysis of Interrupt Process function and according to the interrupt switch situation of system, analyze the function of the storehouse use of total system, by thread being used the estimation of storehouse, make the more efficient and safe operation of system.
Description of drawings
Accompanying drawing is the schematic flow sheet of the inventive method.
Embodiment
Further specify technical scheme of the present invention in conjunction with example below, in following embodiment, the storehouse that provides a kind of analysis to run on the executable file on the AVR platform is used the method for information, but scrutable be that the inventive method is not limited to specific platform.As shown in drawings, concrete flow process is as follows:
A) analyzed executable file is carried out dis-assembling, obtain the assembly code of analyzed executable file.Use corresponding disassembler at different architectures, then the assembly code that obtains is saved in the related data structure.
A.1) when preserving the code that obtains of dis-assembling, the file that dis-assembling is obtained reads in line by line.If the operational code of the assembly code that reads in is branch, jump, call, return, load, store during this several types of push or pop, preserves; When if the operational code of the assembly code that reads in is other type, because instruction is not preserved not influence of storehouse.
A.2), label and subsequent article one instruction binding are preserved together if when running into label.
B) be that unit divides with the fundamental block with resulting assembly code among the step a, at the assembly code in each fundamental block, the storehouse of adding up this fundamental block uses information.
C) storehouse of analyzing each function uses, and uses the storehouse of the fundamental block of adding up among the step b to use, and the storehouse use information of the fundamental block that each function contained is added up, and the storehouse that obtains this function uses.
C.1) if run into circulation during the function inner analysis, then no matter circulate actual execution several times, only the storehouse consumption notation that loop body is produced once adding that circulation is prepared and the storehouse consumption that part produces is finished in circulation, constitutes the analysis that the storehouse of a loop structure uses;
C.2) if run into direct jump instruction during the function inner analysis, then the destination address from redirect begins further analysis;
C.3) if run into indirect jump instruction during the function inner analysis, can't know the destination address of redirect, preserve current time system all effective addresses in using, travel through these destination addresses, the result who uses the conduct that produces storehouse consumption maximum to analyze herein.
D) from assembly code, extract function call code and function return code,, obtain the function call figure of whole application program according to the position relation of function call correlative code.
E) using the analysis result that obtains in step c and the steps d, is starting point with program entry function and thread creation function respectively, and according to function call figure, the storehouse of stack related function uses, and the storehouse that calculates under the worst case of each thread uses information.
E.1) if current function does not call other function, then it has obtained its storehouse by step c and has used information;
E.2) if current function call user-defined function, those functions that are called that can in assembly code, find function to realize, calculate the storehouse consumption that these functions that are called produce successively, use maximal value wherein to add corresponding results among the step c, as the storehouse use information of this function;
E.3) if current function call system function, the storehouse that produces of these system functions uses the realization of information according to different platform so, obtains as fixed data.On the avr platform, obtain these data according to the realization in the avr-libc storehouse of respective version.
F) on the avr platform, extract all functions with " _ vector_N " beginning, relatively the storehouse of these functions uses size, finds out maximal value wherein, as the maximum storehouse use of Interrupt Process function.
F.1) if the Interrupt Process function is embodied as the Interrupt Process function of interrupt type, interrupt handling routine can be nested, and the storehouse of interrupt handling routine uses information to decide according to the level of nesting of reality permission so;
F.2) if the Interrupt Process function is embodied as the Interrupt Process function of signal type, in an Interrupt Process process, interrupt closing, then there is not nest relation between the interrupt handling routine, the maximum storehouse of interrupt handling routine uses and is just produced by independent some Interrupt Process functions itself, the storehouse consumption that more different Interrupt Process function self produces, the storehouse of maximum used information when maximal value wherein was exactly Interrupt Process.
G),, with can not interrupt function in the function, but otherwise be labeled as interrupt function from interrupting that out code begins to be labeled as to the function that interrupts being called the OPEN if there is interrupt switch instruction from function call source of graph function.If but the function of the bottommost layer that the storehouse under the worst case that step e is calculated uses is an interrupt function, to use be exactly that the maximum storehouse that calculated of step e uses and the storehouse use addition gained of the Interrupt Process function that step f calculates to the maximum storehouse of system so; If the function of the bottommost layer that the storehouse under the worst case that step e calculated uses is can not interrupt function, to use be exactly step e result calculated to the maximum storehouse of system so.After step g was finished, the storehouse of whole application program used the static analysis process of information to finish, and can obtain the system stack size of using under the worst case of analyzed application program.
Pass through above-mentioned steps, the storehouse operational analysis method that the present invention proposes, except having the function of the storehouse use information under the static analyzer worst case, also provide the storehouse operational analysis of Interrupt Process function and according to the interrupt switch situation of system, analyze the function that the storehouse of total system uses.
Claims (1)
1. in embedded system, analyze the method that storehouse uses for one kind, it is characterized in that the step of this method is as follows:
A) analyzed executable file is carried out dis-assembling, obtain the assembly code of analyzed executable file;
B) be that unit divides with the fundamental block with resulting assembly code in the step a), at the assembly code in each fundamental block, the storehouse of adding up this fundamental block uses information;
C) storehouse of analyzing each function uses, and uses the storehouse of the fundamental block of adding up in the step b) to use information, and the storehouse use information of the fundamental block that each function contained is added up, and the storehouse that obtains this function uses information;
D) taking-up function call code from assembly code and function return code according to the position relation of function call correlative code, obtain the function call figure of whole application program;
E) use the analysis result that obtains in step c) and the step d), be starting point with program entry function and thread creation function respectively, according to function call figure, the storehouse of stack related function uses information, and the storehouse that calculates under the worst case of each thread uses information;
F) storehouse of analyzing the Interrupt Process function uses information, on the avr platform, extracts all with _ function that vector_N begins, and relatively the storehouse of these functions uses the information size, finds out maximal value wherein, uses information as the maximum storehouse of Interrupt Process function;
G) storehouse of analyzing total system uses information, from function call source of graph function, if there is interrupt switch instruction, with can not interrupt function in the function from interrupting that out code begins to be labeled as to the function that interrupts being called the OPEN, but otherwise be labeled as interrupt function; If but the function of the bottommost layer that the storehouse under the worst case that step e is calculated uses is an interrupt function, to use be exactly that the maximum storehouse that calculated of step e uses and the storehouse use addition gained of the Interrupt Process function that step f calculates to the maximum storehouse of system so; If the function of the bottommost layer that the storehouse under the worst case that step e calculated uses is can not interrupt function, to use be exactly step e result calculated to the maximum storehouse of system so; After step g was finished, the storehouse of whole application program used the static analysis process of information to finish, and obtains the system stack size of using under the worst case of analyzed application program.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2008100615782A CN100573461C (en) | 2008-05-07 | 2008-05-07 | In embedded system, analyze the method that storehouse uses |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2008100615782A CN100573461C (en) | 2008-05-07 | 2008-05-07 | In embedded system, analyze the method that storehouse uses |
Publications (2)
Publication Number | Publication Date |
---|---|
CN101271408A true CN101271408A (en) | 2008-09-24 |
CN100573461C CN100573461C (en) | 2009-12-23 |
Family
ID=40005398
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CNB2008100615782A Expired - Fee Related CN100573461C (en) | 2008-05-07 | 2008-05-07 | In embedded system, analyze the method that storehouse uses |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN100573461C (en) |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102012833A (en) * | 2010-11-09 | 2011-04-13 | 北京神舟航天软件技术有限公司 | Compilation process intermediate result-based static stack detection method |
CN104484179A (en) * | 2014-12-23 | 2015-04-01 | 上海斐讯数据通信技术有限公司 | Stack recalling method |
CN104572448A (en) * | 2014-12-23 | 2015-04-29 | 大唐移动通信设备有限公司 | Method and device for realizing use condition of thread stack |
CN106250231A (en) * | 2016-03-31 | 2016-12-21 | 物联智慧科技(深圳)有限公司 | Computing system and method for calculating stack size |
WO2017128952A1 (en) * | 2016-01-28 | 2017-08-03 | 中兴通讯股份有限公司 | Stack protection method and device |
CN113312054A (en) * | 2021-05-27 | 2021-08-27 | 长沙海格北斗信息技术有限公司 | Software stack consumption analysis method and analysis device for embedded software architecture |
-
2008
- 2008-05-07 CN CNB2008100615782A patent/CN100573461C/en not_active Expired - Fee Related
Cited By (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102012833A (en) * | 2010-11-09 | 2011-04-13 | 北京神舟航天软件技术有限公司 | Compilation process intermediate result-based static stack detection method |
CN104484179A (en) * | 2014-12-23 | 2015-04-01 | 上海斐讯数据通信技术有限公司 | Stack recalling method |
CN104572448A (en) * | 2014-12-23 | 2015-04-29 | 大唐移动通信设备有限公司 | Method and device for realizing use condition of thread stack |
WO2017128952A1 (en) * | 2016-01-28 | 2017-08-03 | 中兴通讯股份有限公司 | Stack protection method and device |
CN107015904A (en) * | 2016-01-28 | 2017-08-04 | 中兴通讯股份有限公司 | The guard method of storehouse and device |
CN107015904B (en) * | 2016-01-28 | 2022-04-19 | 中兴通讯股份有限公司 | Stack protection method and device |
CN106250231A (en) * | 2016-03-31 | 2016-12-21 | 物联智慧科技(深圳)有限公司 | Computing system and method for calculating stack size |
TWI647565B (en) * | 2016-03-31 | 2019-01-11 | 物聯智慧科技(深圳)有限公司 | Calculation system and method for calculating stack size |
CN113312054A (en) * | 2021-05-27 | 2021-08-27 | 长沙海格北斗信息技术有限公司 | Software stack consumption analysis method and analysis device for embedded software architecture |
Also Published As
Publication number | Publication date |
---|---|
CN100573461C (en) | 2009-12-23 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN100573461C (en) | In embedded system, analyze the method that storehouse uses | |
US9021241B2 (en) | Combined branch target and predicate prediction for instruction blocks | |
US10277617B2 (en) | Method and device for feature extraction | |
CN104794401A (en) | Static-analysis-assisted symbolic execution vulnerability detection method | |
US10248424B2 (en) | Control flow integrity | |
CN101299192B (en) | Non-aligning access and storage processing method | |
MY165418A (en) | System and method for detection of malware | |
KR920001321A (en) | Method and apparatus for processing branch in high speed processor | |
CN101154259A (en) | General automated shelling engine and method | |
CN101231597A (en) | Method for execution of JAVA program instruction in smart card | |
US20170139693A1 (en) | Code execution method and device | |
CN101884025B (en) | Method and system for accelerating procedure return sequences | |
CN103870767A (en) | Stack frame content protection method based on ebp (extended base pointer) structure | |
CN107632832A (en) | One kind obscures method towards dalvik bytecode controlling streams | |
JP2009528611A (en) | Optimized compilation method during conditional branching | |
EP2182433A1 (en) | Indirect branching program, and indirect branching method | |
KR102147355B1 (en) | Method and apparatus for converting programs | |
CN106919403B (en) | multi-granularity code clone detection method based on Java byte codes in cloud environment | |
US9715374B2 (en) | Multi-branch determination syntax optimization apparatus | |
CN106325963B (en) | Self-adaptive dynamic compiling and scheduling method and device | |
CN101639791A (en) | Method for improving interruption delay of embedded type real-time operation system | |
CN101295239A (en) | Instruction execution method of Java card virtual machine | |
ATE493705T1 (en) | DETERMINISTIC RULE-BASED DISTRIBUTION OF OBJECTS TO OBJECT-PROCESSING CODE | |
US9396044B2 (en) | Memory efficient thread-level speculation | |
CN109445798B (en) | LuaJIT byte code processing method, device and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C41 | Transfer of patent application or patent right or utility model | ||
TA01 | Transfer of patent application right |
Effective date of registration: 20081219 Address after: 38, Da Da Lu, Xihu District, Zhejiang, Hangzhou Province, China: 310027 Applicant after: Zhejiang University Co-applicant after: INSIGMA GROUP CO., LTD. Address before: 38, Da Da Lu, Xihu District, Zhejiang, Hangzhou Province, China: 310027 Applicant before: Zhejiang University |
|
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20091223 Termination date: 20200507 |