~ubuntu-branches/ubuntu/hoary/binutils/hoary

« back to all changes in this revision

Viewing changes to bfd/elf-m10300.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2005-03-18 13:07:52 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050318130752-j4i37zgqclj53b94
Tags: 2.15-5ubuntu2
debian/rules: Call pkgstriptranslations if present (the package does not
use debhelper, thus it does not happen automatically).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Matsushita 10300 specific support for 32-bit ELF
2
 
   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
 
2
   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3
3
   Free Software Foundation, Inc.
4
4
 
5
5
This file is part of BFD, the Binary File Descriptor library.
85
85
     to the target when it's valid and profitable to do so.  */
86
86
  unsigned char movm_args;
87
87
 
88
 
  /* For funtion symbols, the amount of stack space that would be allocated
 
88
  /* For function symbols, the amount of stack space that would be allocated
89
89
     by the movm instruction.  This is redundant with movm_args, but we
90
90
     add it to the hash table to avoid computing it over and over.  */
91
91
  unsigned char movm_stack_size;
561
561
  flagword   flags;
562
562
  flagword   pltflags;
563
563
  asection * s;
 
564
  struct bfd_link_hash_entry * bh;
564
565
  struct elf_link_hash_entry * h;
565
566
  const struct elf_backend_data * bed = get_elf_backend_data (abfd);
566
567
  int ptralign;
604
605
    {
605
606
      /* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
606
607
         .plt section.  */
607
 
      struct elf_link_hash_entry *h = NULL;
 
608
      bh = NULL;
608
609
      if (! (_bfd_generic_link_add_one_symbol
609
610
             (info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s,
610
611
              (bfd_vma) 0, (const char *) NULL, FALSE,
611
 
              get_elf_backend_data (abfd)->collect,
612
 
              (struct bfd_link_hash_entry **) &h)))
 
612
              get_elf_backend_data (abfd)->collect, &bh)))
613
613
        return FALSE;
 
614
      h = (struct elf_link_hash_entry *) bh;
614
615
      h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
615
616
      h->type = STT_OBJECT;
616
617
 
617
618
      if (info->shared
618
 
          && ! _bfd_elf_link_record_dynamic_symbol (info, h))
 
619
          && ! bfd_elf_link_record_dynamic_symbol (info, h))
619
620
        return FALSE;
620
621
    }
621
622
 
638
639
     (or .got.plt) section.  We don't do this in the linker script
639
640
     because we don't want to define the symbol if we are not creating
640
641
     a global offset table.  */
641
 
  h = NULL;
 
642
  bh = NULL;
642
643
  if (!(_bfd_generic_link_add_one_symbol
643
644
        (info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s,
644
645
         bed->got_symbol_offset, (const char *) NULL, FALSE,
645
 
         bed->collect, (struct bfd_link_hash_entry **) &h)))
 
646
         bed->collect, &bh)))
646
647
    return FALSE;
 
648
  h = (struct elf_link_hash_entry *) bh;
647
649
  h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
648
650
  h->type = STT_OBJECT;
649
651
 
650
652
  if (info->shared
651
 
      && ! _bfd_elf_link_record_dynamic_symbol (info, h))
 
653
      && ! bfd_elf_link_record_dynamic_symbol (info, h))
652
654
    return FALSE;
653
655
 
654
656
  elf_hash_table (info)->hgot = h;
768
770
        /* This relocation describes the C++ object vtable hierarchy.
769
771
           Reconstruct it for later use during GC.  */
770
772
        case R_MN10300_GNU_VTINHERIT:
771
 
          if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
 
773
          if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
772
774
            return FALSE;
773
775
          break;
774
776
 
775
777
        /* This relocation describes which C++ vtable entries are actually
776
778
           used.  Record for later use during GC.  */
777
779
        case R_MN10300_GNU_VTENTRY:
778
 
          if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend))
 
780
          if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
779
781
            return FALSE;
780
782
          break;
781
783
        case R_MN10300_GOT32:
820
822
              /* Make sure this symbol is output as a dynamic symbol.  */
821
823
              if (h->dynindx == -1)
822
824
                {
823
 
                  if (! bfd_elf32_link_record_dynamic_symbol (info, h))
 
825
                  if (! bfd_elf_link_record_dynamic_symbol (info, h))
824
826
                    return FALSE;
825
827
                }
826
828
 
1535
1537
     asection **local_sections;
1536
1538
{
1537
1539
  Elf_Internal_Shdr *symtab_hdr;
1538
 
  struct elf32_mn10300_link_hash_entry **sym_hashes;
 
1540
  struct elf_link_hash_entry **sym_hashes;
1539
1541
  Elf_Internal_Rela *rel, *relend;
1540
1542
 
1541
1543
  if (info->relocatable)
1542
1544
    return TRUE;
1543
1545
 
1544
1546
  symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
1545
 
  sym_hashes = (struct elf32_mn10300_link_hash_entry **)
1546
 
                 (elf_sym_hashes (input_bfd));
 
1547
  sym_hashes = elf_sym_hashes (input_bfd);
1547
1548
 
1548
1549
  rel = relocs;
1549
1550
  relend = relocs + input_section->reloc_count;
1574
1575
        {
1575
1576
          sym = local_syms + r_symndx;
1576
1577
          sec = local_sections[r_symndx];
1577
 
          relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
 
1578
          relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
1578
1579
        }
1579
1580
      else
1580
1581
        {
1582
1583
          bfd_boolean warned;
1583
1584
          struct elf_link_hash_entry *hh;
1584
1585
 
1585
 
          RELOC_FOR_GLOBAL_SYMBOL (hh, (struct elf_link_hash_entry *) sym_hashes,
1586
 
                                   r_symndx, symtab_hdr, relocation,
1587
 
                                   sec, unresolved_reloc, info,
1588
 
                                   warned);
 
1586
          RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
 
1587
                                   r_symndx, symtab_hdr, sym_hashes,
 
1588
                                   hh, sec, relocation,
 
1589
                                   unresolved_reloc, warned);
1589
1590
 
1590
1591
          h = (struct elf32_mn10300_link_hash_entry *) hh;
1591
1592
 
1741
1742
    byte_count += 2;
1742
1743
 
1743
1744
  /* Count the insn to allocate stack space too.  */
1744
 
  if (entry->stack_size > 0 && entry->stack_size <= 128)
1745
 
    byte_count += 3;
1746
 
  else if (entry->stack_size > 0 && entry->stack_size < 256)
1747
 
    byte_count += 4;
 
1745
  if (entry->stack_size > 0)
 
1746
    {
 
1747
      if (entry->stack_size <= 128)
 
1748
        byte_count += 3;
 
1749
      else
 
1750
        byte_count += 4;
 
1751
    }
1748
1752
 
1749
1753
  /* If using "call" will result in larger code, then turn all
1750
 
     the associated "call" instructions into "calls" instrutions.  */
 
1754
     the associated "call" instructions into "calls" instructions.  */
1751
1755
  if (byte_count < entry->direct_calls)
1752
1756
    entry->flags |= MN10300_CONVERT_CALL_TO_CALLS;
1753
1757
 
1757
1761
 
1758
1762
/* This function handles relaxing for the mn10300.
1759
1763
 
1760
 
   There's quite a few relaxing opportunites available on the mn10300:
 
1764
   There are quite a few relaxing opportunities available on the mn10300:
1761
1765
 
1762
1766
        * calls:32 -> calls:16                                     2 bytes
1763
1767
        * call:32  -> call:16                                      2 bytes
2236
2240
                      if (sym_hash->movm_args)
2237
2241
                        bytes += 2;
2238
2242
 
2239
 
                      if (sym_hash->stack_size && sym_hash->stack_size <= 128)
2240
 
                        bytes += 3;
2241
 
                      else if (sym_hash->stack_size
2242
 
                               && sym_hash->stack_size < 256)
2243
 
                        bytes += 4;
 
2243
                      if (sym_hash->stack_size > 0)
 
2244
                        {
 
2245
                          if (sym_hash->stack_size <= 128)
 
2246
                            bytes += 3;
 
2247
                          else
 
2248
                            bytes += 4;
 
2249
                        }
2244
2250
 
2245
2251
                      /* Note that we've deleted prologue bytes for this
2246
2252
                         function.  */
2288
2294
                      if (sym_hash->movm_args)
2289
2295
                        bytes += 2;
2290
2296
 
2291
 
                      if (sym_hash->stack_size && sym_hash->stack_size <= 128)
2292
 
                        bytes += 3;
2293
 
                      else if (sym_hash->stack_size
2294
 
                               && sym_hash->stack_size < 256)
2295
 
                        bytes += 4;
 
2297
                      if (sym_hash->stack_size > 0)
 
2298
                        {
 
2299
                          if (sym_hash->stack_size <= 128)
 
2300
                            bytes += 3;
 
2301
                          else
 
2302
                            bytes += 4;
 
2303
                        }
2296
2304
 
2297
2305
                      /* Note that we've deleted prologue bytes for this
2298
2306
                         function.  */
3485
3493
    }
3486
3494
 
3487
3495
  /* Now figure out how much stack space will be allocated by the movm
3488
 
     instruction.  We need this kept separate from the funtion's normal
 
3496
     instruction.  We need this kept separate from the function's normal
3489
3497
     stack space.  */
3490
3498
  if (hash->movm_args)
3491
3499
    {
4006
4014
/* Return offset of the GOT id in PLT0 entry.  */
4007
4015
#define elf_mn10300_plt0_gotid_offset(info) 9
4008
4016
 
4009
 
/* Return offset of the tempoline in PLT entry */
 
4017
/* Return offset of the temporary in PLT entry */
4010
4018
#define elf_mn10300_plt_temp_offset(info) 8
4011
4019
 
4012
4020
/* Return offset of the symbol in PLT entry.  */
4178
4186
      /* Make sure this symbol is output as a dynamic symbol.  */
4179
4187
      if (h->dynindx == -1)
4180
4188
        {
4181
 
          if (! bfd_elf32_link_record_dynamic_symbol (info, h))
 
4189
          if (! bfd_elf_link_record_dynamic_symbol (info, h))
4182
4190
            return FALSE;
4183
4191
        }
4184
4192
 
4349
4357
  if (elf_hash_table (info)->dynamic_sections_created)
4350
4358
    {
4351
4359
      /* Set the contents of the .interp section to the interpreter.  */
4352
 
      if (! info->shared)
 
4360
      if (info->executable)
4353
4361
        {
4354
4362
          s = bfd_get_section_by_name (dynobj, ".interp");
4355
4363
          BFD_ASSERT (s != NULL);
4483
4491
         in by the dynamic linker and used by the debugger.  */
4484
4492
      if (! info->shared)
4485
4493
        {
4486
 
          if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
 
4494
          if (!_bfd_elf_add_dynamic_entry (info, DT_DEBUG, 0))
4487
4495
            return FALSE;
4488
4496
        }
4489
4497
 
4490
4498
      if (plt)
4491
4499
        {
4492
 
          if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)
4493
 
              || ! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
4494
 
              || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
4495
 
              || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
 
4500
          if (!_bfd_elf_add_dynamic_entry (info, DT_PLTGOT, 0)
 
4501
              || !_bfd_elf_add_dynamic_entry (info, DT_PLTRELSZ, 0)
 
4502
              || !_bfd_elf_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
 
4503
              || !_bfd_elf_add_dynamic_entry (info, DT_JMPREL, 0))
4496
4504
            return FALSE;
4497
4505
        }
4498
4506
 
4499
4507
      if (relocs)
4500
4508
        {
4501
 
          if (! bfd_elf32_add_dynamic_entry (info, DT_RELA, 0)
4502
 
              || ! bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0)
4503
 
              || ! bfd_elf32_add_dynamic_entry (info, DT_RELAENT,
4504
 
                                                sizeof (Elf32_External_Rela)))
 
4509
          if (!_bfd_elf_add_dynamic_entry (info, DT_RELA, 0)
 
4510
              || !_bfd_elf_add_dynamic_entry (info, DT_RELASZ, 0)
 
4511
              || !_bfd_elf_add_dynamic_entry (info, DT_RELAENT,
 
4512
                                              sizeof (Elf32_External_Rela)))
4505
4513
            return FALSE;
4506
4514
        }
4507
4515
 
4508
4516
      if (reltext)
4509
4517
        {
4510
 
          if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
 
4518
          if (!_bfd_elf_add_dynamic_entry (info, DT_TEXTREL, 0))
4511
4519
            return FALSE;
4512
4520
        }
4513
4521
    }
4874
4882
#define elf_backend_plt_readonly        1
4875
4883
#define elf_backend_want_plt_sym        0
4876
4884
#define elf_backend_got_header_size     12
4877
 
#define elf_backend_plt_header_size     PLT0_ENTRY_SIZE
4878
4885
 
4879
4886
#include "elf32-target.h"