Ignore:
Timestamp:
Aug 16, 2003, 6:59:22 PM (22 years ago)
Author:
bird
Message:

binutils v2.14 - offical sources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/binutils/bfd/m68klinux.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* BFD back-end for linux flavored m68k a.out binaries.
    2    Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000
     2   Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003
    33   Free Software Foundation, Inc.
    44
     
    2424#define TEXT_START_ADDR 0x0
    2525#define N_SHARED_LIB(x) 0
    26 #define BYTES_IN_WORD 4
    2726
    2827#define MACHTYPE_OK(mtype) ((mtype) == M_68020 || (mtype) == M_UNKNOWN)
     
    3837#define TARGET_IS_BIG_ENDIAN_P
    3938#define DEFAULT_ARCH bfd_arch_m68k
    40 #define MY(OP) CAT(m68klinux_,OP)
     39
     40/* Do not "beautify" the CONCAT* macro args.  Traditional C will not
     41   remove whitespace added here, and thus will fail to concatenate
     42   the tokens.  */
     43#define MY(OP) CONCAT2 (m68klinux_,OP)
    4144#define TARGETNAME "a.out-m68k-linux"
    4245
     
    4952static void MY_final_link_callback
    5053  PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *));
    51 static boolean m68klinux_bfd_final_link
     54static bfd_boolean m68klinux_bfd_final_link
    5255  PARAMS ((bfd *, struct bfd_link_info *));
    53 static boolean m68klinux_write_object_contents PARAMS ((bfd *));
    54 
    55 static boolean
     56static bfd_boolean m68klinux_write_object_contents PARAMS ((bfd *));
     57
     58static bfd_boolean
    5659m68klinux_bfd_final_link (abfd, info)
    5760     bfd *abfd;
     
    6669/* Set the machine type correctly.  */
    6770
    68 static boolean
     71static bfd_boolean
    6972m68klinux_write_object_contents (abfd)
    7073     bfd *abfd;
     
    7982  WRITE_HEADERS(abfd, execp);
    8083
    81   return true;
     84  return TRUE;
    8285}
    8386
     
    178181  PARAMS ((struct bfd_link_info *, struct linux_link_hash_entry *,
    179182           bfd_vma, int));
    180 static boolean linux_link_create_dynamic_sections
     183static bfd_boolean linux_link_create_dynamic_sections
    181184  PARAMS ((bfd *, struct bfd_link_info *));
    182 static boolean linux_add_one_symbol
     185static bfd_boolean linux_add_one_symbol
    183186  PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword, asection *,
    184            bfd_vma, const char *, boolean, boolean,
     187           bfd_vma, const char *, bfd_boolean, bfd_boolean,
    185188           struct bfd_link_hash_entry **));
    186 static boolean linux_tally_symbols
     189static bfd_boolean linux_tally_symbols
    187190  PARAMS ((struct linux_link_hash_entry *, PTR));
    188 static boolean linux_finish_dynamic_link
     191static bfd_boolean linux_finish_dynamic_link
    189192  PARAMS ((bfd *, struct bfd_link_info *));
    190193
     
    226229{
    227230  struct linux_link_hash_table *ret;
    228 
    229   ret = ((struct linux_link_hash_table *)
    230          bfd_alloc (abfd, sizeof (struct linux_link_hash_table)));
     231  bfd_size_type amt = sizeof (struct linux_link_hash_table);
     232
     233  ret = (struct linux_link_hash_table *) bfd_malloc (amt);
    231234  if (ret == (struct linux_link_hash_table *) NULL)
    232235    {
     
    261264  (aout_link_hash_traverse                                              \
    262265   (&(table)->root,                                                     \
    263     (boolean (*) PARAMS ((struct aout_link_hash_entry *, PTR))) (func), \
     266    (bfd_boolean (*) PARAMS ((struct aout_link_hash_entry *, PTR))) (func),     \
    264267    (info)))
    265268
     
    301304   create it for now.  */
    302305
    303 static boolean
     306static bfd_boolean
    304307linux_link_create_dynamic_sections (abfd, info)
    305308     bfd *abfd;
     
    318321      || ! bfd_set_section_flags (abfd, s, flags)
    319322      || ! bfd_set_section_alignment (abfd, s, 2))
    320     return false;
     323    return FALSE;
    321324  s->_raw_size = 0;
    322325  s->contents = 0;
    323326
    324   return true;
     327  return TRUE;
    325328}
    326329
     
    329332   tweaking needed for dynamic linking support.  */
    330333
    331 static boolean
     334static bfd_boolean
    332335linux_add_one_symbol (info, abfd, name, flags, section, value, string,
    333336                      copy, collect, hashp)
     
    339342     bfd_vma value;
    340343     const char *string;
    341      boolean copy;
    342      boolean collect;
     344     bfd_boolean copy;
     345     bfd_boolean collect;
    343346     struct bfd_link_hash_entry **hashp;
    344347{
    345348  struct linux_link_hash_entry *h;
    346   boolean insert;
     349  bfd_boolean insert;
    347350
    348351  /* Look up and see if we already have this symbol in the hash table.
     
    354357     confusion is possible.  */
    355358
    356   insert = false;
     359  insert = FALSE;
    357360
    358361  if (! info->relocateable
     
    363366    {
    364367      if (! linux_link_create_dynamic_sections (abfd, info))
    365         return false;
     368        return FALSE;
    366369      linux_hash_table (info)->dynobj = abfd;
    367       insert = true;
     370      insert = TRUE;
    368371    }
    369372
     
    371374      && abfd->xvec == info->hash->creator)
    372375    {
    373       h = linux_link_hash_lookup (linux_hash_table (info), name, false,
    374                                   false, false);
     376      h = linux_link_hash_lookup (linux_hash_table (info), name, FALSE,
     377                                  FALSE, FALSE);
    375378      if (h != NULL
    376379          && (h->root.root.type == bfd_link_hash_defined
     
    384387          f = new_fixup (info, h, value, ! IS_PLT_SYM (name));
    385388          if (f == NULL)
    386             return false;
     389            return FALSE;
    387390          f->jump = IS_PLT_SYM (name);
    388391
    389           return true;
     392          return TRUE;
    390393        }
    391394    }
     
    395398                                          value, string, copy, collect,
    396399                                          hashp))
    397     return false;
     400    return FALSE;
    398401
    399402  /* Insert a pointer to our table in the set vector.  The dynamic
     
    411414      if (! (_bfd_generic_link_add_one_symbol
    412415             (info, linux_hash_table (info)->dynobj, SHARABLE_CONFLICTS,
    413               BSF_GLOBAL | BSF_CONSTRUCTOR, s, 0, NULL, false, false, NULL)))
    414         return false;
    415     }
    416 
    417   return true;
     416              BSF_GLOBAL | BSF_CONSTRUCTOR, s, (bfd_vma) 0, NULL,
     417              FALSE, FALSE, NULL)))
     418        return FALSE;
     419    }
     420
     421  return TRUE;
    418422}
    419423
     
    428432   This function is called via linux_link_hash_traverse.  */
    429433
    430 static boolean
     434static bfd_boolean
    431435linux_tally_symbols (h, data)
    432436     struct linux_link_hash_entry *h;
     
    437441  int is_plt;
    438442  struct linux_link_hash_entry *h1, *h2;
    439   boolean exists;
     443  bfd_boolean exists;
     444
     445  if (h->root.root.type == bfd_link_hash_warning)
     446    h = (struct linux_link_hash_entry *) h->root.root.u.i.link;
    440447
    441448  if (h->root.root.type == bfd_link_hash_undefined
     
    450457      p = strrchr (name, '_');
    451458      if (p != NULL)
    452         alloc = (char *) bfd_malloc (strlen (name) + 1);
     459        alloc = (char *) bfd_malloc ((bfd_size_type) strlen (name) + 1);
    453460
    454461      if (p == NULL || alloc == NULL)
     
    480487                                   (h->root.root.root.string
    481488                                    + sizeof PLT_REF_PREFIX - 1),
    482                                    false, false, true);
     489                                   FALSE, FALSE, TRUE);
    483490      /* h2 does not follow indirect symbols.  */
    484491      h2 = linux_link_hash_lookup (linux_hash_table (info),
    485492                                   (h->root.root.root.string
    486493                                    + sizeof PLT_REF_PREFIX - 1),
    487                                    false, false, false);
     494                                   FALSE, FALSE, FALSE);
    488495
    489496      /* The real symbol must exist but if it is also an ABS symbol,
     
    503510             fixup.  In the end, this relaxes some of the requirements
    504511             about the order of performing fixups.  */
    505           exists = false;
     512          exists = FALSE;
    506513          for (f1 = linux_hash_table (info)->fixup_list;
    507514               f1 != NULL;
     
    512519                continue;
    513520              if (f1->h == h1)
    514                 exists = true;
     521                exists = TRUE;
    515522              if (! exists
    516523                  && bfd_is_abs_section (h->root.root.u.def.section))
     
    522529              f1->jump = is_plt;
    523530              f1->builtin = 0;
    524               exists = true;
     531              exists = TRUE;
    525532            }
    526533          if (! exists
     
    540547         symtab.  */
    541548      if (bfd_is_abs_section (h->root.root.u.def.section))
    542         h->root.written = true;
    543     }
    544 
    545   return true;
     549        h->root.written = TRUE;
     550    }
     551
     552  return TRUE;
    546553}
    547554
     
    552559   are required.  */
    553560
    554 boolean
     561bfd_boolean
    555562bfd_m68klinux_size_dynamic_sections (output_bfd, info)
    556563     bfd *output_bfd;
     
    561568
    562569  if (output_bfd->xvec != &MY(vec))
    563     return true;
     570    return TRUE;
    564571
    565572  /* First find the fixups...  */
     
    585592      if (linux_hash_table (info)->fixup_count > 0)
    586593        abort ();
    587       return true;
     594      return TRUE;
    588595    }
    589596
     
    593600  if (s != NULL)
    594601    {
    595       s->_raw_size = 8 + linux_hash_table (info)->fixup_count * 8;
    596       s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
     602      s->_raw_size = linux_hash_table (info)->fixup_count + 1;
     603      s->_raw_size *= 8;
     604      s->contents = (bfd_byte *) bfd_zalloc (output_bfd, s->_raw_size);
    597605      if (s->contents == NULL)
    598606        {
    599607          bfd_set_error (bfd_error_no_memory);
    600           return false;
    601         }
    602       memset (s->contents, 0, (size_t) s->_raw_size);
    603     }
    604 
    605   return true;
     608          return FALSE;
     609        }
     610    }
     611
     612  return TRUE;
    606613}
    607614
     
    610617   the stuff we need.  */
    611618
    612 static boolean
     619static bfd_boolean
    613620linux_finish_dynamic_link (output_bfd, info)
    614621     bfd *output_bfd;
     
    624631
    625632  if (linux_hash_table (info)->dynobj == NULL)
    626     return true;
     633    return TRUE;
    627634
    628635  s = bfd_get_section_by_name (linux_hash_table (info)->dynobj,
     
    639646
    640647  fixup_table = s->contents;
    641   bfd_put_32 (output_bfd, linux_hash_table (info)->fixup_count, fixup_table);
     648  bfd_put_32 (output_bfd, (bfd_vma) linux_hash_table (info)->fixup_count,
     649              fixup_table);
    642650  fixup_table += 4;
    643651
     
    668676      if (f->jump)
    669677        {
    670           bfd_put_32 (output_bfd, new_addr, fixup_table);
     678          bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table);
    671679          fixup_table += 4;
    672680          bfd_put_32 (output_bfd, f->value + 2, fixup_table);
     
    675683      else
    676684        {
    677           bfd_put_32 (output_bfd, new_addr, fixup_table);
     685          bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table);
    678686          fixup_table += 4;
    679687          bfd_put_32 (output_bfd, f->value, fixup_table);
     
    686694    {
    687695      /* Special marker so we know to switch to the other type of fixup */
    688       bfd_put_32 (output_bfd, 0, fixup_table);
     696      bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
    689697      fixup_table += 4;
    690       bfd_put_32 (output_bfd, 0, fixup_table);
     698      bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
    691699      fixup_table += 4;
    692700      ++fixups_written;
     
    714722#endif
    715723
    716           bfd_put_32 (output_bfd, new_addr, fixup_table);
     724          bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table);
    717725          fixup_table += 4;
    718726          bfd_put_32 (output_bfd, f->value, fixup_table);
     
    727735      while (linux_hash_table (info)->fixup_count > fixups_written)
    728736        {
    729           bfd_put_32 (output_bfd, 0, fixup_table);
     737          bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
    730738          fixup_table += 4;
    731           bfd_put_32 (output_bfd, 0, fixup_table);
     739          bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
    732740          fixup_table += 4;
    733741          ++fixups_written;
     
    737745  h = linux_link_hash_lookup (linux_hash_table (info),
    738746                              "__BUILTIN_FIXUPS__",
    739                               false, false, false);
     747                              FALSE, FALSE, FALSE);
    740748
    741749  if (h != NULL
     
    751759#endif
    752760
    753       bfd_put_32 (output_bfd, new_addr, fixup_table);
     761      bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table);
    754762    }
    755763  else
    756     bfd_put_32 (output_bfd, 0, fixup_table);
    757 
    758   if (bfd_seek (output_bfd, os->filepos + s->output_offset, SEEK_SET) != 0)
    759     return false;
    760 
    761   if (bfd_write ((PTR) s->contents, 1, s->_raw_size, output_bfd)
    762       != s->_raw_size)
    763     return false;
    764 
    765   return true;
     764    bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
     765
     766  if (bfd_seek (output_bfd, (file_ptr) (os->filepos + s->output_offset),
     767                SEEK_SET) != 0)
     768    return FALSE;
     769
     770  if (bfd_bwrite ((PTR) s->contents, s->_raw_size, output_bfd) != s->_raw_size)
     771    return FALSE;
     772
     773  return TRUE;
    766774}
    767775
Note: See TracChangeset for help on using the changeset viewer.