Skip to content

Improve binutils to readsyms from binary file#7109

Merged
waruqi merged 22 commits intodevfrom
binutils
Dec 9, 2025
Merged

Improve binutils to readsyms from binary file#7109
waruqi merged 22 commits intodevfrom
binutils

Conversation

@waruqi
Copy link
Member

@waruqi waruqi commented Dec 8, 2025

Support object file, shared library, static library, binary file. (coff/elf/macho)

$ xmake l utils.binary.readsyms.dump ./tests/projects/c/console/build/.objs/test/mingw/i386/release/src/main.c.obj

Symbols:
  TYPE  NAME
--------------------------------------------------------------------------------
  T     _main
  U     __imp____acrt_iob_func
  U     ___main
  U     ___mingw_vfprintf

@waruqi waruqi added this to the v3.0.6 milestone Dec 8, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @waruqi, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances Xmake's binary utility toolkit by integrating a robust symbol reading feature. The new binutils.readsyms function provides the ability to parse and extract symbol information from common object file formats like COFF, ELF, and Mach-O, automatically detecting the file type. This enhancement is built upon a substantial refactoring of the existing binary conversion utilities, promoting modularity and maintainability. A user-friendly Lua module is also included, enabling developers to easily inspect symbols directly from the command line.

Highlights

  • New Symbol Reading Functionality: Introduced binutils.readsyms, a new function that allows users to extract and inspect symbol tables from various binary object file formats.
  • Multi-Format Support: The readsyms function supports automatic detection and parsing of COFF, ELF, and Mach-O binary formats.
  • Code Refactoring and Modularity: Existing binary utility functions (bin2coff, bin2elf, bin2macho) have been refactored into format-specific subdirectories (coff, elf, macho), with common definitions and helper functions moved to dedicated prefix headers for better organization and reusability.
  • Lua Integration and CLI Utility: The new symbol reading capabilities are exposed through Lua wrappers and a new xmake/modules/utils/binary/readsyms.lua module, providing a command-line interface for dumping symbol information in a human-readable format.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant and well-structured refactoring of the binutils module. By organizing the code into coff, elf, and macho subdirectories, you've greatly improved modularity and maintainability. The addition of the readsyms feature to read symbols from binary files is a valuable enhancement.

My review focuses on a few key areas:

  • Error Handling and Resource Management: I've identified a memory leak and unchecked return values in the new COFF symbol reading logic.
  • Correctness: There's a critical issue in the Mach-O symbol reader related to handling file endianness, which could cause it to fail on certain files.
  • Code Style: A minor formatting issue was found.

Overall, this is a great contribution. Addressing the identified issues will make the new functionality more robust and reliable.

@waruqi waruqi merged commit f2dcbc2 into dev Dec 9, 2025
59 of 63 checks passed
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.

1 participant