git: d5f8270917bf - main - libc: switch to __weak_symbol for fortified interpose stubs

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Tue, 16 Jul 2024 05:12:48 UTC
The branch main has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=d5f8270917bfee4242778544b990bb7f82f8a4de

commit d5f8270917bfee4242778544b990bb7f82f8a4de
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2024-07-16 05:12:28 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2024-07-16 05:12:28 +0000

    libc: switch to __weak_symbol for fortified interpose stubs
    
    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
---
 lib/libc/sys/poll.c     | 3 +--
 lib/libc/sys/ppoll.c    | 3 +--
 lib/libc/sys/readv.c    | 3 +--
 lib/libc/sys/recvfrom.c | 3 +--
 lib/libc/sys/recvmsg.c  | 3 +--
 5 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/lib/libc/sys/poll.c b/lib/libc/sys/poll.c
index 7a418afbbf49..5e000f7e728f 100644
--- a/lib/libc/sys/poll.c
+++ b/lib/libc/sys/poll.c
@@ -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));
diff --git a/lib/libc/sys/ppoll.c b/lib/libc/sys/ppoll.c
index ef72a902548b..72c0b5d5e421 100644
--- a/lib/libc/sys/ppoll.c
+++ b/lib/libc/sys/ppoll.c
@@ -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)
diff --git a/lib/libc/sys/readv.c b/lib/libc/sys/readv.c
index d58dba1fc47e..2729f6ed99da 100644
--- a/lib/libc/sys/readv.c
+++ b/lib/libc/sys/readv.c
@@ -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));
diff --git a/lib/libc/sys/recvfrom.c b/lib/libc/sys/recvfrom.c
index 6247b315d078..0cdbd8a4ccaa 100644
--- a/lib/libc/sys/recvfrom.c
+++ b/lib/libc/sys/recvfrom.c
@@ -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)
 {
diff --git a/lib/libc/sys/recvmsg.c b/lib/libc/sys/recvmsg.c
index 334049d6cfad..ce0f5e0478cd 100644
--- a/lib/libc/sys/recvmsg.c
+++ b/lib/libc/sys/recvmsg.c
@@ -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));