mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-04 15:13:53 +08:00
a643f60c53
In _FORTIFY_SOURCE=3, the size expression may be non-constant, resulting in branches in the inline functions remaining intact and causing a tiny overhead. Clang (and in future, gcc) make sure that the -1 case is always safe, i.e. any comparison of the generated expression with (size_t)-1 is always false so that bit is taken care of. The rest is avoidable since we want the _chk variant whenever we have a size expression and it's not -1. Rework the conditionals in a uniform way to clearly indicate two conditions at compile time: - Either the size is unknown (-1) or we know at compile time that the operation length is less than the object size. We can call the original function in this case. It could be that either the length, object size or both are non-constant, but the compiler, through range analysis, is able to fold the *comparison* to a constant. - The size and length are known and the compiler can see at compile time that operation length > object size. This is valid grounds for a warning at compile time, followed by emitting the _chk variant. For everything else, emit the _chk variant. This simplifies most of the fortified function implementations and at the same time, ensures that only one call from _chk or the regular function is emitted. Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> |
||
---|---|---|
.. | ||
bits | ||
sys | ||
accept4.c | ||
accept.c | ||
bind.c | ||
connect.c | ||
getpeername.c | ||
getsockname.c | ||
getsockopt.c | ||
isfdtype.c | ||
listen.c | ||
Makefile | ||
opensock.c | ||
recv.c | ||
recvfrom.c | ||
recvmmsg.c | ||
recvmsg.c | ||
sa_len.c | ||
send.c | ||
sendmmsg.c | ||
sendmsg.c | ||
sendto.c | ||
setsockopt.c | ||
shutdown.c | ||
sockatmark.c | ||
socket.c | ||
socketpair.c | ||
tst-accept4.c | ||
tst-sockopt-time64.c | ||
tst-sockopt.c | ||
Versions |