From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by sourceware.org (Postfix) with ESMTPS id B66833858C50 for ; Sat, 29 Apr 2023 12:39:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B66833858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-4f004943558so1091519e87.3 for ; Sat, 29 Apr 2023 05:39:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682771953; x=1685363953; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=T6zkqyIPuqZjkvIRAv+ZXDuvCE7NTt25O/vR2cQcgvk=; b=sjBOkAsvT8kJ5rsM8dO+dv2D89VDV85XQo2MJYrtKxR2w1re5kZmnZnlRtme3rLzbr 9l39o5fGbaLMLZVziFRrrR+cfVsWgSCEwJ7mvRRdIj4dv/uK5eXyeJSGm3aYr5TM94SV 1cXBx2GJgwGdSZcRxR3zYigYpFGdMATvQcdjC/fA5SAqAuIJ3UbzBfx05jolr38J0r2w FuJuFs3z1S7EEoTpVmFa+LsLusqCBsEwuZFjT4U/J+cClaFSB95xxRbappxmEmeYB+VK P679f76F+T89wDhSmvl3Nk9/lrUm6RvRqsXcTgumMnnBoO08+JRrpgdTQt56UC/Mc1y7 UNDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682771953; x=1685363953; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=T6zkqyIPuqZjkvIRAv+ZXDuvCE7NTt25O/vR2cQcgvk=; b=e4jOVkEuMQQJainWjh7WJk6Q/EL+ZMozK1YGPJtAf0zZ+O8pbya8ZFIljyMlRUa4Ps JqiB8eDnJOYbbl6pmqQR3fV9msOgo09vOMbXPTVFlv0Z9NvmHmYHKYb3aef/MGWGz8Ht sTMT8H1BnMxLRSsHyAms2hBQ8HPREwGUfZUni/uq2zg0F8sg8WARaZ/+sj3+mLnU+3MC yrp3ieF8mY0bZo64o1mVFVoKmIhyyunmFsLYhEpKd/y38bbU2jgX+dNSijwv4rjgeoLw 2R4+p3mZsAGqNkyRz+FmzbI+9ToH+t5WpXlh24DG0bkoKBEcD0AWpNESQiZI4vtj5P0R i9iw== X-Gm-Message-State: AC+VfDwRp7rvmOmtF1hl2CDVS6K6/Gc+5bkTvoRa+5zaNMBXLubPSQHt w8wvN/j/dHXvJ1MHMbM4gpgdoRNfP1fe2g6A/70g9yEC6GI= X-Google-Smtp-Source: ACHHUZ6QXqw+6PgimPoWSMiqGMg2ODIkh/0H9fS/OHJhQaxOnYMBla4aZIbPtsrn4ib9LG6+DzoCKA5pQt6fLuJ/cdo= X-Received: by 2002:a05:6512:403:b0:4e9:6033:20d3 with SMTP id u3-20020a056512040300b004e9603320d3mr2318357lfk.24.1682771952703; Sat, 29 Apr 2023 05:39:12 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Oleg Tolmatcev Date: Sat, 29 Apr 2023 14:39:00 +0200 Message-ID: Subject: Re: [PATCH] optimize handle_COMDAT To: binutils@sourceware.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,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: Thanks for the review. Here is a new version. --- bfd/coffcode.h | 448 +++++++++++++++++++++++------- ----------------- bfd/libcoff-in.h | 11 ++ bfd/peicode.h | 21 +++ 3 files changed, 256 insertions(+), 224 deletions(-) diff --git a/bfd/coffcode.h b/bfd/coffcode.h index 594f3e0457..ab11e957e9 100644 + insert_flags (pe_data (abfd)->flags_hash, symname, isym.n_scnum, + sec_flags, (esym - esymstart) / bfd_coff_symesz (abfd)); + if (htab_elements (pe_data (abfd)->flags_hash) == 0) + fill_flags_hash (abfd, hdr); + + struct flags_entry *found + = find_flags (pe_data (abfd)->flags_hash, name, section->target_index); + found = find_flags (pe_data (abfd)->flags_hash, target_name_underscore, + section->target_index); + free (target_name_underscore); +#else + found = find_flags (pe_data (abfd)->flags_hash, target_name, + section->target_index); +#endif + } + /* Is this the name we're looking for ? */ + if (found != NULL) + { + insert_coff_comdat_info (abfd, section, found->name, found->symbol); + return sec_flags | found->sec_flags; + } } - - breakloop: - return sec_flags; + return sec_flags | SEC_LINK_ONCE; } diff --git a/bfd/libcoff-in.h b/bfd/libcoff-in.h index a0d286d37f..cdd504605b 100644 --- a/bfd/libcoff-in.h +++ b/bfd/libcoff-in.h @@ -24,6 +24,7 @@ #include "bfdlink.h" #include "coff-bfd.h" +#include "hashtab.h" #ifdef __cplusplus extern "C" { @@ -153,10 +154,20 @@ typedef struct pe_tdata const char *style; asection *sec; } build_id; + + htab_t flags_hash; } pe_data_type; #define pe_data(bfd) ((bfd)->tdata.pe_obj_data) +struct flags_entry +{ + flagword sec_flags; + const char *name; + int target_index; + long symbol; +}; + /* Tdata for XCOFF files. */ struct xcoff_tdata diff --git a/bfd/peicode.h b/bfd/peicode.h index e2e2be65b5..df1e678b5a 100644 --- a/bfd/peicode.h +++ b/bfd/peicode.h @@ -255,6 +255,25 @@ coff_swap_scnhdr_in (bfd * abfd, void * ext, void * in) #endif } +static hashval_t +htab_hash_flags (const void *entry) +{ + const struct flags_entry *fe = entry; + hashval_t h = 0; + h = iterative_hash (fe->name, strlen (fe->name), h); + h = iterative_hash_object (fe->target_index, h); + return h; +} + +static int +htab_eq_flags (const void *e1, const void *e2) +{ + const struct flags_entry *fe1 = e1; + const struct flags_entry *fe2 = e2; + return strcmp (fe1->name, fe2->name) == 0 + && fe1->target_index == fe2->target_index; +} + static bool pe_mkobject (bfd * abfd) { @@ -291,6 +310,8 @@ pe_mkobject (bfd * abfd) pe->dos_message[14] = 0x24; pe->dos_message[15] = 0x0; + pe->flags_hash = htab_create (10, htab_hash_flags, htab_eq_flags, NULL); + memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); bfd_coff_long_section_names (abfd) -- 2.40.0.windows.1