From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from angie.orcam.me.uk (angie.orcam.me.uk [78.133.224.34]) by sourceware.org (Postfix) with ESMTP id 4B3833858C56 for ; Wed, 10 Apr 2024 00:02:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4B3833858C56 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=orcam.me.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=orcam.me.uk ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4B3833858C56 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=78.133.224.34 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712707359; cv=none; b=OhluuuKVt5bMlwNG2ZMJtH2YJELH+hraTCI67lEQCHfLMyErtwfzkO1VsCnU+Zl1hAPX/usHs3uj88cFnnxnNagoaD1/Bda06ePGd94TkXe2KML2Vfp02JatMp4yrmBaHC/krd+MQkwt387QnuTptYG7/JI27zaAn0Wf2KPxcUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712707359; c=relaxed/simple; bh=qPOGXpvwnxJtW0NT52MApnkuDnnqUs5fpqBwC8Ge9CQ=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=aJOv90/9D+K+A2FYYMNIkBT10VCSgKeaA8BZX7rQWTWhLdJWTOD0XZYARMbq6tfZaBskxemtyrqgzZgiK3NMtaJJyLHbVjWAqT3dIa7adWSSIo1++rxTuHkdYTK3yod2uKffVFWtG+4adSk5/yPwGg7jJWOrBB7ghoD6q1Fa5Uo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by angie.orcam.me.uk (Postfix, from userid 500) id CE0BE92009C; Wed, 10 Apr 2024 02:02:27 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id C714492009B; Wed, 10 Apr 2024 01:02:27 +0100 (BST) Date: Wed, 10 Apr 2024 01:02:27 +0100 (BST) From: "Maciej W. Rozycki" To: Luis Machado cc: John Baldwin , Tom Tromey , gdb-patches@sourceware.org Subject: Re: [PATCH 0/7] Fix race in DWARF reader In-Reply-To: <8114d4f1-a2ed-4f6f-aa64-339cfde9914b@arm.com> Message-ID: References: <20240217-dwarf-race-relocate-v1-0-d3d2d908c1e8@tromey.com> <871q7m8oid.fsf@tromey.com> <8114d4f1-a2ed-4f6f-aa64-339cfde9914b@arm.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1163.2 required=5.0 tests=BAYES_00,KAM_DMARC_STATUS,KAM_INFOUSMEBIZ,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, 9 Apr 2024, Luis Machado wrote: > >> Tom> The main patch affects MIPS16.  I can't test this -- I tried on a MIPS > >> Tom> machine in the GCC compile farm, but unfortunately the relevant > >> Tom> gdb.arch test says that the processor doesn't support MIPS16.  It's > >> Tom> possible this code is simply dead; I do not know. > >> > >> Elsewhere I mentioned that I had a different idea for this series. > >> > >> It seems to me that most (or maybe even all) the calls to > >> dwarf2_per_objfile::adjust aren't really needed.  Many of them only > >> affect lookup tables, where the adjustment isn't needed.  This includes > >> all calls made by the indexer. > >> > >> Some of the calls (like the one in read_attribute_value) even seem to be > >> wrong. > >> > >> So, I wrote a short series to remove these.  Unfortunately, though, it's > >> hard to know for sure if the result is correct, given that I don't know > >> how to test MIPS16. > >> > >> I could probably test some simple things ("break") by debugging gdb > >> while examining (but not running) a MIPS16 program.  I'm not sure if > >> that's really sufficient though. > >> > >> I'd appreciate some insight if you have any. > > > > I haven't seen anyone active with submitting MIPS patches in several years. > > I no longer make use of MIPS myself (and we've removed it from FreeBSD > > entirely, though I know it's still present in Linux distros).  Even when I > > was working with MIPS I never tested microMIPS / MIPS16. Support for the MIPS target in Linux is certainly far from being dead and I believe new MIPS hardware continues being made. Also a substantial MIPS patch for GDB for R6 ISA support is being pinged for review right now. > > OTOH, I think MIPS16 is similar to Thumb on ARM, and it might even be > > using a similar trick from reading your series (setting the LSB to enter > > "compressed decoding mode" vs "regular decoding mode").  I think ARM uses > > special mapping symbols to mark Thumb vs non-Thumb code though instead of > > depending on the LSB?  That is, I wonder why Thumb doesn't trip over this > > issue the way MIPS16 does? > > > > cc-ing Maciej, who might have a better idea on MIPS bits. Thanks, Luis! I can certainly run MIPS16 GDB verification right away with actual hardware: macro@malta(1)~$ uname -a Linux malta 5.18.0-rc2-00254-gfb649bda6f56-dirty #2 Sat Nov 12 20:14:53 GMT 2022 mips unknown unknown GNU/Linux macro@malta(2)~$ grep mips16 /proc/cpuinfo ASEs implemented : mips16 dsp dsp2 macro@malta(3)~$ however to understand the impact I'd have to go through the code changes, which I can't guarantee any specific timeframe for. Indeed at the machine level it is the LSB of the PC that tells compressed and regular code apart: you just flip the bit as required either by using special instructions with direct calls/jumps or explicitly with indirect ones; it's also correctly set according to the execution mode in effect in PC values recorded by hardware, such as the return address for function calls or the exception PC for kernel traps. Then whether compressed code uses the MIPS16 instruction encoding or the microMIPS instruction encoding it is the property of the implementation. Offhand I recall for compressed functions DWARF line information has the LSB of the PC set according to compressed vs regular encoding, however other DWARF records or the static ELF symbol table do not. Compressed function symbols have appropriate flags set in `st_other' to tell them apart from regular function symbols. BFD uses that information to set the LSB appropriately in relocation processing where applicable. To call a compressed function by hand or for function pointer comparison (e.g. against a datum stored in a program's variable or in a CPU register) in expression evaluation GDB has to recreate the LSB from information available and apply it to symbol values obtained from the symbol table, and it's a bit messy due to how things happened in the past. Conversely, in certain contexts the LSB has to be removed instead, such as `x /i $pc'. I made all this at least work at one point, not without shortcomings (e.g. broken hex instruction dumps in `disassemble /r' output), which is what we have now. Later on Yao Qi came up with a better proposal building on a generalised property of some psABIs where a function pointer is not the function's address: . The proposal got stuck on an issue with the PPC64 target which got never resolved due to the shortage of time and higher priority tasks combined: . Maybe someone can pick it up from there? I could do the necessary MIPS bits then myself, I certainly find it important enough to preempt other stuff I might otherwise want doing instead. Maciej