~ubuntu-branches/debian/jessie/gdb/jessie

« back to all changes in this revision

Viewing changes to bfd/elf32-score7.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Jacobowitz
  • Date: 2010-03-20 01:21:29 UTC
  • mfrom: (1.3.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20100320012129-t7h25y8zgr8c2369
Tags: 7.1-1
* New upstream release, including:
  - PIE support (Closes: #346409).
  - C++ improvements, including static_cast<> et al, namespace imports,
    and bug fixes in printing virtual base classes.
  - Multi-program debugging.  One GDB can now debug multiple programs
    at the same time.
  - Python scripting improvements, including gdb.parse_and_eval.
  - Updated MIPS Linux signal frame layout (Closes: #570875).
  - No internal error stepping over _dl_debug_state (Closes: #569551).
* Update to Standards-Version: 3.8.4 (no changes required).
* Include more relevant (and smaller) docs in the gdbserver package
  (Closes: #571132).
* Do not duplicate documentation in gdb64, gdb-source, and libgdb-dev.
* Fix crash when switching into TUI mode (Closes: #568489).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* 32-bit ELF support for S+core.
2
 
   Copyright 2009 Free Software Foundation, Inc.
 
2
   Copyright 2009, 2010 Free Software Foundation, Inc.
3
3
   Contributed by
4
4
   Brain.lin (brain.lin@sunplusct.com)
5
5
   Mei Ligang (ligang@sunnorth.com.cn)
34
34
#include "elf32-score.h"
35
35
 
36
36
 
37
 
/* Score ELF linker hash table.  */
38
 
struct score_elf_link_hash_table
39
 
{
40
 
  /* The main hash table.  */
41
 
  struct elf_link_hash_table root;
42
 
};
43
 
 
44
37
/* The SCORE ELF linker needs additional information for each symbol in
45
38
   the global hash table.  */
46
39
struct score_elf_link_hash_entry
65
58
/* Traverse a score ELF linker hash table.  */
66
59
#define score_elf_link_hash_traverse(table, func, info) \
67
60
  (elf_link_hash_traverse \
68
 
   (&(table)->root, \
 
61
   ((table),                                                 \
69
62
    (bfd_boolean (*) (struct elf_link_hash_entry *, void *)) (func), \
70
63
    (info)))
71
64
 
72
 
/* Get the SCORE elf linker hash table from a link_info structure.  */
73
 
#define score_elf_hash_table(info) \
74
 
  ((struct score_elf_link_hash_table *) ((info)->hash))
75
 
 
76
65
/* This structure is used to hold .got entries while estimating got sizes.  */
77
66
struct score_got_entry
78
67
{
1020
1009
       too large offsets.  */
1021
1010
    - (g->next ? g->assigned_gotno : 0);
1022
1011
  hsd.max_non_got_dynindx = max_local;
1023
 
  score_elf_link_hash_traverse (((struct score_elf_link_hash_table *)
1024
 
                                 elf_hash_table (info)),
1025
 
                                 score_elf_sort_hash_table_f,
1026
 
                                 &hsd);
 
1012
  score_elf_link_hash_traverse (elf_hash_table (info),
 
1013
                                score_elf_sort_hash_table_f,
 
1014
                                &hsd);
1027
1015
 
1028
1016
  /* There should have been enough room in the symbol table to
1029
1017
     accommodate both the GOT and non-GOT symbols.  */
1038
1026
  return TRUE;
1039
1027
}
1040
1028
 
1041
 
/* Create an entry in an score ELF linker hash table.  */
1042
 
 
1043
 
static struct bfd_hash_entry *
1044
 
score_elf_link_hash_newfunc (struct bfd_hash_entry *entry,
1045
 
                             struct bfd_hash_table *table,
1046
 
                             const char *string)
1047
 
{
1048
 
  struct score_elf_link_hash_entry *ret = (struct score_elf_link_hash_entry *) entry;
1049
 
 
1050
 
  /* Allocate the structure if it has not already been allocated by a subclass.  */
1051
 
  if (ret == NULL)
1052
 
    ret = bfd_hash_allocate (table, sizeof (struct score_elf_link_hash_entry));
1053
 
  if (ret == NULL)
1054
 
    return (struct bfd_hash_entry *) ret;
1055
 
 
1056
 
  /* Call the allocation method of the superclass.  */
1057
 
  ret = ((struct score_elf_link_hash_entry *)
1058
 
         _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
1059
 
 
1060
 
  if (ret != NULL)
1061
 
    {
1062
 
      ret->possibly_dynamic_relocs = 0;
1063
 
      ret->readonly_reloc = FALSE;
1064
 
      ret->no_fn_stub = FALSE;
1065
 
      ret->forced_local = FALSE;
1066
 
    }
1067
 
 
1068
 
  return (struct bfd_hash_entry *) ret;
1069
 
}
1070
 
 
1071
1029
/* Returns the first relocation of type r_type found, beginning with
1072
1030
   RELOCATION.  RELEND is one-past-the-end of the relocation table.  */
1073
1031
 
1650
1608
static bfd_vma
1651
1609
score_elf_global_got_index (bfd *abfd, struct elf_link_hash_entry *h)
1652
1610
{
1653
 
  bfd_vma index;
 
1611
  bfd_vma got_index;
1654
1612
  asection *sgot;
1655
1613
  struct score_got_info *g;
1656
1614
  long global_got_dynindx = 0;
1664
1622
     indices into the GOT.  That makes it easy to calculate the GOT
1665
1623
     offset.  */
1666
1624
  BFD_ASSERT (h->dynindx >= global_got_dynindx);
1667
 
  index = ((h->dynindx - global_got_dynindx + g->local_gotno) * SCORE_ELF_GOT_SIZE (abfd));
1668
 
  BFD_ASSERT (index < sgot->size);
 
1625
  got_index = ((h->dynindx - global_got_dynindx + g->local_gotno) * SCORE_ELF_GOT_SIZE (abfd));
 
1626
  BFD_ASSERT (got_index < sgot->size);
1669
1627
 
1670
 
  return index;
 
1628
  return got_index;
1671
1629
}
1672
1630
 
1673
1631
/* Returns the offset for the entry at the INDEXth position in the GOT.  */
1674
1632
 
1675
1633
static bfd_vma
1676
 
score_elf_got_offset_from_index (bfd *dynobj, bfd *output_bfd,
1677
 
                                 bfd *input_bfd ATTRIBUTE_UNUSED, bfd_vma index)
 
1634
score_elf_got_offset_from_index (bfd *dynobj,
 
1635
                                 bfd *output_bfd,
 
1636
                                 bfd *input_bfd ATTRIBUTE_UNUSED,
 
1637
                                 bfd_vma got_index)
1678
1638
{
1679
1639
  asection *sgot;
1680
1640
  bfd_vma gp;
1683
1643
  g = score_elf_got_info (dynobj, &sgot);
1684
1644
  gp = _bfd_get_gp_value (output_bfd);
1685
1645
 
1686
 
  return sgot->output_section->vma + sgot->output_offset + index - gp;
 
1646
  return sgot->output_section->vma + sgot->output_offset + got_index - gp;
1687
1647
}
1688
1648
 
1689
1649
/* Follow indirect and warning hash entries so that each got entry
2512
2472
 
2513
2473
              if (r_type == R_SCORE_GOT15)
2514
2474
                {
2515
 
                  const Elf_Internal_Rela *relend;
2516
2475
                  const Elf_Internal_Rela *lo16_rel;
2517
2476
                  const struct elf_backend_data *bed;
2518
2477
                  bfd_vma lo_addend = 0, lo_value = 0;
3840
3799
  return NULL;
3841
3800
}
3842
3801
 
3843
 
/* Create a score elf linker hash table.  */
3844
 
 
3845
 
struct bfd_link_hash_table *
3846
 
s7_elf32_score_link_hash_table_create (bfd *abfd)
3847
 
{
3848
 
  struct score_elf_link_hash_table *ret;
3849
 
  bfd_size_type amt = sizeof (struct score_elf_link_hash_table);
3850
 
 
3851
 
  ret = bfd_malloc (amt);
3852
 
  if (ret == NULL)
3853
 
    return NULL;
3854
 
 
3855
 
  if (!_bfd_elf_link_hash_table_init (&ret->root, abfd, score_elf_link_hash_newfunc,
3856
 
                                      sizeof (struct score_elf_link_hash_entry)))
3857
 
    {
3858
 
      free (ret);
3859
 
      return NULL;
3860
 
    }
3861
 
 
3862
 
  return &ret->root.root;
3863
 
}
3864
 
 
3865
3802
bfd_boolean
3866
3803
s7_elf32_score_print_private_bfd_data (bfd *abfd, void * ptr)
3867
3804
{