From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id 36D0D398405B for ; Wed, 14 Jul 2021 13:18:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 36D0D398405B Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16EDHZ5h031824 for ; Wed, 14 Jul 2021 13:18:23 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 39rnxdmw2g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 14 Jul 2021 13:18:23 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 16EDEkIX185870 for ; Wed, 14 Jul 2021 13:18:23 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2102.outbound.protection.outlook.com [104.47.58.102]) by aserp3020.oracle.com with ESMTP id 39q3cf76vk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 14 Jul 2021 13:18:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a8L1SQJyORqqnxNYQrDRII6qBCdJSgLtgogfk86NgTWOptt518dicVO+fYXjIhu2yGzaiGRXxM+xCeIXPoVnhQpWRURyrnMaAszNIOBMvSOeaFp5oM1iNEk81KIYZl32EbstvdMqSjZ75u72lxhFoZtGfjQBvGfzfVztnO0W05tm2N38SPQyZKldjTW2Qm8Scq5x2xCu5XIs+5NadRpYOW6q0uSpRC7dp5l6ey7iiiO9EgXOx3rGRAJD0ahJrQFmNZYjcXKoIposZEzG0eusC2zuyck/P99k+6KA2Is4Nbbt5IS0ixYa9Es5dSQCMzvOLN5ystKlqtbwvYtOpDvS3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U+QBRYMqka3OENah/DuJCBVFLNLGlII1cLat4+VjR8g=; b=DOmSVuxOViYdnYe2JEBd6Nr3x9PgS+iNjSNSJcA5pRrK5sINAe1owqZAsaZc995E2zHtZnKCT/df9yKKba4Uo649Vr5/Aq4ukOrI6t0S8G9U9+wTlcW1BcsvJCH2scd2pR5d1osg3KxAPrHGOQOij49+/wJyeH5Vl/tZTQHV3wQGXcsmqcyh0Zpwfr1gQGq1JwEo7L3xqWd9OkHpEu4ph0Y67gCqxqGc1NoLnFFl4h9CdNdC4E1kM1wv3+j0/xF1vEaqbZSaDimCyeEpbZwJGC2LaKv4BTVZ48lFwegAFULVZ2b99Kvbz4oHJ3hefJlJs2vp6AH6fL/iabP+UslLhw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none Received: from MWHPR1001MB2224.namprd10.prod.outlook.com (2603:10b6:301:2e::26) by CO1PR10MB4657.namprd10.prod.outlook.com (2603:10b6:303:96::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.22; Wed, 14 Jul 2021 13:18:21 +0000 Received: from MWHPR1001MB2224.namprd10.prod.outlook.com ([fe80::e994:1a07:4b43:d614]) by MWHPR1001MB2224.namprd10.prod.outlook.com ([fe80::e994:1a07:4b43:d614%6]) with mapi id 15.20.4308.027; Wed, 14 Jul 2021 13:18:21 +0000 From: Libor Bukata To: Simon Marchi via Gdb-patches CC: Libor Bukata Subject: [RFC][PATCH 2/3] [bfd] Add Solaris specific ELF note processing. Thread-Topic: [RFC][PATCH 2/3] [bfd] Add Solaris specific ELF note processing. Thread-Index: AQHXeLJ+9TA6JeQVVE27aFOxHBsURg== Date: Wed, 14 Jul 2021 13:18:21 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d8b67e99-ec44-40ba-3aba-08d946c9da2c x-ms-traffictypediagnostic: CO1PR10MB4657: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: qn6R3hYKUTEzdYgd1iu8oQ322MaRriLK0PRdljr1KsN5qFVXXGfabzjOGoopFxi4YjNIbQQfMhVHRzv8J4BlI+QEErM0MBXxdV6qL6egTDHujCQYak+bH669wISDtby0DJqXIae97maN6nmNff3tw/6QgZLHROMCtzd0jiEsetagJFywNDb0Ro/qddMZctXHHtDx5AzJTlEJ2qYXOQHEnbUaHcd4YTjgPEpJeBq+ME8OpZCcFDvKqxHsleCh7t+fqJk5PIsAWxmSJFOWfuKCpgqADrszG1wiaIHJvOgI3VjNxfj5UW2r/fPsrlly/Yb2i4IPOuFwkRRxGjyvuzv0g8gnPA7FhYQtEGHgWl2BKxjaLmxU7mIn8c/PqTtwcDa0vovq7ZKRaFx/ckYx/5Ozy/2KhNqmxITDeCy5+tzgKXLw26jUvGnVJUgcPiSLdYPG4tb1gfZomM2QKsY3pIaiCfqxVx6JUBoEml+Bg4EE/1pR+KxaL/NueDYdw44o4GLYWC+Yp7dKmKSxvwol8NC5Wt0PjnFxbdk5UpII3RaAvNjp5HS9p6Ddgz44tSyZ/EO1HIHFIYP8Ub/TWQVZXRFg54bTHsiCZVftFoy6r2SCQnO4psmvGZ1wwXygze+Qmfe4pRZwsbyZJXZgKlTlxyGFtGGoZezCR9HjPrk50UrOX5cQC17+IUr8G9kp3/aTDay/KojPjtaTsp/F+E7oVC24Zw== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2224.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(376002)(136003)(396003)(39860400002)(366004)(8676002)(53546011)(6506007)(478600001)(52536014)(7696005)(186003)(91956017)(66946007)(66476007)(66556008)(64756008)(66446008)(9686003)(86362001)(55016002)(76116006)(316002)(83380400001)(5660300002)(71200400001)(30864003)(6916009)(2906002)(4326008)(33656002)(8936002)(107886003)(38100700002)(44832011)(122000001)(38070700004); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?ODmDDbadYpBD00akr9/ZBu1u13lrr6XxD0rK0X5HQv1sfOu/ghYFfprA4V?= =?iso-8859-1?Q?IJQh7UgR6Zs2FZnmqIIY9626OfvBs2mq1Px3PgX9xnaPRNxRnHm8rdkDgz?= =?iso-8859-1?Q?yOyUe8G7ekOAb9eGeqmIvH9sj+pEzwFGEK0FRfaU1YRu81bBWuUFaRlXkd?= =?iso-8859-1?Q?EiHMi0PCs6hiTflX2ntHPV5wAWbl4FcvzO74Wa0WjUXDyk/YmHf7iWZHfz?= =?iso-8859-1?Q?2EBbinB9Z/OCSDXKINWPZeiiN4G6jrqQw2S7xMLufgx7nm8w5csaeGSSNH?= =?iso-8859-1?Q?w7Lbxb1msVdXciVMn1agyP75RMzUXY7/v4XGwLZubswZWW30m8XvZa69up?= =?iso-8859-1?Q?r4MDApM1iCBTv/wqmtidtPQHW9I9s46HcXOJTuWF4NBEz9MW81R0TSJYwF?= =?iso-8859-1?Q?7ldhhRHaJ7WtwM4QGNNzZnCrQ1x4pRiMNXfN0t4Bo8nXDsA18CvXiEUah9?= =?iso-8859-1?Q?Ca/9rz0iXTbhkIytFM3fK0MzQkDHJcINB9ejWGXLnOy08UoFY8vNFEfOBA?= =?iso-8859-1?Q?gD+e9n+EcJh9i9APPMJryf0OxvfSvdW6M95JZVx8ZDq8oAWX/opN5tUa5L?= =?iso-8859-1?Q?/U+m1k92oLMbrl6RqYrjIddjYOauVdtEgJK/Fobx3LGUakKdnbMqO4zDUm?= =?iso-8859-1?Q?mQPVS5il54yhLdzgLyRcBf7j2mnmQrd2DvpgHhe4p/qDTX4N43u1Vs/WUr?= =?iso-8859-1?Q?hVT3gCio7ZedX/EKa84CbxBSeqk5NhU0eJFwM60G6KMqFXRu6HHhTLbFzT?= =?iso-8859-1?Q?S+tTp7PQCDJKB4+7CbSa5joLKKJfoOMXPp2gaAOvoWtnokwWUkxFyNdsLh?= =?iso-8859-1?Q?dxwa0nyWA0hXm5Xao5dJtlztazRLx1HkFJ0bdp6QhjDlQnnbjHzKyhL3RG?= =?iso-8859-1?Q?IgX0x+k/z5wq2fXcRR1gIgnjUO0o/L2sbFxlPCRizRy42oM6xtsHZFTG0R?= =?iso-8859-1?Q?mtGrm9bEA/cGdFxV8j6ERXV62JnWupnman1Bao+7lbL1xlzCdVD8jsQzy8?= =?iso-8859-1?Q?S79WOfCes6A1Bi6x4Di8NdRhudClFSNWcRE4TLf/WrVkzkc0gHUkJJkr9j?= =?iso-8859-1?Q?VJCFK7+hUcFWFwa1betIDW+5PnAEPRbhaCVKM7nqeVY7MQor6aqE73JjLl?= =?iso-8859-1?Q?k0OKNpbi6EBV4fOszOyyU7Vl0DecNM12bW4vis9JbbxhPUWU6XqNVK6rRS?= =?iso-8859-1?Q?rX2E2/O0rFQV0n/9rXpzeASGkhQaJP9D8/hyPCMm0bdChMagQNny8rvLpy?= =?iso-8859-1?Q?cOer7D2dg0MykyJM05n4EMmLOqu8XVYNLuKcQjKYeeV8c9Kv8uxlyiUeYv?= =?iso-8859-1?Q?jBjcHhmp9Fg8x0ktsJn3wEfX5Q8isUuheDCoCCc7EjqsUHKSvWOIxmjUb6?= =?iso-8859-1?Q?KhJ0eP9ssm7h2AEvQGShIbCdwIy27oVw=3D=3D?= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2224.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d8b67e99-ec44-40ba-3aba-08d946c9da2c X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Jul 2021 13:18:21.1288 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: uSMcJ8/SOr0WIUTLkKkOImWS0Xb/DNp6KNV9dlGeph/KbDtxGzv0Ku5U9oBu3t5o6xZNmLQMaxi8dC8oMfZ6aQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4657 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10044 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 suspectscore=0 phishscore=0 adultscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107140083 X-Proofpoint-GUID: Cn3cNPRXRsv1Ocjucr-5fNE8pp-pM0-O X-Proofpoint-ORIG-GUID: Cn3cNPRXRsv1Ocjucr-5fNE8pp-pM0-O X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_BL, RCVD_IN_MSPIKE_L3, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Jul 2021 13:18:26 -0000 >From 3dafe7a64cd42a017b58d916e3055d993173563a Mon Sep 17 00:00:00 2001=0A= From: Libor Bukata =0A= Date: Wed, 14 Jul 2021 11:53:56 +0200=0A= Subject: [PATCH 2/3] [bfd] Add Solaris specific ELF note processing.=0A= =0A= Added elfcore_grok_solaris_note function that enables to=0A= obtain process status, register values, and program info.=0A= =0A= Tested on Solaris x86_64/sparcv9 and Linux x86_64.=0A= =0A= bfd/ChangeLog:=0A= =0A= 2021-07-12 Libor Bukata =0A= =0A= * elf-bfd.h (elf_backend_grok_lwpstatus): Added function.=0A= * elfxx-target.h (elf_backend_data): Updated ELF backend data.=0A= * bfd/elf.c (elfcore_grok_solaris_note): Solaris specific ELF=0A= note parser. Better GDB's coredump analysis on Solaris...=0A= (call_elfcore_grok_solaris_note): Helper function.=0A= (elf_parse_notes): Added "CORE" groker element.=0A= ---=0A= bfd/elf-bfd.h | 5 +=0A= bfd/elf.c | 294 ++++++++++++++++++++++++++++++++++++++++++-=0A= bfd/elfxx-target.h | 4 +=0A= include/elf/common.h | 23 ++++=0A= 4 files changed, 324 insertions(+), 2 deletions(-)=0A= =0A= diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h=0A= index b3f56b8c2ce..2427fcb1414 100644=0A= --- a/bfd/elf-bfd.h=0A= +++ b/bfd/elf-bfd.h=0A= @@ -1377,6 +1377,11 @@ struct elf_backend_data=0A= bool (*elf_backend_grok_freebsd_prstatus)=0A= (bfd *, Elf_Internal_Note *);=0A= =0A= + /* This function, if defined, is called when a "Solaris" NT_LWPSTATUS=0A= + note is found in a core file. */=0A= + bool (*elf_backend_grok_lwpstatus)=0A= + (bfd *, Elf_Internal_Note *);=0A= +=0A= /* This function, if defined, is called to write a note to a corefile. = */=0A= char *(*elf_backend_write_core_note)=0A= (bfd *abfd, char *buf, int *bufsiz, int note_type, ...);=0A= diff --git a/bfd/elf.c b/bfd/elf.c=0A= index de5abafabf0..58297d1dd35 100644=0A= --- a/bfd/elf.c=0A= +++ b/bfd/elf.c=0A= @@ -9717,7 +9717,10 @@ elfcore_make_note_pseudosection (bfd *abfd,=0A= static bool=0A= elfcore_grok_prfpreg (bfd *abfd, Elf_Internal_Note *note)=0A= {=0A= - return elfcore_make_note_pseudosection (abfd, ".reg2", note);=0A= + asection *sect =3D bfd_get_section_by_name (abfd, ".reg2");=0A= + if (sect =3D=3D NULL)=0A= + return elfcore_make_note_pseudosection (abfd, ".reg2", note);=0A= + return true;=0A= }=0A= =0A= /* Linux dumps the Intel SSE regs in a note named "LINUX" with a note=0A= @@ -10365,6 +10368,9 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *no= te)=0A= =0A= #if defined (HAVE_LWPSTATUS_T)=0A= case NT_LWPSTATUS:=0A= + if (bed->elf_backend_grok_lwpstatus)=0A= + if ((*bed->elf_backend_grok_lwpstatus) (abfd, note))=0A= + return true;=0A= return elfcore_grok_lwpstatus (abfd, note);=0A= #endif=0A= =0A= @@ -11083,6 +11089,287 @@ elfcore_grok_openbsd_procinfo (bfd *abfd, Elf_Int= ernal_Note *note)=0A= return true;=0A= }=0A= =0A= +#if defined(__sun) || defined(__SVR4)=0A= +#include =0A= +#include =0A= +#include =0A= +#include =0A= +#include =0A= +=0A= +static bool=0A= +elfcore_grok_solaris_note (bfd *abfd, Elf_Internal_Note *note)=0A= +{=0A= + asection *sect =3D NULL;=0A= + size_t fpregset_size;=0A= + size_t prgregset_size;=0A= + size_t prgregset_offset;=0A= + char reg2_section_name[16] =3D { 0 };=0A= +=0A= +#ifdef DEBUG=0A= + static const char* note_type[] =3D { "NONE (0)", "NT_PRSTATUS", "NT_PRFP= REG",=0A= + "NT_PRPSINFO", "NT_PRXREG", "NT_PLATFORM", "NT_AUXV", "NT_GWINDOWS",= =0A= + "NT_ASRS", "NT_LDT", "NT_PSTATUS", "INVALID (11)", "INVALID (12)",=0A= + "NT_PSINFO", "NT_PRCRED", "NT_UTSNAME", "NT_LWPSTATUS", "NT_LWPSINFO",= =0A= + "NT_PRPRIV", "NT_PRPRIVINFO", "NT_CONTENT", "NT_ZONENAME",=0A= + "NT_PRCPUXREG", NULL };=0A= +#endif=0A= +=0A= + if (note =3D=3D NULL)=0A= + return true;=0A= +=0A= + /* core files are identified as 32- or 64-bit, SPARC or x86,=0A= + by the size of the descsz which matches the sizeof()=0A= + the type appropriate for that note type (e.g., prstatus_t for=0A= + SOLARIS_NT_PRSTATUS) for the corresponding architecture=0A= + on Solaris. The core file bitness may differ from the bitness of=0A= + gdb itself, so fixed values are used instead of sizeof().=0A= + Appropriate fixed offsets are also used to obtain data from=0A= + the note */=0A= +=0A= + switch ((int) note->type)=0A= + {=0A= + case SOLARIS_NT_PRSTATUS:=0A= + if (note->descsz =3D=3D 508) /* sizeof(prstatus_t) SPARC 32-bit */= =0A= + {=0A= + prgregset_size =3D 152; /* sizeof(prgregset_t) SPARC 32-bit */=0A= + prgregset_offset =3D 356; /* offsetof(prstatus_t, pr_reg) */=0A= +=0A= + elf_tdata (abfd)->core->signal =3D=0A= + bfd_get_16 (abfd, note->descdata + 136);=0A= + elf_tdata (abfd)->core->pid =3D=0A= + bfd_get_32 (abfd, note->descdata + 216);=0A= + elf_tdata (abfd)->core->lwpid =3D=0A= + bfd_get_32 (abfd, note->descdata + 308);=0A= + }=0A= + else if (note->descsz =3D=3D 904) /* sizeof(prstatus_t) SPARC 64-bit= */=0A= + {=0A= + prgregset_size =3D 304; /* sizeof(prgregset_t) SPARC 64-bit */=0A= + prgregset_offset =3D 600; /* offsetof(prstatus_t, pr_reg) */=0A= +=0A= + elf_tdata (abfd)->core->signal =3D=0A= + bfd_get_16 (abfd, note->descdata + 264);=0A= + elf_tdata (abfd)->core->pid =3D=0A= + bfd_get_32 (abfd, note->descdata + 360);=0A= + elf_tdata (abfd)->core->lwpid =3D=0A= + bfd_get_32 (abfd, note->descdata + 520);=0A= + }=0A= + else if (note->descsz =3D=3D 432) /* sizeof(prstatus_t) Intel 32-bit= */=0A= + {=0A= + prgregset_size =3D 76; /* sizeof(prgregset_t) Intel 32-bit */=0A= + prgregset_offset =3D 356; /* offsetof(prstatus_t, pr_reg) */=0A= +=0A= + elf_tdata (abfd)->core->signal =3D=0A= + bfd_get_16 (abfd, note->descdata + 136);=0A= + elf_tdata (abfd)->core->pid =3D=0A= + bfd_get_32 (abfd, note->descdata + 216);=0A= + elf_tdata (abfd)->core->lwpid =3D=0A= + bfd_get_32 (abfd, note->descdata + 308);=0A= + }=0A= + else if (note->descsz =3D=3D 824) /* sizeof(prstatus_t) Intel 64-bit= */=0A= + {=0A= + prgregset_size =3D 224; /* sizeof(prgregset_t) Intel 64-bit */=0A= + prgregset_offset =3D 600; /* offsetof(prstatus_t, pr_reg) */=0A= +=0A= + elf_tdata (abfd)->core->signal =3D=0A= + bfd_get_16 (abfd, note->descdata + 264);=0A= + elf_tdata (abfd)->core->pid =3D=0A= + bfd_get_32 (abfd, note->descdata + 360);=0A= + elf_tdata (abfd)->core->lwpid =3D=0A= + bfd_get_32 (abfd, note->descdata + 520);=0A= + }=0A= +=0A= + sect =3D bfd_get_section_by_name (abfd, ".reg");=0A= + if (sect !=3D NULL)=0A= + sect->size =3D prgregset_size;=0A= +=0A= + return _bfd_elfcore_make_pseudosection (abfd, ".reg",=0A= + prgregset_size, note->descpos + prgregset_offset);=0A= + case SOLARIS_NT_PRPSINFO:=0A= + if (note->descsz =3D=3D 260) /* sizeof(prpsinfo_t) */=0A= + {=0A= + /* offsetof(prpsinfo, pr_fname) */=0A= + elf_tdata (abfd)->core->program=0A= + =3D _bfd_elfcore_strndup (abfd, note->descdata + 84, 16);=0A= + /* offsetof(prpsinfo, pr_psargs) */=0A= + elf_tdata (abfd)->core->command=0A= + =3D _bfd_elfcore_strndup (abfd, note->descdata + 100, 80);=0A= + }=0A= + break;=0A= + case SOLARIS_NT_PSINFO:=0A= + if (note->descsz =3D=3D 336) /* sizeof(psinfo_t) SPARC */=0A= + {=0A= + /* offsetof(psinfo_t, pr_fname) */=0A= + elf_tdata (abfd)->core->program=0A= + =3D _bfd_elfcore_strndup (abfd, note->descdata + 88, 16);=0A= + /* offsetof(psinfo_t, pr_psargs) */=0A= + elf_tdata (abfd)->core->command=0A= + =3D _bfd_elfcore_strndup (abfd, note->descdata + 104, 80);=0A= + }=0A= + else if (note->descsz =3D=3D 360) /* sizeof(psinfo_t) Intel */=0A= + {=0A= + /* offsetof(psinfo_t, pr_fname) */=0A= + elf_tdata (abfd)->core->program=0A= + =3D _bfd_elfcore_strndup (abfd, note->descdata + 88, 16);=0A= + /* offsetof(psinfo_t, pr_psargs) */=0A= + elf_tdata (abfd)->core->command=0A= + =3D _bfd_elfcore_strndup (abfd, note->descdata + 104, 80);=0A= + }=0A= + break;=0A= + case SOLARIS_NT_LWPSTATUS:=0A= + /* offsetof(lwpstatus_t, pr_lwpid */=0A= + elf_tdata (abfd)->core->lwpid =3D=0A= + bfd_get_32 (abfd, note->descdata + 4);=0A= + /* offsetof(lwpstatus_t, pr_cursig */=0A= + elf_tdata (abfd)->core->signal =3D=0A= + bfd_get_16 (abfd, note->descdata + 12);=0A= + (void) snprintf (reg2_section_name, 16, "%s/%i", ".reg2",=0A= + *(int*)(note->descdata + 4));=0A= +=0A= + if (note->descsz =3D=3D 896) /* sizeof(lwpstatus_t) SPARC 32-bit *= /=0A= + {=0A= + fpregset_size =3D 400; /* sizeof(fpregset_t) SPARC 32-bit */=0A= + prgregset_size =3D 152; /* sizeof(prgregset_t) SPARC 32-bit */= =0A= +=0A= + sect =3D bfd_get_section_by_name (abfd, ".reg");=0A= + if (sect !=3D NULL)=0A= + sect->size =3D sizeof(prgregset_t);=0A= + else=0A= + {=0A= + if ((_bfd_elfcore_make_pseudosection (abfd, ".reg",=0A= + prgregset_size,=0A= + note->descpos + 344)) !=3D true)=0A= + return false;=0A= + }=0A= + sect =3D bfd_get_section_by_name (abfd, reg2_section_name);=0A= +=0A= + if (sect !=3D NULL)=0A= + {=0A= + sect->size =3D fpregset_size;=0A= + sect->filepos =3D note->descpos + 496;=0A= + sect->alignment_power =3D 2;=0A= + return true;=0A= + }=0A= + else=0A= + return _bfd_elfcore_make_pseudosection (abfd, ".reg2",=0A= + fpregset_size, note->descpos + 496);=0A= + }=0A= + else if (note->descsz =3D=3D 1392) /* sizeof(lwpstatus_t) SPARC 64= -bit */=0A= + {=0A= + fpregset_size =3D 544; /* sizeof(fpregset_t) SPARC 64-bit */=0A= + prgregset_size =3D 304; /* sizeof(prgregset_t) SPARC 64-bit */= =0A= +=0A= + sect =3D bfd_get_section_by_name (abfd, ".reg");=0A= + if (sect !=3D NULL)=0A= + sect->size =3D sizeof(prgregset_t);=0A= + else=0A= + {=0A= + if ((_bfd_elfcore_make_pseudosection (abfd, ".reg",=0A= + prgregset_size,=0A= + note->descpos + 544)) !=3D true)=0A= + return false;=0A= + }=0A= + sect =3D bfd_get_section_by_name (abfd, reg2_section_name);=0A= +=0A= + if (sect !=3D NULL)=0A= + {=0A= + sect->size =3D fpregset_size;=0A= + sect->filepos =3D note->descpos + 848;=0A= + sect->alignment_power =3D 2;=0A= + return true;=0A= + }=0A= + else=0A= + return _bfd_elfcore_make_pseudosection (abfd, ".reg2",=0A= + fpregset_size, note->descpos + 848);=0A= + }=0A= + else if (note->descsz =3D=3D 800) /* sizeof(lwpstatus_t) Intel 32-= bit */=0A= + {=0A= + fpregset_size =3D 380; /* sizeof(fpregset_t) Intel 32-bit */=0A= + prgregset_size =3D 76; /* sizeof(prgregset_t) Intel 32-bit */= =0A= +=0A= + sect =3D bfd_get_section_by_name (abfd, ".reg");=0A= + if (sect !=3D NULL)=0A= + sect->size =3D prgregset_size;=0A= + else=0A= + {=0A= + if ((_bfd_elfcore_make_pseudosection (abfd, ".reg",=0A= + prgregset_size,=0A= + note->descpos + 344)) !=3D true)=0A= + return false;=0A= + }=0A= + sect =3D bfd_get_section_by_name (abfd, reg2_section_name);=0A= +=0A= + if (sect !=3D NULL)=0A= + {=0A= + sect->size =3D fpregset_size;=0A= + sect->filepos =3D note->descpos + 420;=0A= + sect->alignment_power =3D 2;=0A= + return true;=0A= + }=0A= + else=0A= + return _bfd_elfcore_make_pseudosection (abfd, ".reg2",=0A= + fpregset_size, note->descpos + 420);=0A= + }=0A= + else if (note->descsz =3D=3D 1296) /* sizeof(lwpstatus_t) Intel 64= -bit */=0A= + {=0A= + fpregset_size =3D 528; /* sizeof(fpregset_t) Intel 64-bit */=0A= + prgregset_size =3D 224; /* sizeof(prgregset_t) Intel 64-bit */= =0A= +=0A= + sect =3D bfd_get_section_by_name (abfd, ".reg");=0A= + if (sect !=3D NULL)=0A= + sect->size =3D prgregset_size;=0A= + else=0A= + {=0A= + if ((_bfd_elfcore_make_pseudosection (abfd, ".reg",=0A= + prgregset_size,=0A= + note->descpos + 544)) !=3D true)=0A= + return false;=0A= + }=0A= + sect =3D bfd_get_section_by_name (abfd, reg2_section_name);=0A= +=0A= + if (sect !=3D NULL)=0A= + {=0A= + sect->size =3D fpregset_size;=0A= + sect->filepos =3D note->descpos + 768;=0A= + sect->alignment_power =3D 2;=0A= + return true;=0A= + }=0A= + else=0A= + return _bfd_elfcore_make_pseudosection (abfd, ".reg2",=0A= + fpregset_size, note->descpos + 768);=0A= + }=0A= + break;=0A= + case SOLARIS_NT_LWPSINFO:=0A= + if (note->descsz =3D=3D 128) /* sizeof(lwpsinfo_t) Intel and SPARC= */=0A= + {=0A= + elf_tdata (abfd)->core->lwpid =3D=0A= + bfd_get_32 (abfd, note->descdata + 4);=0A= + }=0A= + break;=0A= + default:=0A= + break;=0A= + }=0A= +=0A= + return true;=0A= +}=0A= +=0A= +/*=0A= + * for name starting with "CORE" this may be either a Solaris=0A= + * core file or a gdb-generated core file. Do Solaris-specific=0A= + * processing on selected note types first with=0A= + * elfcore_grok_solaris_note(), then process the note=0A= + * in elfcore_grok_note().=0A= + */=0A= +static bool=0A= +call_elfcore_grok_solaris_note (bfd *abfd, Elf_Internal_Note *note)=0A= +{=0A= + if (! elfcore_grok_solaris_note (abfd, note)) {=0A= + return false;=0A= + } else {=0A= + return elfcore_grok_note (abfd, note);=0A= + }=0A= +}=0A= +#endif=0A= +=0A= static bool=0A= elfcore_grok_openbsd_note (bfd *abfd, Elf_Internal_Note *note)=0A= {=0A= @@ -12243,7 +12530,10 @@ elf_parse_notes (bfd *abfd, char *buf, size_t size= , file_ptr offset,=0A= GROKER_ELEMENT ( "OpenBSD", elfcore_grok_openbsd_note),=0A= GROKER_ELEMENT ("QNX", elfcore_grok_nto_note),=0A= GROKER_ELEMENT ("SPU/", elfcore_grok_spu_note),=0A= - GROKER_ELEMENT ("GNU", elfobj_grok_gnu_note)=0A= + GROKER_ELEMENT ("GNU", elfobj_grok_gnu_note),=0A= +#if defined(__sun) || defined(__SVR4)=0A= + GROKER_ELEMENT ("CORE", call_elfcore_grok_solaris_note)=0A= +#endif=0A= };=0A= #undef GROKER_ELEMENT=0A= int i;=0A= diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h=0A= index 4c6b1f20340..edd337dfd7b 100644=0A= --- a/bfd/elfxx-target.h=0A= +++ b/bfd/elfxx-target.h=0A= @@ -624,6 +624,9 @@=0A= #ifndef elf_backend_grok_psinfo=0A= #define elf_backend_grok_psinfo NULL=0A= #endif=0A= +#ifndef elf_backend_grok_lwpstatus=0A= +#define elf_backend_grok_lwpstatus NULL=0A= +#endif=0A= #ifndef elf_backend_grok_freebsd_prstatus=0A= #define elf_backend_grok_freebsd_prstatus NULL=0A= #endif=0A= @@ -875,6 +878,7 @@ static const struct elf_backend_data elfNN_bed =3D=0A= elf_backend_sort_relocs_p,=0A= elf_backend_grok_prstatus,=0A= elf_backend_grok_psinfo,=0A= + elf_backend_grok_lwpstatus,=0A= elf_backend_grok_freebsd_prstatus,=0A= elf_backend_write_core_note,=0A= elf_backend_lookup_section_flags_hook,=0A= diff --git a/include/elf/common.h b/include/elf/common.h=0A= index 6e6287206ca..a1ea7ff831f 100644=0A= --- a/include/elf/common.h=0A= +++ b/include/elf/common.h=0A= @@ -739,6 +739,29 @@=0A= #define NT_OPENBSD_WCOOKIE 23=0A= =0A= =0A= +/* Note segments for core files on Solaris systems. Note name=0A= + must start with "CORE". */=0A= +#define SOLARIS_NT_PRSTATUS 1=0A= +#define SOLARIS_NT_PRFPREG 2=0A= +#define SOLARIS_NT_PRPSINFO 3=0A= +#define SOLARIS_NT_PRXREG 4=0A= +#define SOLARIS_NT_PLATFORM 5=0A= +#define SOLARIS_NT_AUXV 6=0A= +#define SOLARIS_NT_GWINDOWS 7=0A= +#define SOLARIS_NT_ASRS 8=0A= +#define SOLARIS_NT_LDT 9=0A= +#define SOLARIS_NT_PSTATUS 10=0A= +#define SOLARIS_NT_PSINFO 13=0A= +#define SOLARIS_NT_PRCRED 14=0A= +#define SOLARIS_NT_UTSNAME 15=0A= +#define SOLARIS_NT_LWPSTATUS 16=0A= +#define SOLARIS_NT_LWPSINFO 17=0A= +#define SOLARIS_NT_PRPRIV 18=0A= +#define SOLARIS_NT_PRPRIVINFO 19=0A= +#define SOLARIS_NT_CONTENT 20=0A= +#define SOLARIS_NT_ZONENAME 21=0A= +#define SOLARIS_NT_PRCPUXREG 22=0A= +=0A= /* Note segments for core files on SPU systems. Note name=0A= must start with "SPU/". */=0A= =0A= -- =0A= 2.31.1=0A= =0A=