aboutsummaryrefslogtreecommitdiff
path: root/bfd/cofflink.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1996-10-01 21:57:47 +0000
committerIan Lance Taylor <ian@airs.com>1996-10-01 21:57:47 +0000
commit8dd53b5cc825712c98e99c0ada5f358d71860fcc (patch)
treed7711229dde7f04900dc275ba82e4f9afbf7bcb5 /bfd/cofflink.c
parenta69e5977e21d49054c4112d6919853d9f5152426 (diff)
downloadgdb-8dd53b5cc825712c98e99c0ada5f358d71860fcc.zip
gdb-8dd53b5cc825712c98e99c0ada5f358d71860fcc.tar.gz
gdb-8dd53b5cc825712c98e99c0ada5f358d71860fcc.tar.bz2
* cofflink.c (coff_link_add_symbols): Don't override a meaningful
symbol type with T_NULL. Warn if symbol type changes. Based on patch from Philippe De Muyter <phdm@labauto1.ulb.ac.be>.
Diffstat (limited to 'bfd/cofflink.c')
-rw-r--r--bfd/cofflink.c39
1 files changed, 35 insertions, 4 deletions
diff --git a/bfd/cofflink.c b/bfd/cofflink.c
index e100025..9d62013 100644
--- a/bfd/cofflink.c
+++ b/bfd/cofflink.c
@@ -381,8 +381,16 @@ coff_link_add_symbols (abfd, info)
&& (*sym_hash)->root.type != bfd_link_hash_defined))
{
(*sym_hash)->class = sym.n_sclass;
- (*sym_hash)->type = sym.n_type;
- (*sym_hash)->numaux = sym.n_numaux;
+ if (sym.n_type != T_NULL)
+ {
+ if ((*sym_hash)->type != T_NULL
+ && (*sym_hash)->type != sym.n_type)
+ (*_bfd_error_handler)
+ ("Warning: type of symbol `%s' changed from %d to %d in %s",
+ name, (*sym_hash)->type, sym.n_type,
+ bfd_get_filename (abfd));
+ (*sym_hash)->type = sym.n_type;
+ }
(*sym_hash)->auxbfd = abfd;
if (sym.n_numaux != 0)
{
@@ -391,6 +399,7 @@ coff_link_add_symbols (abfd, info)
bfd_byte *eaux;
union internal_auxent *iaux;
+ (*sym_hash)->numaux = sym.n_numaux;
alloc = ((union internal_auxent *)
bfd_hash_allocate (&info->hash->table,
(sym.n_numaux
@@ -466,6 +475,7 @@ _bfd_coff_final_link (abfd, info)
bfd_size_type symesz;
struct coff_final_link_info finfo;
boolean debug_merge_allocated;
+ boolean long_section_names;
asection *o;
struct bfd_link_order *p;
size_t max_sym_count;
@@ -521,6 +531,7 @@ _bfd_coff_final_link (abfd, info)
max_lineno_count = 0;
max_reloc_count = 0;
+ long_section_names = false;
for (o = abfd->sections; o != NULL; o = o->next)
{
o->reloc_count = 0;
@@ -566,6 +577,20 @@ _bfd_coff_final_link (abfd, info)
o->rel_filepos = rel_filepos;
rel_filepos += o->reloc_count * relsz;
}
+
+ if (bfd_coff_long_section_names (abfd)
+ && strlen (o->name) > SCNNMLEN)
+ {
+ /* This section has a long name which must go in the string
+ table. This must correspond to the code in
+ coff_write_object_contents which puts the string index
+ into the s_name field of the section header. That is why
+ we pass hash as false. */
+ if (_bfd_stringtab_add (finfo.strtab, o->name, false, false)
+ == (bfd_size_type) -1)
+ goto error_return;
+ long_section_names = true;
+ }
}
/* If doing a relocateable link, allocate space for the pointers we
@@ -869,7 +894,7 @@ _bfd_coff_final_link (abfd, info)
}
/* Write out the string table. */
- if (obj_raw_syment_count (abfd) != 0)
+ if (obj_raw_syment_count (abfd) != 0 || long_section_names)
{
if (bfd_seek (abfd,
(obj_sym_filepos (abfd)
@@ -1538,7 +1563,12 @@ _bfd_coff_link_input_bfd (finfo, input_bfd)
if (*indexp < 0)
{
h = *sym_hash;
- BFD_ASSERT (h->numaux == isymp->n_numaux);
+
+ /* The m68k-motorola-sysv assembler will sometimes
+ generate two symbols with the same name, but only one
+ will have aux entries. */
+ BFD_ASSERT (isymp->n_numaux == 0
+ || h->numaux == isymp->n_numaux);
}
esym += isymesz;
@@ -2431,6 +2461,7 @@ _bfd_coff_generic_relocate_section (output_bfd, info, input_bfd,
+ input_section->output_section->vma;
if (coff_data(output_bfd)->pe)
addr -= pe_data(output_bfd)->pe_opthdr.ImageBase;
+ /* FIXME: Shouldn't 4 be sizeof (addr)? */
fwrite (&addr, 1,4, (FILE *) info->base_file);
}
}