From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from server.nextmovesoftware.com (server.nextmovesoftware.com [162.254.253.69]) by sourceware.org (Postfix) with ESMTPS id BE5453858D33 for ; Thu, 27 Apr 2023 15:15:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BE5453858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=nextmovesoftware.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nextmovesoftware.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nextmovesoftware.com; s=default; h=Content-Type:MIME-Version:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=jVkiNsc44t4+UugfaeptQ7UTiLyaRtS5AKq0RSxoLDQ=; b=Bw861s1rufGwjPK3zs0uh0UClV LGxbiww969qzo19Cz6QyEsRHZC1G0N8rnlaHPMEOu/zHTmapnq7lI9r9elq2s+VlwOINDcLZtAp/3 LxxQggSQPJhqs5wPi6DsmlJzdWvQE4guYz8729kqOfG5ACu20+QOxKTZSTDyTKgvM/jX2EqPYfq+d xNhJLQ5Jib9F56B7+tS+a4FRxvNMEdrneGjFjAXKtq7HAUKf7qixLJzTcuWOlfQf5hgWZtK6Q+bpS E0nlUaDlrux9PfxH8HHO3VTZgxSwk/ftl0qm3DXQJ4BtTJsrr18tSAh0PBmcZihNiyq3RxNhJlYeU hymu9pPg==; Received: from [185.62.158.67] (port=63599 helo=Dell) by server.nextmovesoftware.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ps3Ku-0004AP-08 for gcc-patches@gcc.gnu.org; Thu, 27 Apr 2023 11:15:08 -0400 From: "Roger Sayle" To: "'GCC Patches'" Subject: [PATCH] Synchronize include/ctf.h with upstream binutils/libctf. Date: Thu, 27 Apr 2023 16:15:05 +0100 Message-ID: <002001d9791b$0d55b960$28012c20$@nextmovesoftware.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0021_01D97923.6F1A2160" X-Mailer: Microsoft Outlook 16.0 Thread-Index: Adl5GllMY73BNagyT9qmQp8yllgf0w== Content-Language: en-gb X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server.nextmovesoftware.com X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - nextmovesoftware.com X-Get-Message-Sender-Via: server.nextmovesoftware.com: authenticated_id: roger@nextmovesoftware.com X-Authenticated-Sender: server.nextmovesoftware.com: roger@nextmovesoftware.com X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This is a multipart message in MIME format. ------=_NextPart_000_0021_01D97923.6F1A2160 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit This patch updates include/ctf.h to match the current libctf version in binutils' include/. I recently attempted to build a uber tree (following some notes that are so old they used CVS) and noticed that binutils won't build with GCC's top-level include, due to CTF_F_IDXSORTED not being defined in ctf.h. There was also a discrepancy with ansidecl.h but I'm unsure how (best) to resolve that issue. This patch was tested on x86_64-pc-linux-gnu with a make bootstrap and make -k check, both with and without --target_board=unix{-m32}, with no new failures, to confirm that the usage of ctf.h in ctfout.cc and dwarf2ctf.cc is compatible with the new version. Ok for mainline? 2023-04-27 Roger Sayle include/ChangeLog * ctf.h: Import latest version from binutils/libctf. Thanks in advance, Roger -- ------=_NextPart_000_0021_01D97923.6F1A2160 Content-Type: text/plain; name="patchct.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="patchct.txt" diff --git a/include/ctf.h b/include/ctf.h=0A= index b867fc5..4263799 100644=0A= --- a/include/ctf.h=0A= +++ b/include/ctf.h=0A= @@ -1,5 +1,5 @@=0A= /* CTF format description.=0A= - Copyright (C) 2021-2023 Free Software Foundation, Inc.=0A= + Copyright (C) 2019-2023 Free Software Foundation, Inc.=0A= =0A= This file is part of libctf.=0A= =0A= @@ -89,13 +89,13 @@ extern "C"=0A= entries and reorder them accordingly (dropping the indexes in the = process).=0A= =0A= Variable records (as distinct from data objects) provide a modicum = of support=0A= - for non-ELF systems, mapping a variable name to a CTF type ID. The = variable=0A= - names are sorted into ASCIIbetical order, permitting binary = searching. We do=0A= - not define how the consumer maps these variable names to addresses or=0A= + for non-ELF systems, mapping a variable or function name to a CTF = type ID.=0A= + The names are sorted into ASCIIbetical order, permitting binary = searching.=0A= + We do not define how the consumer maps these variable names to = addresses or=0A= anything else, or indeed what these names represent: they might be = names=0A= looked up at runtime via dlsym() or names extracted at runtime by a = debugger=0A= or anything else the consumer likes. Variable records with = identically-=0A= - named entries in the data object section are removed.=0A= + named entries in the data object or function index section are = removed.=0A= =0A= The data types section is a list of variable size records that = represent each=0A= type, in order by their ID. The types themselves form a directed = graph,=0A= @@ -132,6 +132,12 @@ extern "C"=0A= #define CTF_MAX_SIZE 0xfffffffe /* Max size of a v2 type in bytes. */=0A= #define CTF_LSIZE_SENT 0xffffffff /* Sentinel for v2 ctt_size. */=0A= =0A= +# define CTF_MAX_TYPE_V1 0xffff /* Max type identifier value. */=0A= +# define CTF_MAX_PTYPE_V1 0x7fff /* Max parent type identifier value. = */=0A= +# define CTF_MAX_VLEN_V1 0x3ff /* Max struct, union, enums or args. */=0A= +# define CTF_MAX_SIZE_V1 0xfffe /* Max size of a type in bytes. */=0A= +# define CTF_LSIZE_SENT_V1 0xffff /* Sentinel for v1 ctt_size. */=0A= +=0A= /* Start of actual data structure definitions.=0A= =0A= Every field in these structures must have corresponding code in the=0A= @@ -144,6 +150,20 @@ typedef struct ctf_preamble=0A= unsigned char ctp_flags; /* Flags (see below). */=0A= } ctf_preamble_t;=0A= =0A= +typedef struct ctf_header_v2=0A= +{=0A= + ctf_preamble_t cth_preamble;=0A= + uint32_t cth_parlabel; /* Ref to name of parent lbl uniq'd against. = */=0A= + uint32_t cth_parname; /* Ref to basename of parent. */=0A= + uint32_t cth_lbloff; /* Offset of label section. */=0A= + uint32_t cth_objtoff; /* Offset of object section. */=0A= + uint32_t cth_funcoff; /* Offset of function section. */=0A= + uint32_t cth_varoff; /* Offset of variable section. */=0A= + uint32_t cth_typeoff; /* Offset of type section. */=0A= + uint32_t cth_stroff; /* Offset of string section. */=0A= + uint32_t cth_strlen; /* Length of string section in bytes. */=0A= +} ctf_header_v2_t;=0A= +=0A= typedef struct ctf_header=0A= {=0A= ctf_preamble_t cth_preamble;=0A= @@ -182,13 +202,19 @@ typedef struct ctf_header=0A= # define CTF_VERSION_1_UPGRADED_3 2=0A= # define CTF_VERSION_2 3=0A= =0A= -/* Note: some flags may be valid only in particular format versions. */=0A= -=0A= #define CTF_VERSION_3 4=0A= #define CTF_VERSION CTF_VERSION_3 /* Current version. */=0A= =0A= -#define CTF_F_COMPRESS 0x1 /* Data buffer is compressed by libctf. */=0A= -#define CTF_F_NEWFUNCINFO 0x2 /* New v3 func info section format. */=0A= +/* All of these flags bar CTF_F_COMPRESS and CTF_F_IDXSORTED are = bug-workaround=0A= + flags and are valid only in format v3: in v2 and below they cannot = occur and=0A= + in v4 and later, they will be recycled for other purposes. */=0A= +=0A= +#define CTF_F_COMPRESS 0x1 /* Data buffer is compressed by libctf. */=0A= +#define CTF_F_NEWFUNCINFO 0x2 /* New v3 func info section format. */=0A= +#define CTF_F_IDXSORTED 0x4 /* Index sections already sorted. */=0A= +#define CTF_F_DYNSTR 0x8 /* Strings come from .dynstr. */=0A= +#define CTF_F_MAX (CTF_F_COMPRESS | CTF_F_NEWFUNCINFO | CTF_F_IDXSORTED = \=0A= + | CTF_F_DYNSTR)=0A= =0A= typedef struct ctf_lblent=0A= {=0A= @@ -209,6 +235,52 @@ typedef struct ctf_varent=0A= ctf_type_t. Use of this member is indicated by the presence of=0A= CTF_LSIZE_SENT in ctt_size. */=0A= =0A= +/* In v1, the same applies, only the limit is (USHRT_MAX - 1) and=0A= + CTF_MAX_SIZE_V1, and CTF_LSIZE_SENT_V1 is the sentinel. */=0A= +=0A= +typedef struct ctf_stype_v1=0A= +{=0A= + uint32_t ctt_name; /* Reference to name in string table. */=0A= + unsigned short ctt_info; /* Encoded kind, variant length (see below). = */=0A= +#ifndef __GNUC__=0A= + union=0A= + {=0A= + unsigned short _size; /* Size of entire type in bytes. */=0A= + unsigned short _type; /* Reference to another type. */=0A= + } _u;=0A= +#else=0A= + __extension__=0A= + union=0A= + {=0A= + unsigned short ctt_size; /* Size of entire type in bytes. */=0A= + unsigned short ctt_type; /* Reference to another type. */=0A= + };=0A= +#endif=0A= +} ctf_stype_v1_t;=0A= +=0A= +typedef struct ctf_type_v1=0A= +{=0A= + uint32_t ctt_name; /* Reference to name in string table. */=0A= + unsigned short ctt_info; /* Encoded kind, variant length (see below). = */=0A= +#ifndef __GNUC__=0A= + union=0A= + {=0A= + unsigned short _size; /* Always CTF_LSIZE_SENT_V1. */=0A= + unsigned short _type; /* Do not use. */=0A= + } _u;=0A= +#else=0A= + __extension__=0A= + union=0A= + {=0A= + unsigned short ctt_size; /* Always CTF_LSIZE_SENT_V1. */=0A= + unsigned short ctt_type; /* Do not use. */=0A= + };=0A= +#endif=0A= + uint32_t ctt_lsizehi; /* High 32 bits of type size in bytes. */=0A= + uint32_t ctt_lsizelo; /* Low 32 bits of type size in bytes. */=0A= +} ctf_type_v1_t;=0A= +=0A= +=0A= typedef struct ctf_stype=0A= {=0A= uint32_t ctt_name; /* Reference to name in string table. */=0A= @@ -424,6 +496,13 @@ typedef struct ctf_slice=0A= unsigned short cts_bits;=0A= } ctf_slice_t;=0A= =0A= +typedef struct ctf_array_v1=0A= +{=0A= + unsigned short cta_contents; /* Reference to type of array contents. = */=0A= + unsigned short cta_index; /* Reference to type of array index. */=0A= + uint32_t cta_nelems; /* Number of elements. */=0A= +} ctf_array_v1_t;=0A= +=0A= typedef struct ctf_array=0A= {=0A= uint32_t cta_contents; /* Reference to type of array contents. */=0A= @@ -440,6 +519,28 @@ typedef struct ctf_array=0A= =0A= #define CTF_LSTRUCT_THRESH 536870912=0A= =0A= +/* In v1, the same is true, except that lmembers are used for structs = >=3D 8192=0A= + bytes in size. (The ordering of members in the ctf_member_* = structures is=0A= + different to improve padding.) */=0A= +=0A= +#define CTF_LSTRUCT_THRESH_V1 8192=0A= +=0A= +typedef struct ctf_member_v1=0A= +{=0A= + uint32_t ctm_name; /* Reference to name in string table. */=0A= + unsigned short ctm_type; /* Reference to type of member. */=0A= + unsigned short ctm_offset; /* Offset of this member in bits. */=0A= +} ctf_member_v1_t;=0A= +=0A= +typedef struct ctf_lmember_v1=0A= +{=0A= + uint32_t ctlm_name; /* Reference to name in string table. */=0A= + unsigned short ctlm_type; /* Reference to type of member. */=0A= + unsigned short ctlm_pad; /* Padding. */=0A= + uint32_t ctlm_offsethi; /* High 32 bits of member offset in bits. */=0A= + uint32_t ctlm_offsetlo; /* Low 32 bits of member offset in bits. */=0A= +} ctf_lmember_v1_t;=0A= +=0A= typedef struct ctf_member_v2=0A= {=0A= uint32_t ctm_name; /* Reference to name in string table. */=0A= @@ -498,13 +599,13 @@ struct ctf_archive=0A= /* Offset of the name table. */=0A= uint64_t ctfa_names;=0A= =0A= - /* Offset of the CTF table. Each element starts with a size (a = uint64_t=0A= - in network byte order) then a ctf_dict_t of that size. */=0A= + /* Offset of the CTF table. Each element starts with a size (a = little-=0A= + endian uint64_t) then a ctf_dict_t of that size. */=0A= uint64_t ctfa_ctfs;=0A= };=0A= =0A= -/* An array of ctfa_nnamed of this structure lies at=0A= - ctf_archive[ctf_archive->ctfa_modents] and gives the ctfa_ctfs or=0A= +/* An array of ctfa_ndicts of this structure lies at=0A= + ctf_archive[sizeof(struct ctf_archive)] and gives the ctfa_ctfs or=0A= ctfa_names-relative offsets of each name or ctf_dict_t. */=0A= =0A= typedef struct ctf_archive_modent=0A= ------=_NextPart_000_0021_01D97923.6F1A2160--