summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4fb0d4f)
raw | patch | inline | side by side (parent: 4fb0d4f)
author | David 'Digit' Turner <digit@google.com> | |
Fri, 13 Jun 2014 10:28:11 +0000 (12:28 +0200) | ||
committer | Dan Albert <danalbert@google.com> | |
Mon, 16 Jun 2014 20:10:20 +0000 (13:10 -0700) |
The C library didn't export the 'index' symbol, but its C++ name-mangling
instead, which broke the ABI and prevented some applications from loading
properly.
The main reason was that the implementation under bionic/index.cpp relied
on the declaration to specify that the function has C linkage.
However, the declaration for index() was removed from both <string.h>
and <strings.h> in a recent patch, which made the compiler think it was
ok to compile the function with C++ linkage instead!
This patch does the following:
- Move index() definition to bionic/ndk_cruft.cpp and ensure it uses
C linkage.
Note that this removes index() from the 64-bit library entirely, this
is intentional and will break source compatibility. Simply replacing
an index() call with the equivalent strchr() should be enough to fix
this in third-party code.
- Remove bionic/index.cpp from the tree and build files.
- Remove x86 assembly implementation from arch-x86/ to avoid conflict
with the one in ndk_cruft.cpp
BUG=15606653
Change-Id: I816b589f69c8f8a6511f6be6195d20cf1c4e8123
instead, which broke the ABI and prevented some applications from loading
properly.
The main reason was that the implementation under bionic/index.cpp relied
on the declaration to specify that the function has C linkage.
However, the declaration for index() was removed from both <string.h>
and <strings.h> in a recent patch, which made the compiler think it was
ok to compile the function with C++ linkage instead!
This patch does the following:
- Move index() definition to bionic/ndk_cruft.cpp and ensure it uses
C linkage.
Note that this removes index() from the 64-bit library entirely, this
is intentional and will break source compatibility. Simply replacing
an index() call with the equivalent strchr() should be enough to fix
this in third-party code.
- Remove bionic/index.cpp from the tree and build files.
- Remove x86 assembly implementation from arch-x86/ to avoid conflict
with the one in ndk_cruft.cpp
BUG=15606653
Change-Id: I816b589f69c8f8a6511f6be6195d20cf1c4e8123
libc/arch-arm/arm.mk | patch | blob | history | |
libc/arch-mips/mips.mk | patch | blob | history | |
libc/arch-x86/atom/atom.mk | patch | blob | history | |
libc/arch-x86/atom/string/sse2-index-atom.S | [deleted file] | patch | blob | history |
libc/arch-x86/generic/generic.mk | patch | blob | history | |
libc/arch-x86/silvermont/silvermont.mk | patch | blob | history | |
libc/bionic/index.cpp | [deleted file] | patch | blob | history |
libc/bionic/ndk_cruft.cpp | patch | blob | history |
diff --git a/libc/arch-arm/arm.mk b/libc/arch-arm/arm.mk
index 26690ce40af8241bfbd879606f7102fa0ffe3904..38301bc20bda816f011442441b01c4f940ae9e6c 100644 (file)
--- a/libc/arch-arm/arm.mk
+++ b/libc/arch-arm/arm.mk
bionic/mmap.cpp
libc_common_src_files_arm += \
- bionic/index.cpp \
bionic/memchr.c \
bionic/memrchr.c \
bionic/strchr.cpp \
diff --git a/libc/arch-mips/mips.mk b/libc/arch-mips/mips.mk
index 529e284b7e1faec65c1eb515fc7a40022bcde0f5..fe5e24d59dda312dcc9afba77298639a8e128661 100644 (file)
--- a/libc/arch-mips/mips.mk
+++ b/libc/arch-mips/mips.mk
bionic/mmap.cpp
libc_common_src_files_mips += \
- bionic/index.cpp \
bionic/memchr.c \
bionic/memcmp.c \
bionic/memmove.c \
index abe940d272f309d22a2a4161c621ae5afb18e4eb..3f28fb2361402a1419a568c16f59a8aae5c245b9 100644 (file)
libc_bionic_src_files_x86 += \
arch-x86/atom/string/sse2-bzero-atom.S \
- arch-x86/atom/string/sse2-index-atom.S \
arch-x86/atom/string/sse2-memchr-atom.S \
arch-x86/atom/string/sse2-memrchr-atom.S \
arch-x86/atom/string/sse2-memset-atom.S \
diff --git a/libc/arch-x86/atom/string/sse2-index-atom.S b/libc/arch-x86/atom/string/sse2-index-atom.S
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-Copyright (c) 2011, Intel Corporation
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
-
- * 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.
-
- * Neither the name of Intel Corporation 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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.
-*/
-
-#define strchr index
-#include "sse2-strchr-atom.S"
index 62e81b7c8e9304367157f5c492a95e4732b857b7..4aee5dc63e841aaebda7291be117e030080410f8 100644 (file)
libc_bionic_src_files_x86 += \
- arch-x86/atom/string/sse2-index-atom.S \
arch-x86/atom/string/sse2-memchr-atom.S \
arch-x86/atom/string/sse2-memrchr-atom.S \
arch-x86/atom/string/sse2-strchr-atom.S \
index 9640a24ac1b7b9ebb8b518eab494a0a43c7d8f97..176bee33983eec472bda107924df490529999272 100644 (file)
arch-x86/atom/string/sse2-memrchr-atom.S \
arch-x86/atom/string/sse2-strchr-atom.S \
arch-x86/atom/string/sse2-strrchr-atom.S \
- arch-x86/atom/string/sse2-index-atom.S \
arch-x86/atom/string/sse2-strnlen-atom.S \
arch-x86/atom/string/sse2-wcschr-atom.S \
arch-x86/atom/string/sse2-wcsrchr-atom.S \
diff --git a/libc/bionic/index.cpp b/libc/bionic/index.cpp
--- a/libc/bionic/index.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * 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.
- * 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.
- */
-
-#undef _FORTIFY_SOURCE
-#include <string.h>
-
-char* index(const char* p, int ch) {
- return __strchr_chk(p, ch, __BIONIC_FORTIFY_UNKNOWN_SIZE);
-}
index 1ae388bd7343ca62edeb14fa36e5385075a11169..e3e640a532f722a24ed46a458bb5b7c301ac4477 100644 (file)
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <sys/resource.h>
#include <sys/syscall.h>
#include <sys/time.h>
return 0;
}
+// This was removed from POSIX 2008.
+extern "C" char* index(const char* str, int ch) {
+ return strchr(str, ch);
+}
+
#endif