Message ID | a3693e7a058878c5a64f39ce0e58c7a2605b3a07.1666258361.git.research_trasio@irq.a4lg.com |
---|---|
State | Committed |
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1977138E9D1C for <patchwork@sourceware.org>; Thu, 20 Oct 2022 09:38:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1977138E9D1C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666258728; bh=lhPrc6ldQVn5MVnn3m7xcurdBduYWL9K2YcNIO/MAEU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=bKzE+uWnBkOeMOUWxiZDauWskSOYs0QIlGwfixwsWeYH7MMFAZd3fb34jgYn7qlk+ FKqiygAmrinDKs7yIZUhFPvwcQAlD7hlU7lQDQre8BqK+DSyxXpYSWd7GYIo8JyY2O nW1zaISvwpihNQPfb9QSB84c7zrYCthF/Axu2nSk= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-sender-0.a4lg.com (mail-sender.a4lg.com [153.120.152.154]) by sourceware.org (Postfix) with ESMTPS id 01B5B3898397 for <gdb-patches@sourceware.org>; Thu, 20 Oct 2022 09:36:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 01B5B3898397 Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id 549A6300089; Thu, 20 Oct 2022 09:36:45 +0000 (UTC) To: Tsukasa OI <research_trasio@irq.a4lg.com>, Andrew Burgess <aburgess@redhat.com>, Mike Frysinger <vapier@gentoo.org>, Nick Clifton <nickc@redhat.com> Subject: [PATCH 22/40] sim/m32r: Fixes to Linux emulator Date: Thu, 20 Oct 2022 09:32:27 +0000 Message-Id: <a3693e7a058878c5a64f39ce0e58c7a2605b3a07.1666258361.git.research_trasio@irq.a4lg.com> In-Reply-To: <cover.1666258361.git.research_trasio@irq.a4lg.com> References: <cover.1666258361.git.research_trasio@irq.a4lg.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> From: Tsukasa OI via Gdb-patches <gdb-patches@sourceware.org> Reply-To: Tsukasa OI <research_trasio@irq.a4lg.com> Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
sim+gdb: Suppress warnings if built with Clang (big batch 1)
|
|
Commit Message
Tsukasa OI
Oct. 20, 2022, 9:32 a.m. UTC
This commit fixes various M32R Linux emulator issues. 1. Some header files were missing a. <sys/ioctl.h> for ioctl b. <sys/fsuid.h> for setfsuid/setfsgid (Linux 1.2 or later) c. <sys/file.h> for flock (a syscall on Linux 2.0 or later) d. <sys/sendfile.h> for sendfile (Linux 2.2 or later) 2. syslog function must be called as a syscall rather than POSIX syslog because we are emulating Linux system calls on the Linux host. 3. ftime function is deprecated but used intentionally. We have to disable deprecated function warning. --- sim/m32r/traps.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
Comments
On 20 Oct 2022 09:32, Tsukasa OI wrote: > 1. Some header files were missing this looks fine > 2. syslog function must be called as a syscall rather than POSIX syslog > because we are emulating Linux system calls on the Linux host. i don't think that is accurate. if that were true, every other call in here would be using syscall() instead of calling the C library functions. > 3. ftime function is deprecated but used intentionally. > We have to disable deprecated function warning. this looks fine -mike
On 2022/10/23 23:56, Mike Frysinger wrote: > On 20 Oct 2022 09:32, Tsukasa OI wrote: >> 1. Some header files were missing > > this looks fine > >> 2. syslog function must be called as a syscall rather than POSIX syslog >> because we are emulating Linux system calls on the Linux host. > > i don't think that is accurate. if that were true, every other call in here > would be using syscall() instead of calling the C library functions. Note that this part is a Linux to Linux syscall translator (though I consider this whole idea unsafe). Yes, it uses many C library functions but I consider this is because they are (almost/completely) compatible with underlying syscalls. However, this isn't the case for syslog. POSIX syslog (C library function on <syslog.h>) and Linux syslog (syscall) have very different semantics and Linux syslog should be used here. Probably using glibc wrapper klogctl (<sys/klog.h>) might be a solution (see man page syslog.2). I would like to hear your thoughts. Best regards, Tsukasa > >> 3. ftime function is deprecated but used intentionally. >> We have to disable deprecated function warning. > > this looks fine > -mike
On 27 Oct 2022 11:40, Tsukasa OI wrote: > On 2022/10/23 23:56, Mike Frysinger wrote: > > On 20 Oct 2022 09:32, Tsukasa OI wrote: > >> 2. syslog function must be called as a syscall rather than POSIX syslog > >> because we are emulating Linux system calls on the Linux host. > > > > i don't think that is accurate. if that were true, every other call in here > > would be using syscall() instead of calling the C library functions. > > Note that this part is a Linux to Linux syscall translator (though I > consider this whole idea unsafe). Yes, it uses many C library functions > but I consider this is because they are (almost/completely) compatible > with underlying syscalls. this is incorrect. let's take a step back. the point of the sim runtime environments is to emulate the specified userland regardless of the host OS. it is not a linux-to-linux translator. the runtime decodes syscalls, then attempts to emulate the requested behavior. ideally that would only ever involve going through the standard C library APIs. the m32r linux runtime environment layer has a bunch of linuxisms in there (because it can be hard to emulate linux behavior on non-linux systems). but that doesn't mean it's a linux-to-linux layer, and we shouldn't be making it worse. > However, this isn't the case for syslog. POSIX syslog (C library > function on <syslog.h>) and Linux syslog (syscall) have very different > semantics and Linux syslog should be used here. you are correct here. the arch backends for diff runtime environments are inconsistent whether they pass through to the real host env, or they provide stub/fake data so the program doesn't get real access to the host (basically constructing a sandbox). i see the value in both modes (especially since a sandbox is easier to run cross-OS), but haven't fleshed out how to support these. > Probably using glibc wrapper klogctl (<sys/klog.h>) might be a solution > (see man page syslog.2). I would like to hear your thoughts. klogctl would be OK -mike
diff --git a/sim/m32r/traps.c b/sim/m32r/traps.c index f0fb218a11d..de275b06a40 100644 --- a/sim/m32r/traps.c +++ b/sim/m32r/traps.c @@ -20,6 +20,7 @@ /* This must come before any other includes. */ #include "defs.h" +#include "diagnostics.h" #include "portability.h" #include "sim-main.h" #include "sim-signal.h" @@ -38,9 +39,14 @@ NB: The emulation is also missing argument conversion (endian & bitsize) even on Linux hosts. */ #ifdef __linux__ +#include <sys/file.h> +#include <sys/fsuid.h> +#include <sys/ioctl.h> #include <sys/mman.h> #include <sys/poll.h> #include <sys/resource.h> +#include <sys/sendfile.h> +#include <sys/syscall.h> #include <sys/sysinfo.h> #include <sys/stat.h> #include <sys/time.h> @@ -397,7 +403,10 @@ m32r_trap (SIM_CPU *current_cpu, PCADDR pc, int num) { struct timeb t; +DIAGNOSTIC_PUSH +DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS result = ftime (&t); +DIAGNOSTIC_POP errcode = errno; if (result != 0) @@ -851,7 +860,7 @@ m32r_trap (SIM_CPU *current_cpu, PCADDR pc, int num) break; case TARGET_LINUX_SYS_syslog: - result = syslog (arg1, (char *) t2h_addr (cb, &s, arg2)); + result = syscall (SYS_syslog, arg1, (char *) t2h_addr (cb, &s, arg2), arg3); errcode = errno; break;