return true;
}
-/* Get the name of a symbol. The caller must pass in a buffer of size
- >= SYMNMLEN + 1. */
-
-INLINE const char *
-_bfd_coff_internal_syment_name (abfd, sym, buf)
- bfd *abfd;
- const struct internal_syment *sym;
- char *buf;
-{
- /* FIXME: It's not clear this will work correctly if sizeof
- (_n_zeroes) != 4. */
- if (sym->_n._n_n._n_zeroes != 0
- || sym->_n._n_n._n_offset == 0)
- {
- memcpy (buf, sym->_n._n_name, SYMNMLEN);
- buf[SYMNMLEN] = '\0';
- return buf;
- }
- else
- {
- const char *strings;
-
- BFD_ASSERT (sym->_n._n_n._n_offset >= STRING_SIZE_SIZE);
- strings = obj_coff_strings (abfd);
- if (strings == NULL)
- {
- strings = _bfd_coff_read_string_table (abfd);
- if (strings == NULL)
- return NULL;
- }
- return strings + sym->_n._n_n._n_offset;
- }
-}
-
/* Look through the symbols to see if this object file should be
included in the link. */
return false;
}
-/* Read in and swap the relocs. This returns a buffer holding the
- relocs for section SEC in file ABFD. If CACHE is true and
- INTERNAL_RELOCS is NULL, the relocs read in wil be saved in case
- the function is called again. If EXTERNAL_RELOCS is not NULL, it
- is a buffer large enough to hold the unswapped relocs. If
- INTERNAL_RELOCS is not NULL, it is a buffer large enough to hold
- the swapped relocs. If REQUIRE_INTERNAL is true, then the return
- value must be INTERNAL_RELOCS. The function returns NULL on error. */
-
-struct internal_reloc *
-_bfd_coff_read_internal_relocs (abfd, sec, cache, external_relocs,
- require_internal, internal_relocs)
- bfd *abfd;
- asection *sec;
- boolean cache;
- bfd_byte *external_relocs;
- boolean require_internal;
- struct internal_reloc *internal_relocs;
-{
- bfd_size_type relsz;
- bfd_byte *free_external = NULL;
- struct internal_reloc *free_internal = NULL;
- bfd_byte *erel;
- bfd_byte *erel_end;
- struct internal_reloc *irel;
-
- if (coff_section_data (abfd, sec) != NULL
- && coff_section_data (abfd, sec)->relocs != NULL)
- {
- if (! require_internal)
- return coff_section_data (abfd, sec)->relocs;
- memcpy (internal_relocs, coff_section_data (abfd, sec)->relocs,
- sec->reloc_count * sizeof (struct internal_reloc));
- return internal_relocs;
- }
-
- relsz = bfd_coff_relsz (abfd);
-
- if (external_relocs == NULL)
- {
- free_external = (bfd_byte *) malloc (sec->reloc_count * relsz);
- if (free_external == NULL && sec->reloc_count > 0)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
- external_relocs = free_external;
- }
-
- if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 0
- || (bfd_read (external_relocs, relsz, sec->reloc_count, abfd)
- != relsz * sec->reloc_count))
- goto error_return;
-
- if (internal_relocs == NULL)
- {
- free_internal = ((struct internal_reloc *)
- malloc (sec->reloc_count
- * sizeof (struct internal_reloc)));
- if (free_internal == NULL && sec->reloc_count > 0)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
- internal_relocs = free_internal;
- }
-
- /* Swap in the relocs. */
- erel = external_relocs;
- erel_end = erel + relsz * sec->reloc_count;
- irel = internal_relocs;
- for (; erel < erel_end; erel += relsz, irel++)
- bfd_coff_swap_reloc_in (abfd, (PTR) erel, (PTR) irel);
-
- if (free_external != NULL)
- {
- free (free_external);
- free_external = NULL;
- }
-
- if (cache && free_internal != NULL)
- {
- if (coff_section_data (abfd, sec) == NULL)
- {
- sec->used_by_bfd = ((PTR) bfd_zalloc (abfd,
- sizeof (struct coff_section_tdata)));
- if (sec->used_by_bfd == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
- coff_section_data (abfd, sec)->contents = NULL;
- }
- coff_section_data (abfd, sec)->relocs = free_internal;
- }
-
- return internal_relocs;
-
- error_return:
- if (free_external != NULL)
- free (free_external);
- if (free_internal != NULL)
- free (free_internal);
- return NULL;
-}
-
/* parse out a -heap <reserved>,<commit> line */
static char *
if (info->base_file)
{
- /* So if this is non pcrelative, and is referenced
- to a section or a common symbol, then it needs a reloc */
- if (!howto->pc_relative
- && sym && (sym->n_scnum || sym->n_value))
+ /* Emit a reloc if the backend thinks it needs it. */
+ if (sym && pe_data(output_bfd)->in_reloc_p(output_bfd, howto))
{
/* relocation to a symbol in a section which
isn't absolute - we output the address here
to a file */
bfd_vma addr = rel->r_vaddr
+ - input_section->vma
+ input_section->output_offset
+ input_section->output_section->vma;
if (coff_data(output_bfd)->pe)
}
}
}
-
return true;
}
+
#define coff_mkobject pe_mkobject
#define coff_mkobject_hook pe_mkobject_hook
-
#ifndef GET_FCN_LNNOPTR
-#define GET_FCN_LNNOPTR(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
+#define GET_FCN_LNNOPTR(abfd, ext) \
+ bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
#endif
#ifndef GET_FCN_ENDNDX
-#define GET_FCN_ENDNDX(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
+#define GET_FCN_ENDNDX(abfd, ext) \
+ bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
#endif
#ifndef PUT_FCN_LNNOPTR
filehdr_dst->f_magic = bfd_h_get_16(abfd, (bfd_byte *) filehdr_src->f_magic);
filehdr_dst->f_nscns = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_nscns);
filehdr_dst->f_timdat = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_timdat);
- filehdr_dst->f_symptr =
- bfd_h_get_32 (abfd, (bfd_byte *) filehdr_src->f_symptr);
+
filehdr_dst->f_nsyms = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_nsyms);
- filehdr_dst->f_opthdr = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_opthdr);
filehdr_dst->f_flags = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_flags);
+ filehdr_dst->f_symptr = bfd_h_get_32 (abfd, (bfd_byte *) filehdr_src->f_symptr);
+
+ /* Other people's tools sometimes generate headers
+ with an nsyms but a zero symptr. */
+ if (filehdr_dst->f_nsyms && filehdr_dst->f_symptr)
+ {
+ filehdr_dst->f_flags |= HAS_SYMS;
+ }
+ else
+ {
+ filehdr_dst->f_symptr = 0;
+ filehdr_dst->f_nsyms = 0;
+ filehdr_dst->f_flags &= ~HAS_SYMS;
+ }
+
+ filehdr_dst->f_opthdr = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_opthdr);
}
#ifdef COFF_IMAGE_WITH_PE
if (sec != NULL)
{
aout->DataDirectory[idx].VirtualAddress = sec->lma - base;
- aout->DataDirectory[idx].Size = sec->_raw_size;
+ aout->DataDirectory[idx].Size = sec->_cooked_size;
sec->flags |= SEC_DATA;
}
}
extra->SizeOfHeaders = abfd->sections->filepos;
bfd_h_put_16(abfd, aouthdr_in->magic, (bfd_byte *) aouthdr_out->standard.magic);
- bfd_h_put_16(abfd, aouthdr_in->vstamp, (bfd_byte *) aouthdr_out->standard.vstamp);
+ bfd_h_put_16(abfd, 2 + 55 * 256, (bfd_byte *) aouthdr_out->standard.vstamp);
PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, (bfd_byte *) aouthdr_out->standard.tsize);
PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, (bfd_byte *) aouthdr_out->standard.dsize);
PUT_AOUTHDR_BSIZE (abfd, aouthdr_in->bsize, (bfd_byte *) aouthdr_out->standard.bsize);
PUT_AOUTHDR_ENTRY (abfd, aouthdr_in->entry, (bfd_byte *) aouthdr_out->standard.entry);
PUT_AOUTHDR_TEXT_START (abfd, aouthdr_in->text_start,
(bfd_byte *) aouthdr_out->standard.text_start);
+
PUT_AOUTHDR_DATA_START (abfd, aouthdr_in->data_start,
(bfd_byte *) aouthdr_out->standard.data_start);
bfd * abfd;
{
pe_data_type *pe;
-
abfd->tdata.pe_obj_data =
(struct pe_tdata *) bfd_zalloc (abfd, sizeof (pe_data_type));
+
if (abfd->tdata.pe_obj_data == 0)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
- pe =pe_data (abfd);
+
+ pe = pe_data (abfd);
+
pe->coff.pe = 1;
+ pe->in_reloc_p = in_reloc_p;
return true;
}
return NULL;
pe = pe_data (abfd);
-
pe->coff.sym_filepos = internal_f->f_symptr;
-
/* These members communicate important constants about the symbol
table to GDB's symbol-reading code. These `constants'
unfortunately vary among coff implementations... */
obj_conv_table_size (abfd) =
internal_f->f_nsyms;
+
#ifdef COFF_IMAGE_WITH_PE
- pe->pe_opthdr = ((struct internal_aouthdr *)aouthdr)->pe;
+ if (aouthdr)
+ {
+ pe->pe_opthdr = ((struct internal_aouthdr *)aouthdr)->pe;
+ }
#endif
return (PTR) pe;
return true;
}
-
-