am aa267685
: Merge "Allow GCC-built fortified code to run on a clang-built bionic."
* commit 'aa267685c9da11502c4ec50f86f78a7075b6809c': Allow GCC-built fortified code to run on a clang-built bionic.
This commit is contained in:
commit
ddeca5832e
@ -46,15 +46,19 @@ extern int unlinkat(int dirfd, const char *pathname, int flags);
|
||||
extern int fcntl(int fd, int command, ...);
|
||||
extern int creat(const char* path, mode_t mode);
|
||||
|
||||
#if defined(__BIONIC_FORTIFY) && !defined(__clang__)
|
||||
#if defined(__BIONIC_FORTIFY)
|
||||
|
||||
extern int __open_2(const char*, int);
|
||||
extern int __open_real(const char*, int, ...) __asm__(__USER_LABEL_PREFIX__ "open");
|
||||
extern int __openat_2(int, const char*, int);
|
||||
extern int __openat_real(int, const char*, int, ...) __asm__(__USER_LABEL_PREFIX__ "openat");
|
||||
__errordecl(__creat_missing_mode, "called with O_CREAT, but missing mode");
|
||||
__errordecl(__creat_too_many_args, "too many arguments");
|
||||
extern int __open_real(const char *pathname, int flags, ...)
|
||||
__asm__(__USER_LABEL_PREFIX__ "open");
|
||||
extern int __open_2(const char *, int);
|
||||
|
||||
#if !defined(__clang__)
|
||||
|
||||
__BIONIC_FORTIFY_INLINE
|
||||
int open(const char *pathname, int flags, ...) {
|
||||
int open(const char* pathname, int flags, ...) {
|
||||
if (__builtin_constant_p(flags)) {
|
||||
if ((flags & O_CREAT) && __builtin_va_arg_pack_len() == 0) {
|
||||
__creat_missing_mode(); // compile time error
|
||||
@ -72,12 +76,8 @@ int open(const char *pathname, int flags, ...) {
|
||||
return __open_real(pathname, flags, __builtin_va_arg_pack());
|
||||
}
|
||||
|
||||
extern int __openat_2(int, const char *, int);
|
||||
extern int __openat_real(int dirfd, const char *pathname, int flags, ...)
|
||||
__asm__(__USER_LABEL_PREFIX__ "openat");
|
||||
|
||||
__BIONIC_FORTIFY_INLINE
|
||||
int openat(int dirfd, const char *pathname, int flags, ...) {
|
||||
int openat(int dirfd, const char* pathname, int flags, ...) {
|
||||
if (__builtin_constant_p(flags)) {
|
||||
if ((flags & O_CREAT) && __builtin_va_arg_pack_len() == 0) {
|
||||
__creat_missing_mode(); // compile time error
|
||||
@ -95,7 +95,9 @@ int openat(int dirfd, const char *pathname, int flags, ...) {
|
||||
return __openat_real(dirfd, pathname, flags, __builtin_va_arg_pack());
|
||||
}
|
||||
|
||||
#endif /* defined(__BIONIC_FORTIFY) && !defined(__clang__) */
|
||||
#endif /* !defined(__clang__) */
|
||||
|
||||
#endif /* defined(__BIONIC_FORTIFY) */
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
@ -495,16 +495,15 @@ int sprintf(char *dest, const char *format, ...)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(__clang__)
|
||||
extern char *__fgets_real(char *, int, FILE *)
|
||||
__asm__(__USER_LABEL_PREFIX__ "fgets");
|
||||
extern char* __fgets_chk(char*, int, FILE*, size_t);
|
||||
extern char* __fgets_real(char*, int, FILE*) __asm__(__USER_LABEL_PREFIX__ "fgets");
|
||||
__errordecl(__fgets_too_big_error, "fgets called with size bigger than buffer");
|
||||
__errordecl(__fgets_too_small_error, "fgets called with size less than zero");
|
||||
extern char *__fgets_chk(char *, int, FILE *, size_t);
|
||||
|
||||
#if !defined(__clang__)
|
||||
|
||||
__BIONIC_FORTIFY_INLINE
|
||||
char *fgets(char *dest, int size, FILE *stream)
|
||||
{
|
||||
char *fgets(char* dest, int size, FILE* stream) {
|
||||
size_t bos = __bos(dest);
|
||||
|
||||
// Compiler can prove, at compile time, that the passed in size
|
||||
|
Loading…
Reference in New Issue
Block a user