diff options
author | Luca Bacci <luca.bacci@outlook.com> | 2023-05-17 13:38:14 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2023-05-17 13:38:14 +0100 |
commit | 80d4e113d7b9af8a5a36e5ea4399bca86050784f (patch) | |
tree | a471fa8b0176805e795dd73a3a97b5af94630482 /bfd | |
parent | 80b6c32f233ed28607643c4e4e4e2ee3399fdfd7 (diff) | |
download | fsf-binutils-gdb-80d4e113d7b9af8a5a36e5ea4399bca86050784f.zip fsf-binutils-gdb-80d4e113d7b9af8a5a36e5ea4399bca86050784f.tar.gz fsf-binutils-gdb-80d4e113d7b9af8a5a36e5ea4399bca86050784f.tar.bz2 |
Decorated symbols in import libs (BUG 30421)
PR 30421
* cofflink.c (_decoration_hash_newfunc): New function. (_bfd_coff_link_hash_table_init): Call it.
* libcoff-in.h (struct coff_link_hash_table): Add decoration_hash field. (struct decoration_hash_entry): Declare. (_decoration_hash_newfunc): Prototype.
* libcoff.h: Regenerate.
* emultempl/pe.em (set_decoration): New function. (pe_fixup_stdcalls): Call the new function.
* emultempl/pep.em (set_decoration): New function. (pep_fixup_stdcalls): Call the new function.
* pe-dll.c (make_one): Check for decoated symbols.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 11 | ||||
-rw-r--r-- | bfd/cofflink.c | 34 | ||||
-rw-r--r-- | bfd/libcoff-in.h | 11 | ||||
-rw-r--r-- | bfd/libcoff.h | 11 |
4 files changed, 66 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index dc46206..76d8a95 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,14 @@ +2023-05-17 Luca Bacci <luca.bacci@outlook.com> + + PR 30421 + * cofflink.c (_decoration_hash_newfunc): New function. + (_bfd_coff_link_hash_table_init): Call it. + * libcoff-in.h (struct coff_link_hash_table): Add decoration_hash + field. + (struct decoration_hash_entry): Declare. + (_decoration_hash_newfunc): Prototype. + * libcoff.h: Regenerate. + 2023-05-16 Oleg Tolmatcev <oleg.tolmatcev@gmail.com> * libcoff-in.h (struct coff_tdata): Add section_by_index and diff --git a/bfd/cofflink.c b/bfd/cofflink.c index 9baec2f..24c4a2b 100644 --- a/bfd/cofflink.c +++ b/bfd/cofflink.c @@ -89,6 +89,34 @@ _bfd_coff_link_hash_newfunc (struct bfd_hash_entry *entry, return (struct bfd_hash_entry *) ret; } +struct bfd_hash_entry * +_decoration_hash_newfunc (struct bfd_hash_entry *entry, + struct bfd_hash_table *table, + const char *string) +{ + struct decoration_hash_entry *ret = (struct decoration_hash_entry *) entry; + + /* Allocate the structure if it has not already been allocated by a + subclass. */ + if (ret == NULL) + { + ret = (struct decoration_hash_entry *) + bfd_hash_allocate (table, sizeof (struct decoration_hash_entry)); + if (ret == NULL) + return NULL; + } + + /* Call the allocation method of the superclass. */ + ret = (struct decoration_hash_entry *) + _bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret, table, string); + if (ret != NULL) + { + ret->decorated_link = NULL; + } + + return (struct bfd_hash_entry *) ret; +} + /* Initialize a COFF linker hash table. */ bool @@ -100,7 +128,11 @@ _bfd_coff_link_hash_table_init (struct coff_link_hash_table *table, unsigned int entsize) { memset (&table->stab_info, 0, sizeof (table->stab_info)); - return _bfd_link_hash_table_init (&table->root, abfd, newfunc, entsize); + + return bfd_hash_table_init (&table->decoration_hash, + _decoration_hash_newfunc, + sizeof (struct decoration_hash_entry)) + &&_bfd_link_hash_table_init (&table->root, abfd, newfunc, entsize); } /* Create a COFF linker hash table. */ diff --git a/bfd/libcoff-in.h b/bfd/libcoff-in.h index 9c5780b..24a950d 100644 --- a/bfd/libcoff-in.h +++ b/bfd/libcoff-in.h @@ -290,6 +290,9 @@ struct coff_link_hash_table struct bfd_link_hash_table root; /* A pointer to information used to link stabs in sections. */ struct stab_info stab_info; + /* Hash table that maps undecorated names to their respective + * decorated coff_link_hash_entry as found in fixup_stdcalls */ + struct bfd_hash_table decoration_hash; }; struct coff_reloc_cookie @@ -321,6 +324,12 @@ struct coff_reloc_cookie #define coff_hash_table(p) ((struct coff_link_hash_table *) ((p)->hash)) +struct decoration_hash_entry +{ + struct bfd_hash_entry root; + struct bfd_link_hash_entry *decorated_link; +}; + /* Functions in coffgen.c. */ extern bfd_cleanup coff_object_p (bfd *); @@ -568,6 +577,8 @@ struct coff_section_alignment_entry unsigned int alignment_power; }; +extern struct bfd_hash_entry *_decoration_hash_newfunc + (struct bfd_hash_entry *, struct bfd_hash_table *, const char *); extern struct bfd_hash_entry *_bfd_coff_link_hash_newfunc (struct bfd_hash_entry *, struct bfd_hash_table *, const char *); extern bool _bfd_coff_link_hash_table_init diff --git a/bfd/libcoff.h b/bfd/libcoff.h index 1a8d930..c5d15a1 100644 --- a/bfd/libcoff.h +++ b/bfd/libcoff.h @@ -294,6 +294,9 @@ struct coff_link_hash_table struct bfd_link_hash_table root; /* A pointer to information used to link stabs in sections. */ struct stab_info stab_info; + /* Hash table that maps undecorated names to their respective + * decorated coff_link_hash_entry as found in fixup_stdcalls */ + struct bfd_hash_table decoration_hash; }; struct coff_reloc_cookie @@ -325,6 +328,12 @@ struct coff_reloc_cookie #define coff_hash_table(p) ((struct coff_link_hash_table *) ((p)->hash)) +struct decoration_hash_entry +{ + struct bfd_hash_entry root; + struct bfd_link_hash_entry *decorated_link; +}; + /* Functions in coffgen.c. */ extern bfd_cleanup coff_object_p (bfd *); @@ -572,6 +581,8 @@ struct coff_section_alignment_entry unsigned int alignment_power; }; +extern struct bfd_hash_entry *_decoration_hash_newfunc + (struct bfd_hash_entry *, struct bfd_hash_table *, const char *); extern struct bfd_hash_entry *_bfd_coff_link_hash_newfunc (struct bfd_hash_entry *, struct bfd_hash_table *, const char *); extern bool _bfd_coff_link_hash_table_init |