From patchwork Mon Dec 16 18:24:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Newton X-Patchwork-Id: 22540 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f197.google.com (mail-qc0-f197.google.com [209.85.216.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5091023FC6 for ; Mon, 16 Dec 2013 18:24:40 +0000 (UTC) Received: by mail-qc0-f197.google.com with SMTP id r5sf9425131qcx.0 for ; Mon, 16 Dec 2013 10:24:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:cc:subject:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=ZA0a4vhvgGad1AZOV83fc1zvmrsxXDCRUy3eOabc4ts=; b=hBpBsmBZtHkUrmN0+BI+L8T/SdHJPAjO2BebMRfbkSOKCovPkYqE7OdANsnmbcs3j+ PRVOWHzTn8N1H+1mwoUUdhsB2CtVfRXl0qSSNY50/I+hBlAn2Z/ECTsiUko3IvBj1aBe BOm+qBEnzIE++dnZlnFvgj7N3kZoZsZbBzUpnDpOof5dtXs2QXTzoZnMb91IuDBuwxH3 b9pLLjVq8g4LavzZY9izQ9zQcOOfSyQtJvLSnRcSiV6aMNtKTFer8Gsw4JlfCYB+yYdK ZPn9Z6QqZKE6J3PDkiSr24onFoRIV4n+vsMhqgyMgQ0BmNJwZp2t8zJBuaEJp9JrHSKG ZGVw== X-Gm-Message-State: ALoCoQkskwHxpAgFJFBDUsbj6ZaesRDLHsBvYBxeQ1u5DSpGrw/Pq2MI5EapqD4DYmWTZxTsewSQ X-Received: by 10.58.181.69 with SMTP id du5mr6650545vec.7.1387218280495; Mon, 16 Dec 2013 10:24:40 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.39.102 with SMTP id o6ls2199928qek.28.gmail; Mon, 16 Dec 2013 10:24:40 -0800 (PST) X-Received: by 10.221.23.137 with SMTP id ra9mr41535vcb.80.1387218280211; Mon, 16 Dec 2013 10:24:40 -0800 (PST) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id a6si4168595vdp.130.2013.12.16.10.24.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Dec 2013 10:24:40 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id lh4so3429310vcb.37 for ; Mon, 16 Dec 2013 10:24:40 -0800 (PST) X-Received: by 10.53.13.44 with SMTP id ev12mr7551548vdd.17.1387218280101; Mon, 16 Dec 2013 10:24:40 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp9139vcz; Mon, 16 Dec 2013 10:24:39 -0800 (PST) X-Received: by 10.194.58.136 with SMTP id r8mr15572508wjq.4.1387218279123; Mon, 16 Dec 2013 10:24:39 -0800 (PST) Received: from mail-we0-f177.google.com (mail-we0-f177.google.com [74.125.82.177]) by mx.google.com with ESMTPS id wy3si5514328wjc.103.2013.12.16.10.24.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Dec 2013 10:24:39 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.177 is neither permitted nor denied by best guess record for domain of will.newton@linaro.org) client-ip=74.125.82.177; Received: by mail-we0-f177.google.com with SMTP id u56so5066661wes.36 for ; Mon, 16 Dec 2013 10:24:38 -0800 (PST) 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:35 +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. X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: will.newton@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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);