Skip to content

tools: add symbolprefix.sh - #22266

Merged
GUIDINGLI merged 1 commit into
apache:masterfrom
anjiahao1:20261124_tools-symbolprefix-sh
Nov 25, 2026
Merged

GUIDINGLI merged 1 commit into
apache:masterfrom
anjiahao1:20261124_tools-symbolprefix-sh

Conversation

@anjiahao1

Copy link
Copy Markdown
Contributor

Summary

Add tools/symbolprefix.sh, a helper that adds a prefix to the sections
and symbols in object files and static archives. Selected sections
and symbols can be skipped, so a section can remain shared between the
kernel and user images in a protected build.

Usage:

symbolprefix.sh [--skip-section <section>]... [--skip-symbol <file>] \
  <input...> <output> <prefix>

Impact

  • Is new feature added? YES - a host-side helper tool.
  • Impact on user: NO
  • Impact on build: NO
  • Impact on hardware: NO
  • Impact on documentation: NO
  • Impact on security: NO
  • Impact on compatibility: NO

Testing

Build host: Linux x86_64 (Ubuntu 24.04), GCC 13.3.0

  • bash -n tools/symbolprefix.sh
  • Smoke test: compiled a small object with symbols foo and bar,
    ran the tool with prefix myprefix_, and verified the result:
$ nm sp_out.o | grep myprefix
0000000000000000 T myprefix_bar
0000000000000000 D myprefix_foo

$ readelf -S sp_out.o | grep myprefix
[ 1] .myprefix_text    PROGBITS ...
[ 2] .myprefix_data    PROGBITS ...
[ 3] .myprefix_bss     NOBITS ...

PR verification

  • This PR introduces only one functional change.
  • I have updated all required description fields above.
  • My PR adheres to Contributing Guidelines and Documentation.
  • My PR is still work in progress (not ready for review).
  • My PR is ready for review and can be safely merged into a codebase.

Add a tool that adds a prefix to the sections and symbols in object
files and static archives.  Selected sections and symbols can be
skipped, which allows a section to remain shared between the kernel
and user images in a protected build.

Usage:
  symbolprefix.sh [--skip-section <section>]... [--skip-symbol <file>] \
    <input...> <output> <prefix>

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
@github-actions github-actions Bot added Area: Build system Size: M The size of the change in this PR is medium labels Nov 24, 2026
@github-actions

Copy link
Copy Markdown

@GUIDINGLI
GUIDINGLI merged commit fdfb543 into apache:master Nov 25, 2026
58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Build system Size: M The size of the change in this PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants