mirror of
				https://github.com/mozilla/gecko-dev.git
				synced 2025-11-04 02:09:05 +02:00 
			
		
		
		
	Bug 1896845 - Update the replacement functions for the missing ones in bionic r=KrisWright
This also removes some workarounds for prehistoric Android NDKs Differential Revision: https://phabricator.services.mozilla.com/D210462
This commit is contained in:
		
							parent
							
								
									b547f02b10
								
							
						
					
					
						commit
						adc8165284
					
				
					 3 changed files with 65 additions and 39 deletions
				
			
		
							
								
								
									
										62
									
								
								toolkit/crashreporter/bionic_missing_funcs.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								toolkit/crashreporter/bionic_missing_funcs.cpp
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,62 @@
 | 
				
			||||||
 | 
					/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 | 
				
			||||||
 | 
					/* vim: set ts=8 sts=2 et sw=2 tw=80: */
 | 
				
			||||||
 | 
					/* This Source Code Form is subject to the terms of the Mozilla Public
 | 
				
			||||||
 | 
					 * License, v. 2.0. If a copy of the MPL was not distributed with this
 | 
				
			||||||
 | 
					 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <errno.h>        // For EPERM
 | 
				
			||||||
 | 
					#include <sys/syscall.h>  // For syscall()
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "mozilla/Assertions.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern "C" {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined(__ANDROID_API__) && (__ANDROID_API__ < 24)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Bionic introduced support for getgrgid_r() and getgrnam_r() only in version
 | 
				
			||||||
 | 
					// 24 (that is Android Nougat / 7.0). Since GeckoView is built with version 21,
 | 
				
			||||||
 | 
					// those functions aren't defined, but nix needs them and minidump-writer
 | 
				
			||||||
 | 
					// relies on nix. These functions should never be called in practice hence we
 | 
				
			||||||
 | 
					// implement them only to satisfy nix linking requirements but we crash if we
 | 
				
			||||||
 | 
					// accidentally enter them.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int getgrgid_r(gid_t gid, struct group* grp, char* buf, size_t buflen,
 | 
				
			||||||
 | 
					               struct group** result) {
 | 
				
			||||||
 | 
					  MOZ_CRASH("getgrgid_r() is not available");
 | 
				
			||||||
 | 
					  return EPERM;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int getgrnam_r(const char* name, struct group* grp, char* buf, size_t buflen,
 | 
				
			||||||
 | 
					               struct group** result) {
 | 
				
			||||||
 | 
					  MOZ_CRASH("getgrnam_r() is not available");
 | 
				
			||||||
 | 
					  return EPERM;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif  // __ANDROID_API__ && (__ANDROID_API__ < 24)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined(__ANDROID_API__) && (__ANDROID_API__ < 23)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Bionic introduced support for process_vm_readv() and process_vm_writev() only
 | 
				
			||||||
 | 
					// in version 23 (that is Android Marshmallow / 6.0). Since GeckoView is built
 | 
				
			||||||
 | 
					// on version 21, those functions aren't defined, but nix needs them and
 | 
				
			||||||
 | 
					// minidump-writer actually calls them.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ssize_t process_vm_readv(pid_t pid, const struct iovec* local_iov,
 | 
				
			||||||
 | 
					                         unsigned long int liovcnt,
 | 
				
			||||||
 | 
					                         const struct iovec* remote_iov,
 | 
				
			||||||
 | 
					                         unsigned long int riovcnt, unsigned long int flags) {
 | 
				
			||||||
 | 
					  return syscall(__NR_process_vm_readv, pid, local_iov, liovcnt, remote_iov,
 | 
				
			||||||
 | 
					                 riovcnt, flags);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ssize_t process_vm_writev(pid_t pid, const struct iovec* local_iov,
 | 
				
			||||||
 | 
					                          unsigned long int liovcnt,
 | 
				
			||||||
 | 
					                          const struct iovec* remote_iov,
 | 
				
			||||||
 | 
					                          unsigned long int riovcnt, unsigned long int flags) {
 | 
				
			||||||
 | 
					  return syscall(__NR_process_vm_writev, pid, local_iov, liovcnt, remote_iov,
 | 
				
			||||||
 | 
					                 riovcnt, flags);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif  // defined(__ANDROID_API__) && (__ANDROID_API__ < 23)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -96,12 +96,12 @@ if CONFIG["MOZ_CRASHREPORTER"]:
 | 
				
			||||||
        DEFINES["ANDROID_NDK_MAJOR_VERSION"] = CONFIG["ANDROID_NDK_MAJOR_VERSION"]
 | 
					        DEFINES["ANDROID_NDK_MAJOR_VERSION"] = CONFIG["ANDROID_NDK_MAJOR_VERSION"]
 | 
				
			||||||
        DEFINES["ANDROID_NDK_MINOR_VERSION"] = CONFIG["ANDROID_NDK_MINOR_VERSION"]
 | 
					        DEFINES["ANDROID_NDK_MINOR_VERSION"] = CONFIG["ANDROID_NDK_MINOR_VERSION"]
 | 
				
			||||||
        DEFINES["ANDROID_PACKAGE_NAME"] = '"%s"' % CONFIG["ANDROID_PACKAGE_NAME"]
 | 
					        DEFINES["ANDROID_PACKAGE_NAME"] = '"%s"' % CONFIG["ANDROID_PACKAGE_NAME"]
 | 
				
			||||||
        # NDK5 workarounds
 | 
					 | 
				
			||||||
        DEFINES["_STLP_CONST_CONSTRUCTOR_BUG"] = True
 | 
					 | 
				
			||||||
        DEFINES["_STLP_NO_MEMBER_TEMPLATES"] = True
 | 
					 | 
				
			||||||
        LOCAL_INCLUDES += [
 | 
					        LOCAL_INCLUDES += [
 | 
				
			||||||
            "/toolkit/crashreporter/google-breakpad/src/common/android/include",
 | 
					            "/toolkit/crashreporter/google-breakpad/src/common/android/include",
 | 
				
			||||||
        ]
 | 
					        ]
 | 
				
			||||||
 | 
					        UNIFIED_SOURCES += [
 | 
				
			||||||
 | 
					            "bionic_missing_funcs.cpp",
 | 
				
			||||||
 | 
					        ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DEFINES["UNICODE"] = True
 | 
					    DEFINES["UNICODE"] = True
 | 
				
			||||||
    DEFINES["_UNICODE"] = True
 | 
					    DEFINES["_UNICODE"] = True
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3882,39 +3882,3 @@ void SetNotificationPipeForChild(int childCrashFd) {
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}  // namespace CrashReporter
 | 
					}  // namespace CrashReporter
 | 
				
			||||||
 | 
					 | 
				
			||||||
#if defined(__ANDROID_API__) && (__ANDROID_API__ < 24)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Bionic introduced support for getgrgid_r() and getgrnam_r() only in version
 | 
					 | 
				
			||||||
// 24 (that is Android Nougat / 7.1.2). Since GeckoView is built by version 16
 | 
					 | 
				
			||||||
// (32-bit) or 21 (64-bit), those functions aren't defined, but nix needs them
 | 
					 | 
				
			||||||
// and minidump-writer relies on nix. These functions should never be called
 | 
					 | 
				
			||||||
// in practice hence we implement them only to satisfy nix linking
 | 
					 | 
				
			||||||
// requirements but we crash if we accidentally enter them.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern "C" {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int getgrgid_r(gid_t gid, struct group* grp, char* buf, size_t buflen,
 | 
					 | 
				
			||||||
               struct group** result) {
 | 
					 | 
				
			||||||
  MOZ_CRASH("getgrgid_r() is not available");
 | 
					 | 
				
			||||||
  return EPERM;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int getgrnam_r(const char* name, struct group* grp, char* buf, size_t buflen,
 | 
					 | 
				
			||||||
               struct group** result) {
 | 
					 | 
				
			||||||
  MOZ_CRASH("getgrnam_r() is not available");
 | 
					 | 
				
			||||||
  return EPERM;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int mlockall(int flags) {
 | 
					 | 
				
			||||||
  MOZ_CRASH("mlockall() is not available");
 | 
					 | 
				
			||||||
  return EPERM;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int munlockall(void) {
 | 
					 | 
				
			||||||
  MOZ_CRASH("munlockall() is not available");
 | 
					 | 
				
			||||||
  return EPERM;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif  // __ANDROID_API__ && (__ANDROID_API__ < 24)
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue