摘要 |
The disclosure provides a method for dynamically loading a relocatable file, comprising: analyzing the relocatable file; searching for a relocation section according to the information obtained through the analysis; obtaining a relocation target address after the relocation section is found and calculating an address to be relocated and a skipping distance; determining whether the skipping distance exceeds a range of a short skipping, and if the skipping distance does not exceed the range of the short skipping, then writing the relocation target address into the address to be relocated to perform relocation loading; if the skipping distance exceeds the range of the short skipping, then adding a veneer code segment and making the skipping whose distance exceeds the range of the short skipping indirectly skip to the relocation target address to perform relocation loading. Accordingly, the disclosure provides a device for dynamically loading a relocatable file, comprising: an analyzing module, a calculating module, a searching module, a determining module, and a relocation dynamic loading module. With the solution, dynamically loading a relocatable file can be realized when the calling distance of a function exceeds the range of the short skipping.
|