From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17247 invoked by alias); 14 Apr 2018 16:36:53 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 17231 invoked by uid 89); 14 Apr 2018 16:36:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=yeah, relationship X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 14 Apr 2018 16:36:50 +0000 Received: by simark.ca (Postfix, from userid 112) id 09DEE1EF60; Sat, 14 Apr 2018 12:36:48 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 8F2F01E47D; Sat, 14 Apr 2018 12:36:46 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sat, 14 Apr 2018 16:36:00 -0000 From: Simon Marchi To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v2 01/15] Fix breakpoints in ifunc after inferior resolved it (@got.plt symbol creation) In-Reply-To: References: <20180325191943.8246-1-palves@redhat.com> <20180325191943.8246-2-palves@redhat.com> <4c13e43f-bbad-3b55-12a2-d93f90196dc4@simark.ca> Message-ID: X-Sender: simark@simark.ca User-Agent: Roundcube Webmail/1.3.4 X-SW-Source: 2018-04/txt/msg00258.txt.bz2 On 2018-04-10 17:19, Pedro Alves wrote: > On 04/01/2018 04:35 AM, Simon Marchi wrote: >> On 2018-03-25 03:19 PM, Pedro Alves wrote: > >>> /* This search algorithm is from >>> _bfd_elf_canonicalize_dynamic_reloc. */ >>> for (relplt = obfd->sections; relplt != NULL; relplt = >>> relplt->next) >>> - if (elf_section_data (relplt)->this_hdr.sh_info == plt_elf_idx >>> - && (elf_section_data (relplt)->this_hdr.sh_type == SHT_REL >>> - || elf_section_data (relplt)->this_hdr.sh_type == SHT_RELA)) >>> - break; >>> + { >>> + const auto &this_hdr = elf_section_data (relplt)->this_hdr; >>> + >>> + if (this_hdr.sh_type == SHT_REL || this_hdr.sh_type == >>> SHT_RELA) >>> + { >>> + asection *target_section = NULL; >>> + >>> + if (this_hdr.sh_info == plt_elf_idx) >>> + target_section = plt; >>> + else if (this_hdr.sh_info == got_plt_elf_idx) >>> + target_section = got_plt; >>> + >>> + if (target_section != NULL) >>> + break; >> >> Is it really useful to have/set target_section? Couldn't we just >> break out of the >> loop like this? >> >> if (this_hdr.sh_info == plt_elf_idx >> || this_hdr.sh_info == got_plt_elf_idx) >> break; >> > > Hmm, the original intention was to use target_section in the other > loop, but that didn't work, so I reverted it, but somehow not that > part. :-P > >>> >>> @@ -573,6 +586,18 @@ elf_rel_plt_read (minimal_symbol_reader &reader, >>> >>> std::string string_buffer; >>> >>> + /* Does ADDRESS reside in SECTION of OBFD? */ >>> + auto within_section = [obfd] (asection *section, CORE_ADDR >>> address) >>> + { >>> + if (section == NULL) >>> + return false; >>> + >>> + /* Does the pointer reside in the .got.plt section? */ >> >> That comment should change, since it's not stricly .got.plt. >> > > I've removed it, since the intro comment already says it all. > >> Or maybe you intended to use target_section here at some point? Is >> there a >> relationship between the section that matched in the for loop above >> and the >> section that will contain the address? In other words, could we save >> the >> target_section from above and do > > Yeah, in an earlier version I tried doing that, but then testing on the > different systems found out that there's no relation between the > two sections. > > Here's the updated patch. WDYT? LGTM (though I trust the passing tests more than I trust myself). Simon