Skip to content

BaseTools: Add --export-symbol option to GenFw for explicit symbol exports#1621

Draft
Flickdm wants to merge 1 commit intomicrosoft:release/202502from
Flickdm:feature/export-symbol
Draft

BaseTools: Add --export-symbol option to GenFw for explicit symbol exports#1621
Flickdm wants to merge 1 commit intomicrosoft:release/202502from
Flickdm:feature/export-symbol

Conversation

@Flickdm
Copy link
Member

@Flickdm Flickdm commented Jan 29, 2026

Description

Add --export-symbol option to GenFw for explicit symbol exports

Add support for explicitly specifying symbols to export when converting ELF to PE-COFF format. This enables exporting specific function symbols.

Changes:

  • GenFw.c: Add --export-symbol=NAME argument parsing to specify symbols for export. Multiple symbols can be specified with repeated arguments.
  • ElfConvert.h: Add extern declarations for export symbol tracking.
  • Elf64Convert.c: When explicit export symbols are provided, use those instead of auto-detecting PRM module exports. Searches the ELF symbol table for the specified symbols and adds them to be the PE-COFF export directory.

This feature is needed for GCC/LTO builds where symbols may not be automatically detected for export but need to be explicitly specified in the module's INF BuildOptions.

Usage in INF [BuildOptions]:
GCC:__DLINK_FLAGS = -Wl,--undefined=CryptoEntry
GCC:
_OBJCOPY_STRIPFLAG = --strip-unneeded -R .eh_frame --keep-symbol=CryptoEntry
GCC:*
__GENFW_FLAGS = --export-symbol=CryptoEntry"
For details on how to complete these options and their meaning refer to CONTRIBUTING.md.

  • Impacts functionality?
  • Impacts security?
  • Breaking change?
  • Includes tests?
  • Includes documentation?

How This Was Tested

<Describe the test(s) that were run to verify the changes.>

Integration Instructions

<Describe how these changes should be integrated. Use N/A if nothing is required.>

@codecov-commenter
Copy link

codecov-commenter commented Jan 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (release/202502@668bdb5). Learn more about missing BASE report.

Additional details and impacted files
@@                Coverage Diff                @@
##             release/202502    #1621   +/-   ##
=================================================
  Coverage                  ?    2.22%           
=================================================
  Files                     ?     1460           
  Lines                     ?   381059           
  Branches                  ?     4584           
=================================================
  Hits                      ?     8477           
  Misses                    ?   372509           
  Partials                  ?       73           
Flag Coverage Δ
MdeModulePkg 1.55% <ø> (?)
MdePkg 5.46% <ø> (?)
NetworkPkg 0.55% <ø> (?)
PolicyServicePkg 30.42% <ø> (?)
UefiCpuPkg 4.92% <ø> (?)
UnitTestFrameworkPkg 11.40% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Flickdm Flickdm force-pushed the feature/export-symbol branch 2 times, most recently from 5c73f54 to 84a8b9d Compare January 30, 2026 20:01
Add support for the --export-symbol=NAME command-line option to GenFw.
This allows users to explicitly specify symbols to export to the
PE-COFF export table as an alternative to the PRM (Platform Runtime
Mechanism) automatic discovery.

Key changes:
- New --export-symbol=NAME option can be specified multiple times
- Supports up to 256 explicit export symbols
- Works for X64 and AArch64 architectures
- Validates that all requested symbols are found in the ELF file
- Updates error message to reflect both --prm and --export-symbol support

This feature enables more flexible symbol export control for scenarios
where PRM module export descriptors are not applicable.

Usage in INF [BuildOptions]:
  GCC:*_*_*_DLINK_FLAGS = -Wl,--undefined=CryptoEntry
  GCC:*_*_*_OBJCOPY_STRIPFLAG = --strip-unneeded -R .eh_frame \
                                --keep-symbol=CryptoEntry
  GCC:*_*_*_GENFW_FLAGS = --export-symbol=CryptoEntry

Validation on Linux:
  llvm-readobj --coff-exports YourModule.efi

Signed-off-by: Doug Flick <dougflick@microsoft.com>
@Flickdm Flickdm force-pushed the feature/export-symbol branch from 84a8b9d to 0da25e0 Compare January 30, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants