aboutsummaryrefslogtreecommitdiff
path: root/bfd/cofflink.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/cofflink.c')
-rw-r--r--bfd/cofflink.c49
1 files changed, 44 insertions, 5 deletions
diff --git a/bfd/cofflink.c b/bfd/cofflink.c
index 876aed7..38278e2 100644
--- a/bfd/cofflink.c
+++ b/bfd/cofflink.c
@@ -27,6 +27,7 @@
#include "libbfd.h"
#include "coff/internal.h"
#include "libcoff.h"
+#include "elf-bfd.h"
#include "safe-ctype.h"
static bool coff_link_add_object_symbols (bfd *, struct bfd_link_info *);
@@ -445,7 +446,7 @@ coff_link_add_symbols (bfd *abfd,
if (addit)
{
- if (! (bfd_coff_link_add_one_symbol
+ if (! (_bfd_generic_link_add_one_symbol
(info, abfd, name, flags, section, value,
(const char *) NULL, copy, false,
(struct bfd_link_hash_entry **) sym_hash)))
@@ -931,14 +932,52 @@ _bfd_coff_final_link (bfd *abfd,
bfd_vma written = 0;
bool rewrite = false;
- if (! (sym->flags & BSF_LOCAL)
- || (sym->flags & (BSF_SECTION_SYM | BSF_DEBUGGING_RELOC
- | BSF_THREAD_LOCAL | BSF_RELC | BSF_SRELC
- | BSF_SYNTHETIC))
+ if ((sym->flags & (BSF_SECTION_SYM | BSF_DEBUGGING_RELOC
+ | BSF_THREAD_LOCAL | BSF_RELC | BSF_SRELC
+ | BSF_SYNTHETIC))
|| ((sym->flags & BSF_DEBUGGING)
&& ! (sym->flags & BSF_FILE)))
continue;
+ if (! (sym->flags & BSF_LOCAL))
+ {
+ /* For ELF symbols try to represent their function-ness and
+ size, if available. */
+ if (! (sym->flags & BSF_FUNCTION))
+ continue;
+
+ const elf_symbol_type *elfsym = elf_symbol_from (sym);
+ if (!elfsym)
+ continue;
+
+ struct coff_link_hash_entry *hent
+ = (struct coff_link_hash_entry *) bfd_hash_lookup
+ (&info->hash->table, bfd_asymbol_name (sym),
+ false, false);
+ if (!hent)
+ continue;
+
+ /* coff_data (abfd)->local_n_btshft is what ought to be used
+ here, just that it's set only when reading in COFF
+ objects. */
+ hent->type = DT_FCN << 4;
+ if (!elfsym->internal_elf_sym.st_size)
+ continue;
+
+ hent->aux = bfd_zalloc (abfd, sizeof (*hent->aux));
+ if (!hent->aux)
+ continue;
+
+ hent->numaux = 1;
+ hent->aux->x_sym.x_misc.x_fsize
+ = elfsym->internal_elf_sym.st_size;
+ /* FIXME ->x_sym.x_fcnary.x_fcn.x_endndx would better
+ also be set, yet that would likely need to happen
+ elsewhere anyway. */
+
+ continue;
+ }
+
/* See if we are discarding symbols with this name. */
if ((flaginfo.info->strip == strip_some
&& (bfd_hash_lookup (flaginfo.info->keep_hash,