From patchwork Tue Jun 23 15:05:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Fortune X-Patchwork-Id: 487681 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C25F9140157 for ; Wed, 24 Jun 2015 01:06:03 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=sourceware.org header.i=@sourceware.org header.b=fOaAybvS; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:content-type :content-transfer-encoding:mime-version; q=dns; s=default; b=vrq ESWANf78mtCHa041BAbpYYZC+cvbmwM5hBxSIYfDrrZbfIaakNYF9Ncl89T+skn6 TyJPmjFEhNXmLULKerugZovywZZnGNblW6buwXSDBaDcEvxdSGxRP7wt6yoCdZBu 2FXSofVV/LpV6YOuWe7Xy6SxI5S3AyCqIXnCgpjw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:content-type :content-transfer-encoding:mime-version; s=default; bh=EymadPNau V+e5bcXOrciTtyv4LA=; b=fOaAybvSd7oKNEBtvF4rwD/zoZiP0Wy0FM3/ia/nk 2e1SCP0M4Ws7KiHIsHlQW9zRaIBcQPYgXvI3E2xivIZZ9HAKdxbcgVkhaE3isfJ9 n7TnzggNGW5OThqdfnRVHz9bKrwW9MH7RGopsPUMGtoZlBkJhOb1aGQboB1N7BjW t4= Received: (qmail 99107 invoked by alias); 23 Jun 2015 15:05:58 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 99097 invoked by uid 89); 23 Jun 2015 15:05:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mailapp01.imgtec.com From: Matthew Fortune To: "libc-alpha@sourceware.org" Subject: [PATCH, MIPS] Support shared library debug with MIPS PIE (glibc) Date: Tue, 23 Jun 2015 15:05:51 +0000 Message-ID: <6D39441BF12EF246A7ABCE6654B0235321175F69@LEMAIL01.le.imgtec.org> MIME-Version: 1.0 Following on from binutils submission of DT_MIPS_RLD_MAP2: http://sourceware.org/ml/binutils/2015-06/msg00226.html It is not currently possible to extract dynamic linker maps for MIPS position independent executables. MIPS does not use the DT_DEBUG tag as MIPS has a read-only dynamic section and the MIPS specific DT_MIPS_RLD_MAP tag stores an absolute address of the debug map pointer which is unusable for a PIE. Following previous discussions we are introducing a new dynamic tag as defined below. New dynamic tag: DT_MIPS_RLD_MAP2 - 0x70000035 Definition: This member is used by debugging. It contains a relative offset from the tag's runtime location of a 32-bit word in the .data section which is supplied by the compilation environment. The word's contents are not specified and programs using this value are not ABI - compliant. Manually tested with pre and post DT_MIPS_RLD_MAP2 executables alongside Updated GDB. OK to commit? Thanks, Matthew * elf/elf.h (DT_MIPS_RLD_MAP2): New macro. (DT_MIPS_NUM): Update. * sysdeps/mips/dl-machine.h (ELF_MACHINE_DEBUG_SETUP): Handle DT_MIPS_RLD_MAP2. --- elf/elf.h | 6 +++++- sysdeps/mips/dl-machine.h | 13 ++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/elf/elf.h b/elf/elf.h index 12feb91..51446f5 100644 --- a/elf/elf.h +++ b/elf/elf.h @@ -1727,7 +1727,11 @@ typedef struct PLT is writable. For a non-writable PLT, this is omitted or has a zero value. */ #define DT_MIPS_RWPLT 0x70000034 -#define DT_MIPS_NUM 0x35 +/* An alternative description of the classic MIPS RLD_MAP that is usable + in a PIE as it stores a relative offset from the address of the tag + rather than an absolute address. */ +#define DT_MIPS_RLD_MAP2 0x70000035 +#define DT_MIPS_NUM 0x36 /* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */ diff --git a/sysdeps/mips/dl-machine.h b/sysdeps/mips/dl-machine.h index d63238a..3677b64 100644 --- a/sysdeps/mips/dl-machine.h +++ b/sysdeps/mips/dl-machine.h @@ -68,10 +68,17 @@ in l_info array. */ #define DT_MIPS(x) (DT_MIPS_##x - DT_LOPROC + DT_NUM) -/* If there is a DT_MIPS_RLD_MAP entry in the dynamic section, fill it in - with the run-time address of the r_debug structure */ +/* If there is a DT_MIPS_RLD_MAP2 or DT_MIPS_RLD_MAP entry in the dynamic + section, fill in the debug map pointer with the run-time address of the + r_debug structure. */ #define ELF_MACHINE_DEBUG_SETUP(l,r) \ -do { if ((l)->l_info[DT_MIPS (RLD_MAP)]) \ +do { if ((l)->l_info[DT_MIPS (RLD_MAP2)]) \ + { \ + char *ptr = (char *)(l)->l_info[DT_MIPS (RLD_MAP2)]; \ + ptr += (l)->l_info[DT_MIPS (RLD_MAP2)]->d_un.d_val; \ + *(ElfW(Addr) *)ptr = (ElfW(Addr)) (r); \ + } \ + else if ((l)->l_info[DT_MIPS (RLD_MAP)]) \ *(ElfW(Addr) *)((l)->l_info[DT_MIPS (RLD_MAP)]->d_un.d_ptr) = \ (ElfW(Addr)) (r); \ } while (0)