Wrapper Functions for Private Symbol Access in Legacy Binaries

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Legacy C or C++ code often has private symbols that are not accessible for dynamic linking, preventing new modules from being integrated, as static linkers resolve symbols differently and dynamic linkers struggle with private symbols unless all symbols are exported, which is impractical or error-prone.

Innovation Solution

Generating an intermediate representation (IR) of the program to discover private symbols, creating wrapper functions to make them accessible, and recompiling to include these functions in the executable binary, allowing dynamic linking and hot patching without rewriting entire programs.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Adaptability or versatility

If all symbols are exported to enable dynamic linking, then new modules can be dynamically linked in, but the complexity of the program increases and maintenance becomes error-prone

Engineering Contradiction:
Improvedynamic linking capabilityVSAvoidprogram complexity
Core Design Contradiction:
Adaptability or versatilityVSDevice complexity

Solution Approach 1:

The patent introduces a dynamic linker as an intermediary component that sits between the legacy binary and new modules. This dynamic linker interceptorsymbol resolution requests and dynamically generates the necessary bindings at runtime, allowing new modules to access private symbols without modifying the original binary or manually exporting symbols. This mediator approach enables dynamic linking capability while keeping the original program structure intact and avoiding the complexity of manual symbol export management.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The patent performs preliminary analysis of the legacy binary to identify private symbols that need to be accessed by new modules. By pre-scanning the binary and building a symbol table of private symbols before runtime, the system prepares the necessary information in advance. This preliminary action allows the dynamic linker to quickly resolve symbols during runtime without requiring all symbols to be pre-exported, thus enabling dynamic linking while maintaining program integrity.

Inventive Principle:
Principle #10Preliminary action

2Adaptability or versatility

If manual inspection and explicit export of private symbols is performed, then new modules can access private symbols, but the process becomes error-prone and requires modifying the original program

Engineering Contradiction:
Improvemodule accessibilityVSAvoiderror proneness
Core Design Contradiction:
Adaptability or versatilityVSReliability

Solution Approach 1:

The patent implements a self-service mechanism where the dynamic linker automatically scans the legacy binary, identifies private symbols, and generates appropriate bindings without requiring manual intervention. The system extracts symbol information directly from the binary structure and automatically creates the necessary resolution pathways. This self-service approach eliminates manual inspection and explicit export requirements, reducing errors while maintaining module accessibility.

Inventive Principle:
Principle #25Self-service

3Extent of automation

If a C parser is written to resolve private symbols, then automatic symbol resolution is achieved, but the difficulty of implementation increases due to the C macro system

Engineering Contradiction:
Improveautomatic symbol resolutionVSAvoidparser implementation complexity
Core Design Contradiction:
Extent of automationVSDevice complexity

Solution Approach 1:

The patent replaces the mechanical approach of writing a C parser with a binary analysis approach. Instead of parsing C source code through the complex macro system, the system directly analyzes the compiled binary structure to extract symbol information. This substitution avoids the pitfalls of C macro parsing while achieving automatic symbol resolution through binary inspection and pattern recognition.

Inventive Principle:
Principle #28Mechanics substitution (Replace mechanical system)

4Adaptability or versatility

If wrapper functions are generated for private symbols, then dynamic linking is enabled, but performance slightly decreases due to the added level of indirection

Engineering Contradiction:
Improvedynamic linking supportVSAvoidsymbol resolution speed
Core Design Contradiction:
Adaptability or versatilityVSSpeed

Solution Approach 1:

The patent performs preliminary binding of wrapper functions to their target private symbols during the dynamic linker initialization phase. By pre-resolving the addresses and caching the bindings, the system minimizes runtime overhead. When new modules need to access private symbols, the pre-established bindings are used directly without requiring runtime function generation or complex resolution processes, thus reducing the performance impact of the wrapper function indirection.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS8881123B2Enabling symbol resolution of private symbols in legacy programs and optimizing access to the private symbols
Publication Date: 2014.11.04 ORACLE INT CORP
  • US8881123B2 patent drawing
  • US8881123B2 patent drawing
  • US8881123B2 patent drawing

AI summary

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.