OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [bfd/] [srec.c] - Diff between revs 157 and 225

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 157 Rev 225
Line 1... Line 1...
/* BFD back-end for s-record objects.
/* BFD back-end for s-record objects.
   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
   Free Software Foundation, Inc.
   Free Software Foundation, Inc.
   Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>.
   Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>.
 
 
   This file is part of BFD, the Binary File Descriptor library.
   This file is part of BFD, the Binary File Descriptor library.
 
 
Line 196... Line 196...
{
{
  tdata_type *tdata;
  tdata_type *tdata;
 
 
  srec_init ();
  srec_init ();
 
 
  tdata = bfd_alloc (abfd, sizeof (tdata_type));
  tdata = (tdata_type *) bfd_alloc (abfd, sizeof (tdata_type));
  if (tdata == NULL)
  if (tdata == NULL)
    return FALSE;
    return FALSE;
 
 
  abfd->tdata.srec_data = tdata;
  abfd->tdata.srec_data = tdata;
  tdata->type = 1;
  tdata->type = 1;
Line 269... Line 269...
static bfd_boolean
static bfd_boolean
srec_new_symbol (bfd *abfd, const char *name, bfd_vma val)
srec_new_symbol (bfd *abfd, const char *name, bfd_vma val)
{
{
  struct srec_symbol *n;
  struct srec_symbol *n;
 
 
  n = bfd_alloc (abfd, sizeof (* n));
  n = (struct srec_symbol *) bfd_alloc (abfd, sizeof (* n));
  if (n == NULL)
  if (n == NULL)
    return FALSE;
    return FALSE;
 
 
  n->name = name;
  n->name = name;
  n->val = val;
  n->val = val;
Line 361... Line 361...
                  srec_bad_byte (abfd, lineno, c, error);
                  srec_bad_byte (abfd, lineno, c, error);
                  goto error_return;
                  goto error_return;
                }
                }
 
 
              alc = 10;
              alc = 10;
              symbuf = bfd_malloc (alc + 1);
              symbuf = (char *) bfd_malloc (alc + 1);
              if (symbuf == NULL)
              if (symbuf == NULL)
                goto error_return;
                goto error_return;
 
 
              p = symbuf;
              p = symbuf;
 
 
Line 376... Line 376...
                  if ((bfd_size_type) (p - symbuf) >= alc)
                  if ((bfd_size_type) (p - symbuf) >= alc)
                    {
                    {
                      char *n;
                      char *n;
 
 
                      alc *= 2;
                      alc *= 2;
                      n = bfd_realloc (symbuf, alc + 1);
                      n = (char *) bfd_realloc (symbuf, alc + 1);
                      if (n == NULL)
                      if (n == NULL)
                        goto error_return;
                        goto error_return;
                      p = n + (p - symbuf);
                      p = n + (p - symbuf);
                      symbuf = n;
                      symbuf = n;
                    }
                    }
Line 393... Line 393...
                  srec_bad_byte (abfd, lineno, c, error);
                  srec_bad_byte (abfd, lineno, c, error);
                  goto error_return;
                  goto error_return;
                }
                }
 
 
              *p++ = '\0';
              *p++ = '\0';
              symname = bfd_alloc (abfd, (bfd_size_type) (p - symbuf));
              symname = (char *) bfd_alloc (abfd, (bfd_size_type) (p - symbuf));
              if (symname == NULL)
              if (symname == NULL)
                goto error_return;
                goto error_return;
              strcpy (symname, symbuf);
              strcpy (symname, symbuf);
              free (symbuf);
              free (symbuf);
              symbuf = NULL;
              symbuf = NULL;
Line 480... Line 480...
            check_sum = bytes = HEX (hdr + 1);
            check_sum = bytes = HEX (hdr + 1);
            if (bytes * 2 > bufsize)
            if (bytes * 2 > bufsize)
              {
              {
                if (buf != NULL)
                if (buf != NULL)
                  free (buf);
                  free (buf);
                buf = bfd_malloc ((bfd_size_type) bytes * 2);
                buf = (bfd_byte *) bfd_malloc ((bfd_size_type) bytes * 2);
                if (buf == NULL)
                if (buf == NULL)
                  goto error_return;
                  goto error_return;
                bufsize = bytes * 2;
                bufsize = bytes * 2;
              }
              }
 
 
Line 540... Line 540...
                    bfd_size_type amt;
                    bfd_size_type amt;
                    flagword flags;
                    flagword flags;
 
 
                    sprintf (secbuf, ".sec%d", bfd_count_sections (abfd) + 1);
                    sprintf (secbuf, ".sec%d", bfd_count_sections (abfd) + 1);
                    amt = strlen (secbuf) + 1;
                    amt = strlen (secbuf) + 1;
                    secname = bfd_alloc (abfd, amt);
                    secname = (char *) bfd_alloc (abfd, amt);
                    strcpy (secname, secbuf);
                    strcpy (secname, secbuf);
                    flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
                    flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
                    sec = bfd_make_section_with_flags (abfd, secname, flags);
                    sec = bfd_make_section_with_flags (abfd, secname, flags);
                    if (sec == NULL)
                    if (sec == NULL)
                      goto error_return;
                      goto error_return;
Line 736... Line 736...
 
 
      if (bytes * 2 > bufsize)
      if (bytes * 2 > bufsize)
        {
        {
          if (buf != NULL)
          if (buf != NULL)
            free (buf);
            free (buf);
          buf = bfd_malloc ((bfd_size_type) bytes * 2);
          buf = (bfd_byte *) bfd_malloc ((bfd_size_type) bytes * 2);
          if (buf == NULL)
          if (buf == NULL)
            goto error_return;
            goto error_return;
          bufsize = bytes * 2;
          bufsize = bytes * 2;
        }
        }
 
 
Line 836... Line 836...
    {
    {
      section->used_by_bfd = bfd_alloc (abfd, section->size);
      section->used_by_bfd = bfd_alloc (abfd, section->size);
      if (section->used_by_bfd == NULL)
      if (section->used_by_bfd == NULL)
        return FALSE;
        return FALSE;
 
 
      if (! srec_read_section (abfd, section, section->used_by_bfd))
      if (! srec_read_section (abfd, section,
 
                               (bfd_byte *) section->used_by_bfd))
        return FALSE;
        return FALSE;
    }
    }
 
 
  memcpy (location, (bfd_byte *) section->used_by_bfd + offset,
  memcpy (location, (bfd_byte *) section->used_by_bfd + offset,
          (size_t) count);
          (size_t) count);
Line 870... Line 871...
                           bfd_size_type bytes_to_do)
                           bfd_size_type bytes_to_do)
{
{
  tdata_type *tdata = abfd->tdata.srec_data;
  tdata_type *tdata = abfd->tdata.srec_data;
  srec_data_list_type *entry;
  srec_data_list_type *entry;
 
 
  entry = bfd_alloc (abfd, sizeof (* entry));
  entry = (srec_data_list_type *) bfd_alloc (abfd, sizeof (* entry));
  if (entry == NULL)
  if (entry == NULL)
    return FALSE;
    return FALSE;
 
 
  if (bytes_to_do
  if (bytes_to_do
      && (section->flags & SEC_ALLOC)
      && (section->flags & SEC_ALLOC)
      && (section->flags & SEC_LOAD))
      && (section->flags & SEC_LOAD))
    {
    {
      bfd_byte *data;
      bfd_byte *data;
 
 
      data = bfd_alloc (abfd, bytes_to_do);
      data = (bfd_byte *) bfd_alloc (abfd, bytes_to_do);
      if (data == NULL)
      if (data == NULL)
        return FALSE;
        return FALSE;
      memcpy ((void *) data, location, (size_t) bytes_to_do);
      memcpy ((void *) data, location, (size_t) bytes_to_do);
 
 
      /* Ff S3Forced is TRUE then always select S3 records,
      /* Ff S3Forced is TRUE then always select S3 records,
Line 1179... Line 1180...
  if (csymbols == NULL && symcount != 0)
  if (csymbols == NULL && symcount != 0)
    {
    {
      asymbol *c;
      asymbol *c;
      struct srec_symbol *s;
      struct srec_symbol *s;
 
 
      csymbols = bfd_alloc (abfd, symcount * sizeof (asymbol));
      csymbols = (asymbol *) bfd_alloc (abfd, symcount * sizeof (asymbol));
      if (csymbols == NULL)
      if (csymbols == NULL)
        return -1;
        return -1;
      abfd->tdata.srec_data->csymbols = csymbols;
      abfd->tdata.srec_data->csymbols = csymbols;
 
 
      for (s = abfd->tdata.srec_data->symbols, c = csymbols;
      for (s = abfd->tdata.srec_data->symbols, c = csymbols;
Line 1253... Line 1254...
#define srec_bfd_gc_sections                      bfd_generic_gc_sections
#define srec_bfd_gc_sections                      bfd_generic_gc_sections
#define srec_bfd_merge_sections                   bfd_generic_merge_sections
#define srec_bfd_merge_sections                   bfd_generic_merge_sections
#define srec_bfd_is_group_section                 bfd_generic_is_group_section
#define srec_bfd_is_group_section                 bfd_generic_is_group_section
#define srec_bfd_discard_group                    bfd_generic_discard_group
#define srec_bfd_discard_group                    bfd_generic_discard_group
#define srec_section_already_linked               _bfd_generic_section_already_linked
#define srec_section_already_linked               _bfd_generic_section_already_linked
 
#define srec_bfd_define_common_symbol             bfd_generic_define_common_symbol
#define srec_bfd_link_hash_table_create           _bfd_generic_link_hash_table_create
#define srec_bfd_link_hash_table_create           _bfd_generic_link_hash_table_create
#define srec_bfd_link_hash_table_free             _bfd_generic_link_hash_table_free
#define srec_bfd_link_hash_table_free             _bfd_generic_link_hash_table_free
#define srec_bfd_link_add_symbols                 _bfd_generic_link_add_symbols
#define srec_bfd_link_add_symbols                 _bfd_generic_link_add_symbols
#define srec_bfd_link_just_syms                   _bfd_generic_link_just_syms
#define srec_bfd_link_just_syms                   _bfd_generic_link_just_syms
#define srec_bfd_final_link                       _bfd_generic_final_link
#define srec_bfd_final_link                       _bfd_generic_final_link

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.