From patchwork Wed Oct 21 14:42:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandar Ristovski X-Patchwork-Id: 9291 Received: (qmail 123569 invoked by alias); 21 Oct 2015 14:42:48 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 123556 invoked by uid 89); 21 Oct 2015 14:42:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: smtp-a02.blackberry.com Received: from smtp-a02.blackberry.com (HELO smtp-a02.blackberry.com) (208.65.78.91) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 21 Oct 2015 14:42:47 +0000 Received: from mhs101cnc.rim.net ([10.65.141.79]) by mhs214cnc-app.rim.net with ESMTP; 21 Oct 2015 10:42:45 -0400 Received: from unknown (HELO [10.222.109.89]) ([10.65.140.254]) by mhs101cnc.rim.net with ESMTP; 21 Oct 2015 14:42:45 +0000 Subject: Re: [PATCH 2/2] [nto] Improve ABI sniffing. To: Pedro Alves , gdb-patches@sourceware.org References: <5621218D.6070801@redhat.com> <1445364649-12175-1-git-send-email-aristovski@qnx.com> <1445364649-12175-3-git-send-email-aristovski@qnx.com> <56275FB2.3050509@redhat.com> <5627944D.3050900@qnx.com> <56279777.5060807@redhat.com> <56279EF9.2020200@qnx.com> <56279FD8.8010204@redhat.com> Newsgroups: gmane.comp.gdb.patches From: Aleksandar Ristovski Message-ID: <5627A465.2030503@qnx.com> Date: Wed, 21 Oct 2015 10:42:45 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <56279FD8.8010204@redhat.com> On 15-10-21 10:23 AM, Pedro Alves wrote: > On 10/21/2015 03:14 PM, Aleksandar Ristovski wrote: >> + name = note + sizeof_Elf_Nhdr; >> + if (sectsize < namelen + sizeof_Elf_Nhdr >> + || namelen > sizeof (QNX_NOTE_NAME)) >> + { >> + /* Can not be QNX note. */ >> + XDELETEVEC (note); >> + return; >> + } >> + >> + if (namelen == sizeof (QNX_NOTE_NAME) >> + && 0 == strcmp (name, QNX_NOTE_NAME)) >> + *(enum gdb_osabi *) obj = GDB_OSABI_QNXNTO; >> + >> + XDELETEVEC (note); > > Looks like these two ifs are now the same as the simpler: > > name = note + sizeof_Elf_Nhdr; > if (sectsize >= namelen + sizeof_Elf_Nhdr > && namelen == sizeof (QNX_NOTE_NAME) > && 0 == strcmp (name, QNX_NOTE_NAME)) > *(enum gdb_osabi *) obj = GDB_OSABI_QNXNTO; > > XDELETEVEC (note); > > OK with that change. > > Thanks, > Pedro Alves > Pushed d7161de46af80e460d432d8dbb1c42f8cbacf6dc With the following fixup: Thank you, Aleksandar Ristovski --- a/gdb/nto-tdep.c +++ b/gdb/nto-tdep.c @@ -361,15 +361,8 @@ nto_sniff_abi_note_section (bfd *abfd, asection *sect, void *obj) bfd_get_section_contents (abfd, sect, note, 0, sectsize); namelen = (unsigned int) bfd_h_get_32 (abfd, note); name = note + sizeof_Elf_Nhdr; - if (sectsize < namelen + sizeof_Elf_Nhdr - || namelen > sizeof (QNX_NOTE_NAME)) - { - /* Can not be QNX note. */ - XDELETEVEC (note); - return; - } - - if (namelen == sizeof (QNX_NOTE_NAME) + if (sectsize >= namelen + sizeof_Elf_Nhdr + && namelen == sizeof (QNX_NOTE_NAME) && 0 == strcmp (name, QNX_NOTE_NAME)) *(enum gdb_osabi *) obj = GDB_OSABI_QNXNTO;