diff --git a/chromium/base/allocator/allocator_shim_default_dispatch_to_glibc.cc b/chromium/base/allocator/allocator_shim_default_dispatch_to_glibc.cc index 014ee05115b..788e0506ba3 100644 --- a/chromium/base/allocator/allocator_shim_default_dispatch_to_glibc.cc +++ b/chromium/base/allocator/allocator_shim_default_dispatch_to_glibc.cc @@ -8,6 +8,7 @@ #include #include +#if defined(__GLIBC__) // This translation unit defines a default dispatch for the allocator shim which // routes allocations to libc functions. // The code here is strongly inspired from tcmalloc's libc_override_glibc.h. @@ -87,3 +88,92 @@ const AllocatorDispatch AllocatorDispatch::default_dispatch = { nullptr, /* aligned_free_function */ nullptr, /* next */ }; + +#else // defined(__GLIBC__) + +#include + +extern "C" { +// Declare function pointers to the memory functions +typedef void* (*t_libc_malloc)(size_t size); +typedef void* (*t_libc_calloc)(size_t n, size_t size); +typedef void* (*t_libc_realloc)(void* address, size_t size); +typedef void* (*t_libc_memalign)(size_t alignment, size_t size); +typedef void (*t_libc_free)(void* ptr); +typedef size_t (*t_libc_malloc_usable_size)(void* ptr); + +// Static instances of pointers to libc.so dl symbols +static t_libc_malloc libc_malloc = NULL; +static t_libc_calloc libc_calloc = NULL; +static t_libc_realloc libc_realloc = NULL; +static t_libc_memalign libc_memalign = NULL; +static t_libc_free libc_free = NULL; +static t_libc_malloc_usable_size libc_malloc_usable_size = NULL; + +// resolve the symbols in libc.so +void musl_libc_memory_init(void) +{ + libc_malloc = (t_libc_malloc) dlsym(RTLD_NEXT, "malloc"); + libc_calloc = (t_libc_calloc) dlsym(RTLD_NEXT, "calloc"); + libc_realloc = (t_libc_realloc) dlsym(RTLD_NEXT, "realloc"); + libc_memalign = (t_libc_memalign) dlsym(RTLD_NEXT, "memalign"); + libc_free = (t_libc_free) dlsym(RTLD_NEXT, "free"); + libc_malloc_usable_size = (t_libc_malloc_usable_size) dlsym(RTLD_NEXT, "malloc_usable_size"); +} +} // extern "C" + +namespace { + +using base::allocator::AllocatorDispatch; + +void* MuslMalloc(const AllocatorDispatch*, size_t size, void* context) { + if (!libc_malloc) + musl_libc_memory_init(); + return (*libc_malloc)(size); +} + +void* MuslCalloc(const AllocatorDispatch*, size_t n, size_t size, void* context) { + if (!libc_calloc) + musl_libc_memory_init(); + return (*libc_calloc)(n, size); +} + +void* MuslRealloc(const AllocatorDispatch*, void* address, size_t size, void* context) { + if (!libc_realloc) + musl_libc_memory_init(); + return (*libc_realloc)(address, size); +} + +void* MuslMemalign(const AllocatorDispatch*, size_t alignment, size_t size, void* context) { + if (!libc_memalign) + musl_libc_memory_init(); + return (*libc_memalign)(alignment, size); +} + +void MuslFree(const AllocatorDispatch*, void* address, void* context) { + if (!libc_free) + musl_libc_memory_init(); + (*libc_free)(address); +} + +size_t MuslGetSizeEstimate(const AllocatorDispatch*, void* address, void* context) { + // TODO(siggi, primiano): malloc_usable_size may need redirection in the + // presence of interposing shims that divert allocations. + if (!libc_malloc_usable_size) + musl_libc_memory_init(); + return (*libc_malloc_usable_size)(address); +} + +} // namespace + +const AllocatorDispatch AllocatorDispatch::default_dispatch = { + &MuslMalloc, /* alloc_function */ + &MuslCalloc, /* alloc_zero_initialized_function */ + &MuslMemalign, /* alloc_aligned_function */ + &MuslRealloc, /* realloc_function */ + &MuslFree, /* free_function */ + &MuslGetSizeEstimate, /* get_size_estimate_function */ + nullptr, /* next */ +}; + +#endif diff --git a/chromium/base/debug/stack_trace.cc b/chromium/base/debug/stack_trace.cc index f5e2dbba148..f0bb80ad097 100644 --- a/chromium/base/debug/stack_trace.cc +++ b/chromium/base/debug/stack_trace.cc @@ -225,14 +225,14 @@ std::string StackTrace::ToString() const { } std::string StackTrace::ToStringWithPrefix(const char* prefix_string) const { std::stringstream stream; -#if !defined(__UCLIBC__) && !defined(_AIX) +#if defined(__GLIBC__) && !defined(_AIX) OutputToStreamWithPrefix(&stream, prefix_string); #endif return stream.str(); } std::ostream& operator<<(std::ostream& os, const StackTrace& s) { -#if !defined(__UCLIBC__) & !defined(_AIX) +#if defined(__GLIBC__) & !defined(_AIX) s.OutputToStream(&os); #else os << "StackTrace::OutputToStream not implemented."; diff --git a/chromium/base/debug/stack_trace_posix.cc b/chromium/base/debug/stack_trace_posix.cc index 6a1531e13ff..0b2b2e6a6c0 100644 --- a/chromium/base/debug/stack_trace_posix.cc +++ b/chromium/base/debug/stack_trace_posix.cc @@ -27,7 +27,7 @@ #if !defined(USE_SYMBOLIZE) #include #endif -#if !defined(__UCLIBC__) && !defined(_AIX) +#if defined(__GLIBC__) && !defined(_AIX) #include #endif @@ -88,7 +88,7 @@ void DemangleSymbols(std::string* text) { // Note: code in this function is NOT async-signal safe (std::string uses // malloc internally). -#if !defined(__UCLIBC__) && !defined(_AIX) +#if defined(__GLIBC__) && !defined(_AIX) std::string::size_type search_from = 0; while (search_from < text->size()) { // Look for the start of a mangled symbol, from search_from. @@ -123,7 +123,7 @@ void DemangleSymbols(std::string* text) { search_from = mangled_start + 2; } } -#endif // !defined(__UCLIBC__) && !defined(_AIX) +#endif // defined(__GLIBC__) && !defined(_AIX) } #endif // !defined(USE_SYMBOLIZE) @@ -135,7 +135,7 @@ class BacktraceOutputHandler { virtual ~BacktraceOutputHandler() = default; }; -#if !defined(__UCLIBC__) && !defined(_AIX) +#if defined(__GLIBC__) && !defined(_AIX) void OutputPointer(void* pointer, BacktraceOutputHandler* handler) { // This should be more than enough to store a 64-bit number in hex: // 16 hex digits + 1 for null-terminator. @@ -218,7 +218,7 @@ void ProcessBacktrace(void* const* trace, } #endif // defined(USE_SYMBOLIZE) } -#endif // !defined(__UCLIBC__) && !defined(_AIX) +#endif // defined(__GLIBC__) && !defined(_AIX) void PrintToStderr(const char* output) { // NOTE: This code MUST be async-signal safe (it's used by in-process @@ -834,7 +834,7 @@ size_t CollectStackTrace(void** trace, size_t count) { // NOTE: This code MUST be async-signal safe (it's used by in-process // stack dumping signal handler). NO malloc or stdio is allowed here. -#if !defined(__UCLIBC__) && !defined(_AIX) +#if defined(__GLIBC__) && !defined(_AIX) // Though the backtrace API man page does not list any possible negative // return values, we take no chance. return base::saturated_cast(backtrace(trace, count)); @@ -847,13 +847,13 @@ void StackTrace::PrintWithPrefix(const char* prefix_string) const { // NOTE: This code MUST be async-signal safe (it's used by in-process // stack dumping signal handler). NO malloc or stdio is allowed here. -#if !defined(__UCLIBC__) && !defined(_AIX) +#if defined(__GLIBC__) && !defined(_AIX) PrintBacktraceOutputHandler handler; ProcessBacktrace(trace_, count_, prefix_string, &handler); #endif } -#if !defined(__UCLIBC__) && !defined(_AIX) +#if defined(__GLIBC__) && !defined(_AIX) void StackTrace::OutputToStreamWithPrefix(std::ostream* os, const char* prefix_string) const { StreamBacktraceOutputHandler handler(os); diff --git a/chromium/base/logging.cc b/chromium/base/logging.cc index b5cf2c4933d..4be936d32f2 100644 --- a/chromium/base/logging.cc +++ b/chromium/base/logging.cc @@ -548,7 +548,7 @@ LogMessage::LogMessage(const char* file, int line, const char* condition) LogMessage::~LogMessage() { size_t stack_start = stream_.tellp(); -#if !defined(OFFICIAL_BUILD) && !defined(OS_NACL) && !defined(__UCLIBC__) && \ +#if !defined(OFFICIAL_BUILD) && !defined(OS_NACL) && defined(__GLIBC__) && \ !defined(OS_AIX) if (severity_ == LOG_FATAL && !base::debug::BeingDebugged()) { // Include a stack trace on a fatal, unless a debugger is attached. diff --git a/chromium/base/process/process_metrics_posix.cc b/chromium/base/process/process_metrics_posix.cc index 9d12c427bb3..c8c46ec6d7b 100644 --- a/chromium/base/process/process_metrics_posix.cc +++ b/chromium/base/process/process_metrics_posix.cc @@ -119,14 +119,14 @@ size_t ProcessMetrics::GetMallocUsage() { malloc_statistics_t stats = {0}; malloc_zone_statistics(nullptr, &stats); return stats.size_in_use; -#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) +#elif (defined(OS_LINUX) && defined(__GLIBC__)) || defined(OS_CHROMEOS) || defined(OS_ANDROID) struct mallinfo minfo = mallinfo(); #if BUILDFLAG(USE_TCMALLOC) return minfo.uordblks; #else return minfo.hblkhd + minfo.arena; #endif -#elif defined(OS_FUCHSIA) +#else // defined(OS_FUCHSIA) // TODO(fuchsia): Not currently exposed. https://crbug.com/735087. return 0; #endif diff --git a/chromium/base/third_party/libevent/BUILD.gn b/chromium/base/third_party/libevent/BUILD.gn index 3628030e444..99717b6a06f 100644 --- a/chromium/base/third_party/libevent/BUILD.gn +++ b/chromium/base/third_party/libevent/BUILD.gn @@ -97,15 +97,5 @@ source_set("system_libevent") { } group("libevent") { - if (host_toolchain != current_toolchain) { - if (use_system_libevent) { - public_deps = [ ":system_libevent" ] - } else { - public_deps = [ ":bundled_libevent" ] - } - } else { - # Fix me: unbundle for host build - # this requires host pkg-config besides sysroot one. - public_deps = [ ":bundled_libevent" ] - } + public_deps = [ ":system_libevent" ] } diff --git a/chromium/base/trace_event/malloc_dump_provider.cc b/chromium/base/trace_event/malloc_dump_provider.cc index c327f486596..09ab76171d6 100644 --- a/chromium/base/trace_event/malloc_dump_provider.cc +++ b/chromium/base/trace_event/malloc_dump_provider.cc @@ -132,7 +132,7 @@ bool MallocDumpProvider::OnMemoryDump(const MemoryDumpArgs& args, } #elif defined(OS_FUCHSIA) // TODO(fuchsia): Port, see https://crbug.com/706592. -#else +#elif defined(__GLIBC__) struct mallinfo info = mallinfo(); // In case of Android's jemalloc |arena| is 0 and the outer pages size is // reported by |hblkhd|. In case of dlmalloc the total is given by @@ -142,6 +142,8 @@ bool MallocDumpProvider::OnMemoryDump(const MemoryDumpArgs& args, // Total allocated space is given by |uordblks|. allocated_objects_size = info.uordblks; +#else +// TODO(musl): Port #endif MemoryAllocatorDump* outer_dump = pmd->CreateAllocatorDump("malloc"); diff --git a/chromium/build/config/compiler/BUILD.gn b/chromium/build/config/compiler/BUILD.gn index 6a58d21cf07..b0be3d9d195 100644 --- a/chromium/build/config/compiler/BUILD.gn +++ b/chromium/build/config/compiler/BUILD.gn @@ -796,8 +796,8 @@ config("compiler_cpu_abi") { } } else if (current_cpu == "arm64") { if (is_clang && !is_android && !is_nacl && !is_fuchsia) { - cflags += [ "--target=aarch64-linux-gnu" ] - ldflags += [ "--target=aarch64-linux-gnu" ] + cflags += [ "--target=aarch64-linux-musl" ] + ldflags += [ "--target=aarch64-linux-musl" ] } } else if (current_cpu == "mipsel" && !is_nacl) { ldflags += [ "-Wl,--hash-style=sysv" ] @@ -807,8 +807,8 @@ config("compiler_cpu_abi") { cflags += [ "--target=mipsel-linux-android" ] ldflags += [ "--target=mipsel-linux-android" ] } else { - cflags += [ "--target=mipsel-linux-gnu" ] - ldflags += [ "--target=mipsel-linux-gnu" ] + cflags += [ "--target=mipsel-linux-musl" ] + ldflags += [ "--target=mipsel-linux-musl" ] } } else { cflags += [ "-EL" ] diff --git a/chromium/build/toolchain/linux/BUILD.gn b/chromium/build/toolchain/linux/BUILD.gn index fa8b17e9db3..d9756c70cf4 100644 --- a/chromium/build/toolchain/linux/BUILD.gn +++ b/chromium/build/toolchain/linux/BUILD.gn @@ -14,7 +14,7 @@ clang_toolchain("clang_ppc64") { } clang_toolchain("clang_arm") { - toolprefix = "arm-linux-gnueabihf-" + toolprefix = "arm-linux-musleabihf-" toolchain_args = { current_cpu = "arm" current_os = "linux" @@ -22,7 +22,7 @@ clang_toolchain("clang_arm") { } clang_toolchain("clang_arm64") { - toolprefix = "aarch64-linux-gnu-" + toolprefix = "aarch64-linux-musl-" toolchain_args = { current_cpu = "arm64" current_os = "linux" @@ -30,7 +30,7 @@ clang_toolchain("clang_arm64") { } gcc_toolchain("arm64") { - toolprefix = "aarch64-linux-gnu-" + toolprefix = "aarch64-linux-musl-" cc = "${toolprefix}gcc" cxx = "${toolprefix}g++" @@ -48,7 +48,7 @@ gcc_toolchain("arm64") { } gcc_toolchain("arm") { - toolprefix = "arm-linux-gnueabihf-" + toolprefix = "arm-linux-musleabihf-" cc = "${toolprefix}gcc" cxx = "${toolprefix}g++" @@ -186,7 +186,7 @@ clang_toolchain("clang_mips64el") { } gcc_toolchain("mipsel") { - toolprefix = "mipsel-linux-gnu-" + toolprefix = "mipsel-linux-musl-" cc = "${toolprefix}gcc" cxx = " ${toolprefix}g++" @@ -205,7 +205,7 @@ gcc_toolchain("mipsel") { } gcc_toolchain("mips64el") { - toolprefix = "mips64el-linux-gnuabi64-" + toolprefix = "mips64el-linux-muslabi64-" cc = "${toolprefix}gcc" cxx = "${toolprefix}g++" @@ -264,7 +264,7 @@ gcc_toolchain("ppc64") { } gcc_toolchain("mips") { - toolprefix = "mips-linux-gnu-" + toolprefix = "mips-linux-musl-" cc = "${toolprefix}gcc" cxx = "${toolprefix}g++" @@ -282,7 +282,7 @@ gcc_toolchain("mips") { } gcc_toolchain("mips64") { - toolprefix = "mips64-linux-gnuabi64-" + toolprefix = "mips64-linux-muslabi64-" cc = "${toolprefix}gcc" cxx = "${toolprefix}g++" diff --git a/chromium/net/dns/dns_config_service_posix.cc b/chromium/net/dns/dns_config_service_posix.cc index 5a4aead0acf..5866f75bd10 100644 --- a/chromium/net/dns/dns_config_service_posix.cc +++ b/chromium/net/dns/dns_config_service_posix.cc @@ -8,6 +8,34 @@ #include #include +#if !defined(__GLIBC__) +static inline int res_ninit(res_state statp) +{ + int rc = res_init(); + if (statp != &_res) { + memcpy(statp, &_res, sizeof(*statp)); + } + return rc; +} + +static inline int res_nclose(res_state statp) +{ + if (!statp) { + return -1; + } + + if (statp != &_res) { + memset(statp, 0, sizeof(*statp)); + } + + return 0; +} +#endif + +#if !defined(__GLIBC__) +#include "resolv_compat.h" +#endif + #include "base/bind.h" #include "base/files/file.h" #include "base/files/file_path.h" diff --git a/chromium/net/dns/dns_reloader.cc b/chromium/net/dns/dns_reloader.cc index 0672e711afb..ddfc9bb1cba 100644 --- a/chromium/net/dns/dns_reloader.cc +++ b/chromium/net/dns/dns_reloader.cc @@ -9,6 +9,35 @@ #include +#if !defined(__GLIBC__) +#include +static inline int res_ninit(res_state statp) +{ + int rc = res_init(); + if (statp != &_res) { + memcpy(statp, &_res, sizeof(*statp)); + } + return rc; +} + +static inline int res_nclose(res_state statp) +{ + if (!statp) { + return -1; + } + + if (statp != &_res) { + memset(statp, 0, sizeof(*statp)); + } + + return 0; +} +#endif + +#if !defined(__GLIBC__) +#include "resolv_compat.h" +#endif + #include "base/lazy_instance.h" #include "base/macros.h" #include "base/notreached.h" diff --git a/chromium/net/socket/udp_socket_posix.cc b/chromium/net/socket/udp_socket_posix.cc index 71265568be5..11f22f951a4 100644 --- a/chromium/net/socket/udp_socket_posix.cc +++ b/chromium/net/socket/udp_socket_posix.cc @@ -1152,7 +1152,8 @@ SendResult UDPSocketPosixSender::InternalSendmmsgBuffers( msg_iov->push_back({const_cast(buffer->data()), buffer->length()}); msgvec->reserve(buffers.size()); for (size_t j = 0; j < buffers.size(); j++) - msgvec->push_back({{nullptr, 0, &msg_iov[j], 1, nullptr, 0, 0}, 0}); + msgvec->push_back({{nullptr, 0, &msg_iov[j], 1, 0, 0, 0}, 0}); +// msgvec->push_back({{nullptr, 0, &msg_iov[j], 1, nullptr, 0, 0}, 0}); int result = HANDLE_EINTR(Sendmmsg(fd, &msgvec[0], buffers.size(), 0)); SendResult send_result(0, 0, std::move(buffers)); if (result < 0) { diff --git a/chromium/ppapi/utility/threading/simple_thread.cc b/chromium/ppapi/utility/threading/simple_thread.cc index 02bf49bdd63..05ee1827001 100644 --- a/chromium/ppapi/utility/threading/simple_thread.cc +++ b/chromium/ppapi/utility/threading/simple_thread.cc @@ -13,7 +13,7 @@ namespace pp { namespace { // Use 2MB default stack size for Native Client, otherwise use system default. -#if defined(__native_client__) +#if defined(__native_client__) || !defined(__GLIBC__) const size_t kDefaultStackSize = 2 * 1024 * 1024; #else const size_t kDefaultStackSize = 0; diff --git a/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc b/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc index 6ae09fb1035..57559ee6e04 100644 --- a/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc +++ b/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc @@ -127,21 +127,11 @@ namespace sandbox { // present (as in newer versions of posix_spawn). ResultExpr RestrictCloneToThreadsAndEPERMFork() { const Arg flags(0); - - // TODO(mdempsky): Extend DSL to support (flags & ~mask1) == mask2. - const uint64_t kAndroidCloneMask = CLONE_VM | CLONE_FS | CLONE_FILES | - CLONE_SIGHAND | CLONE_THREAD | - CLONE_SYSVSEM; - const uint64_t kObsoleteAndroidCloneMask = kAndroidCloneMask | CLONE_DETACHED; - - const uint64_t kGlibcPthreadFlags = - CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_THREAD | - CLONE_SYSVSEM | CLONE_SETTLS | CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID; - const BoolExpr glibc_test = flags == kGlibcPthreadFlags; - - const BoolExpr android_test = - AnyOf(flags == kAndroidCloneMask, flags == kObsoleteAndroidCloneMask, - flags == kGlibcPthreadFlags); + const int required = CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | + CLONE_THREAD | CLONE_SYSVSEM; + const int safe = CLONE_SETTLS | CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID | + CLONE_DETACHED; + const BoolExpr thread_clone_ok = (flags&~safe)==required; // The following two flags are the two important flags in any vfork-emulating // clone call. EPERM any clone call that contains both of them. @@ -151,7 +141,7 @@ ResultExpr RestrictCloneToThreadsAndEPERMFork() { AnyOf((flags & (CLONE_VM | CLONE_THREAD)) == 0, (flags & kImportantCloneVforkFlags) == kImportantCloneVforkFlags); - return If(IsAndroid() ? android_test : glibc_test, Allow()) + return If(thread_clone_ok, Allow()) .ElseIf(is_fork_or_clone_vfork, Error(EPERM)) .Else(CrashSIGSYSClone()); } diff --git a/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc b/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc index d9d18822f67..056755719fe 100644 --- a/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc +++ b/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc @@ -392,6 +392,7 @@ bool SyscallSets::IsAllowedProcessStartOrDeath(int sysno) { #if defined(__i386__) case __NR_waitpid: #endif + case __NR_set_tid_address: return true; case __NR_clone: // Should be parameter-restricted. case __NR_setns: // Privileged. @@ -404,7 +405,6 @@ bool SyscallSets::IsAllowedProcessStartOrDeath(int sysno) { #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) case __NR_set_thread_area: #endif - case __NR_set_tid_address: case __NR_unshare: #if !defined(__mips__) && !defined(__aarch64__) case __NR_vfork: @@ -514,6 +514,8 @@ bool SyscallSets::IsAllowedAddressSpaceAccess(int sysno) { case __NR_mlock: case __NR_munlock: case __NR_munmap: + case __NR_mremap: + case __NR_membarrier: return true; case __NR_madvise: case __NR_mincore: @@ -531,7 +533,6 @@ bool SyscallSets::IsAllowedAddressSpaceAccess(int sysno) { case __NR_modify_ldt: #endif case __NR_mprotect: - case __NR_mremap: case __NR_msync: case __NR_munlockall: case __NR_readahead: diff --git a/chromium/sandbox/linux/seccomp-bpf/trap.cc b/chromium/sandbox/linux/seccomp-bpf/trap.cc index f5b86a73ac7..11e594bc866 100644 --- a/chromium/sandbox/linux/seccomp-bpf/trap.cc +++ b/chromium/sandbox/linux/seccomp-bpf/trap.cc @@ -25,6 +25,11 @@ #include "sandbox/linux/system_headers/linux_seccomp.h" #include "sandbox/linux/system_headers/linux_signal.h" +// musl libc defines siginfo_t __si_fields instead of _sifields +#if !defined(__GLIBC__) +#define _sifields __si_fields +#endif + namespace { struct arch_sigsys { diff --git a/chromium/sandbox/linux/system_headers/arm64_linux_syscalls.h b/chromium/sandbox/linux/system_headers/arm64_linux_syscalls.h index a242c18c842..30751fc4ac8 100644 --- a/chromium/sandbox/linux/system_headers/arm64_linux_syscalls.h +++ b/chromium/sandbox/linux/system_headers/arm64_linux_syscalls.h @@ -1119,4 +1119,8 @@ #define __NR_rseq 293 #endif +#if !defined(__NR_membarrier) +#define __NR_membarrier 283 +#endif + #endif // SANDBOX_LINUX_SYSTEM_HEADERS_ARM64_LINUX_SYSCALLS_H_ diff --git a/chromium/sandbox/linux/system_headers/arm_linux_syscalls.h b/chromium/sandbox/linux/system_headers/arm_linux_syscalls.h index 85e2110b4c2..87e683a0911 100644 --- a/chromium/sandbox/linux/system_headers/arm_linux_syscalls.h +++ b/chromium/sandbox/linux/system_headers/arm_linux_syscalls.h @@ -1441,6 +1441,11 @@ #define __NR_io_pgetevents (__NR_SYSCALL_BASE+399) #endif +#if !defined(__NR_membarrier) +#define __NR_membarrier (__NR_SYSCALL_BASE+389) +#endif + + // ARM private syscalls. #if !defined(__ARM_NR_BASE) #define __ARM_NR_BASE (__NR_SYSCALL_BASE + 0xF0000) diff --git a/chromium/sandbox/linux/system_headers/mips64_linux_syscalls.h b/chromium/sandbox/linux/system_headers/mips64_linux_syscalls.h index ec75815a842..612fcfaa946 100644 --- a/chromium/sandbox/linux/system_headers/mips64_linux_syscalls.h +++ b/chromium/sandbox/linux/system_headers/mips64_linux_syscalls.h @@ -1271,4 +1271,8 @@ #define __NR_memfd_create (__NR_Linux + 314) #endif +#if !defined(__NR_membarrier) +#define __NR_membarrier (__NR_Linux + 318) +#endif + #endif // SANDBOX_LINUX_SYSTEM_HEADERS_MIPS64_LINUX_SYSCALLS_H_ diff --git a/chromium/sandbox/linux/system_headers/mips_linux_syscalls.h b/chromium/sandbox/linux/system_headers/mips_linux_syscalls.h index ddbf97f3d8b..1742acd4c3d 100644 --- a/chromium/sandbox/linux/system_headers/mips_linux_syscalls.h +++ b/chromium/sandbox/linux/system_headers/mips_linux_syscalls.h @@ -1433,4 +1433,8 @@ #define __NR_memfd_create (__NR_Linux + 354) #endif +#if !defined(__NR_membarrier) +#define __NR_membarrier (__NR_Linux + 358) +#endif + #endif // SANDBOX_LINUX_SYSTEM_HEADERS_MIPS_LINUX_SYSCALLS_H_ diff --git a/chromium/sandbox/linux/system_headers/x86_32_linux_syscalls.h b/chromium/sandbox/linux/system_headers/x86_32_linux_syscalls.h index 7613c9bbcdc..d0ab832bc35 100644 --- a/chromium/sandbox/linux/system_headers/x86_32_linux_syscalls.h +++ b/chromium/sandbox/linux/system_headers/x86_32_linux_syscalls.h @@ -1710,5 +1710,10 @@ #define __NR_clone3 435 #endif +#if !defined(__NR_membarrier) +#define __NR_membarrier 375 +#endif + + #endif // SANDBOX_LINUX_SYSTEM_HEADERS_X86_32_LINUX_SYSCALLS_H_ diff --git a/chromium/sandbox/linux/system_headers/x86_64_linux_syscalls.h b/chromium/sandbox/linux/system_headers/x86_64_linux_syscalls.h index b0ae0a2edf6..929a56b7c09 100644 --- a/chromium/sandbox/linux/system_headers/x86_64_linux_syscalls.h +++ b/chromium/sandbox/linux/system_headers/x86_64_linux_syscalls.h @@ -1350,5 +1350,10 @@ #define __NR_rseq 334 #endif +#if !defined(__NR_membarrier) +#define __NR_membarrier 324 +#endif + + #endif // SANDBOX_LINUX_SYSTEM_HEADERS_X86_64_LINUX_SYSCALLS_H_ diff --git a/chromium/sandbox/policy/linux/bpf_renderer_policy_linux.cc b/chromium/sandbox/policy/linux/bpf_renderer_policy_linux.cc index 9fe9575eb63..fa1a946f6a8 100644 --- a/chromium/sandbox/policy/linux/bpf_renderer_policy_linux.cc +++ b/chromium/sandbox/policy/linux/bpf_renderer_policy_linux.cc @@ -93,11 +93,11 @@ ResultExpr RendererProcessPolicy::EvaluateSyscall(int sysno) const { case __NR_sysinfo: case __NR_times: case __NR_uname: - return Allow(); - case __NR_sched_getaffinity: case __NR_sched_getparam: case __NR_sched_getscheduler: case __NR_sched_setscheduler: + return Allow(); + case __NR_sched_getaffinity: return RestrictSchedTarget(GetPolicyPid(), sysno); case __NR_prlimit64: // See crbug.com/662450 and setrlimit comment above. diff --git a/chromium/third_party/blink/renderer/platform/wtf/stack_util.cc b/chromium/third_party/blink/renderer/platform/wtf/stack_util.cc index 71b901f4044..f33aba04bc3 100644 --- a/chromium/third_party/blink/renderer/platform/wtf/stack_util.cc +++ b/chromium/third_party/blink/renderer/platform/wtf/stack_util.cc @@ -29,7 +29,7 @@ size_t GetUnderestimatedStackSize() { // FIXME: On Mac OSX and Linux, this method cannot estimate stack size // correctly for the main thread. -#elif defined(__GLIBC__) || defined(OS_ANDROID) || defined(OS_FREEBSD) || \ +#elif defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_FREEBSD) || \ defined(OS_FUCHSIA) // pthread_getattr_np() can fail if the thread is not invoked by // pthread_create() (e.g., the main thread of blink_unittests). @@ -97,7 +97,7 @@ return Threading::ThreadStackSize(); } void* GetStackStart() { -#if defined(__GLIBC__) || defined(OS_ANDROID) || defined(OS_FREEBSD) || \ +#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_FREEBSD) || \ defined(OS_FUCHSIA) pthread_attr_t attr; int error; diff --git a/chromium/third_party/breakpad/breakpad/src/common/linux/elf_core_dump.h b/chromium/third_party/breakpad/breakpad/src/common/linux/elf_core_dump.h index 6e153745dba..6d1c40f7143 100644 --- a/chromium/third_party/breakpad/breakpad/src/common/linux/elf_core_dump.h +++ b/chromium/third_party/breakpad/breakpad/src/common/linux/elf_core_dump.h @@ -37,6 +37,9 @@ #include #include #include +#ifndef __GLIBC__ +#include +#endif #include "common/memory_range.h" diff --git a/chromium/third_party/crashpad/crashpad/util/linux/thread_info.h b/chromium/third_party/crashpad/crashpad/util/linux/thread_info.h index 5b55c24a76d..08cec52b2c5 100644 --- a/chromium/third_party/crashpad/crashpad/util/linux/thread_info.h +++ b/chromium/third_party/crashpad/crashpad/util/linux/thread_info.h @@ -273,7 +273,7 @@ union FloatContext { "Size mismatch"); #elif defined(ARCH_CPU_ARMEL) static_assert(sizeof(f32_t::fpregs) == sizeof(user_fpregs), "Size mismatch"); -#if !defined(__GLIBC__) +#if defined(OS_ANDROID) static_assert(sizeof(f32_t::vfp) == sizeof(user_vfp), "Size mismatch"); #endif #elif defined(ARCH_CPU_ARM64) diff --git a/chromium/third_party/lss/linux_syscall_support.h b/chromium/third_party/lss/linux_syscall_support.h index e4ac22644c0..95a67a8fc16 100644 --- a/chromium/third_party/lss/linux_syscall_support.h +++ b/chromium/third_party/lss/linux_syscall_support.h @@ -824,6 +824,14 @@ struct kernel_statfs { #endif +#undef stat64 +#undef fstat64 + +#ifndef __NR_fstatat +#define __NR_fstatat __NR_fstatat64 +#endif + + #if defined(__x86_64__) #ifndef ARCH_SET_GS #define ARCH_SET_GS 0x1001 @@ -1258,6 +1266,14 @@ struct kernel_statfs { #ifndef __NR_getrandom #define __NR_getrandom 318 #endif + +#ifndef __NR_pread +#define __NR_pread __NR_pread64 +#endif +#ifndef __NR_pwrite +#define __NR_pwrite __NR_pwrite64 +#endif + /* End of x86-64 definitions */ #elif defined(__mips__) #if _MIPS_SIM == _MIPS_SIM_ABI32 @@ -1819,6 +1835,15 @@ struct kernel_statfs { /* End of s390/s390x definitions */ #endif +#ifndef __GLIBC__ + /* For Musl libc pread/pread is the same as pread64/pwrite64 */ +#ifndef __NR_pread +#define __NR_pread __NR_pread64 +#endif +#ifndef __NR_pwrite +#define __NR_pwrite __NR_pwrite64 +#endif +#endif /* ifndef __GLIBC__ */ /* After forking, we must make sure to only call system calls. */ #if defined(__BOUNDED_POINTERS__) diff --git a/chromium/third_party/ots/include/opentype-sanitiser.h b/chromium/third_party/ots/include/opentype-sanitiser.h index 08f23befd50..eb4f706fb4d 100644 --- a/chromium/third_party/ots/include/opentype-sanitiser.h +++ b/chromium/third_party/ots/include/opentype-sanitiser.h @@ -21,6 +21,7 @@ typedef unsigned __int64 uint64_t; #define ots_htons(x) _byteswap_ushort (x) #else #include +#include #include #define ots_ntohl(x) ntohl (x) #define ots_ntohs(x) ntohs (x) diff --git a/chromium/third_party/skia/src/opts/SkRasterPipeline_opts.h b/chromium/third_party/skia/src/opts/SkRasterPipeline_opts.h index 659794d1b50..c42b67628aa 100644 --- a/chromium/third_party/skia/src/opts/SkRasterPipeline_opts.h +++ b/chromium/third_party/skia/src/opts/SkRasterPipeline_opts.h @@ -1001,17 +1001,17 @@ SI F from_half(U16 h) { } SI U16 to_half(F f) { -#if defined(JUMPER_IS_NEON) && defined(SK_CPU_ARM64) \ - && !defined(SK_BUILD_FOR_GOOGLE3) // Temporary workaround for some Google3 builds. - __fp16 fp16 = __fp16(f); - U16 u16; - memcpy(&u16, &fp16, sizeof(U16)); - return u16; +// #if defined(JUMPER_IS_NEON) && defined(SK_CPU_ARM64) \ +// && !defined(SK_BUILD_FOR_GOOGLE3) // Temporary workaround for some Google3 builds. +// __fp16 fp16 = __fp16(f); +// U16 u16; +// memcpy(&u16, &fp16, sizeof(U16)); +// return u16; -#elif defined(JUMPER_IS_HSW) || defined(JUMPER_IS_SKX) - return _mm256_cvtps_ph(f, _MM_FROUND_CUR_DIRECTION); +// #elif defined(JUMPER_IS_HSW) || defined(JUMPER_IS_SKX) +// return _mm256_cvtps_ph(f, _MM_FROUND_CUR_DIRECTION); -#else +// #else // Remember, a float is 1-8-23 (sign-exponent-mantissa) with 127 exponent bias. U32 sem = sk_bit_cast(f), s = sem & 0x80000000, @@ -1021,7 +1021,7 @@ SI U16 to_half(F f) { auto denorm = (I32)em < 0x38800000; // I32 comparison is often quicker, and always safe here. return pack(if_then_else(denorm, U32(0) , (s>>16) + (em>>13) - ((127-15)<<10))); -#endif +// #endif } // Our fundamental vector depth is our pixel stride. diff --git a/chromium/tools/grit/grit/format/gzip_string.py b/chromium/tools/grit/grit/format/gzip_string.py index 3cd17185c9a..95cf00c8dae 100644 --- a/chromium/tools/grit/grit/format/gzip_string.py +++ b/chromium/tools/grit/grit/format/gzip_string.py @@ -12,22 +12,23 @@ import subprocess def GzipStringRsyncable(data): - # Make call to host system's gzip to get access to --rsyncable option. This - # option makes updates much smaller - if one line is changed in the resource, - # it won't have to push the entire compressed resource with the update. - # Instead, --rsyncable breaks the file into small chunks, so that one doesn't - # affect the other in compression, and then only that chunk will have to be - # updated. - gzip_proc = subprocess.Popen(['gzip', '--stdout', '--rsyncable', - '--best', '--no-name'], - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - data, stderr = gzip_proc.communicate(data) - if gzip_proc.returncode != 0: - raise subprocess.CalledProcessError(gzip_proc.returncode, 'gzip', - stderr) - return data + return GzipString(data) + # # Make call to host system's gzip to get access to --rsyncable option. This + # # option makes updates much smaller - if one line is changed in the resource, + # # it won't have to push the entire compressed resource with the update. + # # Instead, --rsyncable breaks the file into small chunks, so that one doesn't + # # affect the other in compression, and then only that chunk will have to be + # # updated. + # gzip_proc = subprocess.Popen(['gzip', '--stdout', '--rsyncable', + # '--best', '--no-name'], + # stdin=subprocess.PIPE, + # stdout=subprocess.PIPE, + # stderr=subprocess.PIPE) + # data, stderr = gzip_proc.communicate(data) + # if gzip_proc.returncode != 0: + # raise subprocess.CalledProcessError(gzip_proc.returncode, 'gzip', + # stderr) + # return data def GzipString(data): diff --git a/chromium/v8/src/base/cpu.cc b/chromium/v8/src/base/cpu.cc index c0e9e707aa2..27fa11ccae9 100644 --- a/chromium/v8/src/base/cpu.cc +++ b/chromium/v8/src/base/cpu.cc @@ -20,7 +20,7 @@ #if V8_OS_QNX #include // cpuinfo #endif -#if V8_OS_LINUX && (V8_HOST_ARCH_PPC || V8_HOST_ARCH_PPC64) +#if V8_OS_LINUX && (V8_HOST_ARCH_PPC || V8_HOST_ARCH_PPC64 || V8_HOST_ARCH_ARM) #include #endif #if V8_OS_AIX diff --git a/chromium/v8/src/base/platform/platform-posix.cc b/chromium/v8/src/base/platform/platform-posix.cc index 89173b593a6..db3e5480d96 100644 --- a/chromium/v8/src/base/platform/platform-posix.cc +++ b/chromium/v8/src/base/platform/platform-posix.cc @@ -854,7 +854,7 @@ bool Thread::Start() { #if V8_OS_MACOSX // Default on Mac OS X is 512kB -- bump up to 1MB stack_size = 1 * 1024 * 1024; -#elif V8_OS_AIX +#elif V8_OS_AIX || !defined(__GLIBC__) // Default on AIX is 96kB -- bump up to 2MB stack_size = 2 * 1024 * 1024; #endif