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/sparclinux.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* BFD back-end for linux flavored sparc a.out binaries.
    2    Copyright 1992, 1993, 1994, 1995, 1996, 1997, 2000
     2   Copyright 1992, 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002, 2003
    33   Free Software Foundation, Inc.
    44
     
    2020USA.  */
    2121
    22 #define TARGET_PAGE_SIZE        4096
    23 #define ZMAGIC_DISK_BLOCK_SIZE 1024
    24 #define SEGMENT_SIZE TARGET_PAGE_SIZE
    25 #define TEXT_START_ADDR        0x0
    26 #define N_SHARED_LIB(x) 0
    27 #define BYTES_IN_WORD 4
     22#define TARGET_PAGE_SIZE        4096
     23#define ZMAGIC_DISK_BLOCK_SIZE  1024
     24#define SEGMENT_SIZE            TARGET_PAGE_SIZE
     25#define TEXT_START_ADDR         0x0
     26#define N_SHARED_LIB(x)         0
    2827
    2928#define MACHTYPE_OK(mtype) ((mtype) == M_SPARC || (mtype) == M_UNKNOWN)
     
    3837
    3938#define DEFAULT_ARCH bfd_arch_sparc
    40 #define MY(OP) CAT(sparclinux_,OP)
     39/* Do not "beautify" the CONCAT* macro args.  Traditional C will not
     40   remove whitespace added here, and thus will fail to concatenate
     41   the tokens.  */
     42#define MY(OP) CONCAT2 (sparclinux_,OP)
    4143#define TARGETNAME "a.out-sparc-linux"
    4244
     
    5052  PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *));
    5153
    52 static boolean sparclinux_bfd_final_link
     54static bfd_boolean sparclinux_bfd_final_link
    5355  PARAMS ((bfd *abfd, struct bfd_link_info *info));
    5456
    55 static boolean
     57static bfd_boolean
    5658sparclinux_bfd_final_link (abfd, info)
    5759     bfd *abfd;
     
    6668/* Set the machine type correctly.  */
    6769
    68 static boolean sparclinux_write_object_contents PARAMS ((bfd *abfd));
    69 
    70 static boolean
     70static bfd_boolean sparclinux_write_object_contents PARAMS ((bfd *abfd));
     71
     72static bfd_boolean
    7173sparclinux_write_object_contents (abfd)
    7274     bfd *abfd;
     
    8183  WRITE_HEADERS(abfd, execp);
    8284
    83   return true;
     85  return TRUE;
    8486}
    8587
     
    9092
    9193#ifndef GOT_REF_PREFIX
    92 #define        GOT_REF_PREFIX  "__GOT_"
     94#define GOT_REF_PREFIX  "__GOT_"
    9395#endif
    9496
     
    99101
    100102#ifndef PLT_REF_PREFIX
    101 #define        PLT_REF_PREFIX  "__PLT_"
     103#define PLT_REF_PREFIX  "__PLT_"
    102104#endif
    103105
     
    177179static struct fixup *new_fixup
    178180  PARAMS ((struct bfd_link_info *, struct linux_link_hash_entry *,
    179           bfd_vma, int));
    180 static boolean linux_link_create_dynamic_sections
     181          bfd_vma, int));
     182static bfd_boolean linux_link_create_dynamic_sections
    181183  PARAMS ((bfd *, struct bfd_link_info *));
    182 static boolean linux_add_one_symbol
     184static bfd_boolean linux_add_one_symbol
    183185  PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword, asection *,
    184           bfd_vma, const char *, boolean, boolean,
    185           struct bfd_link_hash_entry **));
    186 static boolean linux_tally_symbols
     186          bfd_vma, const char *, bfd_boolean, bfd_boolean,
     187          struct bfd_link_hash_entry **));
     188static bfd_boolean linux_tally_symbols
    187189  PARAMS ((struct linux_link_hash_entry *, PTR));
    188 static boolean linux_finish_dynamic_link
     190static bfd_boolean linux_finish_dynamic_link
    189191  PARAMS ((bfd *, struct bfd_link_info *));
    190192
     
    203205  if (ret == (struct linux_link_hash_entry *) NULL)
    204206    ret = ((struct linux_link_hash_entry *)
    205           bfd_hash_allocate (table, sizeof (struct linux_link_hash_entry)));
     207           bfd_hash_allocate (table, sizeof (struct linux_link_hash_entry)));
    206208  if (ret == NULL)
    207209    return (struct bfd_hash_entry *) ret;
     
    209211  /* Call the allocation method of the superclass.  */
    210212  ret = ((struct linux_link_hash_entry *)
    211         NAME(aout,link_hash_newfunc) ((struct bfd_hash_entry *) ret,
    212                                       table, string));
     213        NAME(aout,link_hash_newfunc) ((struct bfd_hash_entry *) ret,
     214                                       table, string));
    213215  if (ret != NULL)
    214216    {
     
    226228{
    227229  struct linux_link_hash_table *ret;
    228 
    229   ret = ((struct linux_link_hash_table *)
    230         bfd_alloc (abfd, sizeof (struct linux_link_hash_table)));
     230  bfd_size_type amt = sizeof (struct linux_link_hash_table);
     231
     232  ret = (struct linux_link_hash_table *) bfd_malloc (amt);
    231233  if (ret == (struct linux_link_hash_table *) NULL)
    232234    return (struct bfd_link_hash_table *) NULL;
    233235  if (! NAME(aout,link_hash_table_init) (&ret->root, abfd,
    234                                         linux_link_hash_newfunc))
     236                                        linux_link_hash_newfunc))
    235237    {
    236238      free (ret);
     
    251253  ((struct linux_link_hash_entry *) \
    252254   aout_link_hash_lookup (&(table)->root, (string), (create), (copy),\
    253                          (follow)))
     255                          (follow)))
    254256
    255257/* Traverse a Linux link hash table.  */
    256258
    257 #define linux_link_hash_traverse(table, func, info)                    \
    258   (aout_link_hash_traverse                                             \
    259    (&(table)->root,                                                    \
    260     (boolean (*) PARAMS ((struct aout_link_hash_entry *, PTR))) (func), \
     259#define linux_link_hash_traverse(table, func, info)                    \
     260  (aout_link_hash_traverse                                             \
     261   (&(table)->root,                                                    \
     262    (bfd_boolean (*) PARAMS ((struct aout_link_hash_entry *, PTR))) (func), \
    261263    (info)))
    262264
     
    278280
    279281  f = (struct fixup *) bfd_hash_allocate (&info->hash->table,
    280                                          sizeof (struct fixup));
     282                                          sizeof (struct fixup));
    281283  if (f == NULL)
    282284    return f;
     
    298300   create it for now.  */
    299301
    300 static boolean
     302static bfd_boolean
    301303linux_link_create_dynamic_sections (abfd, info)
    302304     bfd *abfd;
     
    310312
    311313  /* We choose to use the name ".linux-dynamic" for the fixup table.
    312      Why not? */
     314     Why not?  */
    313315  s = bfd_make_section (abfd, ".linux-dynamic");
    314316  if (s == NULL
    315317      || ! bfd_set_section_flags (abfd, s, flags)
    316318      || ! bfd_set_section_alignment (abfd, s, 2))
    317     return false;
     319    return FALSE;
    318320  s->_raw_size = 0;
    319321  s->contents = 0;
    320322
    321   return true;
     323  return TRUE;
    322324}
    323325
     
    326328   tweaking needed for dynamic linking support.  */
    327329
    328 static boolean
     330static bfd_boolean
    329331linux_add_one_symbol (info, abfd, name, flags, section, value, string,
    330                      copy, collect, hashp)
     332                      copy, collect, hashp)
    331333     struct bfd_link_info *info;
    332334     bfd *abfd;
     
    336338     bfd_vma value;
    337339     const char *string;
    338      boolean copy;
    339      boolean collect;
     340     bfd_boolean copy;
     341     bfd_boolean collect;
    340342     struct bfd_link_hash_entry **hashp;
    341343{
    342344  struct linux_link_hash_entry *h;
    343   boolean insert;
     345  bfd_boolean insert;
    344346
    345347  /* Look up and see if we already have this symbol in the hash table.
     
    351353     confusion is possible.  */
    352354
    353   insert = false;
     355  insert = FALSE;
    354356
    355357  if (! info->relocateable
     
    360362    {
    361363      if (! linux_link_create_dynamic_sections (abfd, info))
    362        return false;
     364        return FALSE;
    363365      linux_hash_table (info)->dynobj = abfd;
    364       insert = true;
     366      insert = TRUE;
    365367    }
    366368
     
    368370      && abfd->xvec == info->hash->creator)
    369371    {
    370       h = linux_link_hash_lookup (linux_hash_table (info), name, false,
    371                                  false, false);
     372      h = linux_link_hash_lookup (linux_hash_table (info), name, FALSE,
     373                                  FALSE, FALSE);
    372374      if (h != NULL
    373          && (h->root.root.type == bfd_link_hash_defined
    374              || h->root.root.type == bfd_link_hash_defweak))
    375        {
    376          struct fixup *f;
    377 
    378          if (hashp != NULL)
    379            *hashp = (struct bfd_link_hash_entry *) h;
    380 
    381          f = new_fixup (info, h, value, ! IS_PLT_SYM (name));
    382          if (f == NULL)
    383            return false;
    384          f->jump = IS_PLT_SYM (name);
    385 
    386          return true;
    387        }
     375          && (h->root.root.type == bfd_link_hash_defined
     376              || h->root.root.type == bfd_link_hash_defweak))
     377        {
     378          struct fixup *f;
     379
     380          if (hashp != NULL)
     381            *hashp = (struct bfd_link_hash_entry *) h;
     382
     383          f = new_fixup (info, h, value, ! IS_PLT_SYM (name));
     384          if (f == NULL)
     385            return FALSE;
     386          f->jump = IS_PLT_SYM (name);
     387
     388          return TRUE;
     389        }
    388390    }
    389391
    390392  /* Do the usual procedure for adding a symbol.  */
    391393  if (! _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section,
    392                                          value, string, copy, collect,
    393                                          hashp))
    394     return false;
     394                                          value, string, copy, collect,
     395                                          hashp))
     396    return FALSE;
    395397
    396398  /* Insert a pointer to our table in the set vector.  The dynamic
    397      linker requires this information */
     399     linker requires this information. */
    398400  if (insert)
    399401    {
     
    401403
    402404      /* Here we do our special thing to add the pointer to the
    403         dynamic section in the SHARABLE_CONFLICTS set vector.  */
     405        dynamic section in the SHARABLE_CONFLICTS set vector.  */
    404406      s = bfd_get_section_by_name (linux_hash_table (info)->dynobj,
    405                                   ".linux-dynamic");
     407                                   ".linux-dynamic");
    406408      BFD_ASSERT (s != NULL);
    407409
    408410      if (! (_bfd_generic_link_add_one_symbol
    409             (info, linux_hash_table (info)->dynobj, SHARABLE_CONFLICTS,
    410              BSF_GLOBAL | BSF_CONSTRUCTOR, s, 0, NULL, false, false, NULL)))
    411        return false;
    412     }
    413 
    414   return true;
     411             (info, linux_hash_table (info)->dynobj, SHARABLE_CONFLICTS,
     412              BSF_GLOBAL | BSF_CONSTRUCTOR, s, (bfd_vma) 0, NULL,
     413              FALSE, FALSE, NULL)))
     414        return FALSE;
     415    }
     416
     417  return TRUE;
    415418}
    416419
     
    425428   This function is called via linux_link_hash_traverse.  */
    426429
    427 static boolean
     430static bfd_boolean
    428431linux_tally_symbols (h, data)
    429432     struct linux_link_hash_entry *h;
     
    434437  int is_plt;
    435438  struct linux_link_hash_entry *h1, *h2;
    436   boolean exists;
     439  bfd_boolean exists;
     440
     441  if (h->root.root.type == bfd_link_hash_warning)
     442    h = (struct linux_link_hash_entry *) h->root.root.u.i.link;
    437443
    438444  if (h->root.root.type == bfd_link_hash_undefined
    439445      && strncmp (h->root.root.root.string, NEEDS_SHRLIB,
    440                  sizeof NEEDS_SHRLIB - 1) == 0)
     446                  sizeof NEEDS_SHRLIB - 1) == 0)
    441447    {
    442448      const char *name;
     
    447453      p = strrchr (name, '_');
    448454      if (p != NULL)
    449        alloc = (char *) bfd_malloc (strlen (name) + 1);
     455        alloc = (char *) bfd_malloc ((bfd_size_type) strlen (name) + 1);
    450456
    451457      if (p == NULL || alloc == NULL)
    452        (*_bfd_error_handler) (_("Output file requires shared library `%s'\n"),
    453                               name);
     458        (*_bfd_error_handler) (_("Output file requires shared library `%s'\n"),
     459                               name);
    454460      else
    455        {
    456          strcpy (alloc, name);
    457          p = strrchr (alloc, '_');
    458          *p++ = '\0';
    459          (*_bfd_error_handler)
    460            (_("Output file requires shared library `%s.so.%s'\n"),
    461             alloc, p);
    462          free (alloc);
    463        }
     461        {
     462          strcpy (alloc, name);
     463          p = strrchr (alloc, '_');
     464          *p++ = '\0';
     465          (*_bfd_error_handler)
     466            (_("Output file requires shared library `%s.so.%s'\n"),
     467             alloc, p);
     468          free (alloc);
     469        }
    464470
    465471      abort ();
     
    473479    {
    474480      /* Look up this symbol twice.  Once just as a regular lookup,
    475         and then again following all of the indirect links until we
    476         reach a real symbol.  */
     481        and then again following all of the indirect links until we
     482        reach a real symbol.  */
    477483      h1 = linux_link_hash_lookup (linux_hash_table (info),
    478                                   (h->root.root.root.string
    479                                    + sizeof PLT_REF_PREFIX - 1),
    480                                   false, false, true);
     484                                   (h->root.root.root.string
     485                                    + sizeof PLT_REF_PREFIX - 1),
     486                                   FALSE, FALSE, TRUE);
    481487      /* h2 does not follow indirect symbols.  */
    482488      h2 = linux_link_hash_lookup (linux_hash_table (info),
    483                                   (h->root.root.root.string
    484                                    + sizeof PLT_REF_PREFIX - 1),
    485                                   false, false, false);
     489                                   (h->root.root.root.string
     490                                    + sizeof PLT_REF_PREFIX - 1),
     491                                   FALSE, FALSE, FALSE);
    486492
    487493      /* The real symbol must exist but if it is also an ABS symbol,
    488         there is no need to have a fixup.  This is because they both
    489         came from the same library.  If on the other hand, we had to
    490         use an indirect symbol to get to the real symbol, we add the
    491         fixup anyway, since there are cases where these symbols come
    492         from different shared libraries */
     494        there is no need to have a fixup.  This is because they both
     495        came from the same library.  If on the other hand, we had to
     496        use an indirect symbol to get to the real symbol, we add the
     497        fixup anyway, since there are cases where these symbols come
     498        from different shared libraries */
    493499      if (h1 != NULL
    494          && (((h1->root.root.type == bfd_link_hash_defined
    495                || h1->root.root.type == bfd_link_hash_defweak)
    496               && ! bfd_is_abs_section (h1->root.root.u.def.section))
    497              || h2->root.root.type == bfd_link_hash_indirect))
    498        {
    499          /* See if there is a "builtin" fixup already present
    500             involving this symbol.  If so, convert it to a regular
    501             fixup.  In the end, this relaxes some of the requirements
    502             about the order of performing fixups.  */
    503          exists = false;
    504          for (f1 = linux_hash_table (info)->fixup_list;
    505               f1 != NULL;
    506               f1 = f1->next)
    507            {
    508              if ((f1->h != h && f1->h != h1)
    509                  || (! f1->builtin && ! f1->jump))
    510                continue;
    511              if (f1->h == h1)
    512               exists = true;
    513              if (! exists
    514                  && bfd_is_abs_section (h->root.root.u.def.section))
    515                {
    516                  f = new_fixup (info, h1, f1->h->root.root.u.def.value, 0);
    517                  f->jump = is_plt;
    518                }
    519              f1->h = h1;
    520              f1->jump = is_plt;
    521              f1->builtin = 0;
    522              exists = true;
    523            }
    524          if (! exists
    525              && bfd_is_abs_section (h->root.root.u.def.section))
    526            {
    527              f = new_fixup (info, h1, h->root.root.u.def.value, 0);
    528              if (f == NULL)
    529                {
    530                  /* FIXME: No way to return error.  */
    531                  abort ();
    532                }
    533              f->jump = is_plt;
    534            }
    535        }
     500          && (((h1->root.root.type == bfd_link_hash_defined
     501                || h1->root.root.type == bfd_link_hash_defweak)
     502               && ! bfd_is_abs_section (h1->root.root.u.def.section))
     503              || h2->root.root.type == bfd_link_hash_indirect))
     504        {
     505          /* See if there is a "builtin" fixup already present
     506             involving this symbol.  If so, convert it to a regular
     507             fixup.  In the end, this relaxes some of the requirements
     508             about the order of performing fixups.  */
     509          exists = FALSE;
     510          for (f1 = linux_hash_table (info)->fixup_list;
     511               f1 != NULL;
     512               f1 = f1->next)
     513            {
     514              if ((f1->h != h && f1->h != h1)
     515                  || (! f1->builtin && ! f1->jump))
     516                continue;
     517              if (f1->h == h1)
     518                exists = TRUE;
     519              if (! exists
     520                  && bfd_is_abs_section (h->root.root.u.def.section))
     521                {
     522                  f = new_fixup (info, h1, f1->h->root.root.u.def.value, 0);
     523                  f->jump = is_plt;
     524                }
     525              f1->h = h1;
     526              f1->jump = is_plt;
     527              f1->builtin = 0;
     528              exists = TRUE;
     529            }
     530          if (! exists
     531              && bfd_is_abs_section (h->root.root.u.def.section))
     532            {
     533              f = new_fixup (info, h1, h->root.root.u.def.value, 0);
     534              if (f == NULL)
     535                {
     536                  /* FIXME: No way to return error.  */
     537                  abort ();
     538                }
     539              f->jump = is_plt;
     540            }
     541        }
    536542
    537543      /* Quick and dirty way of stripping these symbols from the
    538         symtab.  */
     544        symtab.  */
    539545      if (bfd_is_abs_section (h->root.root.u.def.section))
    540        h->root.written = true;
    541     }
    542 
    543   return true;
     546        h->root.written = TRUE;
     547    }
     548
     549  return TRUE;
    544550}
    545551
     
    550556   are required.  */
    551557
    552 boolean
     558bfd_boolean
    553559bfd_sparclinux_size_dynamic_sections (output_bfd, info)
    554560     bfd *output_bfd;
     
    559565
    560566  if (output_bfd->xvec != &MY(vec))
    561     return true;
     567    return TRUE;
    562568
    563569  /* First find the fixups...  */
    564570  linux_link_hash_traverse (linux_hash_table (info),
    565                            linux_tally_symbols,
    566                            (PTR) info);
     571                            linux_tally_symbols,
     572                            (PTR) info);
    567573
    568574  /* If there are builtin fixups, leave room for a marker.  This is
     
    572578    {
    573579      if (f->builtin)
    574        {
    575          ++linux_hash_table (info)->fixup_count;
    576          ++linux_hash_table (info)->local_builtins;
    577          break;
    578        }
     580        {
     581          ++linux_hash_table (info)->fixup_count;
     582          ++linux_hash_table (info)->local_builtins;
     583          break;
     584        }
    579585    }
    580586
     
    582588    {
    583589      if (linux_hash_table (info)->fixup_count > 0)
    584       abort ();
    585       return true;
     590        abort ();
     591      return TRUE;
    586592    }
    587593
    588594  /* Allocate memory for our fixup table.  We will fill it in later.  */
    589595  s = bfd_get_section_by_name (linux_hash_table (info)->dynobj,
    590                               ".linux-dynamic");
     596                               ".linux-dynamic");
    591597  if (s != NULL)
    592598    {
    593       s->_raw_size = 8 + linux_hash_table (info)->fixup_count * 8;
    594       s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
     599      s->_raw_size = linux_hash_table (info)->fixup_count + 1;
     600      s->_raw_size *= 8;
     601      s->contents = (bfd_byte *) bfd_zalloc (output_bfd, s->_raw_size);
    595602      if (s->contents == NULL)
    596        return false;
    597       memset (s->contents, 0, (size_t) s->_raw_size);
    598     }
    599 
    600   return true;
     603        return FALSE;
     604    }
     605
     606  return TRUE;
    601607}
    602608
     
    605611   the stuff we need.  */
    606612
    607 static boolean
     613static bfd_boolean
    608614linux_finish_dynamic_link (output_bfd, info)
    609615     bfd *output_bfd;
     
    619625
    620626  if (linux_hash_table (info)->dynobj == NULL)
    621     return true;
     627    return TRUE;
    622628
    623629  s = bfd_get_section_by_name (linux_hash_table (info)->dynobj,
    624                               ".linux-dynamic");
     630                               ".linux-dynamic");
    625631  BFD_ASSERT (s != NULL);
    626632  os = s->output_section;
     
    629635#ifdef LINUX_LINK_DEBUG
    630636  printf ("Fixup table file offset: %x  VMA: %x\n",
    631          os->filepos + s->output_offset,
    632          os->vma + s->output_offset);
     637          os->filepos + s->output_offset,
     638          os->vma + s->output_offset);
    633639#endif
    634640
    635641  fixup_table = s->contents;
    636   bfd_put_32 (output_bfd, linux_hash_table (info)->fixup_count, fixup_table);
     642  bfd_put_32 (output_bfd,
     643              (bfd_vma) linux_hash_table (info)->fixup_count, fixup_table);
    637644  fixup_table += 4;
    638645
     
    641648    {
    642649      if (f->builtin)
    643        continue;
     650        continue;
    644651
    645652      if (f->h->root.root.type != bfd_link_hash_defined
    646          && f->h->root.root.type != bfd_link_hash_defweak)
    647        {
    648          (*_bfd_error_handler)
    649            (_("Symbol %s not defined for fixups\n"),
    650             f->h->root.root.root.string);
    651          continue;
    652        }
     653          && f->h->root.root.type != bfd_link_hash_defweak)
     654        {
     655          (*_bfd_error_handler)
     656            (_("Symbol %s not defined for fixups\n"),
     657             f->h->root.root.root.string);
     658          continue;
     659        }
    653660
    654661      is = f->h->root.root.u.def.section;
     
    658665#ifdef LINUX_LINK_DEBUG
    659666      printf ("Fixup(%d) %s: %x %x\n",f->jump, f->h->root.root.string,
    660              new_addr, f->value);
     667              new_addr, f->value);
    661668#endif
    662669
    663670      if (f->jump)
    664        {
    665          /* Relative address */
    666          new_addr = new_addr - (f->value + 5);
    667          bfd_put_32 (output_bfd, new_addr, fixup_table);
    668          fixup_table += 4;
    669          bfd_put_32 (output_bfd, f->value + 1, fixup_table);
    670          fixup_table += 4;
    671        }
     671        {
     672          /* Relative address */
     673          new_addr = new_addr - (f->value + 5);
     674          bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table);
     675          fixup_table += 4;
     676          bfd_put_32 (output_bfd, f->value + 1, fixup_table);
     677          fixup_table += 4;
     678        }
    672679      else
    673        {
    674          bfd_put_32 (output_bfd, new_addr, fixup_table);
    675          fixup_table += 4;
    676          bfd_put_32 (output_bfd, f->value, fixup_table);
    677          fixup_table += 4;
    678        }
     680        {
     681          bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table);
     682          fixup_table += 4;
     683          bfd_put_32 (output_bfd, f->value, fixup_table);
     684          fixup_table += 4;
     685        }
    679686      ++fixups_written;
    680687    }
     
    683690    {
    684691      /* Special marker so we know to switch to the other type of fixup */
    685       bfd_put_32 (output_bfd, 0, fixup_table);
     692      bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
    686693      fixup_table += 4;
    687       bfd_put_32 (output_bfd, 0, fixup_table);
     694      bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
    688695      fixup_table += 4;
    689696      ++fixups_written;
    690697      for (f = linux_hash_table (info)->fixup_list; f != NULL; f = f->next)
    691        {
    692          if (! f->builtin)
    693            continue;
    694 
    695          if (f->h->root.root.type != bfd_link_hash_defined
    696              && f->h->root.root.type != bfd_link_hash_defweak)
    697            {
    698              (*_bfd_error_handler)
    699                (_("Symbol %s not defined for fixups\n"),
    700                 f->h->root.root.root.string);
    701              continue;
    702            }
    703 
    704          is = f->h->root.root.u.def.section;
    705          section_offset = is->output_section->vma + is->output_offset;
    706          new_addr = f->h->root.root.u.def.value + section_offset;
     698        {
     699          if (! f->builtin)
     700            continue;
     701
     702          if (f->h->root.root.type != bfd_link_hash_defined
     703              && f->h->root.root.type != bfd_link_hash_defweak)
     704            {
     705              (*_bfd_error_handler)
     706                (_("Symbol %s not defined for fixups\n"),
     707                f->h->root.root.root.string);
     708              continue;
     709            }
     710
     711          is = f->h->root.root.u.def.section;
     712          section_offset = is->output_section->vma + is->output_offset;
     713          new_addr = f->h->root.root.u.def.value + section_offset;
    707714
    708715#ifdef LINUX_LINK_DEBUG
    709          printf ("Fixup(B) %s: %x %x\n", f->h->root.root.string,
    710                  new_addr, f->value);
     716          printf ("Fixup(B) %s: %x %x\n", f->h->root.root.string,
     717                  new_addr, f->value);
    711718#endif
    712719
    713          bfd_put_32 (output_bfd, new_addr, fixup_table);
    714          fixup_table += 4;
    715          bfd_put_32 (output_bfd, f->value, fixup_table);
    716          fixup_table += 4;
    717          ++fixups_written;
    718        }
    719   }
     720          bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table);
     721          fixup_table += 4;
     722          bfd_put_32 (output_bfd, f->value, fixup_table);
     723          fixup_table += 4;
     724          ++fixups_written;
     725        }
     726    }
    720727
    721728  if (linux_hash_table (info)->fixup_count != fixups_written)
     
    723730      (*_bfd_error_handler) (_("Warning: fixup count mismatch\n"));
    724731      while (linux_hash_table (info)->fixup_count > fixups_written)
    725        {
    726          bfd_put_32 (output_bfd, 0, fixup_table);
    727          fixup_table += 4;
    728          bfd_put_32 (output_bfd, 0, fixup_table);
    729          fixup_table += 4;
    730          ++fixups_written;
    731        }
     732        {
     733          bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
     734          fixup_table += 4;
     735          bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
     736          fixup_table += 4;
     737          ++fixups_written;
     738        }
    732739    }
    733740
    734741  h = linux_link_hash_lookup (linux_hash_table (info),
    735                              "__BUILTIN_FIXUPS__",
    736                              false, false, false);
     742                              "__BUILTIN_FIXUPS__",
     743                              FALSE, FALSE, FALSE);
    737744
    738745  if (h != NULL
    739746      && (h->root.root.type == bfd_link_hash_defined
    740          || h->root.root.type == bfd_link_hash_defweak))
     747          || h->root.root.type == bfd_link_hash_defweak))
    741748    {
    742749      is = h->root.root.u.def.section;
     
    748755#endif
    749756
    750       bfd_put_32 (output_bfd, new_addr, fixup_table);
     757      bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table);
    751758    }
    752759  else
    753     bfd_put_32 (output_bfd, 0, fixup_table);
    754 
    755   if (bfd_seek (output_bfd, os->filepos + s->output_offset, SEEK_SET) != 0)
    756     return false;
    757 
    758   if (bfd_write ((PTR) s->contents, 1, s->_raw_size, output_bfd)
    759       != s->_raw_size)
    760     return false;
    761 
    762   return true;
     760    bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
     761
     762  if (bfd_seek (output_bfd, (file_ptr) (os->filepos + s->output_offset),
     763                SEEK_SET) != 0)
     764    return FALSE;
     765
     766  if (bfd_bwrite ((PTR) s->contents, s->_raw_size, output_bfd) != s->_raw_size)
     767    return FALSE;
     768
     769  return TRUE;
    763770}
    764771
Note: See TracChangeset for help on using the changeset viewer.