if (isym.n_sclass == C_STAT
&& isym.n_type == T_NULL
- && isym.n_numaux == 1
- && isym._n._n_n._n_zeroes != 0)
+ && isym.n_numaux == 1)
{
char buf[SYMNMLEN + 1];
+ const char *symname;
- memcpy (buf, isym._n._n_name, SYMNMLEN);
- buf[SYMNMLEN] = '\0';
+ symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
+ if (symname == NULL)
+ abort ();
- if (strcmp (name, buf) == 0)
+ if (strcmp (name, symname) == 0)
{
union internal_auxent aux;
section->alignment_power = 2;
}
#endif
+
+#ifdef COFF_IMAGE_WITH_PE
+ /* In a PE image file, the s_paddr field holds the virtual size of a
+ section, while the s_size field holds the raw size. */
+ if (hdr->s_paddr != 0)
+ {
+ if (coff_section_data (abfd, section) == NULL)
+ {
+ section->used_by_bfd =
+ (PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata));
+ if (section->used_by_bfd == NULL)
+ {
+ /* FIXME: Return error. */
+ abort ();
+ }
+ }
+ if (pei_section_data (abfd, section) == NULL)
+ {
+ coff_section_data (abfd, section)->tdata =
+ (PTR) bfd_zalloc (abfd, sizeof (struct pei_section_tdata));
+ if (coff_section_data (abfd, section)->tdata == NULL)
+ {
+ /* FIXME: Return error. */
+ abort ();
+ }
+ }
+ pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
+ }
+#endif
+
}
#undef ALIGN_SET
#undef ELIFALIGN_SET
break;
#endif
+#ifdef H8300SMAGIC
+ case H8300SMAGIC:
+ arch = bfd_arch_h8300;
+ machine = bfd_mach_h8300s;
+ /* !! FIXME this probably isn't the right place for this */
+ abfd->flags |= BFD_IS_RELAXABLE;
+ break;
+#endif
+
#ifdef SH_ARCH_MAGIC_BIG
case SH_ARCH_MAGIC_BIG:
case SH_ARCH_MAGIC_LITTLE:
break;
#endif
+#ifdef TIC80_ARCH_MAGIC
+ case TIC80_ARCH_MAGIC:
+ arch = bfd_arch_tic80;
+ break;
+#endif
+
default: /* Unreadable input file type */
arch = bfd_arch_obscure;
break;
case bfd_arch_m68k:
#ifdef APOLLOM68KMAGIC
*magicp = APOLLO_COFF_VERSION_NUMBER;
+#else
+ /* NAMES_HAVE_UNDERSCORE may be defined by coff-u68k.c. */
+#ifdef NAMES_HAVE_UNDERSCORE
+ *magicp = MC68KBCSMAGIC;
#else
*magicp = MC68MAGIC;
#endif
+#endif
#ifdef LYNXOS
/* Just overwrite the usual value if we're doing Lynx. */
*magicp = LYNXCOFFMAGIC;
case bfd_mach_h8300h:
*magicp = H8300HMAGIC;
return true;
+ case bfd_mach_h8300s:
+ *magicp = H8300SMAGIC;
+ return true;
}
break;
#endif
current->filepos = sofar;
#ifdef COFF_IMAGE_WITH_PE
- /* With PE we have to pad each section to be a multiple of its page size
- too, and remember both sizes. Cooked_size becomes very useful. */
- current->_cooked_size = current->_raw_size;
+ /* With PE we have to pad each section to be a multiple of its
+ page size too, and remember both sizes. */
+
+ if (coff_section_data (abfd, current) == NULL)
+ {
+ current->used_by_bfd =
+ (PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata));
+ if (current->used_by_bfd == NULL)
+ {
+ /* FIXME: Return error. */
+ abort ();
+ }
+ }
+ if (pei_section_data (abfd, current) == NULL)
+ {
+ coff_section_data (abfd, current)->tdata =
+ (PTR) bfd_zalloc (abfd, sizeof (struct pei_section_tdata));
+ if (coff_section_data (abfd, current)->tdata == NULL)
+ {
+ /* FIXME: Return error. */
+ abort ();
+ }
+ }
+ if (pei_section_data (abfd, current)->virt_size == 0)
+ pei_section_data (abfd, current)->virt_size = current->_raw_size;
+
current->_raw_size = (current->_raw_size + page_size -1) & -page_size;
#endif
#ifndef I960
/* make sure that this section is of the right size too */
if ((abfd->flags & EXEC_P) == 0)
- current->_raw_size = BFD_ALIGN (current->_raw_size,
- 1 << current->alignment_power);
+ {
+ bfd_size_type old_size;
+
+ old_size = current->_raw_size;
+ current->_raw_size = BFD_ALIGN (current->_raw_size,
+ 1 << current->alignment_power);
+ sofar += current->_raw_size - old_size;
+ }
else
{
old_sofar = sofar;
file_ptr sym_base;
unsigned long reloc_size = 0;
unsigned long lnno_size = 0;
+ boolean long_section_names;
asection *text_sec = NULL;
asection *data_sec = NULL;
asection *bss_sec = NULL;
if (bfd_seek (abfd, scn_base, SEEK_SET) != 0)
return false;
+ long_section_names = false;
for (current = abfd->sections;
current != NULL;
current = current->next)
if (len > SCNNMLEN)
{
memset (section.s_name, 0, SCNNMLEN);
- sprintf (section.s_name, "/%d", string_size);
+ sprintf (section.s_name, "/%lu", (unsigned long) string_size);
string_size += len + 1;
+ long_section_names = true;
}
}
#endif
section.s_size = current->_raw_size;
#ifdef COFF_WITH_PE
- section.s_paddr = current->_cooked_size;
+ section.s_paddr = 0;
+#endif
+#ifdef COFF_IMAGE_WITH_PE
+ /* Reminder: s_paddr holds the virtual size of the section. */
+ if (coff_section_data (abfd, current) != NULL
+ && pei_section_data (abfd, current) != NULL)
+ section.s_paddr = pei_section_data (abfd, current)->virt_size;
+ else
+ section.s_paddr = 0;
#endif
/*
internal_a.magic = NMAGIC; /* Assume separate i/d */
#define __A_MAGIC_SET__
#endif /* A29K */
+#ifdef TIC80
+ internal_a.magic = TIC80MAGIC;
+#define __A_MAGIC_SET__
+#endif /* TIC80 */
#ifdef I860
/* FIXME: What are the a.out magic numbers for the i860? */
internal_a.magic = 0;
}
else
{
- internal_f.f_symptr = 0;
+ if (long_section_names)
+ internal_f.f_symptr = sym_base;
+ else
+ internal_f.f_symptr = 0;
internal_f.f_flags |= F_LSYMS;
}
if (abfd->output_has_begun == false) /* set by bfd.c handler */
coff_compute_section_file_positions (abfd);
-#ifdef _LIB
+#if defined(_LIB) && !defined(TARG_AUX)
/* The physical address field of a .lib section is used to hold the
number of shared libraries in the section. This code counts the
if (cache_ptr->line_number == 0)
{
- coff_symbol_type *sym =
- (coff_symbol_type *) (dst.l_addr.l_symndx
- + obj_raw_syments (abfd))->u.syment._n._n_n._n_zeroes;
+ boolean warned;
+ long symndx;
+ coff_symbol_type *sym;
+
+ warned = false;
+ symndx = dst.l_addr.l_symndx;
+ if (symndx < 0 || symndx >= obj_raw_syment_count (abfd))
+ {
+ (*_bfd_error_handler)
+ ("%s: warning: illegal symbol index %ld in line numbers",
+ bfd_get_filename (abfd), dst.l_addr.l_symndx);
+ symndx = 0;
+ warned = true;
+ }
+ /* FIXME: We should not be casting between ints and
+ pointers like this. */
+ sym = ((coff_symbol_type *)
+ ((symndx + obj_raw_syments (abfd))
+ ->u.syment._n._n_n._n_zeroes));
cache_ptr->u.sym = (asymbol *) sym;
- if (sym->lineno != NULL)
+ if (sym->lineno != NULL && ! warned)
{
(*_bfd_error_handler)
("%s: warning: duplicate line number information for `%s'",
if (dst.r_symndx != -1)
{
- /* @@ Should never be greater than count of symbols! */
- if (dst.r_symndx >= obj_conv_table_size (abfd))
- abort ();
- cache_ptr->sym_ptr_ptr = symbols + obj_convert (abfd)[dst.r_symndx];
- ptr = *(cache_ptr->sym_ptr_ptr);
+ if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd))
+ {
+ (*_bfd_error_handler)
+ ("%s: warning: illegal symbol index %ld in relocs",
+ bfd_get_filename (abfd), dst.r_symndx);
+ cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+ ptr = 0;
+ }
+ else
+ {
+ cache_ptr->sym_ptr_ptr = (symbols
+ + obj_convert (abfd)[dst.r_symndx]);
+ ptr = *(cache_ptr->sym_ptr_ptr);
+ }
}
else
{
RTYPE2HOWTO (cache_ptr, &dst);
#endif
+ if (cache_ptr->howto == NULL)
+ {
+ (*_bfd_error_handler)
+ ("%s: illegal relocation type %d at address 0x%lx",
+ bfd_get_filename (abfd), dst.r_type, (long) dst.r_vaddr);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
}
asect->relocation = reloc_cache;