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

« back to all changes in this revision

Viewing changes to bfd/xsym.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:
51
51
#define bfd_sym_bfd_link_hash_table_free            _bfd_generic_link_hash_table_free
52
52
#define bfd_sym_bfd_link_add_symbols                _bfd_generic_link_add_symbols
53
53
#define bfd_sym_bfd_link_just_syms                  _bfd_generic_link_just_syms
 
54
#define bfd_sym_bfd_copy_link_hash_symbol_type \
 
55
  _bfd_generic_copy_link_hash_symbol_type
54
56
#define bfd_sym_bfd_final_link                      _bfd_generic_final_link
55
57
#define bfd_sym_bfd_link_split_section              _bfd_generic_link_split_section
56
58
#define bfd_sym_get_section_contents_in_window      _bfd_generic_get_section_contents_in_window
82
84
compute_offset (unsigned long first_page,
83
85
                unsigned long page_size,
84
86
                unsigned long entry_size,
85
 
                unsigned long index)
 
87
                unsigned long sym_index)
86
88
{
87
89
  unsigned long entries_per_page = page_size / entry_size;
88
 
  unsigned long page_number = first_page + (index / entries_per_page);
89
 
  unsigned long page_offset = (index % entries_per_page) * entry_size;
 
90
  unsigned long page_number = first_page + (sym_index / entries_per_page);
 
91
  unsigned long page_offset = (sym_index % entries_per_page) * entry_size;
90
92
 
91
93
  return (page_number * page_size) + page_offset;
92
94
}
528
530
int
529
531
bfd_sym_fetch_resources_table_entry (bfd *abfd,
530
532
                                     bfd_sym_resources_table_entry *entry,
531
 
                                     unsigned long index)
 
533
                                     unsigned long sym_index)
532
534
{
533
535
  void (*parser) (unsigned char *, size_t, bfd_sym_resources_table_entry *);
534
536
  unsigned long offset;
540
542
  BFD_ASSERT (bfd_sym_valid (abfd));
541
543
  sdata = abfd->tdata.sym_data;
542
544
 
543
 
  if (index == 0)
 
545
  if (sym_index == 0)
544
546
    return -1;
545
547
 
546
548
  switch (sdata->version)
564
566
 
565
567
  offset = compute_offset (sdata->header.dshb_rte.dti_first_page,
566
568
                           sdata->header.dshb_page_size,
567
 
                           entry_size, index);
 
569
                           entry_size, sym_index);
568
570
 
569
571
  if (bfd_seek (abfd, offset, SEEK_SET) < 0)
570
572
    return -1;
579
581
int
580
582
bfd_sym_fetch_modules_table_entry (bfd *abfd,
581
583
                                   bfd_sym_modules_table_entry *entry,
582
 
                                   unsigned long index)
 
584
                                   unsigned long sym_index)
583
585
{
584
586
  void (*parser) (unsigned char *, size_t, bfd_sym_modules_table_entry *);
585
587
  unsigned long offset;
591
593
  BFD_ASSERT (bfd_sym_valid (abfd));
592
594
  sdata = abfd->tdata.sym_data;
593
595
 
594
 
  if (index == 0)
 
596
  if (sym_index == 0)
595
597
    return -1;
596
598
 
597
599
  switch (sdata->version)
615
617
 
616
618
  offset = compute_offset (sdata->header.dshb_mte.dti_first_page,
617
619
                           sdata->header.dshb_page_size,
618
 
                           entry_size, index);
 
620
                           entry_size, sym_index);
619
621
 
620
622
  if (bfd_seek (abfd, offset, SEEK_SET) < 0)
621
623
    return -1;
630
632
int
631
633
bfd_sym_fetch_file_references_table_entry (bfd *abfd,
632
634
                                           bfd_sym_file_references_table_entry *entry,
633
 
                                           unsigned long index)
 
635
                                           unsigned long sym_index)
634
636
{
635
637
  void (*parser) (unsigned char *, size_t, bfd_sym_file_references_table_entry *);
636
638
  unsigned long offset;
642
644
  BFD_ASSERT (bfd_sym_valid (abfd));
643
645
  sdata = abfd->tdata.sym_data;
644
646
 
645
 
  if (index == 0)
 
647
  if (sym_index == 0)
646
648
    return -1;
647
649
 
648
650
  switch (sdata->version)
665
667
 
666
668
  offset = compute_offset (sdata->header.dshb_frte.dti_first_page,
667
669
                           sdata->header.dshb_page_size,
668
 
                           entry_size, index);
 
670
                           entry_size, sym_index);
669
671
 
670
672
  if (bfd_seek (abfd, offset, SEEK_SET) < 0)
671
673
    return -1;
680
682
int
681
683
bfd_sym_fetch_contained_modules_table_entry (bfd *abfd,
682
684
                                             bfd_sym_contained_modules_table_entry *entry,
683
 
                                             unsigned long index)
 
685
                                             unsigned long sym_index)
684
686
{
685
687
  void (*parser) (unsigned char *, size_t, bfd_sym_contained_modules_table_entry *);
686
688
  unsigned long offset;
692
694
  BFD_ASSERT (bfd_sym_valid (abfd));
693
695
  sdata = abfd->tdata.sym_data;
694
696
 
695
 
  if (index == 0)
 
697
  if (sym_index == 0)
696
698
    return -1;
697
699
 
698
700
  switch (sdata->version)
715
717
 
716
718
  offset = compute_offset (sdata->header.dshb_cmte.dti_first_page,
717
719
                           sdata->header.dshb_page_size,
718
 
                           entry_size, index);
 
720
                           entry_size, sym_index);
719
721
 
720
722
  if (bfd_seek (abfd, offset, SEEK_SET) < 0)
721
723
    return -1;
730
732
int
731
733
bfd_sym_fetch_contained_variables_table_entry (bfd *abfd,
732
734
                                               bfd_sym_contained_variables_table_entry *entry,
733
 
                                               unsigned long index)
 
735
                                               unsigned long sym_index)
734
736
{
735
737
  void (*parser) (unsigned char *, size_t, bfd_sym_contained_variables_table_entry *);
736
738
  unsigned long offset;
742
744
  BFD_ASSERT (bfd_sym_valid (abfd));
743
745
  sdata = abfd->tdata.sym_data;
744
746
 
745
 
  if (index == 0)
 
747
  if (sym_index == 0)
746
748
    return -1;
747
749
 
748
750
  switch (sdata->version)
765
767
 
766
768
  offset = compute_offset (sdata->header.dshb_cvte.dti_first_page,
767
769
                           sdata->header.dshb_page_size,
768
 
                           entry_size, index);
 
770
                           entry_size, sym_index);
769
771
 
770
772
  if (bfd_seek (abfd, offset, SEEK_SET) < 0)
771
773
    return -1;
780
782
int
781
783
bfd_sym_fetch_contained_statements_table_entry (bfd *abfd,
782
784
                                                bfd_sym_contained_statements_table_entry *entry,
783
 
                                                unsigned long index)
 
785
                                                unsigned long sym_index)
784
786
{
785
787
  void (*parser) (unsigned char *, size_t, bfd_sym_contained_statements_table_entry *);
786
788
  unsigned long offset;
792
794
  BFD_ASSERT (bfd_sym_valid (abfd));
793
795
  sdata = abfd->tdata.sym_data;
794
796
 
795
 
  if (index == 0)
 
797
  if (sym_index == 0)
796
798
    return -1;
797
799
 
798
800
  switch (sdata->version)
815
817
 
816
818
  offset = compute_offset (sdata->header.dshb_csnte.dti_first_page,
817
819
                           sdata->header.dshb_page_size,
818
 
                           entry_size, index);
 
820
                           entry_size, sym_index);
819
821
 
820
822
  if (bfd_seek (abfd, offset, SEEK_SET) < 0)
821
823
    return -1;
830
832
int
831
833
bfd_sym_fetch_contained_labels_table_entry (bfd *abfd,
832
834
                                            bfd_sym_contained_labels_table_entry *entry,
833
 
                                            unsigned long index)
 
835
                                            unsigned long sym_index)
834
836
{
835
837
  void (*parser) (unsigned char *, size_t, bfd_sym_contained_labels_table_entry *);
836
838
  unsigned long offset;
842
844
  BFD_ASSERT (bfd_sym_valid (abfd));
843
845
  sdata = abfd->tdata.sym_data;
844
846
 
845
 
  if (index == 0)
 
847
  if (sym_index == 0)
846
848
    return -1;
847
849
 
848
850
  switch (sdata->version)
865
867
 
866
868
  offset = compute_offset (sdata->header.dshb_clte.dti_first_page,
867
869
                           sdata->header.dshb_page_size,
868
 
                           entry_size, index);
 
870
                           entry_size, sym_index);
869
871
 
870
872
  if (bfd_seek (abfd, offset, SEEK_SET) < 0)
871
873
    return -1;
880
882
int
881
883
bfd_sym_fetch_contained_types_table_entry (bfd *abfd,
882
884
                                           bfd_sym_contained_types_table_entry *entry,
883
 
                                           unsigned long index)
 
885
                                           unsigned long sym_index)
884
886
{
885
887
  void (*parser) (unsigned char *, size_t, bfd_sym_contained_types_table_entry *);
886
888
  unsigned long offset;
892
894
  BFD_ASSERT (bfd_sym_valid (abfd));
893
895
  sdata = abfd->tdata.sym_data;
894
896
 
895
 
  if (index == 0)
 
897
  if (sym_index == 0)
896
898
    return -1;
897
899
 
898
900
  switch (sdata->version)
915
917
 
916
918
  offset = compute_offset (sdata->header.dshb_ctte.dti_first_page,
917
919
                           sdata->header.dshb_page_size,
918
 
                           entry_size, index);
 
920
                           entry_size, sym_index);
919
921
 
920
922
  if (bfd_seek (abfd, offset, SEEK_SET) < 0)
921
923
    return -1;
930
932
int
931
933
bfd_sym_fetch_file_references_index_table_entry (bfd *abfd,
932
934
                                                 bfd_sym_file_references_index_table_entry *entry,
933
 
                                                 unsigned long index)
 
935
                                                 unsigned long sym_index)
934
936
{
935
937
  void (*parser) (unsigned char *, size_t, bfd_sym_file_references_index_table_entry *);
936
938
  unsigned long offset;
942
944
  BFD_ASSERT (bfd_sym_valid (abfd));
943
945
  sdata = abfd->tdata.sym_data;
944
946
 
945
 
  if (index == 0)
 
947
  if (sym_index == 0)
946
948
    return -1;
947
949
 
948
950
  switch (sdata->version)
965
967
 
966
968
  offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
967
969
                           sdata->header.dshb_page_size,
968
 
                           entry_size, index);
 
970
                           entry_size, sym_index);
969
971
 
970
972
  if (bfd_seek (abfd, offset, SEEK_SET) < 0)
971
973
    return -1;
980
982
int
981
983
bfd_sym_fetch_constant_pool_entry (bfd *abfd,
982
984
                                   bfd_sym_constant_pool_entry *entry,
983
 
                                   unsigned long index)
 
985
                                   unsigned long sym_index)
984
986
{
985
987
  void (*parser) (unsigned char *, size_t, bfd_sym_constant_pool_entry *);
986
988
  unsigned long offset;
992
994
  BFD_ASSERT (bfd_sym_valid (abfd));
993
995
  sdata = abfd->tdata.sym_data;
994
996
 
995
 
  if (index == 0)
 
997
  if (sym_index == 0)
996
998
    return -1;
997
999
 
998
1000
  switch (sdata->version)
1015
1017
 
1016
1018
  offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
1017
1019
                           sdata->header.dshb_page_size,
1018
 
                           entry_size, index);
 
1020
                           entry_size, sym_index);
1019
1021
 
1020
1022
  if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1021
1023
    return -1;
1030
1032
int
1031
1033
bfd_sym_fetch_type_table_entry (bfd *abfd,
1032
1034
                                bfd_sym_type_table_entry *entry,
1033
 
                                unsigned long index)
 
1035
                                unsigned long sym_index)
1034
1036
{
1035
1037
  void (*parser) (unsigned char *, size_t, bfd_sym_type_table_entry *);
1036
1038
  unsigned long offset;
1062
1064
 
1063
1065
  offset = compute_offset (sdata->header.dshb_tte.dti_first_page,
1064
1066
                           sdata->header.dshb_page_size,
1065
 
                           entry_size, index);
 
1067
                           entry_size, sym_index);
1066
1068
 
1067
1069
  if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1068
1070
    return -1;
1122
1124
int
1123
1125
bfd_sym_fetch_type_table_information (bfd *abfd,
1124
1126
                                      bfd_sym_type_information_table_entry *entry,
1125
 
                                      unsigned long index)
 
1127
                                      unsigned long sym_index)
1126
1128
{
1127
1129
  bfd_sym_type_table_entry tindex;
1128
1130
  bfd_sym_data_struct *sdata = NULL;
1132
1134
 
1133
1135
  if (sdata->header.dshb_tte.dti_object_count <= 99)
1134
1136
    return -1;
1135
 
  if (index < 100)
 
1137
  if (sym_index < 100)
1136
1138
    return -1;
1137
1139
 
1138
 
  if (bfd_sym_fetch_type_table_entry (abfd, &tindex, index - 100) < 0)
 
1140
  if (bfd_sym_fetch_type_table_entry (abfd, &tindex, sym_index - 100) < 0)
1139
1141
    return -1;
1140
1142
  if (bfd_sym_fetch_type_information_table_entry (abfd, entry, tindex) < 0)
1141
1143
    return -1;
1144
1146
}
1145
1147
 
1146
1148
const unsigned char *
1147
 
bfd_sym_symbol_name (bfd *abfd, unsigned long index)
 
1149
bfd_sym_symbol_name (bfd *abfd, unsigned long sym_index)
1148
1150
{
1149
1151
  bfd_sym_data_struct *sdata = NULL;
1150
1152
 
1151
1153
  BFD_ASSERT (bfd_sym_valid (abfd));
1152
1154
  sdata = abfd->tdata.sym_data;
1153
1155
 
1154
 
  if (index == 0)
 
1156
  if (sym_index == 0)
1155
1157
    return (const unsigned char *) "";
1156
1158
 
1157
 
  index *= 2;
1158
 
  if ((index / sdata->header.dshb_page_size)
 
1159
  sym_index *= 2;
 
1160
  if ((sym_index / sdata->header.dshb_page_size)
1159
1161
      > sdata->header.dshb_nte.dti_page_count)
1160
1162
    return (const unsigned char *) "\09[INVALID]";
1161
1163
 
1162
 
  return (const unsigned char *) sdata->name_table + index;
 
1164
  return (const unsigned char *) sdata->name_table + sym_index;
1163
1165
}
1164
1166
 
1165
1167
const unsigned char *
1166
 
bfd_sym_module_name (bfd *abfd, unsigned long index)
 
1168
bfd_sym_module_name (bfd *abfd, unsigned long sym_index)
1167
1169
{
1168
1170
  bfd_sym_modules_table_entry entry;
1169
1171
 
1170
 
  if (bfd_sym_fetch_modules_table_entry (abfd, &entry, index) < 0)
 
1172
  if (bfd_sym_fetch_modules_table_entry (abfd, &entry, sym_index) < 0)
1171
1173
    return (const unsigned char *) "\09[INVALID]";
1172
1174
 
1173
1175
  return bfd_sym_symbol_name (abfd, entry.mte_nte_index);
1857
1859
                                  FILE *f,
1858
1860
                                  unsigned char *entry)
1859
1861
{
1860
 
  unsigned long index;
 
1862
  unsigned long sym_index;
1861
1863
  unsigned long offset;
1862
1864
  bfd_sym_data_struct *sdata = NULL;
1863
1865
 
1864
1866
  BFD_ASSERT (bfd_sym_valid (abfd));
1865
1867
  sdata = abfd->tdata.sym_data;
1866
 
  index = (entry - sdata->name_table) / 2;
 
1868
  sym_index = (entry - sdata->name_table) / 2;
1867
1869
 
1868
1870
  if (sdata->version >= BFD_SYM_VERSION_3_4 && entry[0] == 255 && entry[1] == 0)
1869
1871
    {
1870
1872
      unsigned short length = bfd_getb16 (entry + 2);
1871
 
      fprintf (f, "[%8lu] \"%.*s\"\n", index, length, entry + 4);
 
1873
      fprintf (f, "[%8lu] \"%.*s\"\n", sym_index, length, entry + 4);
1872
1874
      offset = 2 + length + 1;
1873
1875
    }
1874
1876
  else
1875
1877
    {
1876
1878
      if (! (entry[0] == 0 || (entry[0] == 1 && entry[1] == '\0')))
1877
 
        fprintf (f, "[%8lu] \"%.*s\"\n", index, entry[0], entry + 1);
 
1879
        fprintf (f, "[%8lu] \"%.*s\"\n", sym_index, entry[0], entry + 1);
1878
1880
 
1879
1881
      if (sdata->version >= BFD_SYM_VERSION_3_4)
1880
1882
        offset = entry[0] + 2;
2176
2178
bfd_sym_display_type_information_table (bfd *abfd, FILE *f)
2177
2179
{
2178
2180
  unsigned long i;
2179
 
  bfd_sym_type_table_entry index;
 
2181
  bfd_sym_type_table_entry sym_index;
2180
2182
  bfd_sym_type_information_table_entry entry;
2181
2183
  bfd_sym_data_struct *sdata = NULL;
2182
2184
 
2194
2196
 
2195
2197
  for (i = 100; i <= sdata->header.dshb_tte.dti_object_count; i++)
2196
2198
    {
2197
 
      if (bfd_sym_fetch_type_table_entry (abfd, &index, i - 100) < 0)
 
2199
      if (bfd_sym_fetch_type_table_entry (abfd, &sym_index, i - 100) < 0)
2198
2200
        fprintf (f, " [%8lu] [INVALID]\n", i);
2199
2201
      else
2200
2202
        {
2201
 
          fprintf (f, " [%8lu] (TINFO %lu) ", i, index);
 
2203
          fprintf (f, " [%8lu] (TINFO %lu) ", i, sym_index);
2202
2204
 
2203
 
          if (bfd_sym_fetch_type_information_table_entry (abfd, &entry, index) < 0)
 
2205
          if (bfd_sym_fetch_type_information_table_entry (abfd, &entry, sym_index) < 0)
2204
2206
            fprintf (f, "[INVALID]");
2205
2207
          else
2206
2208
            bfd_sym_print_type_information_table_entry (abfd, f, &entry);