versioner: Fix bzero/bcopy fortify

This commit replaces `bzero` with `__bionic_bzero` and `bcopy` with
`__bionic_bcopy` because `bzero` and `bcopy` are partially defined in
`libc.map.txt`.  Bionic versioner raises errors because versioner treats
static inline functions as exported function definitions then it
compares the availability with the information specified in
`libc.map.txt`.

This commit fixes the problem by replacing static inline functions into
`__bionic_{bzero,bcopy}` and defining aliases for source-level
compatibility.

Test: PATH=$(pwd)/prebuilts/clang-tools/linux-x86/bin:$PATH \
      bionic/tools/versioner/run_tests.py
Bug: 140110040

Change-Id: I97f2f0dc0abccd0a9fcfe5bb02f4e918362d35cc
This commit is contained in:
Logan Chien 2019-08-27 20:50:24 -07:00
parent 235aad1981
commit b33952c777
3 changed files with 10 additions and 16 deletions

View File

@ -243,23 +243,15 @@ sighandler_t bsd_signal(int signum, sighandler_t handler) {
return signal(signum, handler);
}
// bcopy/bzero were previously `#define`d, so we only have `static` wrappers in
// Bionic headers. Since we have header definitions, we need some way to
// overload these implementations; __never_call will ensure that any calls to
// bcopy/bzero call the in-header implementation. Since the implementations
// should end up functionally identical, it doesn't matter which we actually
// call.
#define __never_call __attribute__((enable_if(false, "never selected")))
// This was removed from POSIX 2008.
void bcopy(const void* src, void* dst, size_t n) __never_call __RENAME(bcopy);
void bcopy(const void* src, void* dst, size_t n) __never_call {
#undef bcopy
void bcopy(const void* src, void* dst, size_t n) {
memmove(dst, src, n);
}
// This was removed from POSIX 2008.
void bzero(void* dst, size_t n) __never_call __RENAME(bzero);
void bzero(void* dst, size_t n) __never_call {
#undef bzero
void bzero(void* dst, size_t n) {
memset(dst, 0, n);
}

View File

@ -30,7 +30,7 @@
#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
__BIONIC_FORTIFY_INLINE
void bcopy(const void *src, void* const dst __pass_object_size0, size_t len)
void __bionic_bcopy(const void *src, void* const dst __pass_object_size0, size_t len)
__overloadable
__clang_error_if(__bos_unevaluated_lt(__bos0(dst), len),
"'bcopy' called with size bigger than buffer") {
@ -43,7 +43,7 @@ void bcopy(const void *src, void* const dst __pass_object_size0, size_t len)
}
__BIONIC_FORTIFY_INLINE
void bzero(void* const b __pass_object_size0, size_t len)
void __bionic_bzero(void* const b __pass_object_size0, size_t len)
__overloadable
__clang_error_if(__bos_unevaluated_lt(__bos0(b), len),
"'bzero' called with size bigger than buffer") {

View File

@ -52,12 +52,14 @@
__BEGIN_DECLS
/** Deprecated. Use memmove() instead. */
static __inline__ __always_inline void bcopy(const void* b1, void* b2, size_t len) {
#define bcopy(b1, b2, len) __bionic_bcopy((b1), (b2), (len))
static __inline__ __always_inline void __bionic_bcopy(const void* b1, void* b2, size_t len) {
__builtin_memmove(b2, b1, len);
}
/** Deprecated. Use memset() instead. */
static __inline__ __always_inline void bzero(void* b, size_t len) {
#define bzero(b, len) __bionic_bzero((b), (len))
static __inline__ __always_inline void __bionic_bzero(void* b, size_t len) {
__builtin_memset(b, 0, len);
}