CN101271408A - Method for analyzing stack use in embedded system - Google Patents

Method for analyzing stack use in embedded system Download PDF

Info

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
Application number
CNA2008100615782A
Other languages
Chinese (zh)
Other versions
CN100573461C (en
Inventor
陈纯
郑扣根
卜佳俊
陈功
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
INSIGMA GROUP CO., LTD.
Zhejiang University ZJU
Original Assignee
Zhejiang University ZJU
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Zhejiang University ZJU filed Critical Zhejiang University ZJU
Priority to CNB2008100615782A priority Critical patent/CN100573461C/en
Publication of CN101271408A publication Critical patent/CN101271408A/en
Application granted granted Critical
Publication of CN100573461C publication Critical patent/CN100573461C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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

In embedded system, analyze the method that storehouse uses
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.
CNB2008100615782A 2008-05-07 2008-05-07 In embedded system, analyze the method that storehouse uses Expired - Fee Related CN100573461C (en)

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 (5)

* Cited by examiner, † Cited by third party
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

Cited By (8)

* Cited by examiner, † Cited by third party
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

Also Published As

Publication number Publication date
CN100573461C (en) 2009-12-23

Similar Documents

Publication Publication Date Title
US9021241B2 (en) Combined branch target and predicate prediction for instruction blocks
JP3894698B2 (en) A hybrid just-in-time compiler that minimizes resource consumption
US10277617B2 (en) Method and device for feature extraction
CN100573461C (en) In embedded system, analyze the method that storehouse uses
CN104794401A (en) Static-analysis-assisted symbolic execution vulnerability detection method
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
CN101231597A (en) Method for execution of JAVA program instruction in smart card
US20180095764A1 (en) Control flow integrity
US20170139693A1 (en) Code execution method and device
CN101884025B (en) Method and system for accelerating procedure return sequences
WO2015032311A1 (en) Code generation method, compiler, scheduling method, apparatus and scheduling system
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
KR102147355B1 (en) Method and apparatus for converting programs
CN106919403B (en) multi-granularity code clone detection method based on Java byte codes in cloud environment
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
ATE493705T1 (en) DETERMINISTIC RULE-BASED DISTRIBUTION OF OBJECTS TO OBJECT-PROCESSING CODE
US9396044B2 (en) Memory efficient thread-level speculation
CN112445520B (en) Branch prediction optimization method for conditional branch instructions in loop
CN104778092B (en) It is a kind of to apply the analysis to the energy consumption leak of sensor and detecting system for Android
CN109445798A (en) A kind of processing method, device and the storage medium of LuaJIT bytecode

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