From 30c702e04297a891b8fa0426905cb198282a709e Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Mon, 30 Jun 2025 15:43:34 +0800 Subject: [PATCH 1/2] docs(design):staticLib --- doc/en/dev/llcppg.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/en/dev/llcppg.md b/doc/en/dev/llcppg.md index 7bcbf740..a4161d1d 100644 --- a/doc/en/dev/llcppg.md +++ b/doc/en/dev/llcppg.md @@ -559,7 +559,8 @@ If `config-file` is not specified, a `llcppg.cfg` file is used in current direct "trimPrefixes": ["Ini", "INI"], "cplusplus":true, "deps":["c","github.com/..../third"], - "mix":false + "mix":false, + "staticLib": false } ``` @@ -575,6 +576,7 @@ The configuration file supports the following options: - `mix`: Set to true when package header files are mixed with other header files in the same directory. In this mode, only files explicitly listed in `include` are processed as package files. - `typeMap`: Custom name mapping from C types to Go types. - `symMap`: Custom name mapping from C function names to Go function names. +- `staticLib`: Set to true to enable static library symbol reading instead of dynamic library linking. When enabled, llcppg will read symbols from static libraries (.a files) rather than dynamic libraries (.so/.dylib files). ## Output From 41be164503d2a723bb8d6f0bf96fb9d10618de88 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Mon, 30 Jun 2025 15:56:27 +0800 Subject: [PATCH 2/2] docs(design):llcppsymg static lib mode --- doc/en/dev/llcppg.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/en/dev/llcppg.md b/doc/en/dev/llcppg.md index a4161d1d..c2ff5d3c 100644 --- a/doc/en/dev/llcppg.md +++ b/doc/en/dev/llcppg.md @@ -672,12 +672,19 @@ llcppsymg config-file llcppsymg - # read config from stdin ``` -llcppsymg is the symbol table generator in the llcppg toolchain, responsible for analyzing C/C++ dynamic libraries and header files to generate symbol mapping tables. Its main functions are: +llcppsymg is the symbol table generator in the llcppg toolchain, responsible for analyzing C/C++ libraries (dynamic or static) and header files to generate symbol mapping tables. Its main functions are: -1. Parse dynamic library symbols: Extract exported symbols from libraries using the nm tool +1. Parse library symbols: Extract exported symbols from libraries using the nm tool 2. Parse header file declarations: Analyze C/C++ header files using libclang for function declarations 3. Find intersection: Match library symbols with header declarations and then generate symbol table named `llcppg.symb.json`. +#### Static Library Support + +When `staticLib: true` is configured in `llcppg.cfg`, llcppsymg switches to static library mode: + +- **Dynamic Library Mode (default)**: Uses nm tool to extract symbols from .so/.dylib files +- **Static Library Mode**: Uses nm tool to extract symbols from .a files + #### Symbol Table This symbol table determines whether the function appears in the generated Go code态its actual name and if it is a method. Its file format is as follows: