CN110058861A - Source code processing method and processing device, storage medium, electronic equipment - Google Patents

Source code processing method and processing device, storage medium, electronic equipment Download PDF

Info

Publication number
CN110058861A
CN110058861A CN201910319622.3A CN201910319622A CN110058861A CN 110058861 A CN110058861 A CN 110058861A CN 201910319622 A CN201910319622 A CN 201910319622A CN 110058861 A CN110058861 A CN 110058861A
Authority
CN
China
Prior art keywords
replaced
name
variable name
intermediate language
function name
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
CN201910319622.3A
Other languages
Chinese (zh)
Other versions
CN110058861B (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.)
Tongdun Network Technology Co.,Ltd.
Original Assignee
Tong Shield Holdings 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 Tong Shield Holdings Ltd filed Critical Tong Shield Holdings Ltd
Priority to CN201910319622.3A priority Critical patent/CN110058861B/en
Publication of CN110058861A publication Critical patent/CN110058861A/en
Application granted granted Critical
Publication of CN110058861B publication Critical patent/CN110058861B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the present invention is about a kind of source code processing method and processing device, storage medium, electronic equipment, belong to software technology field, this method comprises: by compilation of source code to be processed at intermediate language, and traverse the intermediate language and obtain function name to be replaced and/or global variable name to be replaced;Generate random function name corresponding with the function name to be replaced, and/or stochastic variable name corresponding with the global variable name to be replaced;Using the random function name and/or the stochastic variable name in the intermediate language function name to be replaced and/or global variable name to be replaced be replaced;Replaced intermediate language is recompilated, object code file is obtained.The method increase the efficiency treating replacement function name and/or global variable name to be replaced and being replaced, while saving human cost and time cost.

Description

Source code processing method and processing device, storage medium, electronic equipment
Technical field
The present embodiments relate to software technology fields, in particular to a kind of source code processing method, source code processing dress It sets, calculate section readable storage medium storing program for executing and electronic equipment.
Background technique
With the development of mobile internet, the speed of various software developments and update iteration is also getting faster.Existing Software development process in, in order to improve the speed of writing of software, developer is when writing function or variable, mostly Number is all to be named by understandable word to function or variable.
But since function or variable are named by understandable word, it is being compiled into target After file, after decompiling instrument dis-assembling, it is easy to guess out function according to the meaning of the name of function or variable by attacker Any function is realized, what meaning variable represents, therefore in certain degree, and there are the risks of source code leakage.
To solve the above-mentioned problems, in the prior art it is most of be all by developer to above-mentioned function or variable name into The mode that row renames manually solves.But this method has following defects that on the one hand, due to needing developer to carry out manually Renaming, therefore efficiency is lower, and needs to waste more human cost and time cost;It on the other hand, can be due to objective The reason of cause leakage to name or wrong name, cause to rename result accuracy rate lower;Meanwhile can also be easy by attacker according to The meaning of leakage name or wrong name guesss out the function of function, and then further causes the problems such as source code is revealed.
Accordingly, it is desirable to provide a kind of new source code processing method and processing device.
It should be noted that the information in the invention of above-mentioned background technology part is only used for reinforcing the reason to background of the invention Solution, therefore may include the information not constituted to the prior art known to persons of ordinary skill in the art.
Summary of the invention
The purpose of the present invention is to provide a kind of source code processing method, source code processing unit, calculate section readable storage medium storing program for executing And electronic equipment, and then knot is renamed caused by overcoming the limitation and defect due to the relevant technologies at least to a certain extent The lower problem of fruit accuracy rate.
According to one aspect of the disclosure, a kind of source code processing method is provided, comprising: by compilation of source code to be processed in Between language, and traverse the intermediate language and obtain function name to be replaced and/or global variable name to be replaced;It generates with described wait replace The several corresponding random function names of exchange the letters, and/or stochastic variable name corresponding with the global variable name to be replaced;Using described Random function name and/or the stochastic variable name are to the function name to be replaced and/or global change to be replaced in the intermediate language Amount name is replaced;Replaced intermediate language is recompilated, object code file is obtained.
In a kind of exemplary embodiment of the disclosure, traverse the intermediate language obtain function name to be replaced and/or to Replacing global variable name includes: to be compiled to the Open Source Code of LLVM, obtains the dynamic base of the LLVM;Utilize the dynamic Library parses the intermediate language, and traverses the intermediate language after parsing, obtains the function name to be replaced and/or wait replace Change global variable name.
In a kind of exemplary embodiment of the disclosure, random function name corresponding with the function name to be replaced is generated, And/or stochastic variable name corresponding with the global variable name to be replaced includes: one randomly generated test problems of configuration;Described in calling Randomly generated test problems, and random function name corresponding with the function name to be replaced is generated using the randomly generated test problems, and/ Or stochastic variable name corresponding with the global variable name to be replaced.
In a kind of exemplary embodiment of the disclosure, random function corresponding with the function name to be replaced is being generated After name, and/or stochastic variable name corresponding with the global variable name to be replaced, the source code processing method further include: build Found the first mapping relations between the function name to be replaced and the random function name;And/or it establishes described to be replaced complete The second mapping relations between office's variable name and the stochastic variable name;First mapping relations and/or the second mapping are closed System is stored.
In a kind of exemplary embodiment of the disclosure, replaced intermediate language is recompilated, target is obtained Code file includes: to traverse the replaced intermediate language again, and judge whether wrap in the replaced intermediate language Include function name to be replaced and/or global variable name to be replaced;If not including letter to be replaced in the replaced intermediate language Global variable name several and/or to be replaced, then recompilate replaced intermediate language, obtain object code file.
In a kind of exemplary embodiment of the disclosure, is recompilated by replaced intermediate language, obtain mesh After marking code file, the source code processing method further include: search next intermediate language corresponding with the intermediate language Whether call the turn includes identical function name to be replaced and/or global variable name to be replaced;If including identical function to be replaced Name and/or global variable name to be replaced, then judge in replaced next intermediate language, replaces identical described wait replace Exchange the letters is several and/or whether the random function name and/or stochastic variable name of global variable name to be replaced are identical;If replaced identical The function name to be replaced and/or global variable name to be replaced random function name and/or stochastic variable name it is identical, then will replace Next intermediate language after changing is recompilated, and next object code file is obtained.
In a kind of exemplary embodiment of the disclosure, random function name corresponding with the function name to be replaced is generated, And/or stochastic variable name corresponding with the global variable name to be replaced further include: search in first mapping relations whether In the presence of random function name corresponding with the function name to be replaced, and/or search in second mapping relations with the presence or absence of with The corresponding stochastic variable name of the global variable name to be replaced;If it does not exist, then generating corresponding with the function name to be replaced Random function name, and/or stochastic variable name corresponding with the global variable name to be replaced.
According to one aspect of the disclosure, a kind of source code processing unit is provided, comprising: intermediate language spider module is used for By compilation of source code to be processed at intermediate language, and traverses the intermediate language and obtain function name to be replaced and/or to be replaced complete Office's variable name;Generation module, for generating random function name corresponding with the function name to be replaced, and/or with described wait replace Change the corresponding stochastic variable name of global variable name;Replacement module, for utilizing the random function name and/or the stochastic variable Name in the intermediate language function name to be replaced and/or global variable name to be replaced be replaced;Collector, being used for will Replaced intermediate language is recompilated, and object code file is obtained.
According to one aspect of the disclosure, a kind of computer readable storage medium is provided, computer program is stored thereon with, The computer program realizes source code processing method described in above-mentioned any one when being executed by processor.
According to one aspect of the disclosure, a kind of electronic equipment is provided, comprising: processor;And
Memory, for storing the executable instruction of the processor;Wherein, the processor is configured to via execution institute Executable instruction is stated to execute source code processing method described in above-mentioned any one.
The embodiment of the present invention provides a kind of source code processing method, by traverse intermediate language obtain function name to be replaced and/ Or global variable name to be replaced;And generate corresponding with function name to be replaced random function name, and/or with global variable to be replaced The corresponding stochastic variable name of name;Then using random function name and/or stochastic variable name to the function to be replaced in intermediate language Name and/or global variable name to be replaced are replaced;Finally replaced intermediate language is recompilated, obtains target generation Code file;On the one hand, function name to be replaced and/or global variable name to be replaced are obtained by traversing intermediate language;And generate with The corresponding random function name of function name to be replaced, and/or stochastic variable name corresponding with global variable name to be replaced;Then it utilizes Random function name and/or stochastic variable name are to the function name to be replaced and/or global variable name to be replaced progress in intermediate language Replacement, solves in the prior art due to needing developer to rename manually, efficiency is lower, and needs to waste more Human cost and the problem of time cost, improve and treat replacement function name and/or global variable name to be replaced is replaced The efficiency changed, while saving human cost and time cost;On the other hand, it solves in the prior art due to objectively former Leakage name or wrong name because caused by, cause to rename the lower problem of result accuracy rate, improve treat replacement function name and/ Or the accuracy rate that global variable name to be replaced is replaced;It is made due to objective in the prior art in another aspect, solving At leakage name, perhaps wrong name leads to the function of being guessd out function according to the meaning of leakage name or wrong name by attacker, in turn The problems such as further causing source code leakage, improves the safety of source code.
It should be understood that above general description and following detailed description be only it is exemplary and explanatory, not It can the limitation present invention.
Detailed description of the invention
The drawings herein are incorporated into the specification and forms part of this specification, and shows and meets implementation of the invention Example, and be used to explain the principle of the present invention together with specification.It should be evident that the accompanying drawings in the following description is only the present invention Some embodiments for those of ordinary skill in the art without creative efforts, can also basis These attached drawings obtain other attached drawings.
Fig. 1 schematically shows a kind of flow chart of source code processing method of basic open example embodiment.
Fig. 2 schematically shows the flow chart of another source code processing method of basic open example embodiment.
Fig. 3 schematically show according to a kind of generation of disclosure example embodiment it is corresponding with the function name to be replaced with Machine function name, and/or the method flow diagram of stochastic variable name corresponding with the global variable name to be replaced.
Fig. 4 schematically shows the flow chart of another source code processing method according to disclosure example embodiment.
Fig. 5 schematically shows the flow chart of another source code processing method of basic open example embodiment.
Fig. 6 schematically shows a kind of block diagram of source code processing unit of basic open example embodiment.
A kind of electronics for realizing above-mentioned source code processing method that Fig. 7 schematically shows basic open example embodiment is set It is standby.
Fig. 8 schematically shows a kind of computer for realizing above-mentioned source code processing method of basic open example embodiment Readable storage medium storing program for executing.
Specific embodiment
Example embodiment is described more fully with reference to the drawings.However, example embodiment can be with a variety of shapes Formula is implemented, and is not understood as limited to example set forth herein;On the contrary, thesing embodiments are provided so that the present invention will more Fully and completely, and by the design of example embodiment comprehensively it is communicated to those skilled in the art.Described feature, knot Structure or characteristic can be incorporated in any suitable manner in one or more embodiments.In the following description, it provides perhaps More details fully understand embodiments of the present invention to provide.It will be appreciated, however, by one skilled in the art that can It is omitted with practicing technical solution of the present invention one or more in the specific detail, or others side can be used Method, constituent element, device, step etc..In other cases, be not shown in detail or describe known solution to avoid a presumptuous guest usurps the role of the host and So that each aspect of the present invention thickens.
In addition, attached drawing is only schematic illustrations of the invention, it is not necessarily drawn to scale.Identical attached drawing mark in figure Note indicates same or similar part, thus will omit repetition thereof.Some block diagrams shown in the drawings are function Energy entity, not necessarily must be corresponding with physically or logically independent entity.These function can be realized using software form Energy entity, or these functional entitys are realized in one or more hardware modules or integrated circuit, or at heterogeneous networks and/or place These functional entitys are realized in reason device device and/or microcontroller device.
A kind of source code processing method is provided firstly in this example embodiment, this method can run on server, clothes Business device cluster or Cloud Server etc., can also run on device end;Certainly, those skilled in the art can also exist according to demand Other platforms run method of the invention, and particular determination is not done to this in the present exemplary embodiment.Refering to what is shown in Fig. 1, the source code Processing method may comprise steps of:
Compilation of source code to be processed at intermediate language, and is traversed the intermediate language and obtains letter to be replaced by step S110. Global variable name several and/or to be replaced.
Step S120. generates random function name corresponding with the function name to be replaced, and/or with the overall situation to be replaced The corresponding stochastic variable name of variable name.
Step S130. using the random function name and/or the stochastic variable name in the intermediate language wait replace Exchange the letters is several and/or global variable name to be replaced is replaced.
Step S140. recompilates replaced intermediate language, obtains object code file.
In above-mentioned source code processing method, on the one hand, obtain function name to be replaced and/or to be replaced by traversing intermediate language Global variable name;And random function name corresponding with function name to be replaced is generated, and/or corresponding with global variable name to be replaced Stochastic variable name;Then using random function name and/or stochastic variable name in intermediate language function name to be replaced and/or to Replacement global variable name is replaced, and is solved in the prior art due to needing developer to rename manually, efficiency It is lower, and the problem of need to waste more human cost and time cost, it improves and treats replacement function name and/or wait replace The efficiency that global variable name is replaced is changed, while saving human cost and time cost;On the other hand, it solves existing The problem that leakage is named or mistake is named, and causes renaming result accuracy rate lower is caused in technology due to objective, is improved Treat the accuracy rate that replacement function name and/or global variable name to be replaced are replaced;In another aspect, solving the prior art In cause leakage name due to objective perhaps wrong name cause to be guessed by attacker according to the meaning of leakage name or wrong name The function of function out, and then the problems such as source code is revealed is further caused, improve the safety of source code.
In the following, will be carried out in conjunction with attached drawing to each step in source code processing method above-mentioned in this example embodiment detailed Explanation and explanation.
In step s 110, it by compilation of source code to be processed at intermediate language, and traverses the intermediate language and obtains wait replace Exchange the letters is several and/or global variable name to be replaced.
In this exemplary embodiment, firstly, explaining and/or illustrating to LLVM.LLVM is framework compiler (compiler) frame system can be used as the backstage of multilingual compiler to use.Also, program word can also be carried out Compiling duration optimization, link optimized, the compiled online optimization, code building of speech.Further, it can use LLVM for source to be processed Code is compiled into intermediate language, then traverses the intermediate language again and obtains function name to be replaced and/or global variable name to be replaced.
Specifically, traversing, the intermediate language obtains function name to be replaced and/or global variable name to be replaced may include: Firstly, the Open Source Code to LLVM is compiled, the dynamic base of the LLVM is obtained;Then, using the dynamic base to described Intermediate language is parsed, and traverses the intermediate language after parsing, obtains the function name to be replaced and/or global change to be replaced Measure name.Specifically:
Firstly, it is necessary to which the Open Source Code of LLVM is compiled, libLLVM.dylib dynamic base is generated;Then, volume is found out It translates and compiles the compiler directive that source file generates .o in project;Finally, modification compiler directive, in addition compiling parameter-emit-llvm is raw At the intermediate language (such as can be .bc file) of above-mentioned source code to be processed;It further, can after generating intermediate language Intermediate language is parsed with integrated libLLVM.dylib dynamic base, then is traversed all in the intermediate language after parsing The function name and/or global variable name (function name to be replaced and/or global variable name) for needing to obscure.
It should be added that if there is only function name to be replaced or there is only the overall situations to be replaced in a certain source code Variable name then only needs to generate corresponding random function name or stochastic variable name, hereafter similar if it exists The case where, it is also processed similarly, therefore no longer repeat one by one.
In the step s 120, generate random function name corresponding with the function name to be replaced, and/or with it is described to be replaced The corresponding stochastic variable name of global variable name.
In this exemplary embodiment, firstly, one randomly generated test problems of configuration;Then, the randomly generated test problems are called, And random function name corresponding with the function name to be replaced is generated using the randomly generated test problems, and/or with described wait replace Change the corresponding stochastic variable name of global variable name.Herein it should be added that, in order to further improve the safety of source code Property, avoiding causing leakage name due to objective, perhaps wrong name causes by attacker according to leakage name or wrong name Meaning guesss out the function of function, and then further causes the problems such as source code is revealed, and can configure a randomly generated test problems;When need When generating random function name and/or stochastic variable name, it can use the randomly generated test problems and generate and function name pair to be replaced The random function name answered, and/or stochastic variable name corresponding with global variable name to be replaced.
In step s 130, using the random function name and/or the stochastic variable name in the intermediate language Function name to be replaced and/or global variable name to be replaced are replaced.
In this exemplary embodiment, after obtaining above-mentioned random function name and/or stochastic variable name, can use respectively to The corresponding random function name of replacement function name and/or the corresponding stochastic variable name of each global variable name to be replaced are to above-mentioned intermediate language The function name to be replaced and/or global variable name to be replaced called the turn is replaced.By this way, solve in the prior art by In needing developer to rename manually, therefore efficiency is lower, and needs to waste more human cost and time cost The problem of, the efficiency for treating that replacement function name and/or global variable name to be replaced are replaced is improved, while saving manpower Cost and time cost.
In step S140, replaced intermediate language is recompilated, object code file is obtained.
In this example embodiment, firstly, traverse the replaced intermediate language again, and after judging the replacement Intermediate language in whether include function name to be replaced and/or global variable name to be replaced;Secondly, if it is described it is replaced in Between do not include function name to be replaced and/or global variable name to be replaced in language, then replaced intermediate language is carried out again Compiling, obtains object code file.In this way, ensuring no longer includes the function name that do not replace in above-mentioned intermediate language And/or global variable name, and then further improve the safety of source code.
Further, after obtaining above-mentioned object code file, which can also include: by multiple institutes It states object code file to be linked, obtain to operating file.For example, above-mentioned code file of not marking can be .o file;When whole After the completion of all tape handling source codes are all handled in a project, obtained multiple .o files can be linked, obtain target File;The file destination is the file after obscuring.
Fig. 2 schematically shows another source code processing method of basic open example embodiment.Refering to what is shown in Fig. 2, the source Code processing method can also include step S210, step S220 and step S230, be described in detail below.
In step S210, the first mapping established between the function name to be replaced and the random function name is closed System.And/or
In step S220, the second mapping established between the global variable name to be replaced and the stochastic variable name is closed System.
In step S230, first mapping relations and/or the second mapping relations are stored.
In the following, will step S210- step S230 be explained and be illustrated.Firstly, when obtaining above-mentioned random function name And/or after stochastic variable name, each function to be replaced and random function corresponding with the function to be replaced can be established respectively The first mapping relations between name;And establish each global variable name to be replaced and corresponding with the global variable name to be replaced Then the second mapping relations between stochastic variable name again store first mapping relations and/or the second mapping relations. It, can be in this way, when encountering identical function name to be replaced and/or global variable name to be replaced in the same project According to the mapping relations, directly it is replaced using existing random function name and/or stochastic variable name, on the one hand, keep away The lower problem of efficiency caused by generating again is exempted to need;On the other hand, it can be ensured that same wait replace in the same project It is identical when exchange the letters is several and/or stochastic variable name to be replaced uses random function name and/or stochastic variable name, it can keep The uniqueness of one variable name, improve treat replacement function name and/or global variable name to be replaced be replaced it is accurate Rate.
Fig. 3 schematically show according to a kind of generation of disclosure example embodiment it is corresponding with the function name to be replaced with Machine function name, and/or the method flow diagram of stochastic variable name corresponding with the global variable name to be replaced.Refering to what is shown in Fig. 3, Generate random function name corresponding with the function name to be replaced, and/or it is corresponding with the global variable name to be replaced at random Variable name may include step S310 and step S320, be described in detail below.
In step s310, search in first mapping relations with the presence or absence of it is corresponding with the function name to be replaced with Machine function name, and/or search in second mapping relations with the presence or absence of corresponding with the global variable name to be replaced random Variable name.
In step s 320, if it does not exist, then generating random function name corresponding with the function name to be replaced, and/ Or stochastic variable name corresponding with the global variable name to be replaced.
Further, it is shown in Fig. 3 go out example embodiment in, if in the first mapping relations exist and function to be replaced There is stochastic variable name corresponding with global variable name to be replaced in the corresponding random function of name and/or the second mapping relations, then It can directly be obtained from first mapping relations and/or second mapping relations.Specifically, can be based on above-mentioned first mapping Relationship and/or the second mapping relations are inquired.In this way, further improve treat replacement function name and/or to The efficiency that replacement global variable name is replaced.
Fig. 4 schematically shows another source code processing method flow chart according to disclosure example embodiment.With reference to Fig. 4 institute Show, which can also include step S410, step S420 and step S430, be described in detail below.
In step S410, search in corresponding with the intermediate language next intermediate language whether including it is identical to Replacement function name and/or global variable name to be replaced.
In the step s 420, if including identical function name to be replaced and/or global variable name to be replaced, judge institute It states in replaced next intermediate language, replaces the identical function name to be replaced and/or global variable name to be replaced Whether random function name and/or stochastic variable name are identical.
In step S430, if replace the identical function name to be replaced and/or global variable name to be replaced with Machine function name and/or stochastic variable name are identical, then recompilate replaced intermediate language, obtain next target generation Code file.
In example embodiment out shown in Fig. 4, if replacing the identical replacement function name and/or the overall situation to be replaced The random function name and/or stochastic variable name of variable name be not identical, then needs to modify to it.Also, due to the same item It may include multiple source codes to be processed in mesh, and then also may include multiple intermediate languages;Therefore, can be sentenced by the above method What the same function name to be replaced in the intermediate language of the same source code to be processed of breaking and/or stochastic variable name to be replaced used Random function name and/or stochastic variable name Shi Xiangtong;And it is further desired that judging same in the intermediate language of other source codes to be processed The random function name and/or stochastic variable name Shi Xiangtong that one function name to be replaced and/or stochastic variable name to be replaced use.
Further, in the same of the function name to be replaced and/or global variable name to be replaced for replacing some intermediate file When, the function to be replaced and/or global variable to be replaced in other intermediate files with same name are required to look up, then will be looked into The function to be replaced and/or global variable to be replaced of the same name found are replaced together.In this way, allowing to Ensure in the same project, the random function name that the same function name to be replaced and/or stochastic variable name to be replaced use and/ Or it is identical when stochastic variable name, the uniqueness of a variable name can be kept.Herein it should be added that, in order into The safety of the raising source code of one step, the identical function name to be replaced and/or global variable name to be replaced in disparity items are corresponding Random function name and/or stochastic variable name be different.
Fig. 5 schematically shows another source code processing method according to disclosure example embodiment.Refering to what is shown in Fig. 5, should Source code processing method may comprise steps of:
Source file to be processed is compiled into intermediate language by step S510;
Step S520, integrated libLLVM.dylib dynamic base parses intermediate language, then traverses the centre after parsing The function name and global variable name that institute's some need in language is obscured;
Step S530 judges in the first mapping relations and the/the second mapping relations with the presence or absence of the function name pair for needing to obscure The corresponding stochastic variable name of random function name and/or global variable name answered;If it is present the S550 that gos to step;If It is not present, then go to step S540;
Step S540, calls random function, and using the random function generate it is corresponding with the function name obscured of needs with Machine function name and/or the corresponding stochastic variable name of global variable name;
Step S550, using random function name and/or stochastic variable name to the function name and/or global variable for needing to obscure Name is replaced;
The intermediate language that replacement is completed is compiled by step S560, generates .o file;And multiple .o files are subjected to chain It connects, forms file destination.
The disclosure additionally provides a kind of source code processing unit.Refering to what is shown in Fig. 6, the source code processing unit may include centre Language spider module 610, generation module 620, replacement module 630 and collector 640.Wherein:
Intermediate language spider module 610 can be used for compilation of source code to be processed using LLVM into intermediate language, and time It goes through the intermediate language and obtains function name to be replaced and/or global variable name to be replaced.
Generation module 620 can be used for generating random function name corresponding with the function name to be replaced, and/or with it is described The corresponding stochastic variable name of global variable name to be replaced.
Replacement module 630 can be used for using the random function name and/or the stochastic variable name to the intermediate language The function name to be replaced and/or global variable name to be replaced called the turn is replaced.
Collector 640 can be used for recompilating replaced intermediate language, obtain object code file.
In the exemplary embodiment, generation module 620 can be additionally configured to: one randomly generated test problems of configuration;It calls The randomly generated test problems, and random function corresponding with the function name to be replaced is generated using the randomly generated test problems Name, and/or stochastic variable name corresponding with the global variable name to be replaced.
In the exemplary embodiment, the source code processing unit can also include the first mapping relations establish module and/or Second mapping relations establish module and memory module.Wherein, first mapping relations establish module for establish it is described to The first mapping relations between replacement function name and the random function name.Second mapping relations establish module for building Found the second mapping relations between the global variable name to be replaced and the stochastic variable name.The memory module is used for institute It states the first mapping relations and/or the second mapping relations is stored.
In the exemplary embodiment, collector 640 can be additionally configured to: traverse the replaced intermediate language again Speech, and judge in the replaced intermediate language whether to include function name to be replaced and/or global variable name to be replaced;If Do not include function name to be replaced and/or global variable name to be replaced in the replaced intermediate language, then will be replaced in Between language recompilated, obtain object code file.
In the exemplary embodiment, the source code processing unit can also include: searching module, can be used for lookup and institute Whether state in the corresponding next intermediate language of intermediate language includes identical function name to be replaced and/or global variable to be replaced Name;Judgment module judges institute if can be used for includes identical function name to be replaced and/or global variable name to be replaced It states in replaced next intermediate language, replaces the identical function name to be replaced and/or global variable name to be replaced Whether random function name and/or stochastic variable name are identical;Processing module, if can be used for replacing the identical letter to be replaced The random function name and/or stochastic variable name of global variable name several and/or to be replaced are identical, then by replaced intermediate language It is recompilated, obtains next object code file.
In the exemplary embodiment, generation module 620 can be additionally configured to: search in first mapping relations whether In the presence of random function name corresponding with the function name to be replaced, and/or search in second mapping relations with the presence or absence of with The corresponding stochastic variable name of the global variable name to be replaced;If it does not exist, then generating corresponding with the function name to be replaced Random function name, and/or stochastic variable name corresponding with the global variable name to be replaced.
The detail of each module has carried out in corresponding source code processing method in detail in above-mentioned source code processing unit Thin description, therefore details are not described herein again.
It should be noted that although being referred to several modules or list for acting the equipment executed in the above detailed description Member, but this division is not enforceable.In fact, embodiment according to the present invention, it is above-described two or more Module or the feature and function of unit can embody in a module or unit.Conversely, an above-described mould The feature and function of block or unit can be to be embodied by multiple modules or unit with further division.
In addition, although describing each step of method in the present invention in the accompanying drawings with particular order, this does not really want These steps must be executed in this particular order by asking or implying, or having to carry out step shown in whole could realize Desired result.Additional or alternative, it is convenient to omit multiple steps are merged into a step and executed by certain steps, or One step is decomposed into execution of multiple steps etc..
Through the above description of the embodiments, those skilled in the art is it can be readily appreciated that example described herein is implemented Mode can also be realized by software realization in such a way that software is in conjunction with necessary hardware.Therefore, according to the present invention The technical solution of embodiment can be embodied in the form of software products, which can store non-volatile at one Property storage medium (can be CD-ROM, USB flash disk, mobile hard disk etc.) in or network on, including some instructions are so that a calculating Equipment (can be personal computer, server, mobile terminal or network equipment etc.) executes embodiment according to the present invention Method.
In an exemplary embodiment of the present invention, a kind of electronic equipment that can be realized the above method is additionally provided.
Person of ordinary skill in the field it is understood that various aspects of the invention can be implemented as system, method or Program product.Therefore, various aspects of the invention can be embodied in the following forms, it may be assumed that complete hardware embodiment, complete The embodiment combined in terms of full Software Implementation (including firmware, microcode etc.) or hardware and software, can unite here Referred to as circuit, " module " or " system ".
The electronic equipment 700 of this embodiment according to the present invention is described referring to Fig. 7.The electronics that Fig. 7 is shown Equipment 700 is only an example, should not function to the embodiment of the present invention and use scope bring any restrictions.
As shown in fig. 7, electronic equipment 700 is showed in the form of universal computing device.The component of electronic equipment 700 can wrap It includes but is not limited to: at least one above-mentioned processing unit 710, at least one above-mentioned storage unit 720, the different system components of connection The bus 730 of (including storage unit 720 and processing unit 710).
Wherein, the storage unit is stored with program code, and said program code can be held by the processing unit 710 Row, so that various according to the present invention described in the execution of the processing unit 710 above-mentioned " illustrative methods " part of this specification The step of illustrative embodiments.For example, the processing unit 710 can execute step as shown in fig. 1: step S110. By compilation of source code to be processed at intermediate language, and traverses the intermediate language and obtain function name to be replaced and/or to be replaced complete Office's variable name;Step S120. generates random function name corresponding with the function name to be replaced, and/or with it is described it is to be replaced entirely The corresponding stochastic variable name of office's variable name;Step S130. is using the random function name and/or the stochastic variable name to described Function name to be replaced and/or global variable name to be replaced in intermediate language are replaced;Step S140. is by replaced centre Language is recompilated, and object code file is obtained.
Storage unit 720 may include the readable medium of volatile memory cell form, such as Random Access Storage Unit (RAM) 7201 and/or cache memory unit 7202, it can further include read-only memory unit (ROM) 7203.
Storage unit 720 can also include program/utility with one group of (at least one) program module 7205 7204, such program module 7205 includes but is not limited to: operating system, one or more application program, other program moulds It may include the realization of network environment in block and program data, each of these examples or certain combination.
Bus 730 can be to indicate one of a few class bus structures or a variety of, including storage unit bus or storage Cell controller, peripheral bus, graphics acceleration port, processing unit use any bus structures in a variety of bus structures Local bus.
Electronic equipment 700 can also be with one or more external equipments 770 (such as keyboard, sensing equipment, bluetooth equipment Deng) communication, can also be enabled a user to one or more equipment interact with the electronic equipment 700 communicate, and/or with make Any equipment (such as the router, modulation /demodulation that the electronic equipment 700 can be communicated with one or more of the other calculating equipment Device etc.) communication.This communication can be carried out by input/output (I/O) interface 750.Also, electronic equipment 700 can be with By network adapter 760 and one or more network (such as local area network (LAN), wide area network (WAN) and/or public network, Such as internet) communication.As shown, network adapter 760 is communicated by bus 730 with other modules of electronic equipment 700. It should be understood that although not shown in the drawings, other hardware and/or software module can not used in conjunction with electronic equipment 700, including but not Be limited to: microcode, device driver, redundant processing unit, external disk drive array, RAID system, tape drive and Data backup storage system etc..
Through the above description of the embodiments, those skilled in the art is it can be readily appreciated that example described herein is implemented Mode can also be realized by software realization in such a way that software is in conjunction with necessary hardware.Therefore, according to the present invention The technical solution of embodiment can be embodied in the form of software products, which can store non-volatile at one Property storage medium (can be CD-ROM, USB flash disk, mobile hard disk etc.) in or network on, including some instructions are so that a calculating Equipment (can be personal computer, server, terminal installation or network equipment etc.) executes embodiment according to the present invention Method.
In an exemplary embodiment of the present invention, a kind of computer readable storage medium is additionally provided, energy is stored thereon with Enough realize the program product of this specification above method.In some possible embodiments, various aspects of the invention may be used also In the form of being embodied as a kind of program product comprising program code, when described program product is run on the terminal device, institute Program code is stated for executing the terminal device described in above-mentioned " illustrative methods " part of this specification according to this hair The step of bright various illustrative embodiments.
Refering to what is shown in Fig. 8, describing the program product for realizing the above method of embodiment according to the present invention 800, can using portable compact disc read only memory (CD-ROM) and including program code, and can in terminal device, Such as it is run on PC.However, program product of the invention is without being limited thereto, in this document, readable storage medium storing program for executing can be with To be any include or the tangible medium of storage program, the program can be commanded execution system, device or device use or It is in connection.
Described program product can be using any combination of one or more readable mediums.Readable medium can be readable letter Number medium or readable storage medium storing program for executing.Readable storage medium storing program for executing for example can be but be not limited to electricity, magnetic, optical, electromagnetic, infrared ray or System, device or the device of semiconductor, or any above combination.The more specific example of readable storage medium storing program for executing is (non exhaustive List) include: electrical connection with one or more conducting wires, portable disc, hard disk, random access memory (RAM), read-only Memory (ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disc read only memory (CD-ROM), light storage device, magnetic memory device or above-mentioned any appropriate combination.
Computer-readable signal media may include in a base band or as carrier wave a part propagate data-signal, In carry readable program code.The data-signal of this propagation can take various forms, including but not limited to electromagnetic signal, Optical signal or above-mentioned any appropriate combination.Readable signal medium can also be any readable Jie other than readable storage medium storing program for executing Matter, the readable medium can send, propagate or transmit for by instruction execution system, device or device use or and its The program of combined use.
The program code for including on readable medium can transmit with any suitable medium, including but not limited to wirelessly, have Line, optical cable, RF etc. or above-mentioned any appropriate combination.
The program for executing operation of the present invention can be write with any combination of one or more programming languages Code, described program design language include object oriented program language-Java, C++ etc., further include conventional Procedural programming language-such as " C " language or similar programming language.Program code can be fully in user It calculates and executes in equipment, partly executes on a user device, being executed as an independent software package, partially in user's calculating Upper side point is executed on a remote computing or is executed in remote computing device or server completely.It is being related to far Journey calculates in the situation of equipment, and remote computing device can pass through the network of any kind, including local area network (LAN) or wide area network (WAN), it is connected to user calculating equipment, or, it may be connected to external computing device (such as utilize ISP To be connected by internet).
In addition, above-mentioned attached drawing is only the schematic theory of processing included by method according to an exemplary embodiment of the present invention It is bright, rather than limit purpose.It can be readily appreciated that the time that above-mentioned processing shown in the drawings did not indicated or limited these processing is suitable Sequence.In addition, be also easy to understand, these processing, which can be, for example either synchronously or asynchronously to be executed in multiple modules.
Those skilled in the art will readily occur to of the invention its after considering specification and the invention invented here of practice His embodiment.This application is intended to cover any variations, uses, or adaptations of the invention, these modifications, purposes or Adaptive change follow general principle of the invention and the common knowledge in the art do not invented including the present invention or Conventional techniques.The description and examples are only to be considered as illustrative, and true scope and spirit of the invention are by claim It points out.

Claims (10)

1. a kind of source code processing method characterized by comprising
By compilation of source code to be processed at intermediate language, and traverses the intermediate language and obtain function name to be replaced and/or wait replace Change global variable name;
Random function name corresponding with the function name to be replaced is generated, and/or corresponding with the global variable name to be replaced Stochastic variable name;
Using the random function name stochastic variable name to function name to be replaced in the intermediate language and/or to be replaced Global variable name is replaced;
Replaced intermediate language is recompilated, object code file is obtained.
2. source code processing method according to claim 1, which is characterized in that traverse the intermediate language and obtain letter to be replaced Global variable name several and/or to be replaced includes:
The Open Source Code of LLVM is compiled, the dynamic base of the LLVM is obtained;
The intermediate language is parsed using the dynamic base, and traverses the intermediate language after parsing, is obtained described wait replace Exchange the letters is several and/or global variable name to be replaced.
3. source code processing method according to claim 1, which is characterized in that generate corresponding with the function name to be replaced Random function name, and/or stochastic variable name corresponding with the global variable name to be replaced includes:
Configure a randomly generated test problems;
Call the randomly generated test problems, and using the randomly generated test problems generate it is corresponding with the function name to be replaced with Machine function name, and/or stochastic variable name corresponding with the global variable name to be replaced.
4. source code processing method according to claim 1, which is characterized in that corresponding with the function name to be replaced generating Random function name, and/or after stochastic variable name corresponding with the global variable name to be replaced, the source code processing method Further include:
Establish the first mapping relations between the function name to be replaced and the random function name;And/or
Establish the second mapping relations between the global variable name to be replaced and the stochastic variable name;
First mapping relations and/or the second mapping relations are stored.
5. source code processing method according to claim 1, which is characterized in that compiled replaced intermediate language again It translates, obtaining object code file includes:
The replaced intermediate language is traversed again, and judges in the replaced intermediate language whether to include letter to be replaced Global variable name several and/or to be replaced;
If not including function name to be replaced and/or global variable name to be replaced in the replaced intermediate language, will replace Intermediate language after changing is recompilated, and object code file is obtained.
6. source code processing method according to claim 1, which is characterized in that carried out again by replaced intermediate language Compiling, after obtaining object code file, the source code processing method further include:
Search in corresponding with the intermediate language next intermediate language whether including identical function name to be replaced and/or to Replace global variable name;
If judged described replaced next including identical function name to be replaced and/or global variable name to be replaced In intermediate language, replace the identical function name to be replaced and/or global variable name to be replaced random function name and/or with Whether machine variable name is identical;
If replacing the random function name of the identical function name to be replaced and/or global variable name to be replaced and/or random Variable name is identical, then recompilates replaced next intermediate language, obtain next object code file.
7. source code processing method according to claim 4, which is characterized in that generate corresponding with the function name to be replaced Random function name, and/or stochastic variable name corresponding with the global variable name to be replaced further include:
It searches with the presence or absence of random function name corresponding with the function name to be replaced in first mapping relations, and/or looks into It looks in second mapping relations with the presence or absence of stochastic variable name corresponding with the global variable name to be replaced;
If it does not exist, then generate random function name corresponding with the function name to be replaced, and/or with the overall situation to be replaced The corresponding stochastic variable name of variable name.
8. a kind of source code processing unit characterized by comprising
Intermediate language spider module is used for compilation of source code to be processed into intermediate language, and traverses the intermediate language and obtain Function name to be replaced and/or global variable name to be replaced;
Generation module, for generating random function name corresponding with the function name to be replaced, and/or with the overall situation to be replaced The corresponding stochastic variable name of variable name;
Replacement module, for using the random function name and/or the stochastic variable name in the intermediate language wait replace Exchange the letters is several and/or global variable name to be replaced is replaced;
Collector obtains object code file for recompilating replaced intermediate language.
9. a kind of computer readable storage medium, is stored thereon with computer program, which is characterized in that the computer program quilt Claim 1-7 described in any item source code processing methods are realized when processor executes.
10. a kind of electronic equipment characterized by comprising
Processor;And
Memory, for storing the executable instruction of the processor;
Wherein, the processor is configured to require 1-7 described in any item via executing the executable instruction and carry out perform claim Source code processing method.
CN201910319622.3A 2019-04-19 2019-04-19 Source code processing method and device, storage medium and electronic equipment Active CN110058861B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910319622.3A CN110058861B (en) 2019-04-19 2019-04-19 Source code processing method and device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910319622.3A CN110058861B (en) 2019-04-19 2019-04-19 Source code processing method and device, storage medium and electronic equipment

Publications (2)

Publication Number Publication Date
CN110058861A true CN110058861A (en) 2019-07-26
CN110058861B CN110058861B (en) 2020-11-10

Family

ID=67319836

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910319622.3A Active CN110058861B (en) 2019-04-19 2019-04-19 Source code processing method and device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN110058861B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110688320A (en) * 2019-09-30 2020-01-14 潍柴动力股份有限公司 Global variable detection method and device and terminal equipment
CN114461216A (en) * 2021-12-22 2022-05-10 科东(广州)软件科技有限公司 File compiling method and device, electronic equipment and storage medium
CN114546480A (en) * 2022-04-26 2022-05-27 天津所托瑞安汽车科技有限公司 Code automatic integration method, device and readable storage medium
CN116501332A (en) * 2023-06-30 2023-07-28 牛芯半导体(深圳)有限公司 Language conversion method, device, equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103218433A (en) * 2013-04-15 2013-07-24 北京邮电大学 Method and module for managing metadata applied to random access
CN103218549A (en) * 2012-01-19 2013-07-24 阿里巴巴集团控股有限公司 Method and device for encrypting and decrypting Java source code
CN105005718A (en) * 2015-06-23 2015-10-28 电子科技大学 Method for implementing code obfuscation by Markov chain
CN107908933A (en) * 2017-11-08 2018-04-13 北京顶象技术有限公司 A kind of character string encryption method based on intermediate language
US20190095181A1 (en) * 2017-09-15 2019-03-28 Tmaxsoft Co., Ltd Easy-To-Use Type Of Compile-Time Dependency Injection Method And Device In The Java Platform

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103218549A (en) * 2012-01-19 2013-07-24 阿里巴巴集团控股有限公司 Method and device for encrypting and decrypting Java source code
CN103218433A (en) * 2013-04-15 2013-07-24 北京邮电大学 Method and module for managing metadata applied to random access
CN105005718A (en) * 2015-06-23 2015-10-28 电子科技大学 Method for implementing code obfuscation by Markov chain
US20190095181A1 (en) * 2017-09-15 2019-03-28 Tmaxsoft Co., Ltd Easy-To-Use Type Of Compile-Time Dependency Injection Method And Device In The Java Platform
CN107908933A (en) * 2017-11-08 2018-04-13 北京顶象技术有限公司 A kind of character string encryption method based on intermediate language

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110688320A (en) * 2019-09-30 2020-01-14 潍柴动力股份有限公司 Global variable detection method and device and terminal equipment
CN114461216A (en) * 2021-12-22 2022-05-10 科东(广州)软件科技有限公司 File compiling method and device, electronic equipment and storage medium
CN114461216B (en) * 2021-12-22 2022-11-11 科东(广州)软件科技有限公司 File compiling method and device, electronic equipment and storage medium
CN114546480A (en) * 2022-04-26 2022-05-27 天津所托瑞安汽车科技有限公司 Code automatic integration method, device and readable storage medium
CN114546480B (en) * 2022-04-26 2022-08-19 天津所托瑞安汽车科技有限公司 Code automatic integration method, device and readable storage medium
CN116501332A (en) * 2023-06-30 2023-07-28 牛芯半导体(深圳)有限公司 Language conversion method, device, equipment and storage medium
CN116501332B (en) * 2023-06-30 2023-09-29 牛芯半导体(深圳)有限公司 Language conversion method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN110058861B (en) 2020-11-10

Similar Documents

Publication Publication Date Title
CN110058861A (en) Source code processing method and processing device, storage medium, electronic equipment
CN103853596B (en) For the method and system for migrating virtual machine between working group
US20230237277A1 (en) Aspect prompting framework for language modeling
CN111814951B (en) Debugging deep neural network
CN109491653A (en) Component sharing method under micro services framework, device, electronic equipment
CN110502227A (en) The method and device of code completion, storage medium, electronic equipment
JP2023520415A (en) Methods and systems for target-based hyperparameter tuning
CN110059456A (en) Code protection method, code protection device, storage medium and electronic equipment
US11061739B2 (en) Dynamic infrastructure management and processing
CN111435362B (en) Antagonistic training data enhancement for generating a correlation response
US10628465B2 (en) Generating a ranked list of best fitting place names
CN109509048A (en) The recognition methods of malice order, device, electronic equipment and storage medium
CN110059113B (en) Method, system and computer readable storage medium for processing queries
JP2015508918A (en) Redundant consumer transaction rule filtering
CN106951248A (en) Add method, device and the readable storage medium storing program for executing of code
CN110782000A (en) Mimic learning by action shaping with antagonistic reinforcement learning
CN109522010A (en) Initial code adding method and device, storage medium, electronic equipment
CN118114771B (en) Function tool calling method and device in trusted execution environment, medium and equipment
US20150199332A1 (en) Browsing history language model for input method editor
US10891431B2 (en) Populating electronic form data
US20160306641A1 (en) Modeling memory use of applications
CN109684207A (en) Method, apparatus, electronic equipment and the storage medium of sequence of operation encapsulation
CN116263813A (en) Improving classification and regression tree performance by dimension reduction
CN109254816A (en) material processing method and device, storage medium and electronic equipment
CN114897664A (en) Graph model deployment method and device, GPU (graphics processing Unit) and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for 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: 20210913

Address after: 311121 room 607-609, building 18, No. 998, Wenyi West Road, Wuchang Street, Yuhang District, Hangzhou City, Zhejiang Province

Patentee after: Tongdun Network Technology Co.,Ltd.

Address before: Room 704, building 18, No. 998, Wenyi West Road, Wuchang Street, Yuhang District, Hangzhou City, Zhejiang Province

Patentee before: TONGDUN HOLDINGS Co.,Ltd.

TR01 Transfer of patent right