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

« back to all changes in this revision

Viewing changes to bfd/elf64-alpha.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
/* Alpha specific support for 64-bit ELF
2
2
   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
3
 
   2006, 2007, 2008 Free Software Foundation, Inc.
 
3
   2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
4
4
   Contributed by Richard Henderson <rth@tamu.edu>.
5
5
 
6
6
   This file is part of BFD, the Binary File Descriptor library.
103
103
 
104
104
#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so"
105
105
 
 
106
 
 
107
/* Used to implement multiple .got subsections.  */
 
108
struct alpha_elf_got_entry
 
109
{
 
110
  struct alpha_elf_got_entry *next;
 
111
 
 
112
  /* Which .got subsection?  */
 
113
  bfd *gotobj;
 
114
 
 
115
  /* The addend in effect for this entry.  */
 
116
  bfd_vma addend;
 
117
 
 
118
  /* The .got offset for this entry.  */
 
119
  int got_offset;
 
120
 
 
121
  /* The .plt offset for this entry.  */
 
122
  int plt_offset;
 
123
 
 
124
  /* How many references to this entry?  */
 
125
  int use_count;
 
126
 
 
127
  /* The relocation type of this entry.  */
 
128
  unsigned char reloc_type;
 
129
 
 
130
  /* How a LITERAL is used.  */
 
131
  unsigned char flags;
 
132
 
 
133
  /* Have we initialized the dynamic relocation for this entry?  */
 
134
  unsigned char reloc_done;
 
135
 
 
136
  /* Have we adjusted this entry for SEC_MERGE?  */
 
137
  unsigned char reloc_xlated;
 
138
};
 
139
 
 
140
struct alpha_elf_reloc_entry
 
141
{
 
142
  struct alpha_elf_reloc_entry *next;
 
143
 
 
144
  /* Which .reloc section? */
 
145
  asection *srel;
 
146
 
 
147
  /* What kind of relocation? */
 
148
  unsigned int rtype;
 
149
 
 
150
  /* Is this against read-only section? */
 
151
  unsigned int reltext : 1;
 
152
 
 
153
  /* How many did we find?  */
 
154
  unsigned long count;
 
155
};
 
156
 
106
157
struct alpha_elf_link_hash_entry
107
158
{
108
159
  struct elf_link_hash_entry root;
125
176
#define ALPHA_ELF_LINK_HASH_TLS_IE       0x80
126
177
 
127
178
  /* Used to implement multiple .got subsections.  */
128
 
  struct alpha_elf_got_entry
129
 
  {
130
 
    struct alpha_elf_got_entry *next;
131
 
 
132
 
    /* Which .got subsection?  */
133
 
    bfd *gotobj;
134
 
 
135
 
    /* The addend in effect for this entry.  */
136
 
    bfd_vma addend;
137
 
 
138
 
    /* The .got offset for this entry.  */
139
 
    int got_offset;
140
 
 
141
 
    /* The .plt offset for this entry.  */
142
 
    int plt_offset;
143
 
 
144
 
    /* How many references to this entry?  */
145
 
    int use_count;
146
 
 
147
 
    /* The relocation type of this entry.  */
148
 
    unsigned char reloc_type;
149
 
 
150
 
    /* How a LITERAL is used.  */
151
 
    unsigned char flags;
152
 
 
153
 
    /* Have we initialized the dynamic relocation for this entry?  */
154
 
    unsigned char reloc_done;
155
 
 
156
 
    /* Have we adjusted this entry for SEC_MERGE?  */
157
 
    unsigned char reloc_xlated;
158
 
  } *got_entries;
 
179
  struct alpha_elf_got_entry *got_entries;
159
180
 
160
181
  /* Used to count non-got, non-plt relocations for delayed sizing
161
182
     of relocation sections.  */
162
 
  struct alpha_elf_reloc_entry
163
 
  {
164
 
    struct alpha_elf_reloc_entry *next;
165
 
 
166
 
    /* Which .reloc section? */
167
 
    asection *srel;
168
 
 
169
 
    /* What kind of relocation? */
170
 
    unsigned int rtype;
171
 
 
172
 
    /* Is this against read-only section? */
173
 
    unsigned int reltext : 1;
174
 
 
175
 
    /* How many did we find?  */
176
 
    unsigned long count;
177
 
  } *reloc_entries;
 
183
  struct alpha_elf_reloc_entry *reloc_entries;
178
184
};
179
185
 
180
186
/* Alpha ELF linker hash table.  */
210
216
/* Get the Alpha ELF linker hash table from a link_info structure.  */
211
217
 
212
218
#define alpha_elf_hash_table(p) \
213
 
  ((struct alpha_elf_link_hash_table *) ((p)->hash))
 
219
  (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
 
220
  == ALPHA_ELF_DATA ? ((struct alpha_elf_link_hash_table *) ((p)->hash)) : NULL)
214
221
 
215
222
/* Get the object's symbols as our own entry type.  */
216
223
 
281
288
 
282
289
  if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
283
290
                                      elf64_alpha_link_hash_newfunc,
284
 
                                      sizeof (struct alpha_elf_link_hash_entry)))
 
291
                                      sizeof (struct alpha_elf_link_hash_entry),
 
292
                                      ALPHA_ELF_DATA))
285
293
    {
286
294
      free (ret);
287
295
      return NULL;
327
335
#define is_alpha_elf(bfd) \
328
336
  (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
329
337
   && elf_tdata (bfd) != NULL \
330
 
   && elf_object_id (bfd) == ALPHA_ELF_TDATA)
 
338
   && elf_object_id (bfd) == ALPHA_ELF_DATA)
331
339
 
332
340
static bfd_boolean
333
341
elf64_alpha_mkobject (bfd *abfd)
334
342
{
335
343
  return bfd_elf_allocate_object (abfd, sizeof (struct alpha_elf_obj_tdata),
336
 
                                  ALPHA_ELF_TDATA);
 
344
                                  ALPHA_ELF_DATA);
337
345
}
338
346
 
339
347
static bfd_boolean
458
466
   from smaller values.  Start with zero, widen, *then* decrement.  */
459
467
#define MINUS_ONE       (((bfd_vma)0) - 1)
460
468
 
 
469
 
461
470
#define SKIP_HOWTO(N) \
462
 
  HOWTO(N, 0, 0, 0, 0, 0, 0, elf64_alpha_reloc_bad, 0, 0, 0, 0, 0)
 
471
  HOWTO(N, 0, 0, 0, 0, 0, complain_overflow_dont, elf64_alpha_reloc_bad, 0, 0, 0, 0, 0)
463
472
 
464
473
static reloc_howto_type elf64_alpha_howto_table[] =
465
474
{
2315
2324
static void
2316
2325
elf64_alpha_calc_got_offsets (struct bfd_link_info *info)
2317
2326
{
2318
 
  bfd *i, *got_list = alpha_elf_hash_table(info)->got_list;
 
2327
  bfd *i, *got_list;
 
2328
  struct alpha_elf_link_hash_table * htab;
 
2329
 
 
2330
  htab = alpha_elf_hash_table (info);
 
2331
  if (htab == NULL)
 
2332
    return;
 
2333
  got_list = htab->got_list;
2319
2334
 
2320
2335
  /* First, zero out the .got sizes, as we may be recalculating the
2321
2336
     .got after optimizing it.  */
2323
2338
    alpha_elf_tdata(i)->got->size = 0;
2324
2339
 
2325
2340
  /* Next, fill in the offsets for all the global entries.  */
2326
 
  alpha_elf_link_hash_traverse (alpha_elf_hash_table (info),
 
2341
  alpha_elf_link_hash_traverse (htab,
2327
2342
                                elf64_alpha_calc_got_offsets_for_symbol,
2328
2343
                                NULL);
2329
2344
 
2361
2376
elf64_alpha_size_got_sections (struct bfd_link_info *info)
2362
2377
{
2363
2378
  bfd *i, *got_list, *cur_got_obj = NULL;
 
2379
  struct alpha_elf_link_hash_table * htab;
2364
2380
 
2365
 
  got_list = alpha_elf_hash_table (info)->got_list;
 
2381
  htab = alpha_elf_hash_table (info);
 
2382
  if (htab == NULL)
 
2383
    return FALSE;
 
2384
  got_list = htab->got_list;
2366
2385
 
2367
2386
  /* On the first time through, pretend we have an existing got list
2368
2387
     consisting of all of the input files.  */
2402
2421
      if (got_list == NULL)
2403
2422
        return TRUE;
2404
2423
 
2405
 
      alpha_elf_hash_table (info)->got_list = got_list;
 
2424
      htab->got_list = got_list;
2406
2425
    }
2407
2426
 
2408
2427
  cur_got_obj = got_list;
2473
2492
  asection *splt, *spltrel, *sgotplt;
2474
2493
  unsigned long entries;
2475
2494
  bfd *dynobj;
 
2495
  struct alpha_elf_link_hash_table * htab;
 
2496
 
 
2497
  htab = alpha_elf_hash_table (info);
 
2498
  if (htab == NULL)
 
2499
    return;
2476
2500
 
2477
2501
  dynobj = elf_hash_table(info)->dynobj;
2478
2502
  splt = bfd_get_section_by_name (dynobj, ".plt");
2481
2505
 
2482
2506
  splt->size = 0;
2483
2507
 
2484
 
  alpha_elf_link_hash_traverse (alpha_elf_hash_table (info),
 
2508
  alpha_elf_link_hash_traverse (htab,
2485
2509
                                elf64_alpha_size_plt_section_1, splt);
2486
2510
 
2487
2511
  /* Every plt entry requires a JMP_SLOT relocation.  */
2511
2535
                                  struct bfd_link_info *info)
2512
2536
{
2513
2537
  bfd *i;
 
2538
  struct alpha_elf_link_hash_table * htab;
2514
2539
 
2515
2540
  if (info->relocatable)
2516
2541
    return TRUE;
2517
2542
 
 
2543
  htab = alpha_elf_hash_table (info);
 
2544
  if (htab == NULL)
 
2545
    return FALSE;
 
2546
 
2518
2547
  /* First, take care of the indirect symbols created by versioning.  */
2519
 
  alpha_elf_link_hash_traverse (alpha_elf_hash_table (info),
2520
 
                                elf64_alpha_merge_ind_symbols,
 
2548
  alpha_elf_link_hash_traverse (htab, elf64_alpha_merge_ind_symbols,
2521
2549
                                NULL);
2522
2550
 
2523
2551
  if (!elf64_alpha_size_got_sections (info))
2524
2552
    return FALSE;
2525
2553
 
2526
2554
  /* Allocate space for all of the .got subsections.  */
2527
 
  i = alpha_elf_hash_table (info)->got_list;
 
2555
  i = htab->got_list;
2528
2556
  for ( ; i ; i = alpha_elf_tdata(i)->got_link_next)
2529
2557
    {
2530
2558
      asection *s = alpha_elf_tdata(i)->got;
2680
2708
  unsigned long entries;
2681
2709
  bfd *i, *dynobj;
2682
2710
  asection *srel;
 
2711
  struct alpha_elf_link_hash_table * htab;
 
2712
 
 
2713
  htab = alpha_elf_hash_table (info);
 
2714
  if (htab == NULL)
 
2715
    return;
2683
2716
 
2684
2717
  /* Shared libraries often require RELATIVE relocs, and some relocs
2685
2718
     require attention for the main application as well.  */
2686
2719
 
2687
2720
  entries = 0;
2688
 
  for (i = alpha_elf_hash_table(info)->got_list;
 
2721
  for (i = htab->got_list;
2689
2722
       i ; i = alpha_elf_tdata(i)->got_link_next)
2690
2723
    {
2691
2724
      bfd *j;
2718
2751
  srel->size = sizeof (Elf64_External_Rela) * entries;
2719
2752
 
2720
2753
  /* Now do the non-local symbols.  */
2721
 
  alpha_elf_link_hash_traverse (alpha_elf_hash_table (info),
 
2754
  alpha_elf_link_hash_traverse (htab,
2722
2755
                                elf64_alpha_size_rela_got_1, info);
2723
2756
}
2724
2757
 
2731
2764
  bfd *dynobj;
2732
2765
  asection *s;
2733
2766
  bfd_boolean relplt;
 
2767
  struct alpha_elf_link_hash_table * htab;
 
2768
 
 
2769
  htab = alpha_elf_hash_table (info);
 
2770
  if (htab == NULL)
 
2771
    return FALSE;
2734
2772
 
2735
2773
  dynobj = elf_hash_table(info)->dynobj;
2736
2774
  BFD_ASSERT(dynobj != NULL);
2750
2788
         symbols need dynamic relocation entries and which don't.  We've
2751
2789
         collected information in check_relocs that we can now apply to
2752
2790
         size the dynamic relocation sections.  */
2753
 
      alpha_elf_link_hash_traverse (alpha_elf_hash_table (info),
 
2791
      alpha_elf_link_hash_traverse (htab,
2754
2792
                                    elf64_alpha_calc_dynrel_sizes, info);
2755
2793
 
2756
2794
      elf64_alpha_size_rela_got_section (info);
3590
3628
  Elf_Internal_Sym *isymbuf = NULL;
3591
3629
  struct alpha_elf_got_entry **local_got_entries;
3592
3630
  struct alpha_relax_info info;
 
3631
  struct alpha_elf_link_hash_table * htab;
 
3632
 
 
3633
  htab = alpha_elf_hash_table (link_info);
 
3634
  if (htab == NULL)
 
3635
    return FALSE;
3593
3636
 
3594
3637
  /* There's nothing to change, yet.  */
3595
3638
  *again = FALSE;
3603
3646
  BFD_ASSERT (is_alpha_elf (abfd));
3604
3647
 
3605
3648
  /* Make sure our GOT and PLT tables are up-to-date.  */
3606
 
  if (alpha_elf_hash_table(link_info)->relax_trip != link_info->relax_trip)
 
3649
  if (htab->relax_trip != link_info->relax_trip)
3607
3650
    {
3608
 
      alpha_elf_hash_table(link_info)->relax_trip = link_info->relax_trip;
 
3651
      htab->relax_trip = link_info->relax_trip;
3609
3652
 
3610
3653
      /* This should never fail after the initial round, since the only
3611
3654
         error is GOT overflow, and relaxation only shrinks the table.  */
4926
4969
  const struct ecoff_debug_swap *swap
4927
4970
    = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
4928
4971
  HDRR *symhdr = &debug.symbolic_header;
4929
 
  PTR mdebug_handle = NULL;
 
4972
  void * mdebug_handle = NULL;
 
4973
  struct alpha_elf_link_hash_table * htab;
 
4974
 
 
4975
  htab = alpha_elf_hash_table (info);
 
4976
  if (htab == NULL)
 
4977
    return FALSE;
4930
4978
 
4931
4979
  /* Go through the sections and collect the mdebug information.  */
4932
4980
  mdebug_sec = NULL;
5062
5110
                 interesting information, try to find the symbol in
5063
5111
                 the linker global hash table and save the information
5064
5112
                 for the output external symbols.  */
5065
 
              eraw_src = input_debug.external_ext;
 
5113
              eraw_src = (char *) input_debug.external_ext;
5066
5114
              eraw_end = (eraw_src
5067
5115
                          + (input_debug.symbolic_header.iextMax
5068
5116
                             * input_swap->external_ext_size));
5081
5129
                    continue;
5082
5130
 
5083
5131
                  name = input_debug.ssext + ext.asym.iss;
5084
 
                  h = alpha_elf_link_hash_lookup (alpha_elf_hash_table (info),
5085
 
                                                  name, FALSE, FALSE, TRUE);
 
5132
                  h = alpha_elf_link_hash_lookup (htab, name, FALSE, FALSE, TRUE);
5086
5133
                  if (h == NULL || h->esym.ifd != -2)
5087
5134
                    continue;
5088
5135
 
5146
5193
  /* The .got subsections...  */
5147
5194
  {
5148
5195
    bfd *i, *dynobj = elf_hash_table(info)->dynobj;
5149
 
    for (i = alpha_elf_hash_table(info)->got_list;
 
5196
    for (i = htab->got_list;
5150
5197
         i != NULL;
5151
5198
         i = alpha_elf_tdata(i)->got_link_next)
5152
5199
      {