IP Library Granted Patent US 7,603,665
Granted Patent B2
US 7,603,665 · App. 10/880,786 · Granted Oct 13, 2009

Method and apparatus for loading relocatable in-place executable files in a virtual machine

View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 7,603,665
App. No.
10/880,786
Granted
Oct 13, 2009
Kind
B2
Abstract

One embodiment of the present invention provides a system that facilitates loading of an in-place executable file into a virtual machine. The system operates by loading the in-place executable file into the virtual machine, where the in-place executable file contains internal pointers that point to memory locations within the in-place executable file, and a target memory address that specifies a target location in memory where the in-place executable file is configured to be loaded. The system then determines an actual memory address at which the in-place executable file is actually loaded. If the actual memory address and the target memory address are different, the system generates an offset value, which is the difference between the actual memory address and the target memory address. Finally, the system adjusts each internal pointer within the in-place executable file by the offset value so that the internal pointers point to intended locations inside the in-place executable file.

Claims (65)

1. A method for loading an in-place executable file into a virtual machine, comprising:

loading the in-place executable file into the virtual machine, wherein the in-place executable file contains internal pointers that point to memory locations within the in-place executable file, and a target memory address that specifies a target location in memory where the in-place executable file is configured to be loaded;

determining an actual memory address at which the in-place executable file is actually loaded;

if the actual memory address and the target memory address are different,

generating an offset value, which is the difference between the actual memory address and the target memory address, and

adjusting each internal pointer within the in-place executable file by the offset value so that the internal pointers point to intended locations inside the in-place executable file;

wherein the in-place executable file includes a relocation table that identifies the locations of internal pointers within the in-place executable file, wherein the relocation table is structured as a list of offset ranges, wherein each offset range includes a starting address and an ending address of a contiguous set of internal pointers within the in-place executable file; and

wherein the relocation table is removed from the in-place executable file when the in-place executable file is loaded into the virtual machine.

2. The method of claim 1 , wherein the target memory address is located in a header of the in-place executable file.

3. The method of claim 1 , wherein loading the relocation table involves:

retrieving a pointer to the relocation table from a header of the in-place executable file; and

using the pointer to access the relocation table.

4. The method of claim 1 , wherein after adjusting each internal pointer, the method further comprises reclaiming the memory occupied by the relocation table.

5. The method of claim 1 , wherein after adjusting each internal pointer, the method further comprises:

writing the in-place executable file back, with adjusted internal pointers, to the target location without the relocation table; and

setting a relocation bit in the in-place executable file header that indicates that relocation has already taken place;

whereby subsequent executions of the in-place executable file can access the in-place executable file, with adjusted pointers, from the storage medium and can thereby avoid adjusting the pointers.

6. The method of claim 1 , wherein the relocation table is structured as a bitmap, wherein each bit corresponds to a word in the in-place executable file, wherein a set bit indicates that the word contains an internal pointer.

7. The method of claim 6 , wherein the bitmap is compressed to further reduce memory consumption.

8. The method of claim 1 , wherein the relocation table is structured as a packed list, wherein the ending address of the contiguous set of internal pointers is indicated as an offset representing the number of contiguously located internal pointers.

9. The method of claim 1 , wherein the virtual machine is a platform-independent virtual machine.

10. The method of claim 9 , wherein the virtual machine is a Java Virtual Machine.

11. A computer-readable storage medium storing instructions that when executed by a computer cause the computer to perform a method for loading an in-place executable file into a virtual machine, the method comprising:

loading the in-place executable file into the virtual machine, wherein the in-place executable file contains internal pointers that point to memory locations within the in-place executable file, and a target memory address that specifies a target location in memory where the in-place executable file is configured to be loaded;

determining an actual memory address at which the in-place executable file is actually loaded;

if the actual memory address and the target memory address are different,

generating an offset value, which is the difference between the actual memory address and the target memory address, and

adjusting each internal pointer within the in-place executable file by the offset value so that the internal pointers point to intended locations inside the in-place executable file;

wherein the in-place executable file includes a relocation table that identifies the locations of internal pointers within the in-place executable file, wherein the relocation table is structured as a list of offset ranges, wherein each offset range includes a starting address and an ending address of a contiguous set of internal pointers within the in-place executable file; and

wherein the relocation table is removed from the in-place executable file when the in-place executable file is loaded into the virtual machine.

12. The computer-readable storage medium of claim 11 , wherein the target memory address is located in a header of the in-place executable file.

13. The computer-readable storage medium of claim 11 , wherein loading the relocation table involves:

retrieving a pointer to the relocation table from a header of the in-place executable file; and

using the pointer to access the relocation table.

14. The computer-readable storage medium of claim 11 , wherein after adjusting each internal pointer, the method further comprises reclaiming the memory occupied by the relocation table.

15. The computer-readable storage medium of claim 11 , wherein after adjusting each internal pointer, the method further comprises:

writing the in-place executable file back, with adjusted internal pointers, to the target location without the relocation table; and

setting a relocation bit in the in-place executable file header that indicates that relocation has already taken place;

whereby subsequent executions of the in-place executable file can access the in-place executable file, with adjusted pointers, from the storage medium and can thereby avoid adjusting the pointers.

16. The computer-readable storage medium of claim 11 , wherein the relocation table is structured as a bitmap, wherein each bit corresponds to a word in the in-place executable file, wherein a set bit indicates that the word contains an internal pointer.

17. The computer-readable storage medium of claim 16 , wherein the bitmap is compressed to further reduce memory consumption.

18. The computer-readable storage medium of claim 11 , wherein the relocation table is structured as a packed list, wherein the ending address of the contiguous set of internal pointers is indicated as an offset representing the number of contiguously located internal pointers.

19. The computer-readable storage medium of claim 11 , wherein the virtual machine is a platform-independent virtual machine.

20. The computer-readable storage medium of claim 19 , wherein the virtual machine is a Java Virtual Machine.

21. An apparatus having a processor, wherein the apparatus is configured for loading an in-place executable file into a virtual machine, comprising:

a loading mechanism configured to load the in-place executable file into the virtual machine, wherein the in-place executable file contains internal pointers that point to memory locations within the in-place executable file, and a target memory address that specifies a target location in memory where the in-place executable file is configured to be loaded;

a determination mechanism configured to determine an actual memory address at which the in-place executable file is actually loaded;

an offset mechanism configured to generate an offset value, which is the difference between the actual memory address and the target memory address, if the actual memory address and the target memory address are different; and

an adjustment mechanism configured to adjust each internal pointer within the in-place executable file by the offset value so that the internal pointers point to intended locations inside the in-place executable file, if the actual memory address and the target memory address are different;

wherein the in-place executable file includes a relocation table that identifies the locations of internal pointers within the in-place executable file, wherein the relocation table is structured as a list of offset ranges, wherein each offset range includes a starting address and an ending address of a contiguous set of internal pointers within the in-place executable file; and

wherein the relocation table is removed from the in-place executable file when the in-place executable file is loaded into the virtual machine.

22. The apparatus of claim 21 , wherein the target memory address is located in a header of the in-place executable file.

23. The apparatus of claim 21 , further comprising:

a retrieval mechanism configured to retrieve a pointer to the relocation table from a header of the in-place executable file; and

an access mechanism configured to use the pointer to access the relocation table.

24. The apparatus of claim 21 , further comprising a memory reclamation mechanism configured to reclaim the memory occupied by the relocation table, after adjusting each internal pointer.

25. The apparatus of claim 21 , further comprising:

a write mechanism configured to write the in-place executable file back, with adjusted internal pointers, to the target location without the relocation table, after adjusting each internal pointer;

a bit setting mechanism configured to set a relocation bit in the in-place executable file header that indicates that relocation has already taken place, after adjusting each internal pointer; and

whereby during subsequent executions of the in-place executable file, the apparatus can access the in-place executable file, with adjusted pointers, from the storage medium and can thereby avoid adjusting the pointers.

26. The apparatus of claim 21 , wherein the relocation table is structured as a bitmap, wherein each bit corresponds to a word in the in-place executable file, wherein a set bit indicates that the word contains an internal pointer.

27. The apparatus of claim 26 , wherein the bitmap is compressed to further reduce memory consumption.

28. The apparatus of claim 21 , wherein the relocation table is structured as a packed list, wherein the ending address of the contiguous set of internal pointers is indicated as an offset representing the number of contiguously located internal pointers.

29. The apparatus of claim 21 , wherein the virtual machine is a platform-independent virtual machine.

30. The apparatus of claim 29 , wherein the virtual machine is a Java Virtual Machine.

Assignments (2)
MERGER AND CHANGE OF NAME Recorded Dec 16, 2015
From: ORACLE USA, INC.; SUN MICROSYSTEMS, INC.; ORACLE AMERICA, INC.
To: ORACLE AMERICA, INC.
Reel/Frame 037304/0194 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jun 29, 2004
From: TAIVALSAARI, ANTERO K.P.; PITTORE, WILLIAM F.
To: SUN MICROSYSTEMS, INC.
Reel/Frame 015537/0354 →