Back to index

cell-binutils  2.17cvs20070401
Defines | Functions | Variables
i386msdos.c File Reference
#include "bfd.h"
#include "sysdep.h"
#include "libbfd.h"
#include "libaout.h"

Go to the source code of this file.

Defines

#define EXE_MAGIC   0x5a4d
#define EXE_LOAD_HIGH   0x0000
#define EXE_LOAD_LOW   0xffff
#define EXE_PAGE_SIZE   512
#define msdos_mkobject   aout_32_mkobject
#define msdos_make_empty_symbol   aout_32_make_empty_symbol
#define msdos_bfd_reloc_type_lookup   aout_32_reloc_type_lookup
#define msdos_bfd_reloc_name_lookup   aout_32_reloc_name_lookup
#define msdos_close_and_cleanup   _bfd_generic_close_and_cleanup
#define msdos_bfd_free_cached_info   _bfd_generic_bfd_free_cached_info
#define msdos_new_section_hook   _bfd_generic_new_section_hook
#define msdos_get_section_contents   _bfd_generic_get_section_contents
#define msdos_get_section_contents_in_window   _bfd_generic_get_section_contents_in_window
#define msdos_bfd_get_relocated_section_contents   bfd_generic_get_relocated_section_contents
#define msdos_bfd_relax_section   bfd_generic_relax_section
#define msdos_bfd_gc_sections   bfd_generic_gc_sections
#define msdos_bfd_merge_sections   bfd_generic_merge_sections
#define msdos_bfd_is_group_section   bfd_generic_is_group_section
#define msdos_bfd_discard_group   bfd_generic_discard_group
#define msdos_section_already_linked   _bfd_generic_section_already_linked
#define msdos_bfd_link_hash_table_create   _bfd_generic_link_hash_table_create
#define msdos_bfd_link_hash_table_free   _bfd_generic_link_hash_table_free
#define msdos_bfd_link_add_symbols   _bfd_generic_link_add_symbols
#define msdos_bfd_link_just_syms   _bfd_generic_link_just_syms
#define msdos_bfd_final_link   _bfd_generic_final_link
#define msdos_bfd_link_split_section   _bfd_generic_link_split_section
#define msdos_set_arch_mach   _bfd_generic_set_arch_mach
#define msdos_get_symtab_upper_bound   _bfd_nosymbols_get_symtab_upper_bound
#define msdos_canonicalize_symtab   _bfd_nosymbols_canonicalize_symtab
#define msdos_print_symbol   _bfd_nosymbols_print_symbol
#define msdos_get_symbol_info   _bfd_nosymbols_get_symbol_info
#define msdos_find_nearest_line   _bfd_nosymbols_find_nearest_line
#define msdos_find_inliner_info   _bfd_nosymbols_find_inliner_info
#define msdos_get_lineno   _bfd_nosymbols_get_lineno
#define msdos_bfd_is_target_special_symbol   ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
#define msdos_bfd_is_local_label_name   _bfd_nosymbols_bfd_is_local_label_name
#define msdos_bfd_make_debug_symbol   _bfd_nosymbols_bfd_make_debug_symbol
#define msdos_read_minisymbols   _bfd_nosymbols_read_minisymbols
#define msdos_minisymbol_to_symbol   _bfd_nosymbols_minisymbol_to_symbol
#define msdos_canonicalize_reloc   _bfd_norelocs_canonicalize_reloc
#define msdos_get_reloc_upper_bound   _bfd_norelocs_get_reloc_upper_bound
#define msdos_32_bfd_link_split_section   _bfd_generic_link_split_section

Functions

static int msdos_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *info ATTRIBUTE_UNUSED)
static bfd_boolean msdos_write_object_contents (bfd *abfd)
static bfd_boolean msdos_set_section_contents (bfd *abfd, sec_ptr section, const void *location, file_ptr offset, bfd_size_type count)

Variables

const bfd_target i386msdos_vec

Define Documentation

#define EXE_LOAD_HIGH   0x0000

Definition at line 32 of file i386msdos.c.

#define EXE_LOAD_LOW   0xffff

Definition at line 33 of file i386msdos.c.

#define EXE_MAGIC   0x5a4d

Definition at line 31 of file i386msdos.c.

#define EXE_PAGE_SIZE   512

Definition at line 34 of file i386msdos.c.

Definition at line 173 of file i386msdos.c.

Definition at line 147 of file i386msdos.c.

Definition at line 154 of file i386msdos.c.

Definition at line 136 of file i386msdos.c.

Definition at line 144 of file i386msdos.c.

Definition at line 141 of file i386msdos.c.

Definition at line 146 of file i386msdos.c.

Definition at line 166 of file i386msdos.c.

Definition at line 165 of file i386msdos.c.

Definition at line 152 of file i386msdos.c.

Definition at line 150 of file i386msdos.c.

Definition at line 151 of file i386msdos.c.

Definition at line 153 of file i386msdos.c.

Definition at line 155 of file i386msdos.c.

Definition at line 167 of file i386msdos.c.

Definition at line 145 of file i386msdos.c.

Definition at line 143 of file i386msdos.c.

#define msdos_bfd_reloc_name_lookup   aout_32_reloc_name_lookup

Definition at line 133 of file i386msdos.c.

#define msdos_bfd_reloc_type_lookup   aout_32_reloc_type_lookup

Definition at line 132 of file i386msdos.c.

Definition at line 171 of file i386msdos.c.

Definition at line 159 of file i386msdos.c.

Definition at line 135 of file i386msdos.c.

Definition at line 163 of file i386msdos.c.

Definition at line 162 of file i386msdos.c.

Definition at line 164 of file i386msdos.c.

Definition at line 172 of file i386msdos.c.

Definition at line 138 of file i386msdos.c.

Definition at line 139 of file i386msdos.c.

Definition at line 161 of file i386msdos.c.

Definition at line 158 of file i386msdos.c.

#define msdos_make_empty_symbol   aout_32_make_empty_symbol

Definition at line 131 of file i386msdos.c.

Definition at line 169 of file i386msdos.c.

#define msdos_mkobject   aout_32_mkobject

Definition at line 130 of file i386msdos.c.

Definition at line 137 of file i386msdos.c.

Definition at line 160 of file i386msdos.c.

Definition at line 168 of file i386msdos.c.

Definition at line 148 of file i386msdos.c.

Definition at line 156 of file i386msdos.c.


Function Documentation

static bfd_boolean msdos_set_section_contents ( bfd abfd,
sec_ptr  section,
const void *  location,
file_ptr  offset,
bfd_size_type  count 
) [static]

Definition at line 106 of file i386msdos.c.

{

  if (count == 0)
    return TRUE;

  section->filepos = EXE_PAGE_SIZE + bfd_get_section_vma (abfd, section);

  if (bfd_get_section_flags (abfd, section) & SEC_LOAD)
    {
      if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0
          || bfd_bwrite (location, count, abfd) != count)
        return FALSE;
    }

  return TRUE;
}

Here is the call graph for this function:

static int msdos_sizeof_headers ( bfd *abfd  ATTRIBUTE_UNUSED,
struct bfd_link_info *info  ATTRIBUTE_UNUSED 
) [static]

Definition at line 37 of file i386msdos.c.

{
  return 0;
}
static bfd_boolean msdos_write_object_contents ( bfd abfd) [static]

Definition at line 44 of file i386msdos.c.

{
  static char hdr[EXE_PAGE_SIZE];
  file_ptr outfile_size = sizeof(hdr);
  bfd_vma high_vma = 0;
  asection *sec;

  /* Find the total size of the program on disk and in memory.  */
  for (sec = abfd->sections; sec != (asection *) NULL; sec = sec->next)
    {
      if (sec->size == 0)
        continue;
      if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
        {
         bfd_vma sec_vma = bfd_get_section_vma (abfd, sec) + sec->size;
         if (sec_vma > high_vma)
           high_vma = sec_vma;
       }
      if (bfd_get_section_flags (abfd, sec) & SEC_LOAD)
        {
         file_ptr sec_end = (sizeof (hdr)
                           + bfd_get_section_vma (abfd, sec)
                           + sec->size);
         if (sec_end > outfile_size)
           outfile_size = sec_end;
       }
    }

  /* Make sure the program isn't too big.  */
  if (high_vma > (bfd_vma)0xffff)
    {
      bfd_set_error(bfd_error_file_too_big);
      return FALSE;
    }

  /* Constants.  */
  H_PUT_16 (abfd, EXE_MAGIC, &hdr[0]);
  H_PUT_16 (abfd, EXE_PAGE_SIZE / 16, &hdr[8]);
  H_PUT_16 (abfd, EXE_LOAD_LOW, &hdr[12]);
  H_PUT_16 (abfd, 0x3e, &hdr[24]);
  H_PUT_16 (abfd, 0x0001, &hdr[28]); /* XXX??? */
  H_PUT_16 (abfd, 0x30fb, &hdr[30]); /* XXX??? */
  H_PUT_16 (abfd, 0x726a, &hdr[32]); /* XXX??? */

  /* Bytes in last page (0 = full page).  */
  H_PUT_16 (abfd, outfile_size & (EXE_PAGE_SIZE - 1), &hdr[2]);

  /* Number of pages.  */
  H_PUT_16 (abfd, (outfile_size + EXE_PAGE_SIZE - 1) / EXE_PAGE_SIZE, &hdr[4]);

  /* Set the initial stack pointer to the end of the bss.
     The program's crt0 code must relocate it to a real stack.  */
  H_PUT_16 (abfd, high_vma, &hdr[16]);

  if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
      || bfd_bwrite (hdr, (bfd_size_type) sizeof(hdr), abfd) != sizeof(hdr))
    return FALSE;

  return TRUE;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 175 of file i386msdos.c.