From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31908 invoked by alias); 16 Dec 2013 18:24:42 -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 31897 invoked by uid 89); 16 Dec 2013 18:24:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wg0-f51.google.com Received: from mail-wg0-f51.google.com (HELO mail-wg0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 16 Dec 2013 18:24:41 +0000 Received: by mail-wg0-f51.google.com with SMTP id b13so5034734wgh.30 for ; Mon, 16 Dec 2013 10:24:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:content-type:content-transfer-encoding; bh=ZA0a4vhvgGad1AZOV83fc1zvmrsxXDCRUy3eOabc4ts=; b=EwWdWHyohIcuUf3xHQdZXpQNAsS4b04prCvReMecC4DhNRncSSKbXOQIkUwFJevkao rgJGp2e28V0OOybTPPvmXZtl7D9HPHgyRNVCwPuVBH+Ox39GoTBHFInnDBMP173B6Xcs 77CS9KKVuHRz6aUwdlW0Qw5Tzh/4DcemerLcp65EuGIjlYGnER06c2icU5rDW0kAZIqA dY+l2zUPp+HJu7S4QJOp8u6/wZRzg1ZEEnbMeW1jdaQOvWc5ulMhWzZOSa8G8EIAc/ZY dXcVKSNJXQjYDfD+Jckeb/NPe5Ts0GTyAnuvpl3/Crqx5xBa9knvBOOJwUM2v2BdF8c1 0WlA== X-Gm-Message-State: ALoCoQm+qSXmmGNTHXJ2npDxrmqpCDvrWXH02sefwNJVDlpzqifideS5WVMVBvg+xO3f7EJLV8/O X-Received: by 10.194.57.243 with SMTP id l19mr8637392wjq.54.1387218278554; Mon, 16 Dec 2013 10:24:38 -0800 (PST) Received: from localhost.localdomain (cpc6-seac21-2-0-cust453.7-2.cable.virginm.net. [82.1.113.198]) by mx.google.com with ESMTPSA id z2sm9962464wiy.11.2013.12.16.10.24.36 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 16 Dec 2013 10:24:37 -0800 (PST) Message-ID: <52AF4563.2090304@linaro.org> Date: Mon, 16 Dec 2013 18:24:00 -0000 From: Will Newton User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: gdb-patches@sourceware.org CC: Patch Tracking Subject: [PATCH] gdb/elfread.c: Enable ifunc support on ARM. Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2013-12/txt/msg00595.txt.bz2 There are two failures in the gnu-ifunc.exp test on ARM. These are due to the failure to resolve the correct target function when attempting to breakpoint a GNU ifunc resolved function: (gdb) break gnu_ifunc Breakpoint 4 at gnu-indirect-function resolver at 0x2aacb5a2 when gnu_ifunc has been resolved this should actually be: (gdb) break gnu_ifunc Breakpoint 4 at 0x868c There are two reasons for this. The first is that ARM does not have a separate .got.plt section so looking this up will always fail. The second is that the Thumb bit needs to be stripped from the address to allow it to be reliably compared when inserting into the ifunc cache. Tested with no regressions on arm-linux-gnueabihf and x86_64-unknown-linux-gnu. gdb/ChangeLog: 2013-12-16 Will Newton * elfread.c (elf_rel_plt_read): Look for a .got section if looking up .got.plt fails. (elf_gnu_ifunc_resolve_by_got): Call gdbarch_addr_bits_remove on address passed to elf_gnu_ifunc_record_cache. (elf_gnu_ifunc_resolve_addr): Likewise. (elf_gnu_ifunc_resolver_return_stop): Likewise. --- gdb/elfread.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gdb/elfread.c b/gdb/elfread.c index 4a36927..30076e7 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -646,7 +646,12 @@ elf_rel_plt_read (struct objfile *objfile, asymbol **dyn_symbol_table) got_plt = bfd_get_section_by_name (obfd, ".got.plt"); if (got_plt == NULL) - return; + { + /* For platforms where there is no separate .got.plt. */ + got_plt = bfd_get_section_by_name (obfd, ".got"); + if (got_plt == NULL) + return; + } /* This search algorithm is from _bfd_elf_canonicalize_dynamic_reloc. */ for (relplt = obfd->sections; relplt != NULL; relplt = relplt->next) @@ -899,6 +904,7 @@ elf_gnu_ifunc_resolve_by_got (const char *name, CORE_ADDR *addr_p) addr = extract_typed_address (buf, ptr_type); addr = gdbarch_convert_from_func_ptr_addr (gdbarch, addr, ¤t_target); + addr = gdbarch_addr_bits_remove (gdbarch, addr); if (addr_p) *addr_p = addr; @@ -962,6 +968,7 @@ elf_gnu_ifunc_resolve_addr (struct gdbarch *gdbarch, CORE_ADDR pc) address = value_as_address (address_val); address = gdbarch_convert_from_func_ptr_addr (gdbarch, address, ¤t_target); + address = gdbarch_addr_bits_remove (gdbarch, address); if (name_at_pc) elf_gnu_ifunc_record_cache (name_at_pc, address); @@ -1070,6 +1077,7 @@ elf_gnu_ifunc_resolver_return_stop (struct breakpoint *b) resolved_pc = gdbarch_convert_from_func_ptr_addr (gdbarch, resolved_address, ¤t_target); + resolved_pc = gdbarch_addr_bits_remove (gdbarch, resolved_pc); gdb_assert (current_program_space == b->pspace || b->pspace == NULL); elf_gnu_ifunc_record_cache (b->addr_string, resolved_pc); -- 1.8.1.4