summaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorLuca Bacci <luca.bacci@outlook.com>2023-05-17 13:38:14 +0100
committerNick Clifton <nickc@redhat.com>2023-05-17 13:38:14 +0100
commit80d4e113d7b9af8a5a36e5ea4399bca86050784f (patch)
treea471fa8b0176805e795dd73a3a97b5af94630482 /bfd
parent80b6c32f233ed28607643c4e4e4e2ee3399fdfd7 (diff)
downloadbinutils-gdb-80d4e113d7b9af8a5a36e5ea4399bca86050784f.tar.gz
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/ChangeLog11
-rw-r--r--bfd/cofflink.c34
-rw-r--r--bfd/libcoff-in.h11
-rw-r--r--bfd/libcoff.h11
4 files changed, 66 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index dc4620663b2..76d8a954ae3 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 9baec2fc712..24c4a2b0ad7 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 9c5780bfcc0..24a950dedd4 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 1a8d9307734..c5d15a13f7b 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