string: Ensure *_chk routines have their hidden builtin definition available

If libc_hidden_builtin_{def,proto} isn't properly set for *_chk routines,
there are unwanted PLT entries in libc.so.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
This commit is contained in:
Frédéric Bérat 2023-04-20 14:07:52 +02:00
parent ba96ff24b2
commit dd8486ffc1
28 changed files with 58 additions and 1 deletions

View File

@ -28,3 +28,4 @@ __memcpy_chk (void *dstpp, const void *srcpp, size_t len, size_t dstlen)
return memcpy (dstpp, srcpp, len);
}
libc_hidden_builtin_def (__memcpy_chk)

View File

@ -32,3 +32,4 @@ MEMMOVE_CHK (void *dest, const void *src, size_t len, size_t destlen)
return memmove (dest, src, len);
}
libc_hidden_builtin_def (MEMMOVE_CHK)

View File

@ -29,3 +29,4 @@ __mempcpy_chk (void *dstpp, const void *srcpp, size_t len, size_t dstlen)
return __mempcpy (dstpp, srcpp, len);
}
libc_hidden_builtin_def (__mempcpy_chk)

View File

@ -26,3 +26,4 @@ __memset_chk (void *dstpp, int c, size_t len, size_t dstlen)
return memset (dstpp, c, len);
}
libc_hidden_builtin_def (__memset_chk)

View File

@ -32,3 +32,4 @@ __stpcpy_chk (char *dest, const char *src, size_t destlen)
return memcpy (dest, src, len + 1) + len;
}
libc_hidden_builtin_def (__stpcpy_chk)

View File

@ -208,6 +208,13 @@ extern char *__strcat_chk (char *__restrict __dest,
extern char *__strncat_chk (char *__restrict __dest,
const char *__restrict __src,
size_t __len, size_t __destlen) __THROW;
libc_hidden_builtin_proto (__memcpy_chk)
libc_hidden_builtin_proto (__memmove_chk)
libc_hidden_builtin_proto (__mempcpy_chk)
libc_hidden_builtin_proto (__memset_chk)
libc_hidden_builtin_proto (__stpcpy_chk)
#endif
#endif

View File

@ -32,6 +32,7 @@ ENTRY (__memcpy_chk)
cmpl %eax, 16(%esp)
jb HIDDEN_JUMPTARGET (__chk_fail)
END (__memcpy_chk)
libc_hidden_builtin_def (__memcpy_chk)
#endif
ENTRY (memcpy)

View File

@ -33,6 +33,7 @@ ENTRY (__memset_chk)
cmpl %eax, 16(%esp)
jb HIDDEN_JUMPTARGET (__chk_fail)
END (__memset_chk)
libc_hidden_builtin_def (__memset_chk)
#endif
ENTRY (memset)

View File

@ -33,6 +33,7 @@ ENTRY_CHK (__memcpy_chk)
cmpl %eax, 16(%esp)
jb HIDDEN_JUMPTARGET (__chk_fail)
END_CHK (__memcpy_chk)
libc_hidden_builtin_def (__memcpy_chk)
#endif
ENTRY (memcpy)

View File

@ -35,6 +35,7 @@ ENTRY_CHK (__memmove_chk)
cmpl %eax, 16(%esp)
jb HIDDEN_JUMPTARGET (__chk_fail)
END_CHK (__memmove_chk)
libc_hidden_builtin_def (__memmove_chk)
#endif
ENTRY (memmove)

View File

@ -33,6 +33,7 @@ ENTRY_CHK (__mempcpy_chk)
cmpl %eax, 16(%esp)
jb HIDDEN_JUMPTARGET (__chk_fail)
END_CHK (__mempcpy_chk)
libc_hidden_builtin_def (__mempcpy_chk)
#endif
ENTRY (__mempcpy)

View File

@ -33,6 +33,7 @@ ENTRY_CHK (__memset_chk)
cmpl %eax, 16(%esp)
jb HIDDEN_JUMPTARGET (__chk_fail)
END_CHK (__memset_chk)
libc_hidden_builtin_def (__memset_chk)
#endif
ENTRY (memset)

View File

@ -28,4 +28,8 @@
libc_ifunc_redirected (__redirect_memcpy_chk, __memcpy_chk,
IFUNC_SELECTOR ());
# ifdef SHARED
__hidden_ver1 (__memcpy_chk, __GI___memcpy_chk, __redirect_memcpy_chk)
__attribute__ ((visibility ("hidden"))) __attribute_copy__ (__memcpy_chk);
# endif
#endif

View File

@ -28,4 +28,8 @@
libc_ifunc_redirected (__redirect_memmove_chk, __memmove_chk,
IFUNC_SELECTOR ());
# ifdef SHARED
__hidden_ver1 (__memmove_chk, __GI___memmove_chk, __redirect_memmove_chk)
__attribute__ ((visibility ("hidden"))) __attribute_copy__ (__memmove_chk);
# endif
#endif

View File

@ -28,4 +28,8 @@
libc_ifunc_redirected (__redirect_mempcpy_chk, __mempcpy_chk,
IFUNC_SELECTOR ());
# ifdef SHARED
__hidden_ver1 (__mempcpy_chk, __GI___mempcpy_chk, __redirect_mempcpy_chk)
__attribute__ ((visibility ("hidden"))) __attribute_copy__ (__mempcpy_chk);
# endif
#endif

View File

@ -28,5 +28,8 @@
libc_ifunc_redirected (__redirect_memset_chk, __memset_chk,
IFUNC_SELECTOR ());
# ifdef SHARED
__hidden_ver1 (__memset_chk, __GI___memset_chk, __redirect_memset_chk)
__attribute__ ((visibility ("hidden"))) __attribute_copy__ (__memset_chk);
# endif
#endif

View File

@ -31,4 +31,5 @@ ENTRY (__memcpy_chk)
jb __chk_fail
jmp memcpy
END (__memcpy_chk)
libc_hidden_builtin_def (__memcpy_chk)
#endif

View File

@ -30,4 +30,5 @@ ENTRY (__memmove_chk)
jb __chk_fail
jmp memmove
END (__memmove_chk)
libc_hidden_builtin_def (MEMMOVE_CHK)
#endif

View File

@ -30,4 +30,5 @@ ENTRY (__mempcpy_chk)
jb __chk_fail
jmp __mempcpy
END (__mempcpy_chk)
libc_hidden_builtin_def (__mempcpy_chk)
#endif

View File

@ -30,4 +30,5 @@ ENTRY (__memset_chk)
jb __chk_fail
jmp memset
END (__memset_chk)
libc_hidden_builtin_def (__memset_chk)
#endif

View File

@ -30,4 +30,5 @@ ENTRY (__memcpy_chk)
jb __chk_fail
jmp memcpy
END (__memcpy_chk)
libc_hidden_builtin_def (__memcpy_chk)
#endif

View File

@ -30,4 +30,5 @@ ENTRY (__memmove_chk)
jb __chk_fail
jmp memmove
END (__memmove_chk)
libc_hidden_builtin_def (MEMMOVE_CHK)
#endif

View File

@ -30,4 +30,5 @@ ENTRY (__mempcpy_chk)
jb __chk_fail
jmp __mempcpy
END (__mempcpy_chk)
libc_hidden_builtin_def (__mempcpy_chk)
#endif

View File

@ -30,4 +30,5 @@ ENTRY (__memset_chk)
jb __chk_fail
jmp memset
END (__memset_chk)
libc_hidden_builtin_def (__memset_chk)
#endif

View File

@ -28,4 +28,8 @@
libc_ifunc_redirected (__redirect_memcpy_chk, __memcpy_chk,
IFUNC_SELECTOR ());
# ifdef SHARED
__hidden_ver1 (__memcpy_chk, __GI___memcpy_chk, __redirect_memcpy_chk)
__attribute__ ((visibility ("hidden"))) __attribute_copy__ (__memcpy_chk);
# endif
#endif

View File

@ -28,4 +28,8 @@
libc_ifunc_redirected (__redirect_memmove_chk, __memmove_chk,
IFUNC_SELECTOR ());
# ifdef SHARED
__hidden_ver1 (__memmove_chk, __GI___memmove_chk, __redirect_memmove_chk)
__attribute__ ((visibility ("hidden"))) __attribute_copy__ (__memmove_chk);
# endif
#endif

View File

@ -28,4 +28,8 @@
libc_ifunc_redirected (__redirect_mempcpy_chk, __mempcpy_chk,
IFUNC_SELECTOR ());
# ifdef SHARED
__hidden_ver1 (__mempcpy_chk, __GI___mempcpy_chk, __redirect_mempcpy_chk)
__attribute__ ((visibility ("hidden"))) __attribute_copy__ (__mempcpy_chk);
# endif
#endif

View File

@ -28,4 +28,8 @@
libc_ifunc_redirected (__redirect_memset_chk, __memset_chk,
IFUNC_SELECTOR ());
# ifdef SHARED
__hidden_ver1 (__memset_chk, __GI___memset_chk, __redirect_memset_chk)
__attribute__ ((visibility ("hidden"))) __attribute_copy__ (__memset_chk);
# endif
#endif