CN101281470B - Method for reconstructing ELF file formats under multi-core architecture - Google Patents

Method for reconstructing ELF file formats under multi-core architecture Download PDF

Info

Publication number
CN101281470B
CN101281470B CN200810062344XA CN200810062344A CN101281470B CN 101281470 B CN101281470 B CN 101281470B CN 200810062344X A CN200810062344X A CN 200810062344XA CN 200810062344 A CN200810062344 A CN 200810062344A CN 101281470 B CN101281470 B CN 101281470B
Authority
CN
China
Prior art keywords
elf
file
new
elf file
thread
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.)
Expired - Fee Related
Application number
CN200810062344XA
Other languages
Chinese (zh)
Other versions
CN101281470A (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.)
Zhejiang University ZJU
Original Assignee
Zhejiang University ZJU
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang University ZJU filed Critical Zhejiang University ZJU
Priority to CN200810062344XA priority Critical patent/CN101281470B/en
Publication of CN101281470A publication Critical patent/CN101281470A/en
Application granted granted Critical
Publication of CN101281470B publication Critical patent/CN101281470B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Devices For Executing Special Programs (AREA)
  • Stored Programmes (AREA)

Abstract

The invention provides a method for modifying ELF file format in multi-core architecture, which comprises the steps: (1) a user adds a parallel processing flag; (2) independent codes are loaded into different code segments in a ELF file; (3) the flag bit in the header of the ELF file is modified to mark a new ELF format; (4) the starting addresses of newly added segments are added in a new thread; (5) a loader of ELF format is modified; (6) a multi-thread program is executed on different cores; and (7) different thread results are set unifiedly in a main thread by a compiler. According to the invention, the requirement that a current compiler in multi-core platform program design needs multiple bottom layer thread libraries is eliminated; since the process is simple, the steps have good universality, and can be used in different target file formats.

Description

The method of reconstructing ELF file formats under multi-core architecture
Technical field
The present invention relates to modification executable file format under the embedded multi-core platform to utilize the problem of multinuclear processing power, in particular, relate to the ELF file layout transformation under a kind of multi-core system structure.
Background technology
Along with the development of Computer Architecture, the form of executable file is also constantly changing.COM formatted file the earliest is proper binary file, though simple, progressively popular page stores management mode make it can't adapt to the needs of program design better.Therefore a.out etc. occurs and had file header and section in the file is carried out the new executable file structure of branch page alignment, be called NMAGIC.Because people constantly promote the demand in efficient and space, NMAGIC's also progressively develops into QMAGIC and ZMAGIC in updating.These improvement comprise that compressed file head and code segment are mapped in first page and shine upon last code segment and first data segment etc. simultaneously.
Along with the development of Object-oriented Technique, a.out can not adapt to the needs of program design gradually.Therefore the PE file structure that UNIX ELF executable structure and Microsoft have occurred.The two becomes the main flow destination file format on two large platforms respectively.In addition, the destination file format that once occurred also has the OMF form of IBM 360 and Intel/Microsoft.
Be about to become in the epoch of mainstream technology platform at current multi-core platform, if the variation of destination file format also is faced with great challenge one time.On the one hand being existing destination file format has become default objects file layout on many main flow platforms such as ELF and PE, and uses the approval that has also obtained everybody, relatively stable and general.Be the discussion how multi-core platform is efficiently utilized on the other hand.Therefore, can suitably make amendment to destination file format, promptly keep its basic stability and versatility, can make it adapt to new multi-core platform better again, give full play to the processing power of the multinuclear heart, be the basic motives that we revise the ELF file layout.
In addition, because the program design on multi-core platform now is to give compiler to handle detailed details mostly.And these details comprise synchronously, task division, and process creations etc. are designed and developed big that the workload of compiler will be very, and this also can make the efficient of compiler reduce, and it can't be absorbed on the optimization to program.In addition, because the existence of current multiple thread library, compiler need be considered the difference of thread library in the different platform when starting new thread, therefore must comprise the support to multiple thread library, and this can make the huge unusually of compiler change.
So, we attempt to have adopted minimum change as far as possible, a part is divided out the loading bin of giving operating system with the work of multi-process establishment to be finished, and loading bin is to discern the part that can walk abreast in the task not intelligently, is exactly the unique method that can take so revise the form of ELF file destination.
Summary of the invention
Fundamental purpose of the present invention is to overcome deficiency of the prior art, the method that provides the ELF file layout under a kind of multi-core system structure to transform.
In order to solve the problems of the technologies described above, the present invention is achieved by the following technical solutions.
(1) user adds the parallel processing sign:
But the user adds the label of notice compiler parallel processing in institute's written program, the program segment that compiler will originally need order to carry out is independent respectively, but forms a plurality of executed in parallel and to result's the correctness independently program code segments of influence not;
(2) code loading is independently advanced in the code segments different in the ELF file:
Set a plurality of code segments in the ELF file, will write respectively in the different code segment of ELF file through compiling independent program code, a plurality of code segments under this new ELF file layout identify with the mode of .textn respectively, and n is a sequence number, since 1; Has only a code segment in the present ELF file layout.And we will write respectively in the different code segment of ELF file through the independent program code of compiling here, therefore need to exist in the ELF file a plurality of code segments.
(3) zone bit in the modification ELF file header identifies new ELF form:
Last byte of 16 bytes in the ELF file is revised as 0x01 by 0x00, is used for representing the new ELF file layout of employing;
(4) increase the start address of section in new thread that newly adds:
Revise section the start address in new thread of the 12nd, 13,14,15 bytes for newly adding in 16 bytes in the ELF file header;
(5) loading bin of modification ELF form:
Load_elf_binary function to the loading bin of ELF form is made amendment, and at first the form of ELF is judged whether see is the form of redetermination; If, then utilize system call to start a new process, difference according to rreturn value, parent process continues to carry out original loading process, and subprocess is loaded into new code segment the process space of oneself, and the programmable counter of the record in the storehouse is revised as new entry address by start_thread, promptly can use the address of being write down in default address or the ELF file header;
(6) execution of multithread programs on different IPs:
Subprocess is provided with relationship degree between this process and the different CPU by system call sched_setaffinity, to specific nuclear, moves, make full use of the processing power of a plurality of nuclears to dispatch this process;
(7) different threads result's unification is provided with in main thread by compiler.
As a kind of improvement, revise the file layout of ELF form, with compiler decompose out in logic independently text chunk write in the different code segments, when loading, respectively these code segments are loaded in the different processes, to utilize the processing power of multi-core platform.Should the transformation way also eliminate the requirement that needs multiple bottom thread library to support in the compiler of program design under the existing multi-core platform simultaneously.
Compared with prior art, the invention has the beneficial effects as follows:
(1) high efficiency.The present invention has realized the ELF file layout transformation under the multi-core system structure, by being transformed into, the ELF file layout under the multi-core platform holds a plurality of code segments independently in logic, reduce the workload of compiler under the multi-core platform, improved the treatment effeciency of compiler.
(2) platform-neutral.Transform by the ELF file layout under the multi-core system structure among the present invention, the part that needs the multithreading storehouse to support in the multinuclear compiler being given the loading bin of operating system carries out, eliminated the requirement that needs in the compiler the multiple thread library support of different platform, effectively the size of compiler.
(3) practicality.ELF file layout under the multi-core system structure that the present invention proposes is transformed, and has made full use of the processing power of multinuclear processing platform.Owing to the simplicity of handling, this technology also can be utilized in the transformation to destination file formats such as Microsoft PE file layouts simultaneously.
Description of drawings
Fig. 1 is general structure frame figure of the present invention.
Embodiment
In conjunction with the accompanying drawings, the present invention is further described by specific embodiment.
At first explain the noun of using
ELF:Executable and Linkable Format is used for executable file and attachable shared library file.
Load_elf_binary: load the function that code enters the program process space.
Start_thread: specify the start address of new thread, unactual startup new thread just starts automatically up to this thread when system call is withdrawed from.
Sched_setaffinity: set the affinity of certain process, guarantee that promptly this process moves on certain or some processor cores to certain or some processor cores.
ELF file layout under the multi-core system structure is transformed, and may further comprise the steps:
(1) user adds the parallel processing sign:
The user adds the label that the notice compiler can carry out parallel processing in institute's written program.So that the program segment that compiler will originally need order to carry out is independent respectively, formation can executed in parallel and result's correctness not have the program code segments that influences.
(2) compiler advances code loading independently in the code segments different in the ELF file:
Because independently program segment forms in logic, therefore can add them is loaded into different code segments respectively.In original ELF file layout, have only a code segment, comprised all program codes.So carried out synchronously for the independently program segment that decomposes out through compilation process is loaded in the different threads in the past, the thread library that needs to use operating system or third party to provide comes the manual creation thread, and the position that need accurately place the code of being distinguished, this has just brought the problem of reorientation, the very complexity that design is become.Here after we are divided into independent parts to the code of original program, write as the ELF file independently in the code segment respectively.These code segments .text1 .text2 waits and represents.
(3) zone bit in the modification ELF file header identifies new ELF form:
The numerical value of 16 bytes in the ELF file has been represented the version of ELF file, Machine Type, big small end type, type of architecture etc.In the standard of ELF form, last byte of these 16 bytes is always 0x01, and we are revised as 0x01 here, is used for representing us to adopt new ELF file layout.Can use in this sign loading bin that we revised afterwards.
(4) increase the start address of section in new thread that newly adds:
Revise section the start address in new thread of the 12nd, 13,14,15 bytes for newly adding in 16 bytes in the ELF file header.Generally speaking, this address is otiose, because the code segment that newly adds also can utilize the acquiescence start address of storing in the ELF file header when being loaded into thread.Here only provided a kind of method that a kind of section newly is loaded into different addresses.
(5) loading bin of modification ELF form:
Because the ELF file layout is revised, therefore the loading bin at the ELF form also needs to change accordingly.All changes all occur in the load_elf_binary function.Here, we at first judge to the form of ELF whether see is the form of our redetermination, if, then utilize system call to start a new process, according to the difference of rreturn value, parent process continues to carry out original loading process.And subprocess is loaded into new code segment the process space of oneself and by start_thread the programmable counter of the record in the storehouse is revised as new entry address, promptly can use the address of being write down in default address or the ELF file header.
(6) execution of a plurality of threads of scheduling on different IPs:
Subprocess that has just created and parent process are moved on same nuclear, and this is parallel on the macroscopic view and remain serial on the microcosmic just in fact.In order to utilize the advantage of multinuclear, subprocess can be provided with relationship degree between this process and the different CPU by system call sched_setaffinity, move to specific nuclear to dispatch this process.So just made full use of the processing power of a plurality of nuclears.
(7) different threads result's unification:
Result's unification is provided with in main thread by compiler, such as wait for finishing of subprocess by wait.This has been proven technique in existing compiler.
Of the present invention is the method that the ELF file layout under the multi-core system structure is transformed, revise the file layout of ELF form, with compiler decompose out in logic independently text chunk write in the different code segments, when loading, can be loaded into these code segments in the different processes respectively, to utilize the processing power of multi-core platform.Should the transformation way also eliminate the requirement that needs multiple bottom thread library to support in the compiler of program design under the existing multi-core platform simultaneously.Because the simplicity of handling, this framework has good versatility, can use in multiple different destination file format.
At last, it is also to be noted that what more than enumerate only is specific embodiments of the invention.Obviously, the invention is not restricted to above examples of implementation, many distortion can also be arranged.All distortion that those of ordinary skill in the art can directly derive or associate from content disclosed by the invention all should be thought protection scope of the present invention.

Claims (2)

1. the method for a reconstructing ELF file formats under multi-core architecture is characterized in that, may further comprise the steps:
(1) user adds the parallel processing sign:
But the user adds the label of notice compiler parallel processing in institute's written program, the program segment that compiler will originally need order to carry out is independent respectively, but forms a plurality of executed in parallel and to result's the correctness independently program code segments of influence not;
(2) code loading is independently advanced in the code segments different in the ELF file:
Set a plurality of code segments in the ELF file, will write respectively in the different code segment of ELF file through compiling independent program code, a plurality of code segments under this new ELF file layout identify with the mode of .textn respectively, and n is a sequence number, since 1;
(3) zone bit in the modification ELF file header identifies new ELF form:
Last byte of 16 bytes in the ELF file is revised as 0x01 by 0x00, is used for representing the new ELF file layout of employing;
(4) increase the start address of section in new thread that newly adds:
Revise section the start address in new thread of the 12nd, 13,14,15 bytes for newly adding in 16 bytes in the ELF file header;
(5) loading bin of modification ELF form:
Load_elf_binary function to the loading bin of ELF form is made amendment, and at first the form of ELF is judged whether see is the form of redetermination; If, then utilize system call to start a new process, difference according to rreturn value, parent process continues to carry out original loading process, and subprocess is loaded into new code segment the process space of oneself, and the programmable counter of the record in the storehouse is revised as new entry address by start_thread, can use the address of being write down in default address or the ELF file header;
(6) execution of multithread programs on different IPs:
Subprocess is provided with relationship degree between this process and the different CPU by system call sched_setaffinity, to specific nuclear, moves, make full use of the processing power of a plurality of nuclears to dispatch this process;
(7) different threads result's unification is provided with in main thread by compiler;
Described ELF file is meant and can be used for execute file and attachable shared file.
2. the method for reconstructing ELF file formats under multi-core architecture according to claim 1, it is characterized in that, revise the file layout of ELF form, with compiler decompose out in logic independently text chunk write in the different code segments, when loading, respectively these code segments are loaded in the different processes, to utilize the processing power of multi-core platform.
CN200810062344XA 2008-05-09 2008-05-09 Method for reconstructing ELF file formats under multi-core architecture Expired - Fee Related CN101281470B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN200810062344XA CN101281470B (en) 2008-05-09 2008-05-09 Method for reconstructing ELF file formats under multi-core architecture

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN200810062344XA CN101281470B (en) 2008-05-09 2008-05-09 Method for reconstructing ELF file formats under multi-core architecture

Publications (2)

Publication Number Publication Date
CN101281470A CN101281470A (en) 2008-10-08
CN101281470B true CN101281470B (en) 2010-12-08

Family

ID=40013956

Family Applications (1)

Application Number Title Priority Date Filing Date
CN200810062344XA Expired - Fee Related CN101281470B (en) 2008-05-09 2008-05-09 Method for reconstructing ELF file formats under multi-core architecture

Country Status (1)

Country Link
CN (1) CN101281470B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2012164439A1 (en) 2011-06-02 2012-12-06 International Business Machines Corporation Handling cross-thread method calls
KR102434126B1 (en) * 2018-05-03 2022-08-18 엘에스일렉트릭(주) Apparatus for processing programmable logic controller program
CN109901891B (en) * 2019-03-19 2022-06-14 北京智游网安科技有限公司 Method for adding data in ELF program, storage medium and intelligent terminal
CN114924803A (en) * 2022-06-16 2022-08-19 Oppo广东移动通信有限公司 Loading starting method, chip, electronic device and storage medium

Also Published As

Publication number Publication date
CN101281470A (en) 2008-10-08

Similar Documents

Publication Publication Date Title
CN106156278B (en) Database data reading and writing method and device
US8181170B2 (en) Unwind information for optimized programs
US8832672B2 (en) Ensuring register availability for dynamic binary optimization
US7996659B2 (en) Microprocessor instruction that allows system routine calls and returns from all contexts
US8869126B2 (en) Method and apparatus enabling multi threaded program execution for a Cobol program including OpenMP directives by utilizing a two-stage compilation process
CN105242962A (en) Quick lightweight thread triggering method based on heterogeneous many-core
CN101281470B (en) Method for reconstructing ELF file formats under multi-core architecture
CN105446806A (en) Processing method and apparatus for application not responding
CN102364442B (en) Method for transplanting Wine from x86 to advanced risc machine (ARM) platform
CN102364433B (en) Method for realizing Wine construction tool transplanting on ARM (Advanced RISC Machines) processor
CN109522013A (en) A kind of code generating method and device of business function
CN102004662A (en) Embedded scalable virtual machine
US6931632B2 (en) Instrumentation of code having predicated branch-call and shadow instructions
US10534644B2 (en) Method and system for a CPU-local storage mechanism
US7877629B2 (en) Facilitating handling of exceptions in a program implementing a M-on-N threading model
CN100349121C (en) Embedded type parallel computation system and embedded type parallel computing method
CN110515656A (en) CASP instruction execution method, microprocessor and computer equipment
CN109857380B (en) Workflow file compiling method and device
US9250878B1 (en) Function attribute for dynamic stack allocation
CN112558978B (en) Accelerated programming and compiling method for supporting heterogeneous many-core full-chip view angle
WO2023036075A1 (en) Program call stack creation method, and stack backtrace method and apparatus
Conte et al. Optimization of VLIW compatibility systems employing dynamic rescheduling
US8490063B2 (en) Debugging extensible markup language
JP2001356916A (en) Memory blocking compiler and program executing method
Sakurai et al. A Code Transformation Method for Strong Migration Mobile Agent

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
C17 Cessation of patent right
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20101208

Termination date: 20120509