Merge changes I2d334db2,Iab9fbc73
* changes:
Clean up 32-bit x86 memset assembler.
Fix x86 __memset_chk.
diff --git a/README.md b/README.md
index 0b3dcaa..0bf6c6d 100644
--- a/README.md
+++ b/README.md
@@ -220,19 +220,18 @@
The host tests require that you have `lunch`ed either an x86 or x86_64 target.
- $ mma
- $ mm bionic-unit-tests-run-on-host32
- $ mm bionic-unit-tests-run-on-host64 # For 64-bit *targets* only.
+ $ ./tests/run-on-host.sh 32
+ $ ./tests/run-on-host.sh 64 # For x86_64-bit *targets* only.
+
+You can supply gtest flags as extra arguments to this script.
### Against glibc
As a way to check that our tests do in fact test the correct behavior (and not
just the behavior we think is correct), it is possible to run the tests against
-the host's glibc. The executables are already in your path.
+the host's glibc.
- $ mma
- $ bionic-unit-tests-glibc32
- $ bionic-unit-tests-glibc64
+ $ ./tests/run-on-host.sh glibc
Gathering test coverage
diff --git a/libc/Android.bp b/libc/Android.bp
index 4776f90..4905ec6 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -417,12 +417,8 @@
"upstream-openbsd/lib/libc/net/ntohs.c",
"upstream-openbsd/lib/libc/net/res_random.c",
"upstream-openbsd/lib/libc/stdio/asprintf.c",
- "upstream-openbsd/lib/libc/stdio/clrerr.c",
"upstream-openbsd/lib/libc/stdio/dprintf.c",
- "upstream-openbsd/lib/libc/stdio/feof.c",
- "upstream-openbsd/lib/libc/stdio/ferror.c",
"upstream-openbsd/lib/libc/stdio/fflush.c",
- "upstream-openbsd/lib/libc/stdio/fgetc.c",
"upstream-openbsd/lib/libc/stdio/fgetln.c",
"upstream-openbsd/lib/libc/stdio/fgets.c",
"upstream-openbsd/lib/libc/stdio/fgetwc.c",
@@ -431,7 +427,6 @@
"upstream-openbsd/lib/libc/stdio/fmemopen.c",
"upstream-openbsd/lib/libc/stdio/fprintf.c",
"upstream-openbsd/lib/libc/stdio/fpurge.c",
- "upstream-openbsd/lib/libc/stdio/fputc.c",
"upstream-openbsd/lib/libc/stdio/fputs.c",
"upstream-openbsd/lib/libc/stdio/fputwc.c",
"upstream-openbsd/lib/libc/stdio/fputws.c",
@@ -445,10 +440,7 @@
"upstream-openbsd/lib/libc/stdio/getc.c",
"upstream-openbsd/lib/libc/stdio/getchar.c",
"upstream-openbsd/lib/libc/stdio/getdelim.c",
- "upstream-openbsd/lib/libc/stdio/getline.c",
"upstream-openbsd/lib/libc/stdio/gets.c",
- "upstream-openbsd/lib/libc/stdio/getwc.c",
- "upstream-openbsd/lib/libc/stdio/getwchar.c",
"upstream-openbsd/lib/libc/stdio/makebuf.c",
"upstream-openbsd/lib/libc/stdio/mktemp.c",
"upstream-openbsd/lib/libc/stdio/open_memstream.c",
@@ -458,14 +450,9 @@
"upstream-openbsd/lib/libc/stdio/putc.c",
"upstream-openbsd/lib/libc/stdio/putchar.c",
"upstream-openbsd/lib/libc/stdio/puts.c",
- "upstream-openbsd/lib/libc/stdio/putwc.c",
- "upstream-openbsd/lib/libc/stdio/putwchar.c",
"upstream-openbsd/lib/libc/stdio/remove.c",
- "upstream-openbsd/lib/libc/stdio/rewind.c",
"upstream-openbsd/lib/libc/stdio/rget.c",
"upstream-openbsd/lib/libc/stdio/scanf.c",
- "upstream-openbsd/lib/libc/stdio/setbuf.c",
- "upstream-openbsd/lib/libc/stdio/setbuffer.c",
"upstream-openbsd/lib/libc/stdio/setvbuf.c",
"upstream-openbsd/lib/libc/stdio/sscanf.c",
"upstream-openbsd/lib/libc/stdio/swprintf.c",
@@ -480,15 +467,11 @@
"upstream-openbsd/lib/libc/stdio/vfscanf.c",
"upstream-openbsd/lib/libc/stdio/vfwprintf.c",
"upstream-openbsd/lib/libc/stdio/vfwscanf.c",
- "upstream-openbsd/lib/libc/stdio/vprintf.c",
- "upstream-openbsd/lib/libc/stdio/vscanf.c",
"upstream-openbsd/lib/libc/stdio/vsnprintf.c",
"upstream-openbsd/lib/libc/stdio/vsprintf.c",
"upstream-openbsd/lib/libc/stdio/vsscanf.c",
"upstream-openbsd/lib/libc/stdio/vswprintf.c",
"upstream-openbsd/lib/libc/stdio/vswscanf.c",
- "upstream-openbsd/lib/libc/stdio/vwprintf.c",
- "upstream-openbsd/lib/libc/stdio/vwscanf.c",
"upstream-openbsd/lib/libc/stdio/wbuf.c",
"upstream-openbsd/lib/libc/stdio/wprintf.c",
"upstream-openbsd/lib/libc/stdio/wscanf.c",
diff --git a/libc/include/malloc.h b/libc/include/malloc.h
index 07d7896..7452e53 100644
--- a/libc/include/malloc.h
+++ b/libc/include/malloc.h
@@ -23,12 +23,18 @@
__BEGIN_DECLS
-void* malloc(size_t byte_count) __mallocfunc __wur;
-void* calloc(size_t item_count, size_t item_size) __mallocfunc __wur;
-void* realloc(void* p, size_t byte_count) __wur;
+#if defined(__clang__)
+#define __BIONIC_ALLOC_SIZE(...) /* clang doesn't support attribute alloc_size. */
+#else
+#define __BIONIC_ALLOC_SIZE(...) __attribute__((__alloc_size__(__VA_ARGS__)))
+#endif
+
+void* malloc(size_t byte_count) __mallocfunc __BIONIC_ALLOC_SIZE(1) __wur;
+void* calloc(size_t item_count, size_t item_size) __mallocfunc __BIONIC_ALLOC_SIZE(1,2) __wur;
+void* realloc(void* p, size_t byte_count) __BIONIC_ALLOC_SIZE(2) __wur;
void free(void* p);
-void* memalign(size_t alignment, size_t byte_count) __mallocfunc __wur;
+void* memalign(size_t alignment, size_t byte_count) __mallocfunc __BIONIC_ALLOC_SIZE(2) __wur;
size_t malloc_usable_size(const void* p) __INTRODUCED_IN(17);
#ifndef STRUCT_MALLINFO_DECLARED
diff --git a/libc/stdio/stdio.cpp b/libc/stdio/stdio.cpp
index 3aabbe2..d218ee6 100644
--- a/libc/stdio/stdio.cpp
+++ b/libc/stdio/stdio.cpp
@@ -388,11 +388,47 @@
return r;
}
+int fileno_unlocked(FILE* fp) {
+ int fd = fp->_file;
+ if (fd == -1) {
+ errno = EBADF;
+ return -1;
+ }
+ return fd;
+}
+
int fileno(FILE* fp) {
ScopedFileLock sfl(fp);
return fileno_unlocked(fp);
}
+void clearerr_unlocked(FILE* fp) {
+ return __sclearerr(fp);
+}
+
+void clearerr(FILE* fp) {
+ ScopedFileLock sfl(fp);
+ clearerr_unlocked(fp);
+}
+
+int feof_unlocked(FILE* fp) {
+ return __sfeof(fp);
+}
+
+int feof(FILE* fp) {
+ ScopedFileLock sfl(fp);
+ return feof_unlocked(fp);
+}
+
+int ferror_unlocked(FILE* fp) {
+ return __sferror(fp);
+}
+
+int ferror(FILE* fp) {
+ ScopedFileLock sfl(fp);
+ return ferror_unlocked(fp);
+}
+
int __sread(void* cookie, char* buf, int n) {
FILE* fp = reinterpret_cast<FILE*>(cookie);
return TEMP_FAILURE_RETRY(read(fp->_file, buf, n));
@@ -603,3 +639,65 @@
char* ctermid(char* s) {
return s ? strcpy(s, _PATH_TTY) : const_cast<char*>(_PATH_TTY);
}
+
+int fgetc(FILE* fp) {
+ return getc(fp);
+}
+
+int fputc(int c, FILE* fp) {
+ return putc(c, fp);
+}
+
+ssize_t getline(char** buf, size_t* len, FILE* fp) {
+ return getdelim(buf, len, '\n', fp);
+}
+
+wint_t getwc(FILE* fp) {
+ return fgetwc(fp);
+}
+
+wint_t getwchar() {
+ return fgetwc(stdin);
+}
+
+wint_t putwc(wchar_t wc, FILE* fp) {
+ return fputwc(wc, fp);
+}
+
+wint_t putwchar(wchar_t wc) {
+ return fputwc(wc, stdout);
+}
+
+void rewind(FILE* fp) {
+ ScopedFileLock sfl(fp);
+ fseek(fp, 0, SEEK_SET);
+ clearerr_unlocked(fp);
+}
+
+void setbuf(FILE* fp, char* buf) {
+ setbuffer(fp, buf, BUFSIZ);
+}
+
+void setbuffer(FILE* fp, char* buf, int size) {
+ setvbuf(fp, buf, buf ? _IOFBF : _IONBF, size);
+}
+
+int setlinebuf(FILE* fp) {
+ return setvbuf(fp, nullptr, _IOLBF, 0);
+}
+
+int vprintf(const char* fmt, va_list ap) {
+ return vfprintf(stdout, fmt, ap);
+}
+
+int vscanf(const char* fmt, va_list ap) {
+ return vfscanf(stdin, fmt, ap);
+}
+
+int vwprintf(const wchar_t* fmt, va_list ap) {
+ return vfwprintf(stdout, fmt, ap);
+}
+
+int vwscanf(const wchar_t* fmt, va_list ap) {
+ return vfwscanf(stdin, fmt, ap);
+}
diff --git a/libc/stdio/stdio_ext.cpp b/libc/stdio/stdio_ext.cpp
index 88e5951..f2f58c6 100644
--- a/libc/stdio/stdio_ext.cpp
+++ b/libc/stdio/stdio_ext.cpp
@@ -89,24 +89,3 @@
_EXT(fp)->_caller_handles_locking = (type == FSETLOCKING_BYCALLER);
return old_state;
}
-
-void clearerr_unlocked(FILE* fp) {
- return __sclearerr(fp);
-}
-
-int feof_unlocked(FILE* fp) {
- return __sfeof(fp);
-}
-
-int ferror_unlocked(FILE* fp) {
- return __sferror(fp);
-}
-
-int fileno_unlocked(FILE* fp) {
- int fd = fp->_file;
- if (fd == -1) {
- errno = EBADF;
- return -1;
- }
- return fd;
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/clrerr.c b/libc/upstream-openbsd/lib/libc/stdio/clrerr.c
deleted file mode 100644
index ac08c72..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/clrerr.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* $OpenBSD: clrerr.c,v 1.9 2009/11/09 00:18:27 kurt Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include "local.h"
-#undef clearerr
-
-void
-clearerr(FILE *fp)
-{
- FLOCKFILE(fp);
- __sclearerr(fp);
- FUNLOCKFILE(fp);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/feof.c b/libc/upstream-openbsd/lib/libc/stdio/feof.c
deleted file mode 100644
index 0036bab..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/feof.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/* $OpenBSD: feof.c,v 1.8 2009/11/09 00:18:27 kurt Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include "local.h"
-
-/*
- * A subroutine version of the macro feof.
- */
-#undef feof
-
-int
-feof(FILE *fp)
-{
- int ret;
-
- FLOCKFILE(fp);
- ret = __sfeof(fp);
- FUNLOCKFILE(fp);
- return (ret);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/ferror.c b/libc/upstream-openbsd/lib/libc/stdio/ferror.c
deleted file mode 100644
index 00b9c8b..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/ferror.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/* $OpenBSD: ferror.c,v 1.8 2009/11/09 00:18:27 kurt Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include "local.h"
-
-/*
- * A subroutine version of the macro ferror.
- */
-#undef ferror
-
-int
-ferror(FILE *fp)
-{
- int ret;
-
- FLOCKFILE(fp);
- ret = __sferror(fp);
- FUNLOCKFILE(fp);
- return (ret);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/fgetc.c b/libc/upstream-openbsd/lib/libc/stdio/fgetc.c
deleted file mode 100644
index c5d7dde..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/fgetc.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/* $OpenBSD: fgetc.c,v 1.8 2009/11/09 00:18:27 kurt Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-
-int
-fgetc(FILE *fp)
-{
- return (getc(fp));
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/fputc.c b/libc/upstream-openbsd/lib/libc/stdio/fputc.c
deleted file mode 100644
index 98e3960..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/fputc.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* $OpenBSD: fputc.c,v 1.10 2009/11/09 00:18:27 kurt Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <errno.h>
-
-int
-fputc(int c, FILE *fp)
-{
- return (putc(c, fp));
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/getline.c b/libc/upstream-openbsd/lib/libc/stdio/getline.c
deleted file mode 100644
index 55ad396..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/getline.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* $OpenBSD: getline.c,v 1.1 2012/03/21 23:44:35 fgsch Exp $ */
-/* $NetBSD: getline.c,v 1.3 2009/12/02 08:46:33 roy Exp $ */
-
-/*
- * Copyright (c) 2009 The NetBSD Foundation, Inc.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Roy Marples.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-
-ssize_t
-getline(char **__restrict buf, size_t *__restrict buflen, FILE *__restrict fp)
-{
- return getdelim(buf, buflen, '\n', fp);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/getwc.c b/libc/upstream-openbsd/lib/libc/stdio/getwc.c
deleted file mode 100644
index e9bbb7c..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/getwc.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/* $OpenBSD: getwc.c,v 1.1 2005/06/17 20:40:32 espie Exp $ */
-/* $NetBSD: getwc.c,v 1.2 2003/01/18 11:29:55 thorpej Exp $ */
-
-/*-
- * Copyright (c)2001 Citrus Project,
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Citrus$
- */
-
-#include <stdio.h>
-#include <wchar.h>
-
-/*
- * A subroutine version of the macro getwc.
- */
-#undef getwc
-
-wint_t
-getwc(FILE *fp)
-{
-
- return fgetwc(fp);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/getwchar.c b/libc/upstream-openbsd/lib/libc/stdio/getwchar.c
deleted file mode 100644
index 2a112ed..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/getwchar.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/* $OpenBSD: getwchar.c,v 1.1 2005/06/17 20:40:32 espie Exp $ */
-/* $NetBSD: getwchar.c,v 1.2 2003/01/18 11:29:55 thorpej Exp $ */
-
-/*-
- * Copyright (c)2001 Citrus Project,
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Citrus$
- */
-
-#include <stdio.h>
-#include <wchar.h>
-
-/*
- * A subroutine version of the macro getwchar.
- */
-#undef getwchar
-
-wint_t
-getwchar()
-{
-
- return fgetwc(stdin);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/putwc.c b/libc/upstream-openbsd/lib/libc/stdio/putwc.c
deleted file mode 100644
index 8e2ff2d..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/putwc.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/* $OpenBSD: putwc.c,v 1.1 2005/06/17 20:40:32 espie Exp $ */
-/* $NetBSD: putwc.c,v 1.3 2003/01/18 11:29:56 thorpej Exp $ */
-
-/*-
- * Copyright (c)2001 Citrus Project,
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Citrus$
- */
-
-#include <stdio.h>
-#include <wchar.h>
-
-/*
- * A subroutine version of the macro putwc.
- */
-#undef putwc
-
-wint_t
-putwc(wchar_t wc, FILE *fp)
-{
-
- return fputwc(wc, fp);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/putwchar.c b/libc/upstream-openbsd/lib/libc/stdio/putwchar.c
deleted file mode 100644
index 940ec05..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/putwchar.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/* $OpenBSD: putwchar.c,v 1.1 2005/06/17 20:40:32 espie Exp $ */
-/* $NetBSD: putwchar.c,v 1.3 2003/01/18 11:29:56 thorpej Exp $ */
-
-/*-
- * Copyright (c)2001 Citrus Project,
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Citrus$
- */
-
-#include <stdio.h>
-#include <wchar.h>
-
-/*
- * A subroutine version of the macro putwchar.
- */
-#undef putwchar
-
-wint_t
-putwchar(wchar_t wc)
-{
-
- return fputwc(wc, stdout);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/rewind.c b/libc/upstream-openbsd/lib/libc/stdio/rewind.c
deleted file mode 100644
index 28119b6..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/rewind.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* $OpenBSD: rewind.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <errno.h>
-#include <stdio.h>
-
-void
-rewind(FILE *fp)
-{
- (void) fseek(fp, 0L, SEEK_SET);
- clearerr(fp);
- errno = 0; /* not required, but seems reasonable */
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/setbuf.c b/libc/upstream-openbsd/lib/libc/stdio/setbuf.c
deleted file mode 100644
index 883b895..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/setbuf.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* $OpenBSD: setbuf.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include "local.h"
-
-void
-setbuf(FILE *fp, char *buf)
-{
- (void) setvbuf(fp, buf, buf ? _IOFBF : _IONBF, BUFSIZ);
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/setbuffer.c b/libc/upstream-openbsd/lib/libc/stdio/setbuffer.c
deleted file mode 100644
index 8725ff7..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/setbuffer.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/* $OpenBSD: setbuffer.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-
-void
-setbuffer(FILE *fp, char *buf, int size)
-{
-
- (void)setvbuf(fp, buf, buf ? _IOFBF : _IONBF, size);
-}
-
-/*
- * set line buffering
- */
-int
-setlinebuf(FILE *fp)
-{
-
- return (setvbuf(fp, (char *)NULL, _IOLBF, (size_t)0));
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/vprintf.c b/libc/upstream-openbsd/lib/libc/stdio/vprintf.c
deleted file mode 100644
index fcc622c..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/vprintf.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/* $OpenBSD: vprintf.c,v 1.8 2006/01/06 18:53:04 millert Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-
-int
-vprintf(const char *fmt, __va_list ap)
-{
- return (vfprintf(stdout, fmt, ap));
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/vscanf.c b/libc/upstream-openbsd/lib/libc/stdio/vscanf.c
deleted file mode 100644
index 228498e..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/vscanf.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* $OpenBSD: vscanf.c,v 1.8 2006/01/06 18:53:04 millert Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Donn Seeley at UUNET Technologies, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdio.h>
-
-int
-vscanf(const char *fmt, __va_list ap)
-{
-
- return (vfscanf(stdin, fmt, ap));
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/vwprintf.c b/libc/upstream-openbsd/lib/libc/stdio/vwprintf.c
deleted file mode 100644
index 49569c1..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/vwprintf.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/* $OpenBSD: vwprintf.c,v 1.3 2011/04/28 17:38:46 stsp Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <wchar.h>
-
-int
-vwprintf(const wchar_t * __restrict fmt, __va_list ap)
-{
- return (vfwprintf(stdout, fmt, ap));
-}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/vwscanf.c b/libc/upstream-openbsd/lib/libc/stdio/vwscanf.c
deleted file mode 100644
index 7039f02..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/vwscanf.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* $OpenBSD: vwscanf.c,v 1.2 2012/12/05 23:20:01 deraadt Exp $ */
-
-/*-
- * Copyright (c) 2002 Tim J. Robbins
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <wchar.h>
-
-int
-vwscanf(const wchar_t * __restrict fmt, __va_list ap)
-{
-
- return (vfwscanf(stdin, fmt, ap));
-}
diff --git a/libdl/libdl.arm.map b/libdl/libdl.arm.map
index 20efa9a..2cd49c5 100644
--- a/libdl/libdl.arm.map
+++ b/libdl/libdl.arm.map
@@ -21,6 +21,7 @@
LIBC_PLATFORM {
global:
+ android_dlwarning;
android_get_application_target_sdk_version;
android_set_application_target_sdk_version;
android_get_LD_LIBRARY_PATH;
diff --git a/libdl/libdl.arm64.map b/libdl/libdl.arm64.map
index daf5a86..74e029c 100644
--- a/libdl/libdl.arm64.map
+++ b/libdl/libdl.arm64.map
@@ -20,6 +20,7 @@
LIBC_PLATFORM {
global:
+ android_dlwarning;
android_get_application_target_sdk_version;
android_set_application_target_sdk_version;
android_get_LD_LIBRARY_PATH;
diff --git a/libdl/libdl.c b/libdl/libdl.c
index fa5237f..b62ee5c 100644
--- a/libdl/libdl.c
+++ b/libdl/libdl.c
@@ -69,3 +69,5 @@
const char* permitted_when_isolated_path __unused) {
return 0;
}
+
+void android_dlwarning(void* obj, void (*f)(void*, const char*)) { f(obj, 0); }
diff --git a/libdl/libdl.map.txt b/libdl/libdl.map.txt
index 79bced3..962692e 100644
--- a/libdl/libdl.map.txt
+++ b/libdl/libdl.map.txt
@@ -35,6 +35,7 @@
LIBC_PLATFORM {
global:
+ android_dlwarning;
android_get_application_target_sdk_version;
android_set_application_target_sdk_version;
android_get_LD_LIBRARY_PATH;
diff --git a/libdl/libdl.mips.map b/libdl/libdl.mips.map
index daf5a86..74e029c 100644
--- a/libdl/libdl.mips.map
+++ b/libdl/libdl.mips.map
@@ -20,6 +20,7 @@
LIBC_PLATFORM {
global:
+ android_dlwarning;
android_get_application_target_sdk_version;
android_set_application_target_sdk_version;
android_get_LD_LIBRARY_PATH;
diff --git a/libdl/libdl.mips64.map b/libdl/libdl.mips64.map
index daf5a86..74e029c 100644
--- a/libdl/libdl.mips64.map
+++ b/libdl/libdl.mips64.map
@@ -20,6 +20,7 @@
LIBC_PLATFORM {
global:
+ android_dlwarning;
android_get_application_target_sdk_version;
android_set_application_target_sdk_version;
android_get_LD_LIBRARY_PATH;
diff --git a/libdl/libdl.x86.map b/libdl/libdl.x86.map
index daf5a86..74e029c 100644
--- a/libdl/libdl.x86.map
+++ b/libdl/libdl.x86.map
@@ -20,6 +20,7 @@
LIBC_PLATFORM {
global:
+ android_dlwarning;
android_get_application_target_sdk_version;
android_set_application_target_sdk_version;
android_get_LD_LIBRARY_PATH;
diff --git a/libdl/libdl.x86_64.map b/libdl/libdl.x86_64.map
index daf5a86..74e029c 100644
--- a/libdl/libdl.x86_64.map
+++ b/libdl/libdl.x86_64.map
@@ -20,6 +20,7 @@
LIBC_PLATFORM {
global:
+ android_dlwarning;
android_get_application_target_sdk_version;
android_set_application_target_sdk_version;
android_get_LD_LIBRARY_PATH;
diff --git a/linker/Android.bp b/linker/Android.bp
index d7e97f0..a35eb45 100644
--- a/linker/Android.bp
+++ b/linker/Android.bp
@@ -18,6 +18,7 @@
"dlfcn.cpp",
"linker.cpp",
"linker_block_allocator.cpp",
+ "linker_dlwarning.cpp",
"linker_gdb_support.cpp",
"linker_libc_support.c",
"linker_logger.cpp",
diff --git a/linker/dlfcn.cpp b/linker/dlfcn.cpp
index 110846d..c03ffa8 100644
--- a/linker/dlfcn.cpp
+++ b/linker/dlfcn.cpp
@@ -15,6 +15,7 @@
*/
#include "linker.h"
+#include "linker_dlwarning.h"
#include <pthread.h>
#include <stdio.h>
@@ -138,6 +139,11 @@
return get_application_target_sdk_version();
}
+void android_dlwarning(void* obj, void (*f)(void*, const char*)) {
+ ScopedPthreadMutexLocker locker(&g_dl_mutex);
+ get_dlwarning(obj, f);
+}
+
bool android_init_namespaces(const char* public_ns_sonames,
const char* anon_ns_library_path) {
ScopedPthreadMutexLocker locker(&g_dl_mutex);
@@ -199,11 +205,11 @@
// 00000000001 1111111112222222222 3333333333444444444455555555556666666666777 777777788888888889999999999
// 01234567890 1234567890123456789 0123456789012345678901234567890123456789012 345678901234567890123456789
"erate_phdr\0android_dlopen_ext\0android_set_application_target_sdk_version\0android_get_application_tar"
- // 0000000000111111 111122222222223333333333 4444444444555555555566666 6666677
- // 0123456789012345 678901234567890123456789 0123456789012345678901234 5678901
- "get_sdk_version\0android_init_namespaces\0android_create_namespace\0dlvsym\0"
+ // 0000000000111111 111122222222223333333333 4444444444555555555566666 6666677 777777778888888888
+ // 0123456789012345 678901234567890123456789 0123456789012345678901234 5678901 234567890123456789
+ "get_sdk_version\0android_init_namespaces\0android_create_namespace\0dlvsym\0android_dlwarning\0"
#if defined(__arm__)
- // 272
+ // 290
"dl_unwind_find_exidx\0"
#endif
;
@@ -228,8 +234,9 @@
ELFW(SYM_INITIALIZER)(216, &android_init_namespaces, 1),
ELFW(SYM_INITIALIZER)(240, &android_create_namespace, 1),
ELFW(SYM_INITIALIZER)(265, &dlvsym, 1),
+ ELFW(SYM_INITIALIZER)(272, &android_dlwarning, 1),
#if defined(__arm__)
- ELFW(SYM_INITIALIZER)(272, &dl_unwind_find_exidx, 1),
+ ELFW(SYM_INITIALIZER)(290, &dl_unwind_find_exidx, 1),
#endif
};
@@ -246,9 +253,9 @@
// Note that adding any new symbols here requires stubbing them out in libdl.
static unsigned g_libdl_buckets[1] = { 1 };
#if defined(__arm__)
-static unsigned g_libdl_chains[] = { 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0 };
+static unsigned g_libdl_chains[] = { 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 0 };
#else
-static unsigned g_libdl_chains[] = { 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0 };
+static unsigned g_libdl_chains[] = { 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0 };
#endif
static uint8_t __libdl_info_buf[sizeof(soinfo)] __attribute__((aligned(8)));
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 71e3774..68b3a53 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -54,6 +54,7 @@
#include "linker_block_allocator.h"
#include "linker_gdb_support.h"
#include "linker_debug.h"
+#include "linker_dlwarning.h"
#include "linker_sleb128.h"
#include "linker_phdr.h"
#include "linker_relocs.h"
@@ -182,6 +183,73 @@
nullptr
};
+static bool is_system_library(const std::string& realpath) {
+ for (const auto& dir : g_default_namespace.get_default_library_paths()) {
+ if (file_is_in_dir(realpath, dir)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+#if defined(__LP64__)
+static const char* const kSystemLibDir = "/system/lib64";
+#else
+static const char* const kSystemLibDir = "/system/lib";
+#endif
+
+static std::string dirname(const char *path);
+
+// TODO(dimitry): The grey-list is a workaround for http://b/26394120 ---
+// gradually remove libraries from this list until it is gone.
+static bool is_greylisted(const char* name, const soinfo* needed_by) {
+ static const char* const kLibraryGreyList[] = {
+ "libandroid_runtime.so",
+ "libbinder.so",
+ "libcrypto.so",
+ "libcutils.so",
+ "libexpat.so",
+ "libgui.so",
+ "libmedia.so",
+ "libnativehelper.so",
+ "libskia.so",
+ "libssl.so",
+ "libstagefright.so",
+ "libsqlite.so",
+ "libui.so",
+ "libutils.so",
+ "libvorbisidec.so",
+ nullptr
+ };
+
+ // limit greylisting to apps targeting sdk version 23 and below
+ if (get_application_target_sdk_version() > 23) {
+ return false;
+ }
+
+ // if the library needed by a system library - implicitly assume it
+ // is greylisted
+
+ if (needed_by != nullptr && is_system_library(needed_by->get_realpath())) {
+ return true;
+ }
+
+ // if this is an absolute path - make sure it points to /system/lib(64)
+ if (name[0] == '/' && dirname(name) == kSystemLibDir) {
+ // and reduce the path to basename
+ name = basename(name);
+ }
+
+ for (size_t i = 0; kLibraryGreyList[i] != nullptr; ++i) {
+ if (strcmp(name, kLibraryGreyList[i]) == 0) {
+ return true;
+ }
+ }
+
+ return false;
+}
+// END OF WORKAROUND
+
static const ElfW(Versym) kVersymNotNeeded = 0;
static const ElfW(Versym) kVersymGlobal = 1;
@@ -491,7 +559,7 @@
std::vector<char> buf(PATH_MAX), proc_self_fd(PATH_MAX);
__libc_format_buffer(&proc_self_fd[0], proc_self_fd.size(), "/proc/self/fd/%d", fd);
if (readlink(&proc_self_fd[0], &buf[0], buf.size()) == -1) {
- PRINT("readlink('%s') failed: %s [fd=%d]", &proc_self_fd[0], strerror(errno), fd);
+ PRINT("readlink(\"%s\") failed: %s [fd=%d]", &proc_self_fd[0], strerror(errno), fd);
return false;
}
@@ -672,8 +740,8 @@
ELF_ST_BIND(s->st_info) == STB_WEAK) {
return s->st_shndx != SHN_UNDEF;
} else if (ELF_ST_BIND(s->st_info) != STB_LOCAL) {
- DL_WARN("unexpected ST_BIND value: %d for '%s' in '%s'",
- ELF_ST_BIND(s->st_info), si->get_string(s->st_name), si->get_realpath());
+ DL_WARN("unexpected ST_BIND value: %d for \"%s\" in \"%s\"",
+ ELF_ST_BIND(s->st_info), si->get_string(s->st_name), si->get_realpath());
}
return false;
@@ -1081,6 +1149,14 @@
extinfo_ = extinfo;
}
+ bool is_dt_needed() const {
+ return is_dt_needed_;
+ }
+
+ void set_dt_needed(bool is_dt_needed) {
+ is_dt_needed_ = is_dt_needed;
+ }
+
const ElfReader& get_elf_reader() const {
CHECK(si_ != nullptr);
return (*elf_readers_map_)[si_];
@@ -1120,7 +1196,8 @@
LoadTask(const char* name, soinfo* needed_by,
std::unordered_map<const soinfo*, ElfReader>* readers_map)
: name_(name), needed_by_(needed_by), si_(nullptr),
- fd_(-1), close_fd_(false), file_offset_(0), elf_readers_map_(readers_map) {}
+ fd_(-1), close_fd_(false), file_offset_(0), elf_readers_map_(readers_map),
+ is_dt_needed_(false) {}
~LoadTask() {
if (fd_ != -1 && close_fd_) {
@@ -1136,6 +1213,9 @@
bool close_fd_;
off64_t file_offset_;
std::unordered_map<const soinfo*, ElfReader>* elf_readers_map_;
+ // TODO(dimitry): needed by workaround for http://b/26394120 (the grey-list)
+ bool is_dt_needed_;
+ // END OF WORKAROUND
DISALLOW_IMPLICIT_CONSTRUCTORS(LoadTask);
};
@@ -1412,7 +1492,7 @@
}
const char* const path = normalized_path.c_str();
- TRACE("Trying zip file open from path '%s' -> normalized '%s'", input_path, path);
+ TRACE("Trying zip file open from path \"%s\" -> normalized \"%s\"", input_path, path);
// Treat an '!/' separator inside a path as the separator between the name
// of the zip file on disk and the subdirectory to search within it.
@@ -1558,6 +1638,14 @@
fd = open_library_on_paths(zip_archive_cache, name, file_offset, ns->get_default_library_paths(), realpath);
}
+ // TODO(dimitry): workaround for http://b/26394120 (the grey-list)
+ if (fd == -1 && ns != &g_default_namespace && is_greylisted(name, needed_by)) {
+ // try searching for it on default_namespace default_library_path
+ fd = open_library_on_paths(zip_archive_cache, name, file_offset,
+ g_default_namespace.get_default_library_paths(), realpath);
+ }
+ // END OF WORKAROUND
+
return fd;
}
@@ -1567,7 +1655,8 @@
if (get_application_target_sdk_version() <= 22) {
const char* bname = basename(dt_needed);
if (bname != dt_needed) {
- DL_WARN("'%s' library has invalid DT_NEEDED entry '%s'", sopath, dt_needed);
+ DL_WARN("library \"%s\" has invalid DT_NEEDED entry \"%s\"", sopath, dt_needed);
+ add_dlwarning(sopath, "invalid DT_NEEDED entry", dt_needed);
}
return bname;
@@ -1658,25 +1747,40 @@
}
if (!ns->is_accessible(realpath)) {
- // do not load libraries if they are not accessible for the specified namespace.
- const char* needed_or_dlopened_by = task->get_needed_by() == nullptr ?
- "(unknown)" :
- task->get_needed_by()->get_realpath();
+ // TODO(dimitry): workaround for http://b/26394120 - the grey-list
+ const soinfo* needed_by = task->is_dt_needed() ? task->get_needed_by() : nullptr;
+ if (is_greylisted(name, needed_by)) {
+ // print warning only if needed by non-system library
+ if (needed_by == nullptr || !is_system_library(needed_by->get_realpath())) {
+ const soinfo* needed_or_dlopened_by = task->get_needed_by();
+ const char* sopath = needed_or_dlopened_by == nullptr ? "(unknown)" :
+ needed_or_dlopened_by->get_realpath();
+ DL_WARN("library \"%s\" (\"%s\") needed or dlopened by \"%s\" is not accessible for the namespace \"%s\""
+ " - the access is temporarily granted as a workaround for http://b/26394120, note that the access"
+ " will be removed in future releases of Android.",
+ name, realpath.c_str(), sopath, ns->get_name());
+ add_dlwarning(sopath, "unauthorized access to", name);
+ }
+ } else {
+ // do not load libraries if they are not accessible for the specified namespace.
+ const char* needed_or_dlopened_by = task->get_needed_by() == nullptr ?
+ "(unknown)" :
+ task->get_needed_by()->get_realpath();
- DL_ERR("library \"%s\" needed or dlopened by \"%s\" is not accessible for the namespace \"%s\"",
- name, needed_or_dlopened_by, ns->get_name());
+ DL_ERR("library \"%s\" needed or dlopened by \"%s\" is not accessible for the namespace \"%s\"",
+ name, needed_or_dlopened_by, ns->get_name());
- PRINT("library \"%s\" (\"%s\") needed or dlopened by \"%s\" is not accessible for the"
- " namespace: [name=\"%s\", ld_library_paths=\"%s\", default_library_paths=\"%s\","
- " permitted_paths=\"%s\"]",
- name, realpath.c_str(),
- needed_or_dlopened_by,
- ns->get_name(),
- android::base::Join(ns->get_ld_library_paths(), ':').c_str(),
- android::base::Join(ns->get_default_library_paths(), ':').c_str(),
- android::base::Join(ns->get_permitted_paths(), ':').c_str());
-
- return false;
+ PRINT("library \"%s\" (\"%s\") needed or dlopened by \"%s\" is not accessible for the"
+ " namespace: [name=\"%s\", ld_library_paths=\"%s\", default_library_paths=\"%s\","
+ " permitted_paths=\"%s\"]",
+ name, realpath.c_str(),
+ needed_or_dlopened_by,
+ ns->get_name(),
+ android::base::Join(ns->get_ld_library_paths(), ':').c_str(),
+ android::base::Join(ns->get_default_library_paths(), ':').c_str(),
+ android::base::Join(ns->get_permitted_paths(), ':').c_str());
+ return false;
+ }
}
soinfo* si = soinfo_alloc(ns, realpath.c_str(), &file_stat, file_offset, rtld_flags);
@@ -1822,7 +1926,7 @@
// Library might still be loaded, the accurate detection
// of this fact is done by load_library.
- TRACE("[ '%s' find_loaded_library_by_soname returned false (*candidate=%s@%p). Trying harder...]",
+ TRACE("[ \"%s\" find_loaded_library_by_soname failed (*candidate=%s@%p). Trying harder...]",
task->get_name(), candidate == nullptr ? "n/a" : candidate->get_realpath(), candidate);
if (load_library(ns, task, zip_archive_cache, load_tasks, rtld_flags)) {
@@ -1950,6 +2054,7 @@
bool is_dt_needed = needed_by != nullptr && (needed_by != start_with || add_as_children);
task->set_extinfo(is_dt_needed ? nullptr : extinfo);
+ task->set_dt_needed(is_dt_needed);
if(!find_library_internal(ns, task, &zip_archive_cache, &load_tasks, rtld_flags)) {
return false;
@@ -2079,7 +2184,7 @@
}
if (!root->can_unload()) {
- TRACE("not unloading '%s' - the binary is flagged with NODELETE", root->get_realpath());
+ TRACE("not unloading \"%s\" - the binary is flagged with NODELETE", root->get_realpath());
return;
}
@@ -2677,7 +2782,7 @@
const char* sym_name = nullptr;
ElfW(Addr) addend = get_addend(rel, reloc);
- DEBUG("Processing '%s' relocation at index %zd", get_realpath(), idx);
+ DEBUG("Processing \"%s\" relocation at index %zd", get_realpath(), idx);
if (type == R_GENERIC_NONE) {
continue;
}
@@ -3435,7 +3540,7 @@
/* We can't log anything until the linker is relocated */
bool relocating_linker = (flags_ & FLAG_LINKER) != 0;
if (!relocating_linker) {
- INFO("[ Linking '%s' ]", get_realpath());
+ INFO("[ Linking \"%s\" ]", get_realpath());
DEBUG("si->base = %p si->flags = 0x%08x", reinterpret_cast<void*>(base), flags_);
}
@@ -3859,6 +3964,7 @@
soname_ = basename(realpath_.c_str());
DL_WARN("%s: is missing DT_SONAME will use basename as a replacement: \"%s\"",
get_realpath(), soname_);
+ // Don't call add_dlwarning because a missing DT_SONAME isn't important enough to show in the UI
}
return true;
}
@@ -3893,6 +3999,7 @@
// phdr_table_protect_segments() after all of them are applied.
DL_WARN("%s has text relocations. This is wasting memory and prevents "
"security hardening. Please fix.", get_realpath());
+ add_dlwarning(get_realpath(), "text relocations");
if (phdr_table_unprotect_segments(phdr, phnum, load_bias) < 0) {
DL_ERR("can't unprotect loadable segments for \"%s\": %s",
get_realpath(), strerror(errno));
@@ -4156,11 +4263,11 @@
if (!getauxval(AT_SECURE)) {
ldpath_env = getenv("LD_LIBRARY_PATH");
if (ldpath_env != nullptr) {
- INFO("[ LD_LIBRARY_PATH set to '%s' ]", ldpath_env);
+ INFO("[ LD_LIBRARY_PATH set to \"%s\" ]", ldpath_env);
}
ldpreload_env = getenv("LD_PRELOAD");
if (ldpreload_env != nullptr) {
- INFO("[ LD_PRELOAD set to '%s' ]", ldpreload_env);
+ INFO("[ LD_PRELOAD set to \"%s\" ]", ldpreload_env);
}
}
@@ -4319,7 +4426,7 @@
#endif
ElfW(Addr) entry = args.getauxval(AT_ENTRY);
- TRACE("[ Ready to execute '%s' @ %p ]", si->get_realpath(), reinterpret_cast<void*>(entry));
+ TRACE("[ Ready to execute \"%s\" @ %p ]", si->get_realpath(), reinterpret_cast<void*>(entry));
return entry;
}
diff --git a/linker/linker_dlwarning.cpp b/linker/linker_dlwarning.cpp
new file mode 100644
index 0000000..c53ad66
--- /dev/null
+++ b/linker/linker_dlwarning.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "linker_dlwarning.h"
+
+#include <strings.h>
+
+#include <string>
+
+static std::string current_msg;
+
+void add_dlwarning(const char* sopath, const char* message, const char* value) {
+ if (!current_msg.empty()) {
+ current_msg += '\n';
+ }
+
+ current_msg = current_msg + basename(sopath) + ": " + message;
+
+ if (value != nullptr) {
+ current_msg = current_msg + " \"" + value + "\"";
+ }
+}
+
+// Resets the current one (like dlerror but instead of
+// being thread-local it is process-local).
+void get_dlwarning(void* obj, void (*f)(void*, const char*)) {
+ if (current_msg.empty()) {
+ f(obj, nullptr);
+ } else {
+ std::string msg = current_msg;
+ current_msg.clear();
+ f(obj, msg.c_str());
+ }
+}
diff --git a/linker/linker_dlwarning.h b/linker/linker_dlwarning.h
new file mode 100644
index 0000000..0263c72
--- /dev/null
+++ b/linker/linker_dlwarning.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LINKER_DLWARNING_H
+#define __LINKER_DLWARNING_H
+
+void add_dlwarning(const char* sopath, const char* message, const char* value = nullptr);
+
+// Resets the current one (like dlerror but instead of
+// being thread-local it is process-local). The user_data
+// is used to avoid forcing user into saving the message
+// to a global variable.
+void get_dlwarning(void* user_data, void (*f)(void*, const char*));
+
+#endif /* __LINKER_DLWARNING_H */
diff --git a/linker/linker_mips.cpp b/linker/linker_mips.cpp
index 8520c17..02375c4 100644
--- a/linker/linker_mips.cpp
+++ b/linker/linker_mips.cpp
@@ -67,7 +67,7 @@
ElfW(Addr) sym_addr = 0;
const char* sym_name = nullptr;
- DEBUG("Processing '%s' relocation at index %zd", get_realpath(), idx);
+ DEBUG("Processing \"%s\" relocation at index %zd", get_realpath(), idx);
if (type == R_GENERIC_NONE) {
continue;
}
diff --git a/linker/linker_utils.cpp b/linker/linker_utils.cpp
index 1b0c4e4..fb070ee 100644
--- a/linker/linker_utils.cpp
+++ b/linker/linker_utils.cpp
@@ -20,7 +20,7 @@
bool normalize_path(const char* path, std::string* normalized_path) {
// Input should be an absolute path
if (path[0] != '/') {
- PRINT("normalize_path - invalid input: '%s', the input path should be absolute", path);
+ PRINT("normalize_path - invalid input: \"%s\", the input path should be absolute", path);
return false;
}
@@ -89,7 +89,7 @@
}
const char* const path = normalized_path.c_str();
- TRACE("Trying zip file open from path '%s' -> normalized '%s'", input_path, path);
+ TRACE("Trying zip file open from path \"%s\" -> normalized \"%s\"", input_path, path);
// Treat an '!/' separator inside a path as the separator between the name
// of the zip file on disk and the subdirectory to search within it.