CN113672984A - Link method based on file structure design and readable storage medium - Google Patents

Link method based on file structure design and readable storage medium Download PDF

Info

Publication number
CN113672984A
CN113672984A CN202110982013.3A CN202110982013A CN113672984A CN 113672984 A CN113672984 A CN 113672984A CN 202110982013 A CN202110982013 A CN 202110982013A CN 113672984 A CN113672984 A CN 113672984A
Authority
CN
China
Prior art keywords
module
component
file
called
address
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
CN202110982013.3A
Other languages
Chinese (zh)
Other versions
CN113672984B (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.)
Wuhan Tianyu Information Industry Co Ltd
Original Assignee
Wuhan Tianyu Information Industry 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 Wuhan Tianyu Information Industry Co Ltd filed Critical Wuhan Tianyu Information Industry Co Ltd
Priority to CN202110982013.3A priority Critical patent/CN113672984B/en
Publication of CN113672984A publication Critical patent/CN113672984A/en
Application granted granted Critical
Publication of CN113672984B publication Critical patent/CN113672984B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/629Protecting access to data via a platform, e.g. using keys or access control rules to features or functions of an application
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/447Target code generation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • G06F9/449Object-oriented method invocation or resolution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2221/00Indexing scheme relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F2221/21Indexing scheme relating to G06F21/00 and subgroups addressing additional information or applications relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F2221/2141Access rights, e.g. capability lists, access control lists, access tables, access matrices

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Computer Security & Cryptography (AREA)
  • Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • Devices For Executing Special Programs (AREA)
  • Stored Programmes (AREA)

Abstract

The invention provides a linking method based on file structure design and a readable storage medium, wherein the linking method based on the file structure design comprises the following steps: generating target files of different modules by the byte codes generated in the compiler according to a file structure; generating a download script which can be identified by a security module by the target file through a conversion tool; when a downloading instruction is received, downloading and installing the downloading script into the safety module, wherein in the downloading and installing process, the method linkage between different modules is completed according to the file structures of different modules in the downloading script; when a method calling request exists, jumping to the physical address of the method called by the request according to the link of the method called by the request to execute the method. The invention can reduce the file volume and improve the operation efficiency, and simultaneously realizes the security characteristic which is equal to the security module of the file structure design of the traditional Java language virtual machine.

Description

Link method based on file structure design and readable storage medium
Technical Field
The invention relates to the field of storage design of resource-limited equipment, in particular to a link method based on file structure design and a readable storage medium.
Background
In the prior art, devices with limited resources and high requirements for security performance, such as smart cards, internet of things security devices and security modules, are all virtual machines integrating Java language on embedded systems, so that a local native method is realized, an API interface of the Java language is provided for the outside, and secondary development is provided for the outside by the Java language. When the traditional Java virtual machine provides secondary development to the outside in the Java language, the same function is realized, and the memory space occupied by the target binary file generated according to the file structure design of the Java virtual machine is much more than that occupied by C language programming. In addition, in terms of functional operation, because the traditional virtual machine in the Java language needs dynamic searching and other steps when calling the method according to the generated binary file structure, the operation efficiency is slower than that of a C language virtual machine which performs partial bytecode optimization in advance by using a compiler on expressions and logical operations, and the use cost of the traditional virtual machine in the Java language is higher. And different functions of the C language virtual machine can be developed in parallel by adopting different modules compared with the traditional Java language virtual machine, and a user can also set a firewall mechanism between different modules according to the safety characteristics of the user product in use design, so that the access between the modules follows a certain safety access strategy, and the safety characteristics which are the same as the safety characteristics of the traditional Java language virtual machine are realized.
Disclosure of Invention
The invention mainly aims to provide a linking method based on file structure design and a readable storage medium, and aims to solve the technical problems of Java virtual machine operation efficiency and memory space optimization under the same security characteristic in the prior art.
In a first aspect, the present invention provides a linking method based on file structure design, where the linking method based on file structure design includes the following steps:
generating target files of different modules by byte codes generated in a compiler according to a file structure, wherein the file structure comprises: the system comprises a module head component, a module application component, a module constant component, a module file component, a module method component and a module index component;
generating a download script which can be identified by a security module by the target file through a conversion tool;
when a downloading instruction is received, downloading and installing the downloading script into the safety module, wherein in the downloading and installing process, the method linkage between different modules is completed according to the file structures of different modules in the downloading script;
when a method calling request exists, jumping to the physical address of the method called by the request according to the link of the method called by the request to execute the method.
Optionally, the structure of the module head assembly includes the identification number and version number information of the module and the length description of other assemblies in the file structure of the module.
Optionally, if the module is a non-application module, the length of a module application component of the non-application module is 0; and if the module is an application module, the length of a module application component of the application module is not 0, wherein the structure of the module application component of the application module comprises an identification number of the application and a physical address index of an entry function of the application.
Optionally, the structure of the module constant component includes the number of the external referenced modules, the identification number and version number information of the external referenced modules, and a constant structure of the external referenced modules, where the constant structure of the external referenced modules includes a distinguishing identifier of a system method and a non-system method, index numbers of referenced modules in which all called methods are located in the external referenced module structure, and address offsets of all called methods.
Optionally, if the module is a non-system module, the length of the module file component of the non-system module is 0; and if the module is a system module, the length of a module application component of the system module is not 0, wherein the module file component structure of the system module comprises the total number of files in the system module, an array form of the total number of methods of each file in the system file and a method address index number of each file in the system file.
Optionally, the module method component includes a bytecode implementation of internal functions of all methods in the module, where the bytecode implementation includes the number of parameters of all methods, the total number of bytes of local variables, and a bytecode set of executable codes of all methods.
Optionally, the structure of the module index component includes address offsets of all methods to be linked in the method component of the module, and an address index of a constant structure in the module constant component of the external referenced module where the linked method is located.
Optionally, in the downloading and installing process, the step of completing the linking of the method between different modules according to the file structures of different modules in the downloading script includes:
finding a first address offset of a calling method relative to a method component base address of a reference module through an index component of the reference module, and obtaining a calling relation between the calling method and a called method of the referenced module according to the first offset;
after the index number of the referenced module in the constant component of the referencing module is found by the index component of the referencing module, jumping to a constant structure body of the referenced module corresponding to the constant component of the referencing module;
finding the identification number and the version number of the led module through the constant structure body;
judging whether the called method is a system method or not through a distinguishing identifier in a constant component of the reference module;
if the called method is a non-system method, finding a second address offset of the called method relative to a method component base address of the called module in a constant structure body of the called module;
finding the address of the introduced module according to the identification number and the version number of the introduced module, and finding the method component base address of the introduced module according to the address of the introduced module;
finding the physical address of the called method according to the method component base address of the called module and the second address offset;
completing the link between the calling method and the called method based on the physical address of the called method;
if the called method is a system method, finding the address of the guided module according to the identification number and the version number of the guided module, and finding the method component base address of the guided module according to the address of the guided module;
using high bytes of address offset in a constant structure body of the attracted module as a file index number, and finding a file where the called method is located from a plurality of files contained in a file assembly of the attracted module;
using the low byte of the address offset in the constant structure body of the referenced module as a method index number, and finding the physical address of the called method from the file where the called method is located;
and replacing the address offset in the constant structure body of the referenced module by the physical address to complete the linkage of the calling method and the called method.
In a second aspect, the present invention further provides a readable storage medium, on which a linking program designed based on a file structure is stored, wherein when the linking program designed based on the file structure is executed by a processor, the steps of the linking method designed based on the file structure as described above are implemented.
In the invention, the byte code generated in a compiler generates target files of different modules according to a file structure, wherein the file structure comprises: the system comprises a module head component, a module application component, a module constant component, a module file component, a module method component and a module index component; generating a download script which can be identified by a security module by the target file through a conversion tool; when a downloading instruction is received, downloading and installing the downloading script into the safety module, wherein in the downloading and installing process, the method linkage between different modules is completed according to the file structures of different modules in the downloading script; when a method calling request exists, jumping to the physical address of the method called by the request according to the link of the method called by the request to execute the method. The invention can reduce the file volume and improve the operation efficiency, and simultaneously realizes the security characteristic which is equal to the security module of the file structure design of the traditional Java language virtual machine.
Drawings
FIG. 1 is a flowchart illustrating a linking method designed based on a file structure according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a modular head assembly according to an embodiment of the present invention in a linking method based on a file structure design;
FIG. 3 is a diagram illustrating application module application components of an embodiment of a linking method designed based on a file structure according to the present invention;
FIG. 4 is a schematic diagram of module constant components in an embodiment of the linking method designed based on the file structure according to the present invention;
FIG. 5 is a diagram illustrating a system module file component according to an embodiment of the linking method based on file structure design of the present invention;
FIG. 6 is a block diagram illustrating the components of a method for linking a document based on a file structure design according to an embodiment of the present invention;
FIG. 7 is a block diagram of an indexing component according to an embodiment of the linking method based on file structure design of the present invention;
FIG. 8 is a schematic link diagram illustrating a method between different modules according to an embodiment of the present invention;
FIG. 9 is a schematic link diagram illustrating a method between different modules according to yet another embodiment of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
In a first aspect, an embodiment of the present invention provides a linking method designed based on a file structure.
Referring to fig. 1, fig. 1 is a schematic flowchart illustrating an embodiment of a linking method designed based on a file structure according to the present invention.
In an embodiment of the linking method based on the file structure design, the linking method based on the file structure design includes:
step S10, generating object files of different modules according to the byte code generated in the compiler, where the file structure includes: the system comprises a module head component, a module application component, a module constant component, a module file component, a module method component and a module index component;
in this embodiment, in the present embodiment, when a C language code is externally input, a compiler is used to perform macro expansion, perform syntax analysis and semantic analysis on the input C language code to generate a bytecode, and generate target files of different modules from the bytecode generated in the compiler according to a designed file structure. The file structure comprises a module head component such as a module shown in figure 2, a module application component such as a module shown in figure 3, a module constant component such as a module shown in figure 4, a module file component such as a module shown in figure 5, a module method component such as a module shown in figure 6 and a module index component such as a module shown in figure 7. The components in the file structures of the different modules are used for linking method addresses between the different modules.
Further, in one embodiment, the structure of the module head assembly includes the identification number and version number information of the module and the length description of other components in the file structure of the module.
In this embodiment, the structure of the Module _ header is shown in fig. 2, where the Module header includes a version number version entry of the Module, an identification number AID entry of the Module and a byte number AID _ length entry of the identification number AID, and when the virtual machine operates, an address of a target file of the corresponding Module is found according to the identification number AID of the Module and the version number version of the Module; the module head component also contains the lengths of other components in the module, such as an app _ size item representing the length of an application component, a const _ size item representing the length of a constant component, a file _ size item representing the length of a file component, a method _ size item representing the length of a method component, and a reference _ size item representing the length of an index component, wherein the lengths of the components do not contain tag items and size items of the components and only contain data content, and the lengths describe the address spaces of the other components according to the length descriptions when the module head component in the download script of the current module is downloaded into the security module; the module head component also contains a CRC32 checksum sc _ CRC32 entry that represents all data from the module application component to the module index component field, preventing the component from being tampered with; the module head component also comprises a name entry for representing the complete component in the format of UTF _8 and a byte number name _ length entry used in the name entry for representing the name of the component in the format of UTF _8, wherein the structure of the module head component also comprises a tag value and a size value indicating the number of bytes in the component.
Further, in an embodiment, if the module is a non-application module, the length of the module application component of the non-application module is 0; and if the module is an application module, the length of a module application component of the application module is not 0, wherein the structure of the module application component of the application module comprises an identification number of the application and a physical address index of an entry function of the application.
In this embodiment, if the module is a non-application module, the length of the module application component of the non-application module is 0; if the Module is an application Module, the length of a Module application component of the application Module is not 0, and the structure of the Module application component Module _ app is shown in fig. 3. The structure of a module application component of the application module comprises an identification number AID entry of an application and a byte number AID _ length entry of the identification number AID, wherein the identification number AID entry is used for finding a base address of the application component in an application module file structure from an application registry; the structure of the module application component of the application module further includes a physical address index of an applied entry function, such as an install _ Off item, a process _ Off item, a select _ Off item, a deselect _ Off item, an uninstant _ Off item, a MultiSelect _ Off item, a multisteselect _ Off item, and a getsclibinterface _ Off item, which respectively represent address indexes of an install method, a process method, a select method, a deselect method, an uninstant method, a MultiSelect method, a multistep method, and a getsclibinterface method, and these 8 methods are entry functions applied to the system, wherein the entry function is used for finding an address of a module application component of the application module when a method between modules is called, and then finding an entry called by the method according to the physical address index of the entry function; the structure of the module application component of the application module also comprises a name entry for representing the complete component in the format of UTF _8 and a name _ length entry for representing the name of the component in the format of UTF _8, and a tag value and a size value indicating the number of bytes in the component which are contained in each component.
Further, in an embodiment, the structure of the module constant component includes the number of the external referenced modules, the identification number and version number information of the external referenced modules, and a constant structure of the external referenced modules, where the constant structure of the external referenced modules includes the distinguishing identifications of the system method and the non-system method, the index numbers of the referenced modules in which all the called methods are located in the external referenced module structure, and the address offsets of all the called methods.
In this embodiment, the structure of the Module constant component Module _ constant is shown in fig. 4, where the Module constant component includes a Modulecount entry describing the number of external referenced modules that can be called by the current Module; the module constant component further comprises a ModuleAID entry, and the ModuleAID entry is used for finding a base address of a module header component in an external introduced module file structure from a module registry, and according to base addresses of other components of the module header component, the ModuleAID entry comprises a PkgAID structure body, the PkgAID structure body comprises a version entry which represents a version number of an introduced module, the AID entry represents an identification number of the introduced module, and the AID _ length entry represents the byte number of the identification number AID of the introduced module; the module constant component also comprises a count item which represents the number of structural bodies of the constant pool Moduleconst item; the Moduleconst item describes the relevant information of the external referenced module where all called methods are located, the Moduleconst item comprises a Const structure body, the Const structure body comprises a distinguishing identifier of a sysflag item for distinguishing whether the called methods are system methods, a pkgID item represents the index of the referenced module where all the called methods are located in a PkgAID item structure body of the ModuleAID item, and an offset item represents the address offset of all the called methods, wherein the module constant component also comprises a tag value and a size value indicating the number of bytes in the component.
Further, in an embodiment, if the module is a non-system module, the length of the module file component of the non-system module is 0; and if the module is a system module, the length of a module application component of the system module is not 0, wherein the module file component structure of the system module comprises the total number of files in the system module, an array form of the total number of methods of each file in the system file and a method address index number of each file in the system file.
In this embodiment, if the module is a non-system module, the length of the module file component of the non-system module is 0; if the Module is a system Module, the length of a Module application component of the system Module is not 0, and the structure of the Module File component Module _ File is shown in fig. 5, wherein the Module File component structure of the system Module includes a type item to distinguish and identify a system Module File; the module file component structure of the system module comprises number items which represent the total number of files in the system module; the module file component structure of the system module comprises numFun items, and the total method number of each file in the system module is expressed in an array form; the module file assembly structure of the system module comprises a Fun item, and the index number of the method address of each file in the module is represented in an array form, wherein the module file assembly of the system module also comprises a tag value and a size value indicating the number of bytes in the assembly.
Further, in one embodiment, the module method component includes a bytecode implementation of internal functions of all methods in the module, wherein the bytecode implementation includes a parameter number of all methods, a total byte number of local variables, and a bytecode set of executable codes of all methods.
In this embodiment, a structure of the Module method component Module _ method is shown in fig. 6, where the Module method component includes a code item, a bytecode implementation that includes internal functions of all methods in the Module, and is a specific internal logic call, function implementation, and the like of the method. The code item comprises a code _ info structural item, and the code _ info structural item comprises a paranum item and represents the number of parameters of all methods of the module; the code _ info structure item also comprises a localsize item which represents the total number of bytes of the local variable; the code _ info structure item also includes an mcode item, which represents the byte code set of the executable code of all methods of the module, wherein the module method component also contains a tag value and a size value indicating the number of bytes in the component.
Further, in an embodiment, the structure of the module index component includes address offsets of all methods to be linked in the method component of the module, and an address index of a constant structure in the module constant component of the external referenced module where the linked method is located.
In this embodiment, the Module _ reference structure is shown in fig. 7, and the Module index Module includes a Module _ Ref entry including a Ref entry structure. The Ref item structure body contains offset items which represent address offsets of all methods to be linked of the module in the method components; the module index component contains a constID item which represents the address index of the Const structure in the module constant component of the external referenced module where the linked method is located.
Step S20, generating a download script which can be identified by the security module through the target file by a conversion tool;
in this embodiment, the target file having the file structures of the module head component, the module application component, the module constant component, the module file component, the module method component, and the module index component is converted by the conversion tool to generate the download script that can be recognized by the security module. The download script is used for downloading and installing the target file to the security module when the target file is downloaded and installed.
Step S30, when a download instruction is received, downloading and installing the download script into the security module, wherein in the downloading and installing process, the method linkage between different modules is completed according to the file structures of different modules in the download script;
in this embodiment, when a download instruction is received, the download script is downloaded and installed in the security module, wherein in the download and installation process, the linking of the methods between different modules is completed according to the file structures of different modules in the download script. The method linking is to link the physical addresses of the methods between different modules, and the method between different modules needs to be linked when being called after the linking is completed.
Further, in an embodiment, in the downloading and installing process, the step of completing the linking of the method between different modules according to the file structures of different modules in the download script includes:
finding a first address offset of a calling method relative to a method component base address of a reference module through an index component of the reference module, and obtaining a calling relation between the calling method and a called method of the referenced module according to the first offset;
after the index number of the referenced module in the constant component of the referencing module is found by the index component of the referencing module, jumping to a constant structure body of the referenced module corresponding to the constant component of the referencing module;
finding the identification number and the version number of the led module through the constant structure body;
judging whether the called method is a system method or not through a distinguishing identifier in a constant component of the reference module;
if the called method is a non-system method, finding a second address offset of the called method relative to a method component base address of the called module in a constant structure body of the called module;
finding the address of the introduced module according to the identification number and the version number of the introduced module, and finding the method component base address of the introduced module according to the address of the introduced module;
finding the physical address of the called method according to the method component base address of the called module and the second address offset;
completing the link between the calling method and the called method based on the physical address of the called method;
if the called method is a system method, finding the address of the guided module according to the identification number and the version number of the guided module, and finding the method component base address of the guided module according to the address of the guided module;
using high bytes of address offset in a constant structure body of the attracted module as a file index number, and finding a file where the called method is located from a plurality of files contained in a file assembly of the attracted module;
using the low byte of the address offset in the constant structure body of the referenced module as a method index number, and finding the physical address of the called method from the file where the called method is located;
and replacing the address offset in the constant structure body of the referenced module by the physical address to complete the linkage of the calling method and the called method.
In this embodiment, in the downloading and installing process, as shown in fig. 8, a first address offset of the calling method with respect to the method component base address of the referencing module is found through an offset item in a Ref item structure of the indexing component of the referencing module, and a calling relationship between the calling method and the called method of the referenced module is obtained according to the first offset; after the address index of the introduced module in the constant component of the reference module is found through the constID item in the Ref item structure of the index component of the reference module, jumping to the Const structure of the introduced module corresponding to the constant component of the reference module; finding a PkgAID item structure of the introduced module in the Const structure, wherein the PkgAID item structure comprises an identification number and a version number of the introduced module; after judging whether the called method is a system method or not by the distinguishing identifier in the constant component of the quoting module, if the called method is judged to be a non-system method by the distinguishing identifier in the constant component of the quoting module, the step of completing the linking of the methods among different modules according to the file structures of different modules in the download script is shown in fig. 8, and a second address offset of the called method relative to the method component base address of the quoted module is found in an offset item in a Const item structure body of the quoted module; finding a PkgAID item structure body of the introduced module according to the pkgID item, finding the address of the introduced module from a module registration list according to an identification number AID item of the introduced module in the PkgAID item structure body of the introduced module, namely a ModuleID and version number version item shown in the figure, and finding a method component base address of the introduced module according to the address of the introduced module; finding out the physical address FunAddr of the called method according to the method component base address of the called module and the second address offset; a physical address based on the calling method and the called method; if the called method is judged to be the system method by the distinguishing identification in the constant component of the quoting module, the step of completing the linking of the methods between different modules according to the file structures of different modules in the download script is shown in fig. 9, finding the address of the quoted module according to the identification number and the version number of the quoted module included in the PkgAID item structure body of the quoted module, and finding the method component base address of the quoted module according to the address of the quoted module; taking the high byte of the offset item in the test structure body of the referenced module as a file index number fileID, and finding a file where the called method is located from a plurality of files contained in the file assembly of the referenced module; and taking the low byte of the offset item in the test structure body of the referenced module as a method index number FileFunID, finding the index number funID in a Fun array in the file where the called method is located, thereby finding the physical address FunAddr of the called method according to the index number funAddr and replacing the offset item in the test structure body of the referenced module by the physical address FunAddr.
In this embodiment, the offset entry in the Const structure of the referencing module and the identification number AID entry of the referenced module in the PkgAID entry structure of the referenced module are saved, the bytecode corresponding to the method referencing relationship is fetched from the method component of the referencing module through the offset entry reserved in the Ref structure of the indexing component of the referencing module, the identification number AID entry, i.e., the ModuleID, of the referenced module in the PkgAID entry structure of the referenced module and the method address offset, i.e., the offset entry, of the offset entry in the Const structure are written to the operand of the bytecode corresponding to the method referencing relationship, as shown in fig. 8, the method address offset corresponds to operand 0 and operand 1, and operand 2 corresponds to the ModuleID, thereby completing the linking of the calling method and the called method. When the link between the calling method and the called method, namely the link between the calling method and the physical address of the called method, is completed, the physical address of the called method can be jumped according to the physical address of the linked calling method.
In step S40, when there is a method call request, the method is executed by jumping to the physical address of the method requested to be called according to the link of the method requested to be called.
In this embodiment, after the linking of methods between different modules, that is, the address linking of the methods between different modules is completed, when a method call request exists, it is necessary to first determine whether a potential safety hazard exists according to a firewall access rule, and if the potential safety hazard exists, the method call request does not satisfy a safety access permission, and an abnormal access is directly reported without calling the method; and if the potential safety hazard does not exist, the method calling request meets the safety access authority, and the method is executed by jumping to the physical address of the method requested to be called according to the link of the method requested to be called.
In this embodiment, the bytecode generated in the compiler generates target files of different modules according to a file structure, where the file structure includes: the system comprises a module head component, a module application component, a module constant component, a module file component, a module method component and a module index component; generating a download script which can be identified by a security module by the target file through a conversion tool; when a downloading instruction is received, downloading and installing the downloading script into the safety module, wherein in the downloading and installing process, the method linkage between different modules is completed according to the file structures of different modules in the downloading script; when a method calling request exists, jumping to the physical address of the method called by the request according to the link of the method called by the request to execute the method. The invention can reduce the file volume and improve the operation efficiency, and simultaneously realizes the security characteristic which is equal to the security module of the file structure design of the traditional Java language virtual machine.
In a second aspect, the embodiment of the present invention further provides a readable storage medium.
The readable storage medium of the present invention stores a linking program designed based on a file structure, wherein the linking program designed based on a file structure is executed by a processor to implement the steps of the linking method designed based on a file structure as described above.
The method for implementing the link program designed based on the file structure when executed may refer to various embodiments of the link method designed based on the file structure of the present invention, and will not be described herein again.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for causing a terminal device to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. A linking method based on file structure design is characterized in that the linking method based on file structure design comprises the following steps:
generating target files of different modules by byte codes generated in a compiler according to a file structure, wherein the file structure comprises: the system comprises a module head component, a module application component, a module constant component, a module file component, a module method component and a module index component;
generating a download script which can be identified by a security module by the target file through a conversion tool;
when a downloading instruction is received, downloading and installing the downloading script into the safety module, wherein in the downloading and installing process, the method linkage between different modules is completed according to the file structures of different modules in the downloading script;
when a method calling request exists, jumping to the physical address of the method called by the request according to the link of the method called by the request to execute the method.
2. The linking method designed based on the file structure as claimed in claim 1, wherein the structure of the module head component includes the identification number and version number information of the module and the length description of other components in the file structure of the module.
3. The file structure design-based linking method according to claim 1, wherein if the module is a non-application module, the length of a module application component of the non-application module is 0; and if the module is an application module, the length of a module application component of the application module is not 0, wherein the structure of the module application component of the application module comprises an identification number of the application and a physical address index of an entry function of the application.
4. The linking method designed based on the file structure of claim 1, wherein the structure of the module constant component includes the number of the external referenced modules, the identification number and version number information of the external referenced modules, and the constant structure of the external referenced modules, wherein the constant structure of the external referenced modules includes the distinguishing identifications of the system methods and the non-system methods, the index numbers of the referenced modules where all the called methods are located in the external referenced module structure, and the address offsets of all the called methods.
5. The file structure design-based linking method according to claim 1, wherein if the module is a non-system module, the length of a module file component of the non-system module is 0; and if the module is a system module, the length of a module application component of the system module is not 0, wherein the module file component structure of the system module comprises the total number of files in the system module, an array form of the total number of methods of each file in the system file and a method address index number of each file in the system file.
6. The linking method designed based on the file structure as claimed in claim 1, wherein the module method component includes bytecode implementation of internal functions of all methods in the module, wherein the bytecode implementation includes parameter number of all methods, total byte number of local variables, and bytecode set of executable code of all methods.
7. The linking method designed based on the file structure as claimed in claim 1, wherein the structure of the module index component includes the address offset of all methods to be linked of the module in the method component, and the address index of the constant structure body of the external referenced module in the module constant component where the linked method is located.
8. The file structure design-based linking method according to claim 1, wherein the step of completing linking of methods between different modules according to file structures of different modules in the download script during the download installation process comprises:
finding a first address offset of a calling method relative to a method component base address of a reference module through an index component of the reference module, and obtaining a calling relation between the calling method and a called method of the referenced module according to the first offset;
after the index number of the referenced module in the constant component of the referencing module is found by the index component of the referencing module, jumping to a constant structure body of the referenced module corresponding to the constant component of the referencing module;
finding the identification number and the version number of the led module through the constant structure body;
judging whether the called method is a system method or not through a distinguishing identifier in a constant component of the reference module;
if the called method is a non-system method, finding a second address offset of the called method relative to a method component base address of the called module in a constant structure body of the called module;
finding the address of the introduced module according to the identification number and the version number of the introduced module, and finding the method component base address of the introduced module according to the address of the introduced module;
finding the physical address of the called method according to the method component base address of the called module and the second address offset;
completing the link between the calling method and the called method based on the physical address of the called method;
if the called method is a system method, finding the address of the guided module according to the identification number and the version number of the guided module, and finding the method component base address of the guided module according to the address of the guided module;
using high bytes of address offset in a constant structure body of the attracted module as a file index number, and finding a file where the called method is located from a plurality of files contained in a file assembly of the attracted module;
using the low byte of the address offset in the constant structure body of the referenced module as a method index number, and finding the physical address of the called method from the file where the called method is located;
and replacing the address offset in the constant structure body of the referenced module by the physical address to complete the linkage of the calling method and the called method.
9. A readable storage medium, wherein a linking program designed based on a file structure is stored on the readable storage medium, and wherein when the linking program designed based on the file structure is executed by a processor, the following steps are implemented:
generating target files of different modules by byte codes generated in a compiler according to a file structure, wherein the file structure comprises: the system comprises a module head component, a module application component, a module constant component, a module file component, a module method component and a module index component;
generating a download script which can be identified by a security module by the target file through a conversion tool;
when a downloading instruction is received, downloading and installing the downloading script into the safety module, wherein in the downloading and installing process, the method linkage between different modules is completed according to the file structures of different modules in the downloading script;
when a method calling request exists, jumping to the physical address of the method called by the request according to the link of the method called by the request to execute the method.
10. The readable storage medium of claim 9, wherein the linking program based on the file structure design, when executed by the processor, further implements the steps of the linking method based on the file structure design according to any one of claims 2 to 8.
CN202110982013.3A 2021-08-25 2021-08-25 Link method based on file structure design and readable storage medium Active CN113672984B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110982013.3A CN113672984B (en) 2021-08-25 2021-08-25 Link method based on file structure design and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110982013.3A CN113672984B (en) 2021-08-25 2021-08-25 Link method based on file structure design and readable storage medium

Publications (2)

Publication Number Publication Date
CN113672984A true CN113672984A (en) 2021-11-19
CN113672984B CN113672984B (en) 2022-02-01

Family

ID=78546190

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110982013.3A Active CN113672984B (en) 2021-08-25 2021-08-25 Link method based on file structure design and readable storage medium

Country Status (1)

Country Link
CN (1) CN113672984B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102722813A (en) * 2012-04-21 2012-10-10 郁晓东 Hierarchical multiple electronic currency device and multiple electronic currency management method
CN102890758A (en) * 2012-10-11 2013-01-23 北京深思洛克软件技术股份有限公司 Method and system for protecting executable file
US8589951B2 (en) * 2011-01-07 2013-11-19 International Business Machines Corporation Conserving memory by using objects that are selectably mutable during runtime
CN103677778A (en) * 2012-09-18 2014-03-26 北京中电华大电子设计有限责任公司 Method for analyzing Classref constant of CAP file
CN103927187A (en) * 2014-05-09 2014-07-16 成都凯智科技有限公司 Program execution method of embedded system
CN107291423A (en) * 2016-03-31 2017-10-24 龙芯中科技术有限公司 The method and apparatus for building running environment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8589951B2 (en) * 2011-01-07 2013-11-19 International Business Machines Corporation Conserving memory by using objects that are selectably mutable during runtime
CN102722813A (en) * 2012-04-21 2012-10-10 郁晓东 Hierarchical multiple electronic currency device and multiple electronic currency management method
CN103677778A (en) * 2012-09-18 2014-03-26 北京中电华大电子设计有限责任公司 Method for analyzing Classref constant of CAP file
CN102890758A (en) * 2012-10-11 2013-01-23 北京深思洛克软件技术股份有限公司 Method and system for protecting executable file
CN103927187A (en) * 2014-05-09 2014-07-16 成都凯智科技有限公司 Program execution method of embedded system
CN107291423A (en) * 2016-03-31 2017-10-24 龙芯中科技术有限公司 The method and apparatus for building running environment

Also Published As

Publication number Publication date
CN113672984B (en) 2022-02-01

Similar Documents

Publication Publication Date Title
JP3689368B2 (en) Method of loading an application into a multi-application embedded system with data processing resources, corresponding system and execution method
US5727147A (en) System and method for resolving symbolic references to externally located program files
AU771699B2 (en) Token-based linking
JP6602283B2 (en) System and method for supporting object-oriented script tools
US20050028155A1 (en) Java execution device and Java execution method
KR20040004551A (en) Method and device for creating and using pre-internalized program files
KR20000052759A (en) Using a high level programming language with a microcontroller
CN111930382B (en) Application page access method, device and equipment
CN112052006B (en) Software code compiling method and system
CN105516154A (en) Security policy configuration method and device applied to SEAndroid (Security-Enhanced Android) system
CN108845800B (en) Method, device, equipment and storage medium for realizing component extension function
CN108804120B (en) Page construction method, device, equipment and storage medium
CN113672984B (en) Link method based on file structure design and readable storage medium
US20090187897A1 (en) Compiling method and compiling program
AU2003204197A1 (en) System and method for defining and using subclasses declaratively within markup
CN113703779A (en) Cross-platform multi-language compiling method and ultra-light Internet of things virtual machine
CN111596970A (en) Dynamic library delay loading method, device, equipment and storage medium
CN112579129A (en) Software updating method, device, equipment and storage medium based on server
CN1582431A (en) Installation of a compiled program, particularly in a chip card
CN117056906B (en) Instruction access control method, system, storage medium and equipment
CN114416219B (en) System function calling method, device, electronic equipment and readable medium
CN116700840B (en) File execution method, device, electronic equipment and readable storage medium
US20240192936A1 (en) Systems and methods for creating an extended smart card application file from multiple smart card application files
CN112306632A (en) Java Card virtual machine execution engine and execution method
CN115309405A (en) Code link optimization method

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