From patchwork Mon Oct 3 07:50:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 1640 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp835767wrs; Mon, 3 Oct 2022 00:50:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5BzP2TLzOhZNZ0J2Gg9u01eaKFF4VLGLbvf4yCoA/l4DBsFZ8HzY8i0RV7gvJwhEttRroP X-Received: by 2002:a17:906:794b:b0:787:bb35:84cd with SMTP id l11-20020a170906794b00b00787bb3584cdmr13764518ejo.428.1664783446313; Mon, 03 Oct 2022 00:50:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664783446; cv=none; d=google.com; s=arc-20160816; b=PnETQrBwfCChu4C3XxQU7kWz0gH0Y/XzDlWFMDrB1biaX+6c1Fq7ivXd5K34MOTEHd xNh+1HhkbAVyAmyrX9snyvgtxeah5UAl2LhyBD3IvgL5vzaPt/hZ+MOr9Nkg+XMr2y55 iQKUmcSH1mqZD0acKpUx/xIzyyKemUcOKRjeus7xCukylxajiNY/jKpiFEEuWT9n/QOd a5QFoFgzHLGISCD51YeOkLi62MoetzRZRzlk/E/3k+/Eip2fz7uQprLUg9Was65Hqa1T rJHQTaL5C0sPjANLJY/hqHiNnYM22BK+7lD6NOxc2qfOkqDNvUeIWadHwrG5Vvb5Qsu6 SfuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :in-reply-to:content-language:references:to:subject:from:user-agent :mime-version:date:message-id:dkim-signature:dkim-signature :dmarc-filter:delivered-to; bh=bHh65kSsjli+/ACswomclRsELnXOmLXLXxZEUyNbYWI=; b=CunO9A9SiqAmt6mWaXcrGBONI271NNE6HfJmGB8OcEoZS2jGuZngWE4FKeBnCRfcyC 3BUpEqsc55/MPa6/tRsGy965poMrXxdDz26O85CH1HvHoasBjBhPrMSO91sZczOvZyHR gjcqHCXkRgFV41eUkVm1BoF8yyDujNH3T7YIEdxNnUWSV4isrIX2w+wYkWTcvPSZo6z2 d/V966ay0eBkH0ZxLfxmaVJUgkvcS+FxkQK0Bjdr5/r7aGG7aEMLEGJzcukLh1YJ5+YB sPmVt8/AsxsVp4VlFHG9pmGYmtV12+z++k2H51DjFK+Rs0KrXswglmATVo4YvXa6NOtw MYfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@suse.cz header.s=susede2_rsa header.b=DVIzIJuF; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id bj26-20020a170906b05a00b0073d5b605cefsi6905367ejb.261.2022.10.03.00.50.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 00:50:46 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@suse.cz header.s=susede2_rsa header.b=DVIzIJuF; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3AAF43857379 for ; Mon, 3 Oct 2022 07:50:45 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 4E69F3858D38 for ; Mon, 3 Oct 2022 07:50:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4E69F3858D38 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 8B37021981; Mon, 3 Oct 2022 07:50:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1664783438; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=02lT3UbqqFIzMO3bDRuKXt7r3nC6kosZEOgFHxAO1SY=; b=DVIzIJuF57wAeK4Q6kxhjRbpRZnr0bSc06eUefmn2tQzLLOafB4k7DSibCI2BXfg7U+JAa zYERZ2PydajFjZSxTzNwxvCAQVXqoQneWFm5BWSXlpE3tvpUPeYHLYOl5muUrhiigiRKkZ 9EWRGKzqNd5oUgWIowDzsmgJqGPeAXU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1664783438; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=02lT3UbqqFIzMO3bDRuKXt7r3nC6kosZEOgFHxAO1SY=; b=ZzQ2hhpqanjUY9glRDZTsZbN2aVw8vk/mHyi9/gaMuY8KFhTBuYLhey9W6n6ZMnV5xEPG3 1u2E2cDAW7xRKYCQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 78BF01332F; Mon, 3 Oct 2022 07:50:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id rE+BHE6UOmMDUQAAMHmgww (envelope-from ); Mon, 03 Oct 2022 07:50:38 +0000 Message-ID: <597ed978-d121-220c-b56b-2ffb94bd091c@suse.cz> Date: Mon, 3 Oct 2022 09:50:38 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH 1/2] refactor usage of compressed_debug_section_type To: binutils@sourceware.org References: <20ce4355-56ca-ad6f-d7de-4c1522d33b5d@suse.cz> Content-Language: en-US In-Reply-To: <20ce4355-56ca-ad6f-d7de-4c1522d33b5d@suse.cz> X-Spam-Status: No, score=-29.4 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fangrui Song Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1745651967205701302?= X-GMAIL-MSGID: =?utf-8?q?1745651967205701302?= bfd/ChangeLog: * bfd-in.h (bfd_hash_set_default_size): Add COMPRESS_UNKNOWN enum value. (struct compressed_type_tuple): New. * bfd-in2.h (bfd_hash_set_default_size): Regenerate. (struct compressed_type_tuple): Likewise. * libbfd.c (ARRAY_SIZE): New macro. (bfd_get_compression_algorithm): New function. (bfd_get_compression_algorithm_name): Likewise. gas/ChangeLog: * as.c: Do not special-case, use the new functions. ld/ChangeLog: * emultempl/elf.em: Do not special-case, use the new functions. * lexsup.c (elf_static_list_options): Likewise. --- bfd/bfd-in.h | 20 +++++++++++++++++--- bfd/bfd-in2.h | 20 +++++++++++++++++--- bfd/libbfd.c | 36 ++++++++++++++++++++++++++++++++++++ gas/as.c | 34 +++++++++------------------------- ld/emultempl/elf.em | 22 +++++++--------------- ld/lexsup.c | 8 ++------ 6 files changed, 88 insertions(+), 52 deletions(-) diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h index 4765ea80536..82e33d400f3 100644 --- a/bfd/bfd-in.h +++ b/bfd/bfd-in.h @@ -335,15 +335,23 @@ extern void bfd_hash_traverse this size. */ extern unsigned long bfd_hash_set_default_size (unsigned long); -/* Types of compressed DWARF debug sections. We currently support - zlib. */ +/* Types of compressed DWARF debug sections. */ enum compressed_debug_section_type { COMPRESS_DEBUG_NONE = 0, COMPRESS_DEBUG = 1 << 0, COMPRESS_DEBUG_GNU_ZLIB = COMPRESS_DEBUG | 1 << 1, COMPRESS_DEBUG_GABI_ZLIB = COMPRESS_DEBUG | 1 << 2, - COMPRESS_DEBUG_ZSTD = COMPRESS_DEBUG | 1 << 3 + COMPRESS_DEBUG_ZSTD = COMPRESS_DEBUG | 1 << 3, + COMPRESS_UNKNOWN = 1 << 4 +}; + +/* Tuple for compressed_debug_section_type and their name. */ + +struct compressed_type_tuple +{ + enum compressed_debug_section_type type; + const char *name; }; /* This structure is used to keep track of stabs in sections @@ -456,6 +464,12 @@ extern void bfd_free_window (bfd_window *); extern bool bfd_get_file_window (bfd *, file_ptr, bfd_size_type, bfd_window *, bool); + + +extern enum compressed_debug_section_type bfd_get_compression_algorithm + (const char *); +extern const char *bfd_get_compression_algorithm_name + (enum compressed_debug_section_type); /* Externally visible ELF routines. */ diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 5c80956c79c..39f925362e0 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -342,15 +342,23 @@ extern void bfd_hash_traverse this size. */ extern unsigned long bfd_hash_set_default_size (unsigned long); -/* Types of compressed DWARF debug sections. We currently support - zlib. */ +/* Types of compressed DWARF debug sections. */ enum compressed_debug_section_type { COMPRESS_DEBUG_NONE = 0, COMPRESS_DEBUG = 1 << 0, COMPRESS_DEBUG_GNU_ZLIB = COMPRESS_DEBUG | 1 << 1, COMPRESS_DEBUG_GABI_ZLIB = COMPRESS_DEBUG | 1 << 2, - COMPRESS_DEBUG_ZSTD = COMPRESS_DEBUG | 1 << 3 + COMPRESS_DEBUG_ZSTD = COMPRESS_DEBUG | 1 << 3, + COMPRESS_UNKNOWN = 1 << 4 +}; + +/* Tuple for compressed_debug_section_type and their name. */ + +struct compressed_type_tuple +{ + enum compressed_debug_section_type type; + const char *name; }; /* This structure is used to keep track of stabs in sections @@ -463,6 +471,12 @@ extern void bfd_free_window (bfd_window *); extern bool bfd_get_file_window (bfd *, file_ptr, bfd_size_type, bfd_window *, bool); + + +extern enum compressed_debug_section_type bfd_get_compression_algorithm + (const char *); +extern const char *bfd_get_compression_algorithm_name + (enum compressed_debug_section_type); /* Externally visible ELF routines. */ diff --git a/bfd/libbfd.c b/bfd/libbfd.c index d33f3416206..14e7d8ef34f 100644 --- a/bfd/libbfd.c +++ b/bfd/libbfd.c @@ -1244,3 +1244,39 @@ _bfd_generic_init_private_section_data (bfd *ibfd ATTRIBUTE_UNUSED, { return true; } + +/* Display texts for type of compressed DWARF debug sections. */ +static const struct compressed_type_tuple compressed_debug_section_names[] = +{ + { COMPRESS_DEBUG_NONE, "none" }, + { COMPRESS_DEBUG, "zlib" }, + { COMPRESS_DEBUG_GNU_ZLIB, "zlib-gnu" }, + { COMPRESS_DEBUG_GABI_ZLIB, "zlib-gabi" }, + { COMPRESS_DEBUG_ZSTD, "zstd" }, +}; + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) +#endif + +/* Return compressed_debug_section_type from a string representation. */ +enum compressed_debug_section_type +bfd_get_compression_algorithm (const char *name) +{ + for (unsigned i = 0; i < ARRAY_SIZE (compressed_debug_section_names); ++i) + if (strcasecmp (compressed_debug_section_names[i].name, name) == 0) + return compressed_debug_section_names[i].type; + + return COMPRESS_UNKNOWN; +} + +/* Return compression algorithm name based on the type. */ +const char * +bfd_get_compression_algorithm_name (enum compressed_debug_section_type type) +{ + for (unsigned i = 0; i < ARRAY_SIZE (compressed_debug_section_names); ++i) + if (type == compressed_debug_section_names[i].type) + return compressed_debug_section_names[i].name; + + return NULL; +} diff --git a/gas/as.c b/gas/as.c index 9ce3d622f95..a5c2d2459f7 100644 --- a/gas/as.c +++ b/gas/as.c @@ -250,21 +250,16 @@ Options:\n\ fprintf (stream, _("\ --alternate initially turn on alternate macro syntax\n")); -#ifdef DEFAULT_FLAG_COMPRESS_DEBUG fprintf (stream, _("\ --compress-debug-sections[={none|zlib|zlib-gnu|zlib-gabi|zstd}]\n\ - compress DWARF debug sections using zlib [default]\n")); + compress DWARF debug sections\n")), fprintf (stream, _("\ - --nocompress-debug-sections\n\ - don't compress DWARF debug sections\n")); -#else - fprintf (stream, _("\ - --compress-debug-sections[={none|zlib|zlib-gnu|zlib-gabi|zstd}]\n\ - compress DWARF debug sections using zlib\n")); + Default: %s\n"), + bfd_get_compression_algorithm_name (flag_compress_debug)); + fprintf (stream, _("\ --nocompress-debug-sections\n\ - don't compress DWARF debug sections [default]\n")); -#endif + don't compress DWARF debug sections\n")); fprintf (stream, _("\ -D produce assembler debugging messages\n")); fprintf (stream, _("\ @@ -741,24 +736,13 @@ This program has absolutely no warranty.\n")); if (optarg) { #if defined OBJ_ELF || defined OBJ_MAYBE_ELF - if (strcasecmp (optarg, "none") == 0) - flag_compress_debug = COMPRESS_DEBUG_NONE; - else if (strcasecmp (optarg, "zlib") == 0) - flag_compress_debug = COMPRESS_DEBUG_GABI_ZLIB; - else if (strcasecmp (optarg, "zlib-gnu") == 0) - flag_compress_debug = COMPRESS_DEBUG_GNU_ZLIB; - else if (strcasecmp (optarg, "zlib-gabi") == 0) - flag_compress_debug = COMPRESS_DEBUG_GABI_ZLIB; - else if (strcasecmp (optarg, "zstd") == 0) - { -#ifdef HAVE_ZSTD - flag_compress_debug = COMPRESS_DEBUG_ZSTD; -#else + flag_compress_debug = bfd_get_compression_algorithm (optarg); +#ifndef HAVE_ZSTD + if (flag_compress_debug == COMPRESS_DEBUG_ZSTD) as_fatal (_ ("--compress-debug-sections=zstd: gas is not " "built with zstd support")); #endif - } - else + if (flag_compress_debug == COMPRESS_UNKNOWN) as_fatal (_("Invalid --compress-debug-sections option: `%s'"), optarg); #else diff --git a/ld/emultempl/elf.em b/ld/emultempl/elf.em index acd66f907d1..5dfc03a740c 100644 --- a/ld/emultempl/elf.em +++ b/ld/emultempl/elf.em @@ -660,24 +660,16 @@ gld${EMULATION_NAME}_handle_option (int optc) break; case OPTION_COMPRESS_DEBUG: - if (strcasecmp (optarg, "none") == 0) - link_info.compress_debug = COMPRESS_DEBUG_NONE; - else if (strcasecmp (optarg, "zlib") == 0) - link_info.compress_debug = COMPRESS_DEBUG_GABI_ZLIB; - else if (strcasecmp (optarg, "zlib-gnu") == 0) - link_info.compress_debug = COMPRESS_DEBUG_GNU_ZLIB; - else if (strcasecmp (optarg, "zlib-gabi") == 0) - link_info.compress_debug = COMPRESS_DEBUG_GABI_ZLIB; - else if (strcasecmp (optarg, "zstd") == 0) + link_info.compress_debug = bfd_get_compression_algorithm (optarg); + if (strcasecmp (optarg, "zstd") == 0) { -#ifdef HAVE_ZSTD - link_info.compress_debug = COMPRESS_DEBUG_ZSTD; -#else - einfo (_ ("%F%P: --compress-debug-sections=zstd: ld is not built " - "with zstd support\n")); +#ifndef HAVE_ZSTD + if (link_info.compress_debug == COMPRESS_DEBUG_ZSTD) + einfo (_ ("%F%P: --compress-debug-sections=zstd: ld is not built " + "with zstd support\n")); #endif } - else + if (link_info.compress_debug == COMPRESS_UNKNOWN) einfo (_("%F%P: invalid --compress-debug-sections option: \`%s'\n"), optarg); break; diff --git a/ld/lexsup.c b/ld/lexsup.c index 299371fb775..0c01c9966e0 100644 --- a/ld/lexsup.c +++ b/ld/lexsup.c @@ -2148,13 +2148,9 @@ elf_static_list_options (FILE *file) fprintf (file, _("\ --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi|zstd]\n\ Compress DWARF debug sections\n")); -#ifdef DEFAULT_FLAG_COMPRESS_DEBUG fprintf (file, _("\ - Default: zlib-gabi\n")); -#else - fprintf (file, _("\ - Default: none\n")); -#endif + Default: %s\n"), + bfd_get_compression_algorithm_name (link_info.compress_debug)); fprintf (file, _("\ -z common-page-size=SIZE Set common page size to SIZE\n")); fprintf (file, _("\ From patchwork Mon Oct 3 07:50:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 1641 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp835859wrs; Mon, 3 Oct 2022 00:51:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7546qQZLlVWW5TP/GE7Xvl9pU7U8zC3FZK++WMJeGwo6ABFnDiYlIUVTgoIkPblgCqjYHu X-Received: by 2002:a17:907:74a:b0:77e:9455:b4e3 with SMTP id xc10-20020a170907074a00b0077e9455b4e3mr14463007ejb.471.1664783463369; Mon, 03 Oct 2022 00:51:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664783463; cv=none; d=google.com; s=arc-20160816; b=mWHQUn4Fwgm94sl9eqV0nnjIEMxWlpxePMe3PJB91pYuaX/LB0EgrkGRgGwUsbjPUn /SWtBxLjDaoH20voLcPCTzjxfVJS7bz3CWFcIfY5/mRSe6M/eTwjbF8U4spaiTKXU27z +cxbheP6HyQ/hKNVK6fhFHDGDuA6wd35RaUebTD3/QL/m6AfkGPE8DdpAelmYGVZs3z8 PlDg7ApFl/FNoJqkcXDvDtMRL5tJfcpf0Yg9fQEwY++4QXPTq4Vgnl2kUgf0XDAyUDav au/9IM4l0utkqrT4nFOuevIjDok2Q0qtw12d5ya/54NHUWm5RWCCjv9nzpXGaYGK40YL LTCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :in-reply-to:content-language:references:to:subject:from:user-agent :mime-version:date:message-id:dkim-signature:dkim-signature :dmarc-filter:delivered-to; bh=EUaI8NTLCrTPfiS1tJdEAhhCwRVbJTgHUdLS1y0e61k=; b=iSGP2TDUxYs8dMmyrs6ff758ZWKJI0gB4LZhk89r7xCzPcjVhQDuYqZlQwWPJ/vx/c /PxdqbinaZimQ86t1kPEma9azfOKlXcUtBGxpWs1Ld2a/xmsZ8LOQLUGiZf0JQESx+ah e13bAW6s59jDOrbMdJsrumD65P+d8VFAUNVMTT/ahoy7FF25mbWEZR70NEVRWqcDSAaz 1pMAwNZM1zNXmKZXGne0xYD/zmta8Oo/TgeVD5bzfcFz8QrTZ94OL4aMdlTFJL/+39Sa TPDU595IMUApqqU3R9Rji/MrRatDdu2/Ybc8hwIzVTx/H8sbBoGSeap/gD0NJBnEoCvO PiPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=UDlsxG1n; dkim=neutral (no key) header.i=@sourceware.org header.s=susede2_ed25519 header.b=abeDTnYf; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id dm21-20020a170907949500b007429f0c69ccsi7001845ejc.579.2022.10.03.00.51.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 00:51:03 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=UDlsxG1n; dkim=neutral (no key) header.i=@sourceware.org header.s=susede2_ed25519 header.b=abeDTnYf; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7E45C3854179 for ; Mon, 3 Oct 2022 07:50:55 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 33CA3385735F for ; Mon, 3 Oct 2022 07:50:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 33CA3385735F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6FDC521981; Mon, 3 Oct 2022 07:50:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1664783444; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EUaI8NTLCrTPfiS1tJdEAhhCwRVbJTgHUdLS1y0e61k=; b=UDlsxG1n5XL38kXLiflZPQyvV4GBs/HAgVOy3ps1MDSqzhsQ++pev6j5Hy6bedlmBEFe6/ 13Kkxry9Jg/1FhS9PEWnxTwGkKyAxQc5qBxwoWDf7h1bHBFOYHD5dx/qRJ+s9mnMPGPCET b71yzH+ukX1neklcKBC+zhAjBDJvMO0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1664783444; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EUaI8NTLCrTPfiS1tJdEAhhCwRVbJTgHUdLS1y0e61k=; b=abeDTnYfxr/hhn8Movq5YZNMRY2+DDNJhMXliXFJ92uhhcsvkSKPdhaaTvMYQAXG/vPeGq 98C2R9hqM/sgHFCg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 509211332F; Mon, 3 Oct 2022 07:50:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 7IuWElSUOmMIUQAAMHmgww (envelope-from ); Mon, 03 Oct 2022 07:50:44 +0000 Message-ID: Date: Mon, 3 Oct 2022 09:50:44 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH 2/2] add --enable-default-compressed-debug-sections-algorithm configure option To: binutils@sourceware.org References: <20ce4355-56ca-ad6f-d7de-4c1522d33b5d@suse.cz> Content-Language: en-US In-Reply-To: <20ce4355-56ca-ad6f-d7de-4c1522d33b5d@suse.cz> X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fangrui Song Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1745651984588415018?= X-GMAIL-MSGID: =?utf-8?q?1745651984588415018?= ChangeLog: * configure.ac: Add --enable-default-compressed-debug-sections-algorithm. * configure: Regenerate. gas/ChangeLog: * NEWS: Document the new option. * as.c (flag_compress_debug): Set default algorithm based on the configure option. * configure.ac: Add --enable-default-compressed-debug-sections-algorithm. * configure: Regenerate. * config.in: Likewise. ld/ChangeLog: * NEWS: Document the new option. * configure.ac: Add --enable-default-compressed-debug-sections-algorithm. * configure: Regenerate. * config.in: Likewise. * ldmain.c: Set default algorithm based on the configure option. --- configure | 13 +++++++++++++ configure.ac | 6 ++++++ gas/NEWS | 3 +++ gas/as.c | 2 +- gas/config.in | 3 +++ gas/configure | 23 +++++++++++++++++++++-- gas/configure.ac | 12 ++++++++++++ ld/NEWS | 3 +++ ld/config.in | 3 +++ ld/configure | 23 +++++++++++++++++++++-- ld/configure.ac | 12 ++++++++++++ ld/ldmain.c | 2 +- 12 files changed, 99 insertions(+), 6 deletions(-) diff --git a/configure b/configure index f14e0efd675..a430e625c75 100755 --- a/configure +++ b/configure @@ -792,6 +792,7 @@ enable_gold enable_ld enable_gprofng enable_compressed_debug_sections +enable_default_compressed_debug_sections_algorithm enable_year2038 enable_libquadmath enable_libquadmath_support @@ -1523,6 +1524,9 @@ Optional Features: --enable-compressed-debug-sections={all,gas,gold,ld,none} Enable compressed debug sections for gas, gold or ld by default + --enable-default-compressed-debug-sections-algorithm={zlib,zstd} + Default compression algorithm for + --enable-compressed-debug-sections. --enable-year2038 enable support for timestamps past the year 2038 --disable-libquadmath do not build libquadmath directory --disable-libquadmath-support @@ -3119,6 +3123,15 @@ else fi +# Select default compression algorithm. +# Check whether --enable-default_compressed_debug_sections_algorithm was given. +if test "${enable_default_compressed_debug_sections_algorithm+set}" = set; then : + enableval=$enable_default_compressed_debug_sections_algorithm; +else + default_compressed_debug_sections_algorithm= +fi + + # Configure extra directories which are host specific case "${host}" in diff --git a/configure.ac b/configure.ac index 0152c69292e..9c4c9e13907 100644 --- a/configure.ac +++ b/configure.ac @@ -422,6 +422,12 @@ AC_ARG_ENABLE(compressed_debug_sections, fi ], [enable_compressed_debug_sections=]) +# Select default compression algorithm. +AC_ARG_ENABLE(default_compressed_debug_sections_algorithm, +[AS_HELP_STRING([--enable-default-compressed-debug-sections-algorithm={zlib,zstd}], + [Default compression algorithm for --enable-compressed-debug-sections.])], +[], [default_compressed_debug_sections_algorithm=]) + # Configure extra directories which are host specific case "${host}" in diff --git a/gas/NEWS b/gas/NEWS index 9a8b726b942..d9043d9d469 100644 --- a/gas/NEWS +++ b/gas/NEWS @@ -2,6 +2,9 @@ * gas now supports --compress-debug-sections=zstd to compress debug sections with zstd. +* Add --enable-default-compressed-debug-sections-algorithm={zlib,zstd} + that selects the default compression algorithm + for --enable-compressed-debug-sections. Changes in 2.39: diff --git a/gas/as.c b/gas/as.c index a5c2d2459f7..d42dd5394b5 100644 --- a/gas/as.c +++ b/gas/as.c @@ -226,7 +226,7 @@ print_version_id (void) #ifdef DEFAULT_FLAG_COMPRESS_DEBUG enum compressed_debug_section_type flag_compress_debug - = COMPRESS_DEBUG_GABI_ZLIB; + = DEFAULT_COMPRESSED_DEBUG_ALGORITHM; #endif static void diff --git a/gas/config.in b/gas/config.in index 0d1668a3eac..232bc350759 100644 --- a/gas/config.in +++ b/gas/config.in @@ -22,6 +22,9 @@ /* Default architecture. */ #undef DEFAULT_ARCH +/* Default compression algorithm for --enable-compressed-debug-sections. */ +#undef DEFAULT_COMPRESSED_DEBUG_ALGORITHM + /* Default CRIS architecture. */ #undef DEFAULT_CRIS_ARCH diff --git a/gas/configure b/gas/configure index 02cded59b6a..cae14c066d2 100755 --- a/gas/configure +++ b/gas/configure @@ -810,6 +810,7 @@ enable_largefile enable_targets enable_checking enable_compressed_debug_sections +enable_default_compressed_debug_sections_algorithm enable_x86_relax_relocations enable_elf_stt_common enable_generate_build_notes @@ -1476,6 +1477,9 @@ Optional Features: --enable-checking enable run-time checks --enable-compressed-debug-sections={all,gas,none} compress debug sections by default + --enable-default-compressed-debug-sections-algorithm={zlib,zstd} + Default compression algorithm for + --enable-compressed-debug-sections. --enable-x86-relax-relocations generate x86 relax relocations by default --enable-elf-stt-common generate ELF common symbols with STT_COMMON type by @@ -10722,7 +10726,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10725 "configure" +#line 10729 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -10828,7 +10832,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10831 "configure" +#line 10835 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11502,6 +11506,15 @@ if test "${enable_compressed_debug_sections+set}" = set; then : esac fi +# Select default compression algorithm. +ac_default_compressed_debug_sections_algorithm=COMPRESS_DEBUG_GABI_ZLIB +# Check whether --enable-default_compressed_debug_sections_algorithm was given. +if test "${enable_default_compressed_debug_sections_algorithm+set}" = set; then : + enableval=$enable_default_compressed_debug_sections_algorithm; case "${enableval}" in + zstd) ac_default_compressed_debug_sections_algorithm=COMPRESS_DEBUG_ZSTD ;; +esac +fi + # PR gas/19520 # Decide if x86 assembler should generate relax relocations. ac_default_x86_relax_relocations=unset @@ -12671,6 +12684,12 @@ $as_echo "#define DEFAULT_FLAG_COMPRESS_DEBUG 1" >>confdefs.h fi + +cat >>confdefs.h <<_ACEOF +#define DEFAULT_COMPRESSED_DEBUG_ALGORITHM $ac_default_compressed_debug_sections_algorithm +_ACEOF + + # Turn on all targets if possible if test ${all_targets} = "yes"; then case ${target_cpu_type} in diff --git a/gas/configure.ac b/gas/configure.ac index e6f3298cb3e..feb43399ce8 100644 --- a/gas/configure.ac +++ b/gas/configure.ac @@ -76,6 +76,15 @@ AC_ARG_ENABLE(compressed_debug_sections, *) ac_default_compressed_debug_sections=unset ;; esac])dnl +# Select default compression algorithm. +ac_default_compressed_debug_sections_algorithm=COMPRESS_DEBUG_GABI_ZLIB +AC_ARG_ENABLE(default_compressed_debug_sections_algorithm, + AS_HELP_STRING([--enable-default-compressed-debug-sections-algorithm={zlib,zstd}], + [Default compression algorithm for --enable-compressed-debug-sections.]), +[case "${enableval}" in + zstd) ac_default_compressed_debug_sections_algorithm=COMPRESS_DEBUG_ZSTD ;; +esac])dnl + # PR gas/19520 # Decide if x86 assembler should generate relax relocations. ac_default_x86_relax_relocations=unset @@ -755,6 +764,9 @@ if test x$ac_default_compressed_debug_sections = xyes ; then AC_DEFINE(DEFAULT_FLAG_COMPRESS_DEBUG, 1, [Define if you want compressed debug sections by default.]) fi +AC_DEFINE_UNQUOTED(DEFAULT_COMPRESSED_DEBUG_ALGORITHM, $ac_default_compressed_debug_sections_algorithm, + [Default compression algorithm for --enable-compressed-debug-sections.]) + # Turn on all targets if possible if test ${all_targets} = "yes"; then case ${target_cpu_type} in diff --git a/ld/NEWS b/ld/NEWS index dfe2690d9f2..d7ceb0c68b6 100644 --- a/ld/NEWS +++ b/ld/NEWS @@ -2,6 +2,9 @@ * ld now supports zstd compressed debug sections. The new option --compress-debug-sections=zstd compresses debug sections with zstd. +* Add --enable-default-compressed-debug-sections-algorithm={zlib,zstd} + that selects the default compression algorithm + for --enable-compressed-debug-sections. Changes in 2.39: diff --git a/ld/config.in b/ld/config.in index 3916740eee4..ad0dc6a106c 100644 --- a/ld/config.in +++ b/ld/config.in @@ -7,6 +7,9 @@ #endif #define __CONFIG_H__ 1 +/* Default compression algorithm for --enable-compressed-debug-sections. */ +#undef DEFAULT_COMPRESSED_DEBUG_ALGORITHM + /* Define to 1 if you want to emit gnu hash in the ELF linker by default. */ #undef DEFAULT_EMIT_GNU_HASH diff --git a/ld/configure b/ld/configure index 9dd3ed5f1e7..7906f52aadf 100755 --- a/ld/configure +++ b/ld/configure @@ -841,6 +841,7 @@ with_sysroot enable_gold enable_got enable_compressed_debug_sections +enable_default_compressed_debug_sections_algorithm enable_new_dtags enable_relro enable_textrel_check @@ -1524,6 +1525,9 @@ Optional Features: multigot) --enable-compressed-debug-sections={all,ld,none} compress debug sections by default] + --enable-default-compressed-debug-sections-algorithm={zlib,zstd} + Default compression algorithm for + --enable-compressed-debug-sections. --enable-new-dtags set DT_RUNPATH instead of DT_RPATH by default] --enable-relro enable -z relro in ELF linker by default --enable-textrel-check=[yes|no|warning|error] @@ -11620,7 +11624,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11623 "configure" +#line 11627 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11726,7 +11730,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11729 "configure" +#line 11733 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -15544,6 +15548,15 @@ if test "${enable_compressed_debug_sections+set}" = set; then : esac fi +# Select default compression algorithm. +ac_default_compressed_debug_sections_algorithm=COMPRESS_DEBUG_GABI_ZLIB +# Check whether --enable-default_compressed_debug_sections_algorithm was given. +if test "${enable_default_compressed_debug_sections_algorithm+set}" = set; then : + enableval=$enable_default_compressed_debug_sections_algorithm; case "${enableval}" in + zstd) ac_default_compressed_debug_sections_algorithm=COMPRESS_DEBUG_ZSTD ;; +esac +fi + # Decide setting DT_RUNPATH instead of DT_RPATH by default ac_default_new_dtags=unset # Provide a configure time option to override our default. @@ -17340,6 +17353,12 @@ $as_echo "#define DEFAULT_FLAG_COMPRESS_DEBUG 1" >>confdefs.h fi + +cat >>confdefs.h <<_ACEOF +#define DEFAULT_COMPRESSED_DEBUG_ALGORITHM $ac_default_compressed_debug_sections_algorithm +_ACEOF + + if test "${ac_default_new_dtags}" = unset; then ac_default_new_dtags=0 fi diff --git a/ld/configure.ac b/ld/configure.ac index f1b2f9897f8..6123ea78611 100644 --- a/ld/configure.ac +++ b/ld/configure.ac @@ -163,6 +163,15 @@ AC_ARG_ENABLE(compressed_debug_sections, ,no, | ,none,) ac_default_compressed_debug_sections=no ;; esac])dnl +# Select default compression algorithm. +ac_default_compressed_debug_sections_algorithm=COMPRESS_DEBUG_GABI_ZLIB +AC_ARG_ENABLE(default_compressed_debug_sections_algorithm, + AS_HELP_STRING([--enable-default-compressed-debug-sections-algorithm={zlib,zstd}], + [Default compression algorithm for --enable-compressed-debug-sections.]), +[case "${enableval}" in + zstd) ac_default_compressed_debug_sections_algorithm=COMPRESS_DEBUG_ZSTD ;; +esac])dnl + # Decide setting DT_RUNPATH instead of DT_RPATH by default ac_default_new_dtags=unset # Provide a configure time option to override our default. @@ -510,6 +519,9 @@ if test x$ac_default_compressed_debug_sections = xyes ; then AC_DEFINE(DEFAULT_FLAG_COMPRESS_DEBUG, 1, [Define if you want compressed debug sections by default.]) fi +AC_DEFINE_UNQUOTED(DEFAULT_COMPRESSED_DEBUG_ALGORITHM, $ac_default_compressed_debug_sections_algorithm, + [Default compression algorithm for --enable-compressed-debug-sections.]) + if test "${ac_default_new_dtags}" = unset; then ac_default_new_dtags=0 fi diff --git a/ld/ldmain.c b/ld/ldmain.c index d63002c994a..10f7a0538aa 100644 --- a/ld/ldmain.c +++ b/ld/ldmain.c @@ -352,7 +352,7 @@ main (int argc, char **argv) link_info.spare_dynamic_tags = 5; link_info.path_separator = ':'; #ifdef DEFAULT_FLAG_COMPRESS_DEBUG - link_info.compress_debug = COMPRESS_DEBUG_GABI_ZLIB; + link_info.compress_debug = DEFAULT_COMPRESSED_DEBUG_ALGORITHM; #endif #ifdef DEFAULT_NEW_DTAGS link_info.new_dtags = DEFAULT_NEW_DTAGS;