Skip to content

Commit

Permalink
libc: switch to __weak_symbol for fortified interpose stubs
Browse files Browse the repository at this point in the history
GCC doesn't like `#pragma weak macro(foo)`, but that's fine; just slap
a __weak_symbol on the definition to more reliably make it weak
anyways.

Reviewed by:	kib (earlier version), markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45976
  • Loading branch information
kevans91 committed Jul 16, 2024
1 parent 0c47b9c commit d5f8270
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 10 deletions.
3 changes: 1 addition & 2 deletions lib/libc/sys/poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@

__weak_reference(__sys_poll, __poll);

#pragma weak __ssp_real(poll)
int
int __weak_symbol
__ssp_real(poll)(struct pollfd pfd[], nfds_t nfds, int timeout)
{
return (INTERPOS_SYS(poll, pfd, nfds, timeout));
Expand Down
3 changes: 1 addition & 2 deletions lib/libc/sys/ppoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@

__weak_reference(__sys_ppoll, __ppoll);

#pragma weak __ssp_real(ppoll)
int
int __weak_symbol
__ssp_real(ppoll)(struct pollfd pfd[], nfds_t nfds,
const struct timespec *__restrict timeout,
const sigset_t *__restrict newsigmask)
Expand Down
3 changes: 1 addition & 2 deletions lib/libc/sys/readv.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@

__weak_reference(__sys_readv, __readv);

#pragma weak readv
ssize_t
ssize_t __weak_symbol
__ssp_real(readv)(int fd, const struct iovec *iov, int iovcnt)
{
return (INTERPOS_SYS(readv, fd, iov, iovcnt));
Expand Down
3 changes: 1 addition & 2 deletions lib/libc/sys/recvfrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@

__weak_reference(__sys_recvfrom, __recvfrom);

#pragma weak recvfrom
ssize_t
ssize_t __weak_symbol
__ssp_real(recvfrom)(int s, void *buf, size_t len, int flags,
struct sockaddr * __restrict from, socklen_t * __restrict fromlen)
{
Expand Down
3 changes: 1 addition & 2 deletions lib/libc/sys/recvmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@

__weak_reference(__sys_recvmsg, __recvmsg);

#pragma weak recvmsg
ssize_t
ssize_t __weak_symbol
__ssp_real(recvmsg)(int s, struct msghdr *msg, int flags)
{
return (INTERPOS_SYS(recvmsg, s, msg, flags));
Expand Down

0 comments on commit d5f8270

Please sign in to comment.