From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5677 invoked by alias); 16 Mar 2004 12:35:52 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 5664 invoked from network); 16 Mar 2004 12:35:50 -0000 Received: from unknown (HELO walton.kettenis.dyndns.org) (213.93.115.144) by sources.redhat.com with SMTP; 16 Mar 2004 12:35:50 -0000 Received: from elgar.kettenis.dyndns.org (elgar.kettenis.dyndns.org [192.168.0.2]) by walton.kettenis.dyndns.org (8.12.6p3/8.12.6) with ESMTP id i2GCZk4a000348; Tue, 16 Mar 2004 13:35:46 +0100 (CET) (envelope-from kettenis@elgar.kettenis.dyndns.org) Received: from elgar.kettenis.dyndns.org (localhost [127.0.0.1]) by elgar.kettenis.dyndns.org (8.12.6p3/8.12.6) with ESMTP id i2GCZkdD000494; Tue, 16 Mar 2004 13:35:46 +0100 (CET) (envelope-from kettenis@elgar.kettenis.dyndns.org) Received: (from kettenis@localhost) by elgar.kettenis.dyndns.org (8.12.6p3/8.12.6/Submit) id i2GCZksp000491; Tue, 16 Mar 2004 13:35:46 +0100 (CET) Date: Fri, 19 Mar 2004 00:09:00 -0000 Message-ID: <200403161235.i2GCZksp000491@elgar.kettenis.dyndns.org> From: Mark Kettenis To: binutils@sources.redhat.com CC: gdb-patches@sources.redhat.com Subject: [PATCH/RFA] Create .wcookie sections for OpenBSD/sparc core dumps X-SW-Source: 2004-03/txt/msg00348.txt.bz2 Message-ID: <20040319000900.P2tHhaT93X17g4yaEGdBB8HbTNKxoev8vKxqkkH7Q0E@z> Currently backtraces in core dumps generated by OpenBSD/sparc kernels that use StackGhost are broken in GDB. We need the StackGhost cookie to fix that, and it is stored in the core files. Unfortunately BFD doesn't exectly present it to us in an easy way. The attached patch modifies netbsd-core.c such that for OpenBSD/sparc corefiles, BFD creates a .wcookie section containing the cookie. This seems the natural approach, since it will make the transition to ELF core files easier (where presumably the cookie would be stored in an ELF note). The approach is inspired by the .auxv section created for NT_AUXV notes. OK, to check this in? Mark Index: ChangeLog from Mark Kettenis * netbsd-core.c (CORE_WCOOKIE_OFFSET): New define. (netbsd_core_file_p): Create a .wcookie section for OpenBSD/sparc. Index: netbsd-core.c =================================================================== RCS file: /cvs/src/src/bfd/netbsd-core.c,v retrieving revision 1.12 diff -u -p -r1.12 netbsd-core.c --- netbsd-core.c 16 Mar 2004 12:22:18 -0000 1.12 +++ netbsd-core.c 16 Mar 2004 12:26:45 -0000 @@ -34,6 +34,10 @@ NetBSD/sparc64 overlaps with M_MIPS1. */ #define M_SPARC64_OPENBSD M_MIPS1 +/* Offset of StackGhost cookie within `struct md_coredump' on + OpenBSD/sparc. */ +#define CORE_WCOOKIE_OFFSET 344 + struct netbsd_core_struct { struct core core; @@ -139,6 +143,25 @@ netbsd_core_file_p (abfd) asect->vma = coreseg.c_addr; asect->filepos = offset; asect->alignment_power = 2; + + if (CORE_GETMID (core) == M_SPARC_NETBSD + && CORE_GETFLAG (coreseg) == CORE_CPU + && coreseg.c_size > CORE_WCOOKIE_OFFSET) + { + /* Truncate the .reg section. */ + asect->_raw_size = CORE_WCOOKIE_OFFSET; + + /* And create the .wcookie section. */ + asect = bfd_make_section_anyway (abfd, ".wcookie"); + if (asect == NULL) + goto punt; + + asect->flags = SEC_ALLOC + SEC_HAS_CONTENTS; + asect->_raw_size = 4; + asect->vma = 0; + asect->filepos = offset + CORE_WCOOKIE_OFFSET; + asect->alignment_power = 2; + } offset += coreseg.c_size; }