From: Oleg Tolmatcev <oleg.tolmatcev@gmail.com>
To: binutils@sourceware.org
Subject: Re: [PATCH] optimize handle_COMDAT
Date: Sat, 29 Apr 2023 14:39:00 +0200 [thread overview]
Message-ID: <CACcXsZjt+PmZWGEWgN=qfYjD2dA25+s51cWcSGLsKVat_XM5Qw@mail.gmail.com> (raw)
In-Reply-To: <ZEi91e/BbLW7A9mW@squeak.grove.modra.org>
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
next prev parent reply other threads:[~2023-04-29 12:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-25 16:48 Oleg Tolmatcev
2023-04-26 5:59 ` Alan Modra
2023-04-29 12:39 ` Oleg Tolmatcev [this message]
2023-05-04 4:11 ` Alan Modra
2023-05-04 17:33 ` Oleg Tolmatcev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CACcXsZjt+PmZWGEWgN=qfYjD2dA25+s51cWcSGLsKVat_XM5Qw@mail.gmail.com' \
--to=oleg.tolmatcev@gmail.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).