CN104881274A - Method for identifying useless codes - Google Patents

Method for identifying useless codes Download PDF

Info

Publication number
CN104881274A
CN104881274A CN201410072475.1A CN201410072475A CN104881274A CN 104881274 A CN104881274 A CN 104881274A CN 201410072475 A CN201410072475 A CN 201410072475A CN 104881274 A CN104881274 A CN 104881274A
Authority
CN
China
Prior art keywords
file
image file
symbol
compiling
reference tree
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
CN201410072475.1A
Other languages
Chinese (zh)
Other versions
CN104881274B (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.)
Yuanzhiuniverse (Fujian) Technology Group Co.,Ltd.
Original Assignee
Shanghai Feixun Data Communication Technology Co Ltd
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 Shanghai Feixun Data Communication Technology Co Ltd filed Critical Shanghai Feixun Data Communication Technology Co Ltd
Priority to CN201410072475.1A priority Critical patent/CN104881274B/en
Publication of CN104881274A publication Critical patent/CN104881274A/en
Application granted granted Critical
Publication of CN104881274B publication Critical patent/CN104881274B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention discloses a method for identifying useless codes. The method comprises following steps: compiling and linking a source file so as to generate an image file; compiling and linking the image file so as to generate a map file; assigning an entry function, and performing disassembling analysis on the image file so as to obtain a symbol reference tree; and searching for symbols listed in the map file from the symbol reference tree, wherein the symbols cannot found in the symbol reference tree are the useless symbols. By employing the method for identifying useless the codes, the identified useless codes can be cleaned, so that the software maintenance difficulty is reduced, the space occupied by hardware is reduced, the product cost is finally reduced, and the product competitiveness is improved.

Description

Identify the method for dead code
Technical field
The present invention relates to a kind of method identifying dead code.
Background technology
In software development and maintenance process, always leave some useless codes (that is, rubbish code) inadvertently, these dead codes accumulate over a long period, cumulative, take valuable ROM space and memory source.
Summary of the invention
The technical matters that the present invention need solve is to provide a kind of method identifying dead code, identifies dead code and can carry out clearing up thus reduce software maintenance difficulty and the hardware space needed for minimizing.
For solving above-mentioned technical matters, the present invention devises a kind of method identifying dead code, it is characterized in that, comprises the following steps:
Step 1: image file is generated to source file compiling, link;
Step 2: map file is generated to described image file compiling, link, or map file is generated to source file compiling, link;
Step 3: specify entrance function main, then by carrying out dis-assembling parsing to image file, obtain the symbolic reference tree of entrance function main;
Step 4: the symbol listed by map file is searched in described symbolic reference tree, search less than symbol be ignore character.
Improve further as the present invention, described image file is executable file a.out.
The invention provides a kind of method identifying dead code, identifying dead code can clear up, thus reduces software maintenance difficulty, reduces the hardware space taken, finally reduces cost of products, improves product competitiveness.
Accompanying drawing explanation
Fig. 1 is the schematic flow sheet of the embodiment of the method for identification dead code of the present invention.
Embodiment
Technical scheme of the present invention is understood better in order to make relevant technical staff in the field, below in conjunction with the accompanying drawing of embodiment of the present invention, technical scheme in embodiment of the present invention is clearly and completely described, obviously, described embodiment is only the present invention's part embodiment, instead of whole embodiments.
The invention provides a kind of method identifying dead code, the dead code of source file (i.e. rubbish code) can be identified.Identify dead code, next step deletion can be carried out.Delete dead code, software maintenance difficulty can be reduced and reduce the hardware space taken.
As shown in Figure 1, be the embodiment that the present invention is concrete, source file comprises a lot of code, comprising dead code and useful code.
In order to identify dead code, comprise following four steps:
Step 1: first, generate image file to source file compiling, link, in the present embodiment, described image file is executable file a.out.
Step 2: more described image file a.out compiled, link generation map file.In other embodiments of the invention, can compile source file, link generation map file, namely map file also can be generated by source file direct compilation, link.Contain symbol and the symbol address information of all codes of source file in map file, namely include the symbol of dead code and the symbol of useful code.
Step 3: specify entrance function main, then by carrying out dis-assembling parsing to image file, obtain the symbolic reference tree of entrance function main.Specify entrance function main, namely recall the code that can call, the code that can call is useful code, thus, and the symbol of what described symbolic reference tree comprised is useful code.
Step 4: the symbol listed by map file is searched in described symbolic reference tree, search less than symbol be the symbol of dead code.As in Fig. 1, embodiment illustrates, symbol " main, test_2, test_1 " in map file can find in symbolic reference tree, for the symbol of useful code, and " test_3 " searches less than, the symbol that " test_3 " is dead code in symbolic reference tree.Thus, symbolic reference tree search less than symbol be namely considered as the symbol of dead code.
The invention provides a kind of method identifying dead code, identifying dead code can clear up, thus reduces software maintenance difficulty, reduces the hardware space taken, finally reduces cost of products, improves product competitiveness.
Below only have expressed one embodiment of the present invention, it describes comparatively concrete and detailed, but therefore can not be interpreted as the restriction to the scope of the claims of the present invention.It should be pointed out that for the person of ordinary skill of the art, without departing from the inventive concept of the premise, can also make some distortion and improvement, these all belong to protection scope of the present invention.Therefore, the protection domain of patent of the present invention should be as the criterion with claims.

Claims (2)

1. identify a method for dead code, it is characterized in that, comprise the following steps:
Step 1: image file is generated to source file compiling, link;
Step 2: map file is generated to described image file compiling, link, or map file is generated to source file compiling, link;
Step 3: specify entrance function main, then by carrying out dis-assembling parsing to image file, obtain the symbolic reference tree of entrance function main;
Step 4: the symbol listed by map file is searched in described symbolic reference tree, search less than symbol be ignore character.
2. the method for identification dead code according to claim 1, is characterized in that, described image file is executable file a.out.
CN201410072475.1A 2014-02-28 2014-02-28 The method for identifying dead code Active CN104881274B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410072475.1A CN104881274B (en) 2014-02-28 2014-02-28 The method for identifying dead code

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410072475.1A CN104881274B (en) 2014-02-28 2014-02-28 The method for identifying dead code

Publications (2)

Publication Number Publication Date
CN104881274A true CN104881274A (en) 2015-09-02
CN104881274B CN104881274B (en) 2018-02-13

Family

ID=53948783

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410072475.1A Active CN104881274B (en) 2014-02-28 2014-02-28 The method for identifying dead code

Country Status (1)

Country Link
CN (1) CN104881274B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105511934A (en) * 2015-12-08 2016-04-20 贵阳朗玛信息技术股份有限公司 Resource processing method and device in application program development
CN106598828A (en) * 2015-10-14 2017-04-26 阿里巴巴集团控股有限公司 Method and device for determining invalid class in source code
CN107358099A (en) * 2017-06-09 2017-11-17 南京邮电大学 Useless change quantity measuring method based on LLVM intermediate representation program microtomies
CN110389764A (en) * 2019-06-19 2019-10-29 平安普惠企业管理有限公司 Dead code method for cleaning, equipment, storage medium and device
CN110879709A (en) * 2019-11-29 2020-03-13 五八有限公司 Detection method and device of useless codes, terminal equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020170044A1 (en) * 2001-02-23 2002-11-14 Microsoft Corporation Method and system for register allocation
EP2090983A1 (en) * 2008-02-15 2009-08-19 Siemens Aktiengesellschaft Determining an architecture for executing code in a multi architecture environment
CN103049304A (en) * 2013-01-21 2013-04-17 中国人民解放军国防科学技术大学 Method for accelerating operating speed of graphics processing unit (GPU) through dead code removal

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020170044A1 (en) * 2001-02-23 2002-11-14 Microsoft Corporation Method and system for register allocation
EP2090983A1 (en) * 2008-02-15 2009-08-19 Siemens Aktiengesellschaft Determining an architecture for executing code in a multi architecture environment
CN103049304A (en) * 2013-01-21 2013-04-17 中国人民解放军国防科学技术大学 Method for accelerating operating speed of graphics processing unit (GPU) through dead code removal

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106598828A (en) * 2015-10-14 2017-04-26 阿里巴巴集团控股有限公司 Method and device for determining invalid class in source code
CN105511934A (en) * 2015-12-08 2016-04-20 贵阳朗玛信息技术股份有限公司 Resource processing method and device in application program development
CN105511934B (en) * 2015-12-08 2018-11-13 贵阳朗玛信息技术股份有限公司 Method for processing resource in application development and device
CN107358099A (en) * 2017-06-09 2017-11-17 南京邮电大学 Useless change quantity measuring method based on LLVM intermediate representation program microtomies
CN107358099B (en) * 2017-06-09 2020-05-05 南京邮电大学 Useless variable detection method based on LLVM intermediate representation program slicing technology
CN110389764A (en) * 2019-06-19 2019-10-29 平安普惠企业管理有限公司 Dead code method for cleaning, equipment, storage medium and device
CN110879709A (en) * 2019-11-29 2020-03-13 五八有限公司 Detection method and device of useless codes, terminal equipment and storage medium

Also Published As

Publication number Publication date
CN104881274B (en) 2018-02-13

Similar Documents

Publication Publication Date Title
CN104881274A (en) Method for identifying useless codes
CN108256063B (en) Knowledge base construction method for network security
CN103942212B (en) The character detecting method and device of a kind of user interface
CN107918666B (en) Data synchronization method and system on block chain
CN103970733B (en) A kind of Chinese new word identification method based on graph structure
CN106843840B (en) Source code version evolution annotation multiplexing method based on similarity analysis
CN103076892A (en) Method and equipment for providing input candidate items corresponding to input character string
CN102708320A (en) Method and device for recognition of virus APK (android package)
CN105677710A (en) Processing method and system of big data
CN106126383B (en) A kind of log processing method and device
CN104699737A (en) Method and system for managing a search
CN107832047B (en) A kind of non-api function argument recommended method based on LSTM
WO2010127045A3 (en) Method and system for calling variations in a sample polynucleotide sequence with respect to a reference polynucleotide sequence
KR101617696B1 (en) Method and device for mining data regular expression
CN101441687B (en) Method and apparatus for extracting virus characteristic of virus document
CN102905002A (en) Method and system for automatically combining contact items
CN105976302A (en) Configurable data comparing method and system
CN104615542A (en) Vulnerability correlation analysis assisted vulnerability mining method based on function calling
CN101286147A (en) Mobile terminal character string internationalization process
CN103294820A (en) WEB page classifying method and system based on semantic extension
CN105183476A (en) Cross-application program construction method and device
CN105488198A (en) Recommendation method of application program and terminal
CN105938496A (en) Webpage content extraction method and apparatus
CN103902906A (en) Mobile terminal malicious code detecting method and system based on application icon
CN110851519A (en) Method for processing data through ETL tool based on NLP natural language

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
EXSB Decision made by sipo to initiate substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20201113

Address after: Room 10242, No. 260, Jiangshu Road, Xixing street, Binjiang District, Hangzhou City, Zhejiang Province

Patentee after: Hangzhou Jiji Intellectual Property Operation Co.,Ltd.

Address before: 201616 Shanghai city Songjiang District Guangfulin road 4855 Lane 20, No. 90

Patentee before: Phicomm (Shanghai) Co.,Ltd.

TR01 Transfer of patent right
EE01 Entry into force of recordation of patent licensing contract
EE01 Entry into force of recordation of patent licensing contract

Application publication date: 20150902

Assignee: Hangzhou xiaobuzhixue Information Technology Co.,Ltd.

Assignor: Hangzhou Jiji Intellectual Property Operation Co.,Ltd.

Contract record no.: X2021330000454

Denomination of invention: Method for identifying useless code

Granted publication date: 20180213

License type: Common License

Record date: 20211019

EE01 Entry into force of recordation of patent licensing contract
EE01 Entry into force of recordation of patent licensing contract

Application publication date: 20150902

Assignee: Hangzhou national software industry base Co.,Ltd.

Assignor: Hangzhou Jiji Intellectual Property Operation Co.,Ltd.

Contract record no.: X2021330000669

Denomination of invention: Method for identifying useless code

Granted publication date: 20180213

License type: Common License

Record date: 20211103

TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20230925

Address after: Room 1701-1706, Feili Center, No. 72 Daxing Street, Binhai Community, Donghai Street, Fengze District, Quanzhou City, Fujian Province, 362000

Patentee after: Yuanzhiuniverse (Fujian) Technology Group Co.,Ltd.

Address before: Room 10242, No. 260, Jiangshu Road, Xixing street, Binjiang District, Hangzhou City, Zhejiang Province

Patentee before: Hangzhou Jiji Intellectual Property Operation Co.,Ltd.