Skip to content

librdmacm: Allow librspreload version script entries the libc lacks - #1853

Open
kraj wants to merge 1 commit into
linux-rdma:masterfrom
kraj:rspreload-lfs64-map
Open

kraj wants to merge 1 commit into
linux-rdma:masterfrom
kraj:rspreload-lfs64-map

Conversation

@kraj

@kraj kraj commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

librspreload.map exports fcntl, fcntl64, sendfile and sendfile64, but which of them preload.c ends up defining depends on the libc. On musl there are no LFS64 symbols, so the fcntl64() and sendfile64() wrappers are not built, while on glibc with _FILE_OFFSET_BITS=64 the fcntl() and sendfile() wrappers are emitted as fcntl64 and sendfile64. Linkers that check the version script, like lld, then fail, e.g. on musl:

error: version script assignment of 'global' to symbol 'fcntl64' failed: symbol not defined
error: version script assignment of 'global' to symbol 'sendfile64' failed: symbol not defined

Pass --undefined-version for the preload module when the linker supports it, so whichever of these names are defined get exported.

Tested:

  • glibc x86-64, clang + lld and GNU ld 2.47: fcntl, fcntl64, sendfile and sendfile64 are all exported as before.
  • glibc x86-64 with RDMA_PRELOAD_WRAP_LFS64 forced to 0 (what musl gets), clang + lld: master fails with the errors above; with this change it links and exports fcntl and sendfile.
  • rdma-core 65.0 with clang/lld for x86-64 musl in Yocto (previous revision of this change).

Copilot AI balanced review requested due to automatic review settings November 10, 2026 14:27

Copilot AI 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.

🟡 Changes recommended

The export-map logic can hide redirected sendfile64/fcntl64 symbols, breaking interception, and overwrite the source map during in-source configuration.

2 open issues
What changed in this PR

This PR adjusts librspreload’s version script to avoid strict-linker failures when explicit LFS64 wrappers are disabled.

Changes:

  • Generate a filtered version script without fcntl64 and sendfile64 when RDMA_PRELOAD_WRAP_LFS64 is false.
  • Track the original script as a configure dependency and use the generated script for linking.
File Description
buildlib/​rdma_functions.cmake Conditionally filters LFS64 exports from librspreload’s version script.

Review effort: Balanced

Comment thread buildlib/rdma_functions.cmake Resolved
Comment thread buildlib/rdma_functions.cmake Resolved
librspreload.map exports fcntl, fcntl64, sendfile and sendfile64, but
which of them preload.c ends up defining depends on the libc. On musl
there are no LFS64 symbols, so the fcntl64() and sendfile64() wrappers
are not built, while on glibc with _FILE_OFFSET_BITS=64 the fcntl() and
sendfile() wrappers are emitted as fcntl64 and sendfile64. Linkers that
check the version script, like lld, then fail, e.g. on musl:

  error: version script assignment of 'global' to symbol 'fcntl64' failed: symbol not defined
  error: version script assignment of 'global' to symbol 'sendfile64' failed: symbol not defined

Pass --undefined-version for the preload module when the linker
supports it, so whichever of these names are defined get exported.

Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
@kraj
kraj force-pushed the rspreload-lfs64-map branch from f2ed6ae to 5cabbac Compare November 10, 2026 14:49
@kraj kraj changed the title librdmacm: Do not export LFS64 wrappers that are not built librdmacm: Allow librspreload version script entries the libc lacks Nov 10, 2026
Copilot AI balanced review requested due to automatic review settings November 10, 2026 14:49

Copilot AI 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.

🟢 Approval recommended

No active review issues remain for the change addressing librspreload linking when wrapper symbols are absent.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

# emits the plain wrappers under the 64 names. Let linkers that check the
# version script (lld) skip the names that do not exist.
RDMA_CHECK_C_LINKER_FLAG("-Wl,--undefined-version" SUPPORTS_UNDEFINED_VERSION)
if (SUPPORTS_UNDEFINED_VERSION)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think that you need to use RDMA_AddOptLDFlag() macro and don't open-code it. Can you use it here?

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.

3 participants