Skip to content

Add REPL exports command backed by optional LIEF integration - #4

Open
YSaxon wants to merge 2 commits into
masterfrom
codex/add-symbol-listing-feature-in-repl-mode
Open

Add REPL exports command backed by optional LIEF integration#4
YSaxon wants to merge 2 commits into
masterfrom
codex/add-symbol-listing-feature-in-repl-mode

Conversation

@YSaxon

@YSaxon YSaxon commented Mar 10, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Provide an easy REPL command to list exported symbols/functions from a shared library in a cross-platform, cross-architecture way using LIEF when available.
  • Integrate LIEF consistently with existing dependency patterns so cross-target CI (Conan/CMakeDeps / find_package) can supply LIEF across architectures while allowing local builds to remain optional.

Description

  • Add a new LIEF-backed module src/export_symbols.cpp and header src/export_symbols.h that expose list_exported_symbols_with_lief() and print exported symbol names when CLIFFI_HAS_LIEF is enabled.
  • Add a new REPL command parser parseListExports() and wire exports <library> into src/main.c (help text, command routing, and error handling) to call the new module.
  • Update CMakeLists.txt to enable C++ compilation, add export_symbols.cpp to sources, and detect/link LIEF via pkg-config or find_package(lief) depending on the build flow; expose CLIFFI_HAS_LIEF compile-time definition when found.
  • Add lief/0.15.1 to conanfile.txt, update README.md docs, Homebrew formula cliffi.rb, and macOS CI steps to include LIEF so cross-arch CI can supply the dependency.
  • Provide a graceful runtime fallback: if LIEF is not available in the build, exports prints a clear error instructing users to rebuild with LIEF support.

Testing

  • Configured and built with cmake -S . -B build -DCMAKE_BUILD_TYPE=Release and cmake --build build -j4 successfully.
  • Ran the full test suite with ctest --output-on-failure and all unit/integration tests passed (156/156 tests passed).
  • Manually exercised the new REPL command with a local build lacking LIEF: printf 'exports ./build/libcliffi_test.so\nexit\n' | ./build/cliffi --repl and observed the graceful fallback error message (expected behavior).
  • Attempted conan install to validate Conan/CMakeDeps flow but conan was not available in the environment, so cross-arch package validation was not executed locally.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2ea66090b4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/export_symbols.cpp
#include <memory>

bool list_exported_symbols_with_lief(const char* library_path) {
std::unique_ptr<LIEF::Binary> binary = LIEF::Parser::parse(library_path);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Set a minimum C++ standard for the LIEF codepath

This new implementation uses C++11 features (std::unique_ptr and range-based iteration), but the build files do not set CMAKE_CXX_STANDARD (or target-level CXX_STANDARD), so builds that enable LIEF on toolchains whose default is pre-C++11 will fail at compile time. This is especially risky for older cross-compilers in the dockcross/conan workflow where defaults vary by image.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant