GENERATING CODE FOR FUNCTION CALLS THAT USE MULTIPLE ADDRESSING MODES
First Claim
1. An apparatus comprising:
- at least one processor;
a memory coupled to the at least one processor; and
a linker residing in the memory and executed by the at least one processor, the linker comprising;
a multiple addressing mode resolver that generates code to resolve a plurality of function calls in a computer program, wherein at least one of the plurality of function calls has a caller instruction that references a callee function, wherein the plurality of function calls includes a first function call that comprises code that uses a first addressing mode where a first address for first data is specified as an offset from a base pointer, where the base pointer is stored in a fixed processor register, wherein the plurality of function calls includes a second function call that comprises code that uses a relative addressing mode where a second address for second data is specified as an offset from an address of an instruction that references the second data, wherein the relative addressing mode does not preserve the base pointer stored in the fixed processor register.
1 Assignment
0 Petitions
Accused Products
Abstract
A compiler and linker include multiple addressing mode resolvers that generate code to resolve a plurality of function calls that use different addressing modes. A first addressing mode is defined where a first address for first data is specified as an offset from a base pointer. A second, relative addressing mode is defined where a second address for second data is specified as an offset from an address of an instruction that references the second data. The generated code assures correct operation when functions with different addressing modes are included in the computer program. The generated code preserves a base pointer when executing a function that uses relative addressing, when needed. The compiler inserts one or more relocation markers that trigger certain functions in the linker. A linker resolves the relocation markers inserted by the compiler, and generates code, when needed, that handles a mismatch between addressing modes.
0 Citations
19 Claims
-
1. An apparatus comprising:
-
at least one processor; a memory coupled to the at least one processor; and a linker residing in the memory and executed by the at least one processor, the linker comprising; a multiple addressing mode resolver that generates code to resolve a plurality of function calls in a computer program, wherein at least one of the plurality of function calls has a caller instruction that references a callee function, wherein the plurality of function calls includes a first function call that comprises code that uses a first addressing mode where a first address for first data is specified as an offset from a base pointer, where the base pointer is stored in a fixed processor register, wherein the plurality of function calls includes a second function call that comprises code that uses a relative addressing mode where a second address for second data is specified as an offset from an address of an instruction that references the second data, wherein the relative addressing mode does not preserve the base pointer stored in the fixed processor register. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9)
-
-
10. An apparatus comprising:
-
at least one processor; a memory coupled to the at least one processor; and a linker residing in the memory and executed by the at least one processor, the linker comprising; a multiple addressing mode resolver that generates code to resolve a plurality of function calls in a computer program, wherein at least one of the plurality of function calls has a caller instruction that references a callee function, wherein the plurality of function calls includes a first function call that comprises code that uses a first addressing mode where a first address for first data is specified as an offset from a base pointer, where the base pointer is stored in a fixed processor register, wherein the plurality of function calls includes a second function call that comprises code that uses a relative addressing mode where a second address for second data is specified as an offset from an address of an instruction that references the second data, wherein the relative addressing mode does not preserve the base pointer stored in the fixed processor register, wherein the multiple addressing mode resolver scans a text portion of the computer program to locate a relocation marker inserted by a compiler to indicate the caller instruction at the relocation marker does not need the base pointer and determines when a target of the caller instruction at the relocation marker can be resolved from the text portion, and when the target of the caller instruction cannot be resolved from the text portion, the multiple addressing mode resolver generates first stub code to resolve the target of the caller instruction at run-time and modifies the caller instruction to target the first stub code, and when a target of the caller instruction can be resolved from the text portion, the multiple addressing mode resolver determines whether the callee function of the caller instruction requires the base pointer, and when the callee function of the caller instruction does not require the base pointer, the multiple addressing mode resolver modifies the caller instruction to target the callee function, and when the callee function of the caller instruction requires the base pointer, the multiple addressing mode resolver generates second stub code to directly resolve a target of the caller instruction, and optimized so there is no save of the first fixed processor register in the second stub code, and modifies the caller instruction to target the second stub code.
-
-
11. A method for linking a computer program, the method comprising:
-
scanning a text portion of a computer program for a plurality of function calls; and generating code to resolve the plurality of function calls, wherein at least one of the plurality of function calls has a caller instruction that references a callee function, wherein the plurality of function calls includes a first function call that comprises code that uses a first addressing mode where a first address for first data is specified as an offset from a base pointer, where the base pointer is stored in a fixed processor register, wherein the plurality of function calls includes a second function call that comprises code that uses a relative addressing mode where a second address for second data is specified as an offset from an address of an instruction that references the second data, wherein the relative addressing mode does not preserve the base pointer stored in the fixed processor register. - View Dependent Claims (12, 13, 14, 15, 16, 17, 18, 19)
-
Specification