summaryrefslogtreecommitdiffstats
path: root/libc/include
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2013-12-19 12:21:07 -0800
committerElliott Hughes <enh@google.com>2013-12-19 14:20:22 -0800
commitcd0609f4fcec9bdcb99a2127137c5570b18c499c (patch)
treec44ef75939752fb371678851d00688bdbd0e27a9 /libc/include
parentcf7a4a4fda076ec76bb79fdbd039665171e8cd75 (diff)
downloadbionic-cd0609f4fcec9bdcb99a2127137c5570b18c499c.zip
bionic-cd0609f4fcec9bdcb99a2127137c5570b18c499c.tar.gz
bionic-cd0609f4fcec9bdcb99a2127137c5570b18c499c.tar.bz2
Allow GCC-built fortified code to run on a clang-built bionic.
Even though code built with clang won't be fully fortified and won't contain calls to our various helpers, binaries built with GCC will. Change-Id: I389b2f1e22a3e89b22aadedc46397bf704f9ca79
Diffstat (limited to 'libc/include')
-rw-r--r--libc/include/fcntl.h24
-rw-r--r--libc/include/stdio.h11
2 files changed, 18 insertions, 17 deletions
diff --git a/libc/include/fcntl.h b/libc/include/fcntl.h
index f41cbcc..ffbbd47 100644
--- a/libc/include/fcntl.h
+++ b/libc/include/fcntl.h
@@ -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
diff --git a/libc/include/stdio.h b/libc/include/stdio.h
index 260a4e7..c241d94 100644
--- a/libc/include/stdio.h
+++ b/libc/include/stdio.h
@@ -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