Commit Graph
9 Commits
Author SHA1 Message Date
SymbX 9e79e97458 workaround for waitpid
Make a Github release / release (push) Skipped
2026-10-02 00:12:54 +03:00
SymbX 3f08204f92 workaround to support pidfd_open (backported) while waitpid is missing
Make a Github release / release (push) Skipped
2026-09-29 22:35:50 +03:00
Yu Watanabe 0ce8c68f02 include: use linux/pidfd.h rather than sys/pidfd.h
Since glibc-2.43, sys/pidfd.h defines struct pidfd_info, but its
definition is slightly older compared with linux v6.19. See
https://sourceware.org/git/?p=glibc.git;a=commit;h=c0c9524a11c56889ec5b1de2e0b78112f2ebc0b7
https://lore.kernel.org/all/20251028-work-coredump-signal-v1-0-ca449b7b7aa0@kernel.org/

This imports linux/pidfd.h (and linux/ioctl.h) from the kernel 7.2-rc6,
and make our header that overrides sys/pidfd.h includes linux/pidfd.h.
Then, we can always use uptodate definition of struct pidfd_info.

Note, linux/pidfd.h includes linux/fcntl.h, but it conflicts glibc's
fcntl.h. So, this also replaces linux/fcntl.h with glibc's fcntl.h.
2026-08-11 00:27:15 +09:00
Emanuele Rocca 577f2f975d include: add coredump_code to struct pidfd_info
Linux v7.1 adds coredump_code to struct pidfd_info and defines a few new
constants. Reflect the changes in include/override/sys/pidfd.h too.

Stop including the libc version of sys/pidfd.h to be able to override the
definition of pidfd_info.

Signed-off-by: Emanuele Rocca <emanuele.rocca@arm.com>
2026-05-19 08:14:18 +00:00
Daan De Meyer f795d54591 libc,shared: detect newer library symbols at runtime
For libc syscall wrappers (pidfd_open, fsopen, openat2, etc.) we previously
gated the calls behind build-time HAVE_* checks. Replace these with shim
functions in src/libc/ that fall back to the raw syscall at runtime when the
loaded glibc lacks the symbol. The infrastructure lives in src/libc/libc-shim.h:
DEFINE_SYSCALL_SHIM falls back to a direct syscall, DEFINE_LIBC_SHIM returns
ENOSYS (for posix_spawn-family helpers that have no corresponding syscall), and
DEFINE_LIBC_ERRNO_SHIM sets errno=ENOSYS and returns -1 (for read/write-style
helpers). The weak reference to the libc symbol is bound via __asm__(\"name\")
rename so the bare libc identifier never appears as a C token — this avoids
both #undef boilerplate against override-header redirects and the resulting
-Wredundant-decls warning. Drop the corresponding cc.has_function() loop from
meson.build.

For optional libraries (libcryptsetup, libdw, libarchive), drop the per-symbol
HAVE_* checks. Always declare the prototypes, suppressing the redundant-decl
warnings via DISABLE_WARNING_REDUNDANT_DECLS and NOLINT, and resolve the symbols
after the main dlopen via a new DLSYM_OPTIONAL() helper that only assigns on
success. libcryptsetup's crypt_set_keyring_to_link / crypt_token_set_external_path
and libarchive's *_is_set wrappers use fallback functions as their pointer
initializers (returning -ENOSYS and 0 respectively), so call sites can invoke
the symbol unconditionally and just check for -ENOSYS where the \"not supported\"
distinction matters.

The same shim treatment applies to pidfd_spawn / posix_spawnattr_setcgroup_np
(src/libc/spawn.c) and epoll_pwait2 (src/libc/epoll.c), with corresponding
override headers in src/include/override/spawn.h and
src/include/override/sys/epoll.h. posix_spawn_wrapper() in process-util.c and
epoll_wait_usec() in sd-event.c now detect ENOSYS in the return value instead
of checking the function pointer, falling back to plain posix_spawn() and
epoll_wait() respectively. coredump-config and coredump-submit get a
dlopen_dw_has_dwfl_set_sysroot() helper. The kexec arch gate now uses
defined(__NR_kexec_file_load) directly; pidfd.h uses __has_include_next() to
decide whether to pull in glibc's header.

This lets binaries built against newer glibc / libcryptsetup / libdw /
libarchive headers still load and run on older targets where these symbols are
absent.
2026-05-13 10:29:50 +02:00
Yu Watanabe 208f88def3 include: update struct pidfd_info and relevant constants 2025-10-19 10:01:46 +09:00
Daan De Meyer 3111327ca4 include: Add missing IWYU pragmas 2025-09-19 12:44:29 +02:00
Yu Watanabe 543a48b653 libc-wrapper: introduce a tiny libc wrapper
Then, move syscall definitions to the wrapper, and prototypes are moved
to relevant headers.

This also adds checks for add_key() and request_key(), as one day
glibc may be going to add some of them separatedly.

The check for fspick in meson.build is dropped, as it is currently
unused in our code.

This also moves
- basic/missing_bpf.h -> include/override/linux/bpf.h,
- basic/missing_keyctl.h -> include/override/linux/keyctl.h.
2025-07-11 13:05:46 +09:00
Yu Watanabe 1a60b97524 include: move libc header wrappers to src/include/override/, and kernel headers to src/include/uapi/
Preparation for later changes.
2025-07-11 12:44:26 +09:00