/* Text. */
obj_textsec(abfd)->filepos = pos;
+ if (!obj_textsec(abfd)->user_set_vma)
+ obj_textsec(abfd)->vma = vma;
+ else
+ vma = obj_textsec(abfd)->vma;
+
pos += obj_textsec(abfd)->_raw_size;
vma += obj_textsec(abfd)->_raw_size;
in->desc = bfd_h_get_16 (abfd, ext->e_desc);
in->other = bfd_h_get_8 (abfd, ext->e_other);
in->type = bfd_h_get_8 (abfd, ext->e_type);
- in->symbol.udata = 0;
+ in->symbol.udata.p = NULL;
if (! translate_from_native_sym_flags (abfd, in))
return false;
if (! aout_get_external_symbols (abfd))
return false;
- if (obj_aout_external_sym_count (abfd) == 0)
- {
- bfd_set_error (bfd_error_no_symbols);
- return false;
- }
-
cached_size = (obj_aout_external_sym_count (abfd)
* sizeof (aout_symbol_type));
cached = (aout_symbol_type *) malloc (cached_size);
- if (cached == NULL)
+ if (cached == NULL && cached_size != 0)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
- memset (cached, 0, cached_size);
+ if (cached_size != 0)
+ memset (cached, 0, cached_size);
/* Convert from external symbol information to internal. */
if (! (NAME(aout,translate_symbol_table)
h->written = true;
- if (finfo->info->strip == strip_all
- || (finfo->info->strip == strip_some
- && bfd_hash_lookup (finfo->info->keep_hash, h->root.root.string,
- false, false) == NULL))
+ /* An indx of -2 means the symbol must be written. */
+ if (h->indx != -2
+ && (finfo->info->strip == strip_all
+ || (finfo->info->strip == strip_some
+ && bfd_hash_lookup (finfo->info->keep_hash, h->root.root.string,
+ false, false) == NULL)))
return true;
switch (h->root.type)
if (r_index == -1)
{
- const char *name;
-
- name = strings + GET_WORD (input_bfd,
- syms[r_index].e_strx);
- if (! ((*finfo->info->callbacks->unattached_reloc)
- (finfo->info, name, input_bfd, input_section,
- r_addr)))
- return false;
- r_index = 0;
+ if (h != NULL)
+ {
+ /* We decided to strip this symbol, but it
+ turns out that we can't. Note that we
+ lose the other and desc information here.
+ I don't think that will ever matter for a
+ global symbol. */
+ if (h->indx < 0)
+ {
+ h->indx = -2;
+ h->written = false;
+ if (! aout_link_write_other_symbol (h,
+ (PTR) finfo))
+ return false;
+ }
+ r_index = h->indx;
+ }
+ else
+ {
+ const char *name;
+
+ name = strings + GET_WORD (input_bfd,
+ syms[r_index].e_strx);
+ if (! ((*finfo->info->callbacks->unattached_reloc)
+ (finfo->info, name, input_bfd, input_section,
+ r_addr)))
+ return false;
+ r_index = 0;
+ }
}
relocation = 0;
if (r_index == -1)
{
- const char *name;
-
- name = (strings
- + GET_WORD (input_bfd, syms[r_index].e_strx));
- if (! ((*finfo->info->callbacks->unattached_reloc)
- (finfo->info, name, input_bfd, input_section,
- r_addr)))
- return false;
- r_index = 0;
+ if (h != NULL)
+ {
+ /* We decided to strip this symbol, but it
+ turns out that we can't. Note that we
+ lose the other and desc information here.
+ I don't think that will ever matter for a
+ global symbol. */
+ if (h->indx < 0)
+ {
+ h->indx = -2;
+ h->written = false;
+ if (! aout_link_write_other_symbol (h,
+ (PTR) finfo))
+ return false;
+ }
+ r_index = h->indx;
+ }
+ else
+ {
+ const char *name;
+
+ name = strings + GET_WORD (input_bfd,
+ syms[r_index].e_strx);
+ if (! ((*finfo->info->callbacks->unattached_reloc)
+ (finfo->info, name, input_bfd, input_section,
+ r_addr)))
+ return false;
+ r_index = 0;
+ }
}
relocation = 0;
h = aout_link_hash_lookup (aout_hash_table (finfo->info),
pr->u.name, false, false, true);
if (h != (struct aout_link_hash_entry *) NULL
- && h->indx == -1)
+ && h->indx >= 0)
r_index = h->indx;
+ else if (h != NULL)
+ {
+ /* We decided to strip this symbol, but it turns out that we
+ can't. Note that we lose the other and desc information
+ here. I don't think that will ever matter for a global
+ symbol. */
+ h->indx = -2;
+ h->written = false;
+ if (! aout_link_write_other_symbol (h, (PTR) finfo))
+ return false;
+ r_index = h->indx;
+ }
else
{
if (! ((*finfo->info->callbacks->unattached_reloc)
long
coff_get_symtab (abfd, alocation)
- bfd *abfd;
- asymbol **alocation;
+ bfd *abfd;
+ asymbol **alocation;
{
- unsigned int counter = 0;
- coff_symbol_type *symbase;
- coff_symbol_type **location = (coff_symbol_type **) (alocation);
- if (!bfd_coff_slurp_symbol_table(abfd))
- return -1;
-
- symbase = obj_symbols(abfd);
- while (counter < bfd_get_symcount(abfd))
- {
- /* This nasty code looks at the symbol to decide whether or
- not it is descibes a constructor/destructor entry point. It
- is structured this way to (hopefully) speed non matches */
-#if 0
- if (0 && symbase->symbol.name[9] == '$')
- {
- bfd_constructor_entry(abfd,
- (asymbol **)location,
- symbase->symbol.name[10] == 'I' ?
- "CTOR" : "DTOR");
- }
-#endif
- *(location++) = symbase++;
- counter++;
- }
- *location++ = 0;
- return bfd_get_symcount(abfd);
+ unsigned int counter;
+ coff_symbol_type *symbase;
+ coff_symbol_type **location = (coff_symbol_type **) alocation;
+
+ if (! bfd_coff_slurp_symbol_table (abfd))
+ return -1;
+
+ symbase = obj_symbols (abfd);
+ counter = bfd_get_symcount (abfd);
+ while (counter-- > 0)
+ *location++ = symbase++;
+
+ *location = NULL;
+
+ return bfd_get_symcount (abfd);
}
/* Set lineno_count for the output sections of a COFF file. */
the relocs we can get the index for a symbol. This method is a
hack. FIXME. */
-#define set_index(symbol, idx) ((symbol)->udata = (PTR) (idx))
+#define set_index(symbol, idx) ((symbol)->udata.i = (idx))
/* Write a symbol out to a COFF file. */
}
}
+ obj_raw_syment_count (abfd) = written;
+
/* Now write out strings */
if (string_size != 0)
char *string_table = NULL;
char *debug_section = NULL;
unsigned long size;
-
unsigned int raw_size;
- if (obj_raw_syments(abfd) != (combined_entry_type *)NULL) {
- return obj_raw_syments(abfd);
- }
- size = obj_raw_syment_count (abfd) * sizeof (combined_entry_type);
- if (size == 0)
- {
- bfd_set_error (bfd_error_no_symbols);
- return (NULL);
- }
- internal = (combined_entry_type *)bfd_alloc(abfd, size);
- if (!internal)
+ if (obj_raw_syments (abfd) != NULL)
+ return obj_raw_syments (abfd);
+
+ size = obj_raw_syment_count (abfd) * sizeof (combined_entry_type);
+ internal = (combined_entry_type *) bfd_alloc (abfd, size);
+ if (internal == NULL && size != 0)
{
bfd_set_error (bfd_error_no_memory);
return NULL;
internal_end = internal + obj_raw_syment_count (abfd);
symesz = bfd_coff_symesz (abfd);
- raw_size = obj_raw_syment_count (abfd) * symesz;
- raw = bfd_alloc(abfd,raw_size);
- if (!raw)
+ raw_size = obj_raw_syment_count (abfd) * symesz;
+ raw = bfd_alloc (abfd, raw_size);
+ if (raw == NULL && raw_size != 0)
{
bfd_set_error (bfd_error_no_memory);
return NULL;
}
- if (bfd_seek(abfd, obj_sym_filepos(abfd), SEEK_SET) == -1
- || bfd_read(raw, raw_size, 1, abfd) != raw_size)
- return (NULL);
+ if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) == -1
+ || bfd_read (raw, raw_size, 1, abfd) != raw_size)
+ return NULL;
+
/* mark the end of the symbols */
raw_end = (char *) raw + obj_raw_syment_count (abfd) * symesz;
+
/*
FIXME SOMEDAY. A string table size of zero is very weird, but
probably possible. If one shows up, it will probably kill us.
}
/* Free all the raw stuff */
- bfd_release(abfd, raw);
+ if (raw != NULL)
+ bfd_release (abfd, raw);
for (internal_ptr = internal; internal_ptr < internal_end;
internal_ptr ++)