# US 2014/0157247 A1 · Enabling Symbol Resolution of Private Symbols in Legacy Programs and Optimizing Access to the Private Symbols

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2014/0157247 A1
- Document ID: US20140157247A1
- Status: Published application
- Kind: A1
- Application number: 13/690,513
- Filed: 2012-11-30
- Published: 2014-06-05
- Earliest claimed: 2012-11-30
- Assignees: Oracle International Corporation
- Applicants: Oracle International Corporation
- Inventors: Mason Chang; Hassan Chafi; Eric Sedlar
- Web page: https://patentgrep.com/patent/US20140157247A1

## CPC

- G06F 8/4441: {Reducing the execution time required by the program code}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method for generating a binary executable of a program so that private symbols in a module are accessible from another module. In one embodiment, the method compiles a source program to an intermediate representation and scans the representation to find the private symbols in the program's modules. It then wraps a function around each private symbol. When called, the function returns an address of the private symbol, so that the other module can access the symbol from outside the module in which the symbol is found. At run time, a call is made to obtain the address of the function, which is then executed to obtain the address of the private symbol so that the symbol can be accessed. In another embodiment, a Just-In-Time compiler executes the wrapper functions and patches the executable program with the direct address of the private symbol to avoid a call to the wrapper function.

## Claims

### Claim 1

A method for generating an executable binary of a program in which private symbols are externally accessible, the method comprising:
generating an intermediate representation (IR) of the program by compiling the program,
wherein the program contains at least one module that includes one or more private symbols, and
wherein each private symbol is accessible only within the at least one module;
discovering the private symbols in the program by scanning the IR;
generating a wrapper function for each of the discovered private symbols, such that calling the wrapper function provides access to the private symbol from another module;
combining the program with the wrapper functions to create a combined program; and
generating the executable binary by recompiling the combined program, so that the other module in the executable binary has access to each of the private symbols of the at least one module by calling the wrapper function for the private symbol.

### Claim 2 (depends on 1)

The method of claim 1, wherein the program is a C program.

### Claim 3 (depends on 1)

The method of claim 1, wherein the program is a C++ program.

### Claim 4 (depends on 1)

The method of claim 1,
wherein calling the wrapper function returns a pointer to the private symbol; and
wherein dereferencing the pointer gives access to a value of the private symbol.

### Claim 5 (depends on 1)

The method of claim 1, wherein at least one of the private symbols is declared “static.”

### Claim 6

A non-transitory computer-readable medium containing one or more sequences of instructions for generating an executable binary of a program in which private symbols are externally accessible, wherein execution of the one or more sequences of instructions by one or more processors causes the one or more processors to perform the steps of:
generating an intermediate representation (IR) of the program by compiling the program, wherein the program contains at least one module that includes one or more private symbols, and wherein each private symbol is accessible only within the at least one module;
discovering the private symbols in the program by scanning the IR;
generating a wrapper function for each of the discovered private symbols, such that calling the wrapper function provides access to the private symbol from another module;
combining the program with the wrapper functions to create a combined program; and
generating the executable binary by recompiling the combined program, so that the other module in the executable binary has access to each of the private symbols of the at least one module by calling the wrapper function for the private symbol.

### Claim 7 (depends on 6)

The non-transitory computer-readable medium of claim 6, wherein the program is a C program.

### Claim 8 (depends on 6)

The non-transitory computer-readable medium of claim 6, wherein the program is a C++ program.

### Claim 9 (depends on 6)

The non-transitory computer-readable medium of claim 6,
wherein calling the wrapper function returns a pointer to the private symbol; and
wherein dereferencing the pointer gives access to a value of the private symbol.

### Claim 10 (depends on 6)

The non-transitory computer-readable medium of claim 6, wherein at least one of the private symbols is declared “static.”

### Claim 11

A method for generating an executable binary of a program in which private symbols are externally accessible, the method comprising:
generating an intermediate representation (IR) of the program by compiling the program,
wherein the program contains at least one module that includes one or more private symbols,
wherein the IR contains a wrapper function for each private symbol, and
wherein the wrapper function, when called, provides an address for each private symbol so that a function in another module has access to the private symbol via the address; and
generating the executable binary by recompiling the program, wherein recompiling includes, for each private symbol:
identifying a pointer to the wrapper function by scanning the IR;
obtaining a direct address of the private symbol by using the pointer to the wrapper function to execute the wrapper function;
creating an optimized function that contains the direct address for the private symbol; and
patching the function in the other module so that the function executes the optimized function to access the private symbol.

### Claim 12 (depends on 11)

The method of claim 11, wherein the program is a C program.

### Claim 13 (depends on 11)

The method of claim 11, wherein the program is a C++ program.

### Claim 14 (depends on 11)

The method of claim 11,
wherein the function included in the wrapper, when executed, returns a pointer to the private symbol; and
wherein obtaining access to the private symbol includes dereferencing the pointer to the private symbol.

### Claim 15 (depends on 11)

The method of claim 11, wherein at least one of the private symbols is declared “static.”

### Claim 16 (depends on 11)

The method of claim 11, wherein patching the function includes placing in the function a jump to the optimized function.

### Claim 17

A non-transitory computer-readable medium containing one or more sequences of instructions for generating an executable binary of a program in which private symbols are externally accessible, wherein execution of the one or more sequences of instructions by one or more processors causes the one or more processors to perform the steps of:
generating an intermediate representation (IR) of the program by compiling the program,
wherein the program contains at least one module that includes one or more private symbols,
wherein the IR contains a wrapper function for each private symbol, and
wherein the wrapper function, when called, provides an address for each private symbol so that a function in another module has access to the private symbol via the address; and
generating the executable binary by recompiling the program, wherein recompiling includes, for each private symbol:
identifying a pointer to the wrapper function by scanning the IR;
obtaining a direct address of the private symbol by using the pointer to the wrapper function to execute the wrapper function;
creating an optimized function that contains the direct address for the private symbol; and
patching the function in the other module so that the function executes the optimized function to access the private symbol.

### Claim 18 (depends on 17)

The non-transitory computer-readable medium of claim 17, wherein the program is a C program.

### Claim 19 (depends on 17)

The non-transitory computer-readable medium of claim 17, wherein the program is a C++ program.

### Claim 20 (depends on 17)

The non-transitory computer-readable medium of claim 17,
wherein the function included in the wrapper, when executed, returns a pointer to the private symbol; and
wherein obtaining access to the private symbol includes dereferencing the pointer to the private symbol.

### Claim 21 (depends on 17)

The non-transitory computer-readable medium of claim 17, wherein at least one of the private symbols is declared “static.”

### Claim 22 (depends on 17)

The method of claim 17, wherein patching the function includes placing in the function a jump to the optimized function.
