Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libsys: Add CHERI_LIB_C18N to CFLAGS when appropriate #2217

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/c18n/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ CHERI_LIB_C18N=yes
SHLIBDIR= /usr/lib${COMPAT_libcompat:U}/c18n
LIBDIR= /usr/lib${COMPAT_libcompat:U}/c18n

CFLAGS+=-DCHERI_LIB_C18N

.include "../Makefile.inc"
4 changes: 0 additions & 4 deletions lib/libc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ CANCELPOINTS_CFLAGS=-fexceptions
CFLAGS+=${CANCELPOINTS_CFLAGS}
.endif

.ifdef CHERI_LIB_C18N
CFLAGS+=-DCHERI_LIB_C18N
.endif

# Use a more efficient TLS model for libc since we can reasonably assume that
# it will be loaded during program startup.
CFLAGS+= -ftls-model=initial-exec
Expand Down
2 changes: 1 addition & 1 deletion lib/libc/include/libc_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ int __strerror_rl(int errnum, char *strerrbuf, size_t buflen,

#ifdef CHERI_LIB_C18N
__pid_t __sys_rfork(int);
int sigaction_c18n(int, const struct sigaction *, struct sigaction *);
int _rtld_sigaction(int, const struct sigaction *, struct sigaction *);
#endif

#endif /* _LIBC_PRIVATE_H_ */
13 changes: 0 additions & 13 deletions lib/libc/sys/sigaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,6 @@

__weak_reference(__sys_sigaction, __sigaction);
__weak_reference(sigaction, __libc_sigaction);
#ifdef CHERI_LIB_C18N
/*
* This weak symbol will always be resolved at runtime.
*/
#pragma weak _rtld_sigaction
int _rtld_sigaction(int, const struct sigaction *, struct sigaction *);

int
sigaction_c18n(int sig, const struct sigaction *act, struct sigaction *oact)
{
return (_rtld_sigaction(sig, act, oact));
}
#endif

#pragma weak sigaction
int
Expand Down
15 changes: 14 additions & 1 deletion lib/libsys/interposing_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@
#include <sys/types.h>
#include "libc_private.h"

#ifdef CHERI_LIB_C18N
/*
* XXX: A wrapper is needed to redirect the call because directly referencing
* _rtld_sigaction as a function pointer causes it to not be wrapped in a
* trampoline at the moment.
*/
int
_rtld_sigaction_wrapper(int sig, const struct sigaction *oact,
struct sigaction *act) {
return (_rtld_sigaction(sig, oact, act));
}
#endif

#define SLOT(a, b) \
[INTERPOS_##a] = (interpos_func_t)b
static interpos_func_t __libsys_interposing[INTERPOS_MAX] = {
Expand All @@ -57,7 +70,7 @@ static interpos_func_t __libsys_interposing[INTERPOS_MAX] = {
SLOT(sendto, __sys_sendto),
SLOT(setcontext, __sys_setcontext),
#ifdef CHERI_LIB_C18N
SLOT(sigaction, sigaction_c18n),
SLOT(sigaction, _rtld_sigaction_wrapper),
#else
SLOT(sigaction, __sys_sigaction),
#endif
Expand Down
4 changes: 0 additions & 4 deletions lib/libthr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,9 @@
CFLAGS+=-D_PTHREAD_FORCED_UNWIND
.endif

.ifdef CHERI_LIB_C18N
CFLAGS+=-DCHERI_LIB_C18N
.endif

LDFLAGS+=-Wl,-znodelete
LDFLAGS+=-Wl,--auxiliary,libsys.so.7

Check warning on line 64 in lib/libthr/Makefile

View workflow job for this annotation

GitHub Actions / Style Checker

Missing Signed-off-by: line
VERSION_DEF=${SRCTOP}/lib/libc/Versions.def
SYMBOL_MAPS=${LIBTHR_SRCTOP}/pthread.map

Expand Down
Loading