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

« back to all changes in this revision

Viewing changes to bfd/elf32-arm.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 ARM
2
2
   Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
3
 
   2008, 2009  Free Software Foundation, Inc.
 
3
   2008, 2009, 2010  Free Software Foundation, Inc.
4
4
 
5
5
   This file is part of BFD, the Binary File Descriptor library.
6
6
 
61
61
#define ARM_ELF_ABI_VERSION             0
62
62
#define ARM_ELF_OS_ABI_VERSION          ELFOSABI_ARM
63
63
 
64
 
static struct elf_backend_data elf32_arm_vxworks_bed;
65
 
 
66
64
static bfd_boolean elf32_arm_write_section (bfd *output_bfd,
67
65
                                            struct bfd_link_info *link_info,
68
66
                                            asection *sec,
224
222
  HOWTO (R_ARM_THM_CALL,        /* type */
225
223
         1,                     /* rightshift */
226
224
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
227
 
         25,                    /* bitsize */
 
225
         24,                    /* bitsize */
228
226
         TRUE,                  /* pc_relative */
229
227
         0,                     /* bitpos */
230
228
         complain_overflow_signed,/* complain_on_overflow */
2441
2439
#define is_arm_elf(bfd) \
2442
2440
  (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
2443
2441
   && elf_tdata (bfd) != NULL \
2444
 
   && elf_object_id (bfd) == ARM_ELF_TDATA)
 
2442
   && elf_object_id (bfd) == ARM_ELF_DATA)
2445
2443
 
2446
2444
static bfd_boolean
2447
2445
elf32_arm_mkobject (bfd *abfd)
2448
2446
{
2449
2447
  return bfd_elf_allocate_object (abfd, sizeof (struct elf_arm_obj_tdata),
2450
 
                                  ARM_ELF_TDATA);
 
2448
                                  ARM_ELF_DATA);
2451
2449
}
2452
2450
 
2453
2451
/* The ARM linker needs to keep track of the number of relocs that it
2517
2515
 
2518
2516
/* Get the ARM elf linker hash table from a link_info structure.  */
2519
2517
#define elf32_arm_hash_table(info) \
2520
 
  ((struct elf32_arm_link_hash_table *) ((info)->hash))
 
2518
  (elf_hash_table_id ((struct elf_link_hash_table *) ((info)->hash)) \
 
2519
  == ARM_ELF_DATA ? ((struct elf32_arm_link_hash_table *) ((info)->hash)) : NULL)
2521
2520
 
2522
2521
#define arm_stub_hash_lookup(table, string, create, copy) \
2523
2522
  ((struct elf32_arm_stub_hash_entry *) \
2524
2523
   bfd_hash_lookup ((table), (string), (create), (copy)))
2525
2524
 
 
2525
/* Array to keep track of which stub sections have been created, and
 
2526
   information on stub grouping.  */
 
2527
struct map_stub
 
2528
{
 
2529
  /* This is the section to which stubs in the group will be
 
2530
     attached.  */
 
2531
  asection *link_sec;
 
2532
  /* The stub section.  */
 
2533
  asection *stub_sec;
 
2534
};
 
2535
 
2526
2536
/* ARM ELF linker hash table.  */
2527
2537
struct elf32_arm_link_hash_table
2528
2538
{
2638
2648
 
2639
2649
  /* Array to keep track of which stub sections have been created, and
2640
2650
     information on stub grouping.  */
2641
 
  struct map_stub
2642
 
  {
2643
 
    /* This is the section to which stubs in the group will be
2644
 
       attached.  */
2645
 
    asection *link_sec;
2646
 
    /* The stub section.  */
2647
 
    asection *stub_sec;
2648
 
  } *stub_group;
 
2651
  struct map_stub *stub_group;
2649
2652
 
2650
2653
  /* Assorted information used by elf32_arm_size_stubs.  */
2651
2654
  unsigned int bfd_count;
2666
2669
  /* Allocate the structure if it has not already been allocated by a
2667
2670
     subclass.  */
2668
2671
  if (ret == NULL)
2669
 
    ret = bfd_hash_allocate (table, sizeof (struct elf32_arm_link_hash_entry));
 
2672
    ret = (struct elf32_arm_link_hash_entry *)
 
2673
        bfd_hash_allocate (table, sizeof (struct elf32_arm_link_hash_entry));
2670
2674
  if (ret == NULL)
2671
2675
    return (struct bfd_hash_entry *) ret;
2672
2676
 
2700
2704
     subclass.  */
2701
2705
  if (entry == NULL)
2702
2706
    {
2703
 
      entry = bfd_hash_allocate (table,
2704
 
                                 sizeof (struct elf32_arm_stub_hash_entry));
 
2707
      entry = (struct bfd_hash_entry *)
 
2708
          bfd_hash_allocate (table, sizeof (struct elf32_arm_stub_hash_entry));
2705
2709
      if (entry == NULL)
2706
2710
        return entry;
2707
2711
    }
2741
2745
  struct elf32_arm_link_hash_table *htab;
2742
2746
 
2743
2747
  htab = elf32_arm_hash_table (info);
 
2748
  if (htab == NULL)
 
2749
    return FALSE;
 
2750
 
2744
2751
  /* BPABI objects never have a GOT, or associated sections.  */
2745
2752
  if (htab->symbian_p)
2746
2753
    return TRUE;
2770
2777
  struct elf32_arm_link_hash_table *htab;
2771
2778
 
2772
2779
  htab = elf32_arm_hash_table (info);
 
2780
  if (htab == NULL)
 
2781
    return FALSE;
 
2782
 
2773
2783
  if (!htab->sgot && !create_got_section (dynobj, info))
2774
2784
    return FALSE;
2775
2785
 
2882
2892
  struct elf32_arm_link_hash_table *ret;
2883
2893
  bfd_size_type amt = sizeof (struct elf32_arm_link_hash_table);
2884
2894
 
2885
 
  ret = bfd_malloc (amt);
 
2895
  ret = (struct elf32_arm_link_hash_table *) bfd_malloc (amt);
2886
2896
  if (ret == NULL)
2887
2897
    return NULL;
2888
2898
 
2889
2899
  if (!_bfd_elf_link_hash_table_init (& ret->root, abfd,
2890
2900
                                      elf32_arm_link_hash_newfunc,
2891
 
                                      sizeof (struct elf32_arm_link_hash_entry)))
 
2901
                                      sizeof (struct elf32_arm_link_hash_entry),
 
2902
                                      ARM_ELF_DATA))
2892
2903
    {
2893
2904
      free (ret);
2894
2905
      return NULL;
2968
2979
                                       Tag_CPU_arch);
2969
2980
  int profile;
2970
2981
 
2971
 
  if (arch != TAG_CPU_ARCH_V7)
 
2982
  if (arch != TAG_CPU_ARCH_V7 && arch != TAG_CPU_ARCH_V7E_M)
2972
2983
    return FALSE;
2973
2984
 
2974
2985
  profile = bfd_elf_get_obj_attr_int (globals->obfd, OBJ_ATTR_PROC,
2996
3007
                                             Tag_CPU_arch);
2997
3008
  return arch == TAG_CPU_ARCH_V6T2
2998
3009
         || arch == TAG_CPU_ARCH_V6K
2999
 
         || arch == TAG_CPU_ARCH_V7;
 
3010
         || arch == TAG_CPU_ARCH_V7
 
3011
         || arch == TAG_CPU_ARCH_V7E_M;
3000
3012
}
3001
3013
 
3002
3014
static bfd_boolean
3004
3016
{
3005
3017
  const int arch = bfd_elf_get_obj_attr_int (globals->obfd, OBJ_ATTR_PROC,
3006
3018
                                             Tag_CPU_arch);
3007
 
  return arch == TAG_CPU_ARCH_V6T2 || arch == TAG_CPU_ARCH_V7;
 
3019
  return (arch == TAG_CPU_ARCH_V6T2 || arch == TAG_CPU_ARCH_V7
 
3020
          || arch == TAG_CPU_ARCH_V7E_M);
3008
3021
}
3009
3022
 
3010
3023
static bfd_boolean
3055
3068
    return stub_type;
3056
3069
 
3057
3070
  globals = elf32_arm_hash_table (info);
 
3071
  if (globals == NULL)
 
3072
    return stub_type;
3058
3073
 
3059
3074
  thumb_only = using_thumb_only (globals);
3060
3075
 
3248
3263
  if (hash)
3249
3264
    {
3250
3265
      len = 8 + 1 + strlen (hash->root.root.root.string) + 1 + 8 + 1;
3251
 
      stub_name = bfd_malloc (len);
 
3266
      stub_name = (char *) bfd_malloc (len);
3252
3267
      if (stub_name != NULL)
3253
3268
        sprintf (stub_name, "%08x_%s+%x",
3254
3269
                 input_section->id & 0xffffffff,
3258
3273
  else
3259
3274
    {
3260
3275
      len = 8 + 1 + 8 + 1 + 8 + 1 + 8 + 1;
3261
 
      stub_name = bfd_malloc (len);
 
3276
      stub_name = (char *) bfd_malloc (len);
3262
3277
      if (stub_name != NULL)
3263
3278
        sprintf (stub_name, "%08x_%x:%x+%x",
3264
3279
                 input_section->id & 0xffffffff,
3343
3358
 
3344
3359
          namelen = strlen (link_sec->name);
3345
3360
          len = namelen + sizeof (STUB_SUFFIX);
3346
 
          s_name = bfd_alloc (htab->stub_bfd, len);
 
3361
          s_name = (char *) bfd_alloc (htab->stub_bfd, len);
3347
3362
          if (s_name == NULL)
3348
3363
            return NULL;
3349
3364
 
3434
3449
{
3435
3450
#define MAXRELOCS 2
3436
3451
  struct elf32_arm_stub_hash_entry *stub_entry;
 
3452
  struct elf32_arm_link_hash_table *globals;
3437
3453
  struct bfd_link_info *info;
3438
 
  struct elf32_arm_link_hash_table *htab;
3439
3454
  asection *stub_sec;
3440
3455
  bfd *stub_bfd;
3441
3456
  bfd_vma stub_addr;
3445
3460
  int size;
3446
3461
  const insn_sequence *template_sequence;
3447
3462
  int i;
3448
 
  struct elf32_arm_link_hash_table * globals;
3449
3463
  int stub_reloc_idx[MAXRELOCS] = {-1, -1};
3450
3464
  int stub_reloc_offset[MAXRELOCS] = {0, 0};
3451
3465
  int nrelocs = 0;
3455
3469
  info = (struct bfd_link_info *) in_arg;
3456
3470
 
3457
3471
  globals = elf32_arm_hash_table (info);
 
3472
  if (globals == NULL)
 
3473
    return FALSE;
3458
3474
 
3459
 
  htab = elf32_arm_hash_table (info);
3460
3475
  stub_sec = stub_entry->stub_sec;
3461
3476
 
3462
 
  if ((htab->fix_cortex_a8 < 0)
 
3477
  if ((globals->fix_cortex_a8 < 0)
3463
3478
      != (stub_entry->stub_type >= arm_stub_a8_veneer_lwm))
3464
3479
    /* We have to do the a8 fixes last, as they are less aligned than
3465
3480
       the other veneers.  */
3705
3720
  bfd_size_type amt;
3706
3721
  struct elf32_arm_link_hash_table *htab = elf32_arm_hash_table (info);
3707
3722
 
 
3723
  if (htab == NULL)
 
3724
    return 0;
3708
3725
  if (! is_elf_hash_table (htab))
3709
3726
    return 0;
3710
3727
 
3725
3742
  htab->bfd_count = bfd_count;
3726
3743
 
3727
3744
  amt = sizeof (struct map_stub) * (top_id + 1);
3728
 
  htab->stub_group = bfd_zmalloc (amt);
 
3745
  htab->stub_group = (struct map_stub *) bfd_zmalloc (amt);
3729
3746
  if (htab->stub_group == NULL)
3730
3747
    return -1;
3731
3748
 
3742
3759
 
3743
3760
  htab->top_index = top_index;
3744
3761
  amt = sizeof (asection *) * (top_index + 1);
3745
 
  input_list = bfd_malloc (amt);
 
3762
  input_list = (asection **) bfd_malloc (amt);
3746
3763
  htab->input_list = input_list;
3747
3764
  if (input_list == NULL)
3748
3765
    return -1;
3776
3793
{
3777
3794
  struct elf32_arm_link_hash_table *htab = elf32_arm_hash_table (info);
3778
3795
 
 
3796
  if (htab == NULL)
 
3797
    return;
 
3798
 
3779
3799
  if (isec->output_section->index <= htab->top_index)
3780
3800
    {
3781
3801
      asection **list = htab->input_list + isec->output_section->index;
3782
3802
 
3783
 
      if (*list != bfd_abs_section_ptr)
 
3803
      if (*list != bfd_abs_section_ptr && (isec->flags & SEC_CODE) != 0)
3784
3804
        {
3785
3805
          /* Steal the link_sec pointer for our list.  */
3786
3806
#define PREV_SEC(sec) (htab->stub_group[(sec)->id].link_sec)
3899
3919
static int
3900
3920
a8_reloc_compare (const void *a, const void *b)
3901
3921
{
3902
 
  const struct a8_erratum_reloc *ra = a, *rb = b;
 
3922
  const struct a8_erratum_reloc *ra = (const struct a8_erratum_reloc *) a;
 
3923
  const struct a8_erratum_reloc *rb = (const struct a8_erratum_reloc *) b;
3903
3924
 
3904
3925
  if (ra->from < rb->from)
3905
3926
    return -1;
3934
3955
  unsigned int num_a8_fixes = *num_a8_fixes_p;
3935
3956
  unsigned int a8_fix_table_size = *a8_fix_table_size_p;
3936
3957
 
 
3958
  if (htab == NULL)
 
3959
    return FALSE;
 
3960
 
3937
3961
  for (section = input_bfd->sections;
3938
3962
       section != NULL;
3939
3963
       section = section->next)
4024
4048
                  struct a8_erratum_reloc key, *found;
4025
4049
 
4026
4050
                  key.from = base_vma + i;
4027
 
                  found = bsearch (&key, a8_relocs, num_a8_relocs,
4028
 
                                   sizeof (struct a8_erratum_reloc),
4029
 
                                   &a8_reloc_compare);
 
4051
                  found = (struct a8_erratum_reloc *)
 
4052
                      bsearch (&key, a8_relocs, num_a8_relocs,
 
4053
                               sizeof (struct a8_erratum_reloc),
 
4054
                               &a8_reloc_compare);
4030
4055
 
4031
4056
                  if (found)
4032
4057
                    {
4143
4168
                          if (num_a8_fixes == a8_fix_table_size)
4144
4169
                            {
4145
4170
                              a8_fix_table_size *= 2;
4146
 
                              a8_fixes = bfd_realloc (a8_fixes,
4147
 
                                sizeof (struct a8_erratum_fix)
4148
 
                                * a8_fix_table_size);
 
4171
                              a8_fixes = (struct a8_erratum_fix *)
 
4172
                                  bfd_realloc (a8_fixes,
 
4173
                                               sizeof (struct a8_erratum_fix)
 
4174
                                               * a8_fix_table_size);
4149
4175
                            }
4150
4176
 
4151
4177
                          if (num_a8_fixes < prev_num_a8_fixes)
4166
4192
 
4167
4193
                          if (!stub_name)
4168
4194
                            {
4169
 
                              stub_name = bfd_malloc (8 + 1 + 8 + 1);
 
4195
                              stub_name = (char *) bfd_malloc (8 + 1 + 8 + 1);
4170
4196
                              if (stub_name != NULL)
4171
4197
                                sprintf (stub_name, "%x:%x", section->id, i);
4172
4198
                            }
4223
4249
  struct a8_erratum_reloc *a8_relocs = NULL;
4224
4250
  unsigned int num_a8_relocs = 0, a8_reloc_table_size = 10, i;
4225
4251
 
 
4252
  if (htab == NULL)
 
4253
    return FALSE;
 
4254
 
4226
4255
  if (htab->fix_cortex_a8)
4227
4256
    {
4228
 
      a8_fixes = bfd_zmalloc (sizeof (struct a8_erratum_fix)
4229
 
                              * a8_fix_table_size);
4230
 
      a8_relocs = bfd_zmalloc (sizeof (struct a8_erratum_reloc)
4231
 
                               * a8_reloc_table_size);
 
4257
      a8_fixes = (struct a8_erratum_fix *)
 
4258
          bfd_zmalloc (sizeof (struct a8_erratum_fix) * a8_fix_table_size);
 
4259
      a8_relocs = (struct a8_erratum_reloc *)
 
4260
          bfd_zmalloc (sizeof (struct a8_erratum_reloc) * a8_reloc_table_size);
4232
4261
    }
4233
4262
 
4234
4263
  /* Propagate mach to stub bfd, because it may not have been
4442
4471
                             use the PLT stub as target address to
4443
4472
                             decide whether a branch stub is
4444
4473
                             needed.  */
4445
 
                          if (globals->splt != NULL && hash != NULL
 
4474
                          if (globals != NULL
 
4475
                              && globals->splt != NULL
 
4476
                              && hash != NULL
4446
4477
                              && hash->root.plt.offset != (bfd_vma) -1)
4447
4478
                            {
4448
4479
                              sym_sec = globals->splt;
4467
4498
                          struct elf32_arm_link_hash_table *globals =
4468
4499
                            elf32_arm_hash_table (info);
4469
4500
 
4470
 
                          if (globals->splt != NULL && hash != NULL
 
4501
                          if (globals != NULL
 
4502
                              && globals->splt != NULL
 
4503
                              && hash != NULL
4471
4504
                              && hash->root.plt.offset != (bfd_vma) -1)
4472
4505
                            {
4473
4506
                              sym_sec = globals->splt;
4539
4572
 
4540
4573
                      if (sym_name == NULL)
4541
4574
                        sym_name = "unnamed";
4542
 
                      stub_entry->output_name
4543
 
                        = bfd_alloc (htab->stub_bfd,
 
4575
                      stub_entry->output_name = (char *)
 
4576
                          bfd_alloc (htab->stub_bfd,
4544
4577
                                     sizeof (THUMB2ARM_GLUE_ENTRY_NAME)
4545
4578
                                     + strlen (sym_name));
4546
4579
                      if (stub_entry->output_name == NULL)
4591
4624
                          if (num_a8_relocs == a8_reloc_table_size)
4592
4625
                            {
4593
4626
                              a8_reloc_table_size *= 2;
4594
 
                              a8_relocs = bfd_realloc (a8_relocs,
4595
 
                                sizeof (struct a8_erratum_reloc)
4596
 
                                * a8_reloc_table_size);
 
4627
                              a8_relocs = (struct a8_erratum_reloc *)
 
4628
                                  bfd_realloc (a8_relocs,
 
4629
                                               sizeof (struct a8_erratum_reloc)
 
4630
                                               * a8_reloc_table_size);
4597
4631
                            }
4598
4632
 
4599
4633
                          a8_relocs[num_a8_relocs].from = from;
4744
4778
  struct elf32_arm_link_hash_table *htab;
4745
4779
 
4746
4780
  htab = elf32_arm_hash_table (info);
 
4781
  if (htab == NULL)
 
4782
    return FALSE;
4747
4783
 
4748
4784
  for (stub_sec = htab->stub_bfd->sections;
4749
4785
       stub_sec != NULL;
4757
4793
 
4758
4794
      /* Allocate memory to hold the linker stubs.  */
4759
4795
      size = stub_sec->size;
4760
 
      stub_sec->contents = bfd_zalloc (htab->stub_bfd, size);
 
4796
      stub_sec->contents = (unsigned char *) bfd_zalloc (htab->stub_bfd, size);
4761
4797
      if (stub_sec->contents == NULL && size != 0)
4762
4798
        return FALSE;
4763
4799
      stub_sec->size = 0;
4789
4825
 
4790
4826
  /* We need a pointer to the armelf specific hash table.  */
4791
4827
  hash_table = elf32_arm_hash_table (link_info);
 
4828
  if (hash_table == NULL)
 
4829
    return NULL;
4792
4830
 
4793
 
  tmp_name = bfd_malloc ((bfd_size_type) strlen (name)
4794
 
                         + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1);
 
4831
  tmp_name = (char *) bfd_malloc ((bfd_size_type) strlen (name)
 
4832
                                  + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1);
4795
4833
 
4796
4834
  BFD_ASSERT (tmp_name);
4797
4835
 
4823
4861
 
4824
4862
  /* We need a pointer to the elfarm specific hash table.  */
4825
4863
  hash_table = elf32_arm_hash_table (link_info);
 
4864
  if (hash_table == NULL)
 
4865
    return NULL;
4826
4866
 
4827
 
  tmp_name = bfd_malloc ((bfd_size_type) strlen (name)
4828
 
                         + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1);
 
4867
  tmp_name = (char *) bfd_malloc ((bfd_size_type) strlen (name)
 
4868
                                  + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1);
4829
4869
 
4830
4870
  BFD_ASSERT (tmp_name);
4831
4871
 
4935
4975
  s = bfd_get_section_by_name (abfd, name);
4936
4976
  BFD_ASSERT (s != NULL);
4937
4977
 
4938
 
  contents = bfd_alloc (abfd, size);
 
4978
  contents = (bfd_byte *) bfd_alloc (abfd, size);
4939
4979
 
4940
4980
  BFD_ASSERT (s->size == size);
4941
4981
  s->contents = contents;
4985
5025
  bfd_size_type size;
4986
5026
 
4987
5027
  globals = elf32_arm_hash_table (link_info);
4988
 
 
4989
5028
  BFD_ASSERT (globals != NULL);
4990
5029
  BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
4991
5030
 
4994
5033
 
4995
5034
  BFD_ASSERT (s != NULL);
4996
5035
 
4997
 
  tmp_name = bfd_malloc ((bfd_size_type) strlen (name) + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1);
 
5036
  tmp_name = (char *) bfd_malloc ((bfd_size_type) strlen (name)
 
5037
                                  + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1);
4998
5038
 
4999
5039
  BFD_ASSERT (tmp_name);
5000
5040
 
5057
5097
    return;
5058
5098
 
5059
5099
  globals = elf32_arm_hash_table (link_info);
5060
 
 
5061
5100
  BFD_ASSERT (globals != NULL);
5062
5101
  BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
5063
5102
 
5071
5110
  BFD_ASSERT (s != NULL);
5072
5111
 
5073
5112
  /* Add symbol for veneer.  */
5074
 
  tmp_name = bfd_malloc ((bfd_size_type) strlen (ARM_BX_GLUE_ENTRY_NAME) + 1);
 
5113
  tmp_name = (char *)
 
5114
      bfd_malloc ((bfd_size_type) strlen (ARM_BX_GLUE_ENTRY_NAME) + 1);
5075
5115
 
5076
5116
  BFD_ASSERT (tmp_name);
5077
5117
 
5108
5148
 
5109
5149
  if (sec_data->map == NULL)
5110
5150
    {
5111
 
      sec_data->map = bfd_malloc (sizeof (elf32_arm_section_map));
 
5151
      sec_data->map = (elf32_arm_section_map *)
 
5152
          bfd_malloc (sizeof (elf32_arm_section_map));
5112
5153
      sec_data->mapcount = 0;
5113
5154
      sec_data->mapsize = 1;
5114
5155
    }
5118
5159
  if (sec_data->mapcount > sec_data->mapsize)
5119
5160
    {
5120
5161
      sec_data->mapsize *= 2;
5121
 
      sec_data->map = bfd_realloc_or_free (sec_data->map, sec_data->mapsize
5122
 
                                           * sizeof (elf32_arm_section_map));
 
5162
      sec_data->map = (elf32_arm_section_map *)
 
5163
          bfd_realloc_or_free (sec_data->map, sec_data->mapsize
 
5164
                               * sizeof (elf32_arm_section_map));
5123
5165
    }
5124
5166
 
5125
5167
  if (sec_data->map)
5151
5193
  elf32_vfp11_erratum_list *newerr;
5152
5194
 
5153
5195
  hash_table = elf32_arm_hash_table (link_info);
5154
 
 
5155
5196
  BFD_ASSERT (hash_table != NULL);
5156
5197
  BFD_ASSERT (hash_table->bfd_of_glue_owner != NULL);
5157
5198
 
5162
5203
 
5163
5204
  BFD_ASSERT (s != NULL);
5164
5205
 
5165
 
  tmp_name = bfd_malloc ((bfd_size_type) strlen
5166
 
                         (VFP11_ERRATUM_VENEER_ENTRY_NAME) + 10);
 
5206
  tmp_name = (char *) bfd_malloc ((bfd_size_type) strlen
 
5207
                                  (VFP11_ERRATUM_VENEER_ENTRY_NAME) + 10);
5167
5208
 
5168
5209
  BFD_ASSERT (tmp_name);
5169
5210
 
5187
5228
 
5188
5229
  /* Link veneer back to calling location.  */
5189
5230
  errcount = ++(sec_data->erratumcount);
5190
 
  newerr = bfd_zmalloc (sizeof (elf32_vfp11_erratum_list));
 
5231
  newerr = (elf32_vfp11_erratum_list *)
 
5232
      bfd_zmalloc (sizeof (elf32_vfp11_erratum_list));
5191
5233
 
5192
5234
  newerr->type = VFP11_ERRATUM_ARM_VENEER;
5193
5235
  newerr->vma = -1;
5315
5357
  BFD_ASSERT (!(abfd->flags & DYNAMIC));
5316
5358
 
5317
5359
  globals = elf32_arm_hash_table (info);
5318
 
 
5319
5360
  BFD_ASSERT (globals != NULL);
5320
5361
 
5321
5362
  if (globals->bfd_of_glue_owner != NULL)
5355
5396
  /* Here we have a bfd that is to be included on the link.  We have a
5356
5397
     hook to do reloc rummaging, before section sizes are nailed down.  */
5357
5398
  globals = elf32_arm_hash_table (link_info);
5358
 
 
5359
5399
  BFD_ASSERT (globals != NULL);
5360
5400
 
5361
5401
  check_use_blx (globals);
5556
5596
  struct elf32_arm_link_hash_table *globals = elf32_arm_hash_table (link_info);
5557
5597
  obj_attribute *out_attr = elf_known_obj_attributes_proc (obfd);
5558
5598
 
 
5599
  if (globals == NULL)
 
5600
    return;
 
5601
 
5559
5602
  if (globals->fix_cortex_a8 == -1)
5560
5603
    {
5561
5604
      /* Turn on Cortex-A8 erratum workaround for ARMv7-A.  */
5575
5618
  struct elf32_arm_link_hash_table *globals = elf32_arm_hash_table (link_info);
5576
5619
  obj_attribute *out_attr = elf_known_obj_attributes_proc (obfd);
5577
5620
 
 
5621
  if (globals == NULL)
 
5622
    return;
5578
5623
  /* We assume that ARMv7+ does not need the VFP11 denorm erratum fix.  */
5579
5624
  if (out_attr[Tag_CPU_arch].i >= TAG_CPU_ARCH_V7)
5580
5625
    {
5679
5724
bfd_arm_vfp11_insn_decode (unsigned int insn, unsigned int *destmask, int *regs,
5680
5725
                           int *numregs)
5681
5726
{
5682
 
  enum bfd_arm_vfp11_pipe pipe = VFP11_BAD;
 
5727
  enum bfd_arm_vfp11_pipe vpipe = VFP11_BAD;
5683
5728
  bfd_boolean is_double = ((insn & 0xf00) == 0xb00) ? 1 : 0;
5684
5729
 
5685
5730
  if ((insn & 0x0f000e10) == 0x0e000a00)  /* A data-processing insn.  */
5698
5743
        case 1: /* fnmac[sd].  */
5699
5744
        case 2: /* fmsc[sd].  */
5700
5745
        case 3: /* fnmsc[sd].  */
5701
 
          pipe = VFP11_FMAC;
 
5746
          vpipe = VFP11_FMAC;
5702
5747
          bfd_arm_vfp11_write_mask (destmask, fd);
5703
5748
          regs[0] = fd;
5704
5749
          regs[1] = bfd_arm_vfp11_regno (insn, is_double, 16, 7);  /* Fn.  */
5710
5755
        case 5: /* fnmul[sd].  */
5711
5756
        case 6: /* fadd[sd].  */
5712
5757
        case 7: /* fsub[sd].  */
5713
 
          pipe = VFP11_FMAC;
 
5758
          vpipe = VFP11_FMAC;
5714
5759
          goto vfp_binop;
5715
5760
 
5716
5761
        case 8: /* fdiv[sd].  */
5717
 
          pipe = VFP11_DS;
 
5762
          vpipe = VFP11_DS;
5718
5763
          vfp_binop:
5719
5764
          bfd_arm_vfp11_write_mask (destmask, fd);
5720
5765
          regs[0] = bfd_arm_vfp11_regno (insn, is_double, 16, 7);   /* Fn.  */
5744
5789
              case 27: /* ftosiz[sd].  */
5745
5790
                /* These instructions will not bounce due to underflow.  */
5746
5791
                *numregs = 0;
5747
 
                pipe = VFP11_FMAC;
 
5792
                vpipe = VFP11_FMAC;
5748
5793
                break;
5749
5794
 
5750
5795
              case 3: /* fsqrt[sd].  */
5751
5796
                /* fsqrt cannot underflow, but it can (perhaps) overwrite
5752
5797
                   registers to cause the erratum in previous instructions.  */
5753
5798
                bfd_arm_vfp11_write_mask (destmask, fd);
5754
 
                pipe = VFP11_DS;
 
5799
                vpipe = VFP11_DS;
5755
5800
                break;
5756
5801
 
5757
5802
              case 15: /* fcvt{ds,sd}.  */
5766
5811
 
5767
5812
                  *numregs = rnum;
5768
5813
 
5769
 
                  pipe = VFP11_FMAC;
 
5814
                  vpipe = VFP11_FMAC;
5770
5815
                }
5771
5816
                break;
5772
5817
 
5796
5841
            }
5797
5842
        }
5798
5843
 
5799
 
      pipe = VFP11_LS;
 
5844
      vpipe = VFP11_LS;
5800
5845
    }
5801
5846
  else if ((insn & 0x0e100e00) == 0x0c100a00)  /* A load insn.  */
5802
5847
    {
5831
5876
          return VFP11_BAD;
5832
5877
        }
5833
5878
 
5834
 
      pipe = VFP11_LS;
 
5879
      vpipe = VFP11_LS;
5835
5880
    }
5836
5881
  /* Single-register transfer. Note L==0.  */
5837
5882
  else if ((insn & 0x0f100e10) == 0x0e000a10)
5853
5898
          break;
5854
5899
        }
5855
5900
 
5856
 
      pipe = VFP11_LS;
 
5901
      vpipe = VFP11_LS;
5857
5902
    }
5858
5903
 
5859
 
  return pipe;
 
5904
  return vpipe;
5860
5905
}
5861
5906
 
5862
5907
 
5878
5923
  struct elf32_arm_link_hash_table *globals = elf32_arm_hash_table (link_info);
5879
5924
  int use_vector = (globals->vfp11_fix == BFD_ARM_VFP11_FIX_VECTOR);
5880
5925
 
 
5926
  if (globals == NULL)
 
5927
    return FALSE;
 
5928
 
5881
5929
  /* We use a simple FSM to match troublesome VFP11 instruction sequences.
5882
5930
     The states transition as follows:
5883
5931
 
5976
6024
                  | (contents[i + 1] << 8)
5977
6025
                  | contents[i];
5978
6026
              unsigned int writemask = 0;
5979
 
              enum bfd_arm_vfp11_pipe pipe;
 
6027
              enum bfd_arm_vfp11_pipe vpipe;
5980
6028
 
5981
6029
              switch (state)
5982
6030
                {
5983
6031
                case 0:
5984
 
                  pipe = bfd_arm_vfp11_insn_decode (insn, &writemask, regs,
 
6032
                  vpipe = bfd_arm_vfp11_insn_decode (insn, &writemask, regs,
5985
6033
                                                    &numregs);
5986
6034
                  /* I'm assuming the VFP11 erratum can trigger with denorm
5987
6035
                     operands on either the FMAC or the DS pipeline. This might
5988
6036
                     lead to slightly overenthusiastic veneer insertion.  */
5989
 
                  if (pipe == VFP11_FMAC || pipe == VFP11_DS)
 
6037
                  if (vpipe == VFP11_FMAC || vpipe == VFP11_DS)
5990
6038
                    {
5991
6039
                      state = use_vector ? 1 : 2;
5992
6040
                      first_fmac = i;
5997
6045
                case 1:
5998
6046
                  {
5999
6047
                    int other_regs[3], other_numregs;
6000
 
                    pipe = bfd_arm_vfp11_insn_decode (insn, &writemask,
 
6048
                    vpipe = bfd_arm_vfp11_insn_decode (insn, &writemask,
6001
6049
                                                      other_regs,
6002
6050
                                                      &other_numregs);
6003
 
                    if (pipe != VFP11_BAD
 
6051
                    if (vpipe != VFP11_BAD
6004
6052
                        && bfd_arm_vfp11_antidependency (writemask, regs,
6005
6053
                                                         numregs))
6006
6054
                      state = 3;
6012
6060
                case 2:
6013
6061
                  {
6014
6062
                    int other_regs[3], other_numregs;
6015
 
                    pipe = bfd_arm_vfp11_insn_decode (insn, &writemask,
 
6063
                    vpipe = bfd_arm_vfp11_insn_decode (insn, &writemask,
6016
6064
                                                      other_regs,
6017
6065
                                                      &other_numregs);
6018
 
                    if (pipe != VFP11_BAD
 
6066
                    if (vpipe != VFP11_BAD
6019
6067
                        && bfd_arm_vfp11_antidependency (writemask, regs,
6020
6068
                                                         numregs))
6021
6069
                      state = 3;
6033
6081
 
6034
6082
              if (state == 3)
6035
6083
                {
6036
 
                  elf32_vfp11_erratum_list *newerr
6037
 
                    = bfd_zmalloc (sizeof (elf32_vfp11_erratum_list));
 
6084
                  elf32_vfp11_erratum_list *newerr =(elf32_vfp11_erratum_list *)
 
6085
                      bfd_zmalloc (sizeof (elf32_vfp11_erratum_list));
6038
6086
                  int errcount;
6039
6087
 
6040
6088
                  errcount = ++(elf32_arm_section_data (sec)->erratumcount);
6101
6149
    return;
6102
6150
 
6103
6151
  globals = elf32_arm_hash_table (link_info);
 
6152
  if (globals == NULL)
 
6153
    return;
6104
6154
 
6105
 
  tmp_name = bfd_malloc ((bfd_size_type) strlen
6106
 
                           (VFP11_ERRATUM_VENEER_ENTRY_NAME) + 10);
 
6155
  tmp_name = (char *) bfd_malloc ((bfd_size_type) strlen
 
6156
                                  (VFP11_ERRATUM_VENEER_ENTRY_NAME) + 10);
6107
6157
 
6108
6158
  for (sec = abfd->sections; sec != NULL; sec = sec->next)
6109
6159
    {
6183
6233
  struct elf32_arm_link_hash_table *globals;
6184
6234
 
6185
6235
  globals = elf32_arm_hash_table (link_info);
 
6236
  if (globals == NULL)
 
6237
    return;
6186
6238
 
6187
6239
  globals->target1_is_rel = target1_is_rel;
6188
6240
  if (strcmp (target2_type, "rel") == 0)
6258
6310
    return FALSE;
6259
6311
 
6260
6312
  globals = elf32_arm_hash_table (info);
6261
 
 
6262
6313
  BFD_ASSERT (globals != NULL);
6263
6314
  BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
6264
6315
 
6356
6407
    return NULL;
6357
6408
 
6358
6409
  globals = elf32_arm_hash_table (info);
6359
 
 
6360
6410
  BFD_ASSERT (globals != NULL);
6361
6411
  BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
6362
6412
 
6452
6502
  struct elf32_arm_link_hash_table * globals;
6453
6503
 
6454
6504
  globals = elf32_arm_hash_table (info);
6455
 
 
6456
6505
  BFD_ASSERT (globals != NULL);
6457
6506
  BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
6458
6507
 
6507
6556
    return TRUE;
6508
6557
 
6509
6558
  globals = elf32_arm_hash_table (info);
6510
 
 
6511
6559
  BFD_ASSERT (globals != NULL);
6512
6560
  BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
6513
6561
 
6543
6591
  struct elf32_arm_link_hash_table *globals;
6544
6592
 
6545
6593
  globals = elf32_arm_hash_table (info);
6546
 
 
6547
6594
  BFD_ASSERT (globals != NULL);
6548
6595
  BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
6549
6596
 
6581
6628
    return;
6582
6629
 
6583
6630
  globals = elf32_arm_hash_table (link_info);
 
6631
  if (globals == NULL)
 
6632
    return;
 
6633
 
6584
6634
  /* If blx is available then exported Thumb symbols are OK and there is
6585
6635
     nothing to do.  */
6586
6636
  if (globals->use_blx)
6758
6808
  struct elf32_arm_link_hash_table * globals;
6759
6809
 
6760
6810
  globals = elf32_arm_hash_table (info);
 
6811
  if (globals == NULL)
 
6812
    return bfd_reloc_notsupported;
6761
6813
 
6762
6814
  BFD_ASSERT (is_arm_elf (input_bfd));
6763
6815
 
6861
6913
         run time.  */
6862
6914
      if ((info->shared || globals->root.is_relocatable_executable)
6863
6915
          && (input_section->flags & SEC_ALLOC)
6864
 
          && !(elf32_arm_hash_table (info)->vxworks_p
 
6916
          && !(globals->vxworks_p
6865
6917
               && strcmp (input_section->output_section->name,
6866
6918
                          ".tls_vars") == 0)
6867
6919
          && ((r_type != R_ARM_REL32 && r_type != R_ARM_REL32_NOI)
7198
7250
 
7199
7251
    case R_ARM_ABS8:
7200
7252
      value += addend;
7201
 
      if ((long) value > 0x7f || (long) value < -0x80)
 
7253
 
 
7254
      /* There is no way to tell whether the user intended to use a signed or
 
7255
         unsigned addend.  When checking for overflow we accept either,
 
7256
         as specified by the AAELF.  */
 
7257
      if ((long) value > 0xff || (long) value < -0x80)
7202
7258
        return bfd_reloc_overflow;
7203
7259
 
7204
7260
      bfd_put_8 (input_bfd, value, hit_data);
7207
7263
    case R_ARM_ABS16:
7208
7264
      value += addend;
7209
7265
 
7210
 
      if ((long) value > 0x7fff || (long) value < -0x8000)
 
7266
      /* See comment for R_ARM_ABS8.  */
 
7267
      if ((long) value > 0xffff || (long) value < -0x8000)
7211
7268
        return bfd_reloc_overflow;
7212
7269
 
7213
7270
      bfd_put_16 (input_bfd, value, hit_data);
7533
7590
        bitsize = howto->bitsize;
7534
7591
        if (!thumb2)
7535
7592
          bitsize -= 2;
7536
 
        reloc_signed_max = ((1 << (bitsize - 1)) - 1) >> howto->rightshift;
 
7593
        reloc_signed_max = (1 << (bitsize - 1)) - 1;
7537
7594
        reloc_signed_min = ~reloc_signed_max;
7538
7595
 
7539
7596
        /* Assumes two's complement.  */
8092
8149
            (_("%B(%A+0x%lx): R_ARM_TLS_LE32 relocation not permitted in shared object"),
8093
8150
             input_bfd, input_section,
8094
8151
             (long) rel->r_offset, howto->name);
8095
 
          return FALSE;
 
8152
          return (bfd_reloc_status_type) FALSE;
8096
8153
        }
8097
8154
      else
8098
8155
        value = tpoff (info, value);
8728
8785
  struct elf32_arm_link_hash_table * globals;
8729
8786
 
8730
8787
  globals = elf32_arm_hash_table (info);
 
8788
  if (globals == NULL)
 
8789
    return FALSE;
8731
8790
 
8732
8791
  symtab_hdr = & elf_symtab_hdr (input_bfd);
8733
8792
  sym_hashes = elf_sym_hashes (input_bfd);
9030
9089
  return TRUE;
9031
9090
}
9032
9091
 
9033
 
/* Add a new unwind edit to the list described by HEAD, TAIL.  If INDEX is zero,
 
9092
/* Add a new unwind edit to the list described by HEAD, TAIL.  If TINDEX is zero,
9034
9093
   adds the edit to the start of the list.  (The list must be built in order of
9035
 
   ascending INDEX: the function's callers are primarily responsible for
 
9094
   ascending TINDEX: the function's callers are primarily responsible for
9036
9095
   maintaining that condition).  */
9037
9096
 
9038
9097
static void
9040
9099
                       arm_unwind_table_edit **tail,
9041
9100
                       arm_unwind_edit_type type,
9042
9101
                       asection *linked_section,
9043
 
                       unsigned int index)
 
9102
                       unsigned int tindex)
9044
9103
{
9045
 
  arm_unwind_table_edit *new_edit = xmalloc (sizeof (arm_unwind_table_edit));
 
9104
  arm_unwind_table_edit *new_edit = (arm_unwind_table_edit *)
 
9105
      xmalloc (sizeof (arm_unwind_table_edit));
9046
9106
  
9047
9107
  new_edit->type = type;
9048
9108
  new_edit->linked_section = linked_section;
9049
 
  new_edit->index = index;
 
9109
  new_edit->index = tindex;
9050
9110
  
9051
 
  if (index > 0)
 
9111
  if (tindex > 0)
9052
9112
    {
9053
9113
      new_edit->next = NULL;
9054
9114
 
9158
9218
 
9159
9219
  /* Walk all text sections in order of increasing VMA.  Eilminate duplicate
9160
9220
     index table entries (EXIDX_CANTUNWIND and inlined unwind opcodes),
9161
 
     and add EXIDX_CANTUNWIND entries for sections with no unwind table data.
9162
 
   */
 
9221
     and add EXIDX_CANTUNWIND entries for sections with no unwind table data.  */
9163
9222
 
9164
9223
  for (i = 0; i < num_text_sections; i++)
9165
9224
    {
9299
9358
{
9300
9359
  struct elf32_arm_link_hash_table *globals = elf32_arm_hash_table (info);
9301
9360
 
 
9361
  if (globals == NULL)
 
9362
    return FALSE;
 
9363
 
9302
9364
  /* Invoke the regular ELF backend linker to do all the work.  */
9303
9365
  if (!bfd_elf_final_link (abfd, info))
9304
9366
    return FALSE;
9539
9601
  /* Note: the tag and its argument below are uleb128 values, though
9540
9602
     currently-defined values fit in one byte for each.  */
9541
9603
  if (!attr->s)
9542
 
    attr->s = bfd_alloc (abfd, 3);
 
9604
    attr->s = (char *) bfd_alloc (abfd, 3);
9543
9605
  attr->s[0] = Tag_CPU_arch;
9544
9606
  attr->s[1] = arch;
9545
9607
  attr->s[2] = '\0';
9624
9686
      T(V6S_M),  /* V6_M.  */
9625
9687
      T(V6S_M)   /* V6S_M.  */
9626
9688
    };
 
9689
  const int v7e_m[] =
 
9690
    {
 
9691
      -1,        /* PRE_V4.  */
 
9692
      -1,        /* V4.  */
 
9693
      T(V7E_M),  /* V4T.  */
 
9694
      T(V7E_M),  /* V5T.  */
 
9695
      T(V7E_M),  /* V5TE.  */
 
9696
      T(V7E_M),  /* V5TEJ.  */
 
9697
      T(V7E_M),  /* V6.  */
 
9698
      T(V7E_M),  /* V6KZ.  */
 
9699
      T(V7E_M),  /* V6T2.  */
 
9700
      T(V7E_M),  /* V6K.  */
 
9701
      T(V7E_M),  /* V7.  */
 
9702
      T(V7E_M),  /* V6_M.  */
 
9703
      T(V7E_M),  /* V6S_M.  */
 
9704
      T(V7E_M)   /* V7E_M.  */
 
9705
    };
9627
9706
  const int v4t_plus_v6_m[] =
9628
9707
    {
9629
9708
      -1,               /* PRE_V4.  */
9639
9718
      T(V7),            /* V7.  */
9640
9719
      T(V6_M),          /* V6_M.  */
9641
9720
      T(V6S_M),         /* V6S_M.  */
 
9721
      T(V7E_M),         /* V7E_M.  */
9642
9722
      T(V4T_PLUS_V6_M)  /* V4T plus V6_M.  */
9643
9723
    };
9644
9724
  const int *comb[] =
9648
9728
      v7,
9649
9729
      v6_m,
9650
9730
      v6s_m,
 
9731
      v7e_m,
9651
9732
      /* Pseudo-architecture.  */
9652
9733
      v4t_plus_v6_m
9653
9734
    };
9654
9735
 
9655
9736
  /* Check we've not got a higher architecture than we know about.  */
9656
9737
 
9657
 
  if (oldtag >= MAX_TAG_CPU_ARCH || newtag >= MAX_TAG_CPU_ARCH)
 
9738
  if (oldtag > MAX_TAG_CPU_ARCH || newtag > MAX_TAG_CPU_ARCH)
9658
9739
    {
9659
9740
      _bfd_error_handler (_("error: %B: Unknown CPU architecture"), ibfd);
9660
9741
      return -1;
9717
9798
  /* Some tags have 0 = don't care, 1 = strong requirement,
9718
9799
     2 = weak requirement.  */
9719
9800
  static const int order_021[3] = {0, 2, 1};
9720
 
  /* For use with Tag_VFP_arch.  */
9721
 
  static const int order_01243[5] = {0, 1, 2, 4, 3};
9722
9801
  int i;
9723
9802
  bfd_boolean result = TRUE;
9724
9803
 
9733
9812
      /* This is the first object.  Copy the attributes.  */
9734
9813
      _bfd_elf_copy_obj_attributes (ibfd, obfd);
9735
9814
 
 
9815
      out_attr = elf_known_obj_attributes_proc (obfd);
 
9816
 
9736
9817
      /* Use the Tag_null value to indicate the attributes have been
9737
9818
         initialized.  */
9738
 
      elf_known_obj_attributes_proc (obfd)[0].i = 1;
9739
 
 
9740
 
      return TRUE;
 
9819
      out_attr[0].i = 1;
 
9820
 
 
9821
      /* We do not output objects with Tag_MPextension_use_legacy - we move
 
9822
         the attribute's value to Tag_MPextension_use.  */
 
9823
      if (out_attr[Tag_MPextension_use_legacy].i != 0)
 
9824
        {
 
9825
          if (out_attr[Tag_MPextension_use].i != 0
 
9826
              && out_attr[Tag_MPextension_use_legacy].i
 
9827
                != out_attr[Tag_MPextension_use].i)
 
9828
            {
 
9829
              _bfd_error_handler
 
9830
                (_("Error: %B has both the current and legacy "
 
9831
                   "Tag_MPextension_use attributes"), ibfd);
 
9832
              result = FALSE;
 
9833
            }
 
9834
 
 
9835
          out_attr[Tag_MPextension_use] =
 
9836
            out_attr[Tag_MPextension_use_legacy];
 
9837
          out_attr[Tag_MPextension_use_legacy].type = 0;
 
9838
          out_attr[Tag_MPextension_use_legacy].i = 0;
 
9839
        }
 
9840
 
 
9841
      return result;
9741
9842
    }
9742
9843
 
9743
9844
  in_attr = elf_known_obj_attributes_proc (ibfd);
9752
9853
        {
9753
9854
          _bfd_error_handler
9754
9855
            (_("error: %B uses VFP register arguments, %B does not"),
9755
 
             ibfd, obfd);
 
9856
             in_attr[Tag_ABI_VFP_args].i ? ibfd : obfd,
 
9857
             in_attr[Tag_ABI_VFP_args].i ? obfd : ibfd);
9756
9858
          result = FALSE;
9757
9859
        }
9758
9860
    }
9910
10012
            }
9911
10013
          break;
9912
10014
        case Tag_VFP_arch:
9913
 
          /* Use the "greatest" from the sequence 0, 1, 2, 4, 3, or the
9914
 
             largest value if greater than 4 (for future-proofing).  */
9915
 
          if ((in_attr[i].i > 4 && in_attr[i].i > out_attr[i].i)
9916
 
              || (in_attr[i].i <= 4 && out_attr[i].i <= 4
9917
 
                  && order_01243[in_attr[i].i] > order_01243[out_attr[i].i]))
9918
 
            out_attr[i].i = in_attr[i].i;
 
10015
            {
 
10016
              static const struct
 
10017
              {
 
10018
                  int ver;
 
10019
                  int regs;
 
10020
              } vfp_versions[7] =
 
10021
                {
 
10022
                  {0, 0},
 
10023
                  {1, 16},
 
10024
                  {2, 16},
 
10025
                  {3, 32},
 
10026
                  {3, 16},
 
10027
                  {4, 32},
 
10028
                  {4, 16}
 
10029
                };
 
10030
              int ver;
 
10031
              int regs;
 
10032
              int newval;
 
10033
 
 
10034
              /* Values greater than 6 aren't defined, so just pick the
 
10035
                 biggest */
 
10036
              if (in_attr[i].i > 6 && in_attr[i].i > out_attr[i].i)
 
10037
                {
 
10038
                  out_attr[i] = in_attr[i];
 
10039
                  break;
 
10040
                }
 
10041
              /* The output uses the superset of input features
 
10042
                 (ISA version) and registers.  */
 
10043
              ver = vfp_versions[in_attr[i].i].ver;
 
10044
              if (ver < vfp_versions[out_attr[i].i].ver)
 
10045
                ver = vfp_versions[out_attr[i].i].ver;
 
10046
              regs = vfp_versions[in_attr[i].i].regs;
 
10047
              if (regs < vfp_versions[out_attr[i].i].regs)
 
10048
                regs = vfp_versions[out_attr[i].i].regs;
 
10049
              /* This assumes all possible supersets are also a valid
 
10050
                 options.  */
 
10051
              for (newval = 6; newval > 0; newval--)
 
10052
                {
 
10053
                  if (regs == vfp_versions[newval].regs
 
10054
                      && ver == vfp_versions[newval].ver)
 
10055
                    break;
 
10056
                }
 
10057
              out_attr[i].i = newval;
 
10058
            }
9919
10059
          break;
9920
10060
        case Tag_PCS_config:
9921
10061
          if (out_attr[i].i == 0)
10033
10173
            out_attr[i].i = in_attr[i].i;
10034
10174
          break;
10035
10175
 
 
10176
        case Tag_DIV_use:
 
10177
          /* This tag is set to zero if we can use UDIV and SDIV in Thumb
 
10178
             mode on a v7-M or v7-R CPU; to one if we can not use UDIV or
 
10179
             SDIV at all; and to two if we can use UDIV or SDIV on a v7-A
 
10180
             CPU.  We will merge as follows: If the input attribute's value
 
10181
             is one then the output attribute's value remains unchanged.  If
 
10182
             the input attribute's value is zero or two then if the output
 
10183
             attribute's value is one the output value is set to the input
 
10184
             value, otherwise the output value must be the same as the
 
10185
             inputs.  */ 
 
10186
          if (in_attr[i].i != 1 && out_attr[i].i != 1) 
 
10187
            { 
 
10188
              if (in_attr[i].i != out_attr[i].i)
 
10189
                {
 
10190
                  _bfd_error_handler
 
10191
                    (_("DIV usage mismatch between %B and %B"),
 
10192
                     ibfd, obfd); 
 
10193
                  result = FALSE;
 
10194
                }
 
10195
            } 
 
10196
 
 
10197
          if (in_attr[i].i != 1)
 
10198
            out_attr[i].i = in_attr[i].i; 
 
10199
          
 
10200
          break;
 
10201
 
 
10202
        case Tag_MPextension_use_legacy:
 
10203
          /* We don't output objects with Tag_MPextension_use_legacy - we
 
10204
             move the value to Tag_MPextension_use.  */
 
10205
          if (in_attr[i].i != 0 && in_attr[Tag_MPextension_use].i != 0)
 
10206
            {
 
10207
              if (in_attr[Tag_MPextension_use].i != in_attr[i].i)
 
10208
                {
 
10209
                  _bfd_error_handler
 
10210
                    (_("%B has has both the current and legacy "
 
10211
                       "Tag_MPextension_use attributes"), 
 
10212
                     ibfd);
 
10213
                  result = FALSE;
 
10214
                }
 
10215
            }
 
10216
 
 
10217
          if (in_attr[i].i > out_attr[Tag_MPextension_use].i)
 
10218
            out_attr[Tag_MPextension_use] = in_attr[i];
 
10219
 
 
10220
          break;
 
10221
 
10036
10222
        case Tag_nodefaults:
10037
10223
          /* This tag is set if it exists, but the value is unused (and is
10038
10224
             typically zero).  We don't actually need to do anything here -
10195
10381
   object file when linking.  */
10196
10382
 
10197
10383
static bfd_boolean
10198
 
elf32_arm_merge_private_bfd_data (bfd * ibfd, bfd * obfd)
10199
 
{
10200
 
  flagword out_flags;
10201
 
  flagword in_flags;
10202
 
  bfd_boolean flags_compatible = TRUE;
10203
 
  asection *sec;
10204
 
 
10205
 
  /* Check if we have the same endianess.  */
10206
 
  if (! _bfd_generic_verify_endian_match (ibfd, obfd))
10207
 
    return FALSE;
10208
 
 
10209
 
  if (! is_arm_elf (ibfd) || ! is_arm_elf (obfd))
10210
 
    return TRUE;
10211
 
 
10212
 
  if (!elf32_arm_merge_eabi_attributes (ibfd, obfd))
10213
 
    return FALSE;
10214
 
 
10215
 
  /* The input BFD must have had its flags initialised.  */
10216
 
  /* The following seems bogus to me -- The flags are initialized in
10217
 
     the assembler but I don't think an elf_flags_init field is
10218
 
     written into the object.  */
10219
 
  /* BFD_ASSERT (elf_flags_init (ibfd)); */
10220
 
 
10221
 
  in_flags  = elf_elfheader (ibfd)->e_flags;
10222
 
  out_flags = elf_elfheader (obfd)->e_flags;
10223
 
 
10224
 
  /* In theory there is no reason why we couldn't handle this.  However
10225
 
     in practice it isn't even close to working and there is no real
10226
 
     reason to want it.  */
10227
 
  if (EF_ARM_EABI_VERSION (in_flags) >= EF_ARM_EABI_VER4
10228
 
      && !(ibfd->flags & DYNAMIC)
10229
 
      && (in_flags & EF_ARM_BE8))
10230
 
    {
10231
 
      _bfd_error_handler (_("error: %B is already in final BE8 format"),
10232
 
                          ibfd);
10233
 
      return FALSE;
10234
 
    }
10235
 
 
10236
 
  if (!elf_flags_init (obfd))
10237
 
    {
10238
 
      /* If the input is the default architecture and had the default
10239
 
         flags then do not bother setting the flags for the output
10240
 
         architecture, instead allow future merges to do this.  If no
10241
 
         future merges ever set these flags then they will retain their
10242
 
         uninitialised values, which surprise surprise, correspond
10243
 
         to the default values.  */
10244
 
      if (bfd_get_arch_info (ibfd)->the_default
10245
 
          && elf_elfheader (ibfd)->e_flags == 0)
10246
 
        return TRUE;
10247
 
 
10248
 
      elf_flags_init (obfd) = TRUE;
10249
 
      elf_elfheader (obfd)->e_flags = in_flags;
10250
 
 
10251
 
      if (bfd_get_arch (obfd) == bfd_get_arch (ibfd)
10252
 
          && bfd_get_arch_info (obfd)->the_default)
10253
 
        return bfd_set_arch_mach (obfd, bfd_get_arch (ibfd), bfd_get_mach (ibfd));
10254
 
 
10255
 
      return TRUE;
10256
 
    }
10257
 
 
10258
 
  /* Determine what should happen if the input ARM architecture
10259
 
     does not match the output ARM architecture.  */
10260
 
  if (! bfd_arm_merge_machines (ibfd, obfd))
10261
 
    return FALSE;
10262
 
 
10263
 
  /* Identical flags must be compatible.  */
10264
 
  if (in_flags == out_flags)
10265
 
    return TRUE;
10266
 
 
10267
 
  /* Check to see if the input BFD actually contains any sections.  If
10268
 
     not, its flags may not have been initialised either, but it
10269
 
     cannot actually cause any incompatiblity.  Do not short-circuit
10270
 
     dynamic objects; their section list may be emptied by
10271
 
    elf_link_add_object_symbols.
10272
 
 
10273
 
    Also check to see if there are no code sections in the input.
10274
 
    In this case there is no need to check for code specific flags.
10275
 
    XXX - do we need to worry about floating-point format compatability
10276
 
    in data sections ?  */
10277
 
  if (!(ibfd->flags & DYNAMIC))
10278
 
    {
10279
 
      bfd_boolean null_input_bfd = TRUE;
10280
 
      bfd_boolean only_data_sections = TRUE;
10281
 
 
10282
 
      for (sec = ibfd->sections; sec != NULL; sec = sec->next)
10283
 
        {
10284
 
          /* Ignore synthetic glue sections.  */
10285
 
          if (strcmp (sec->name, ".glue_7")
10286
 
              && strcmp (sec->name, ".glue_7t"))
10287
 
            {
10288
 
              if ((bfd_get_section_flags (ibfd, sec)
10289
 
                   & (SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS))
10290
 
                  == (SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS))
10291
 
                only_data_sections = FALSE;
10292
 
 
10293
 
              null_input_bfd = FALSE;
10294
 
              break;
10295
 
            }
10296
 
        }
10297
 
 
10298
 
      if (null_input_bfd || only_data_sections)
10299
 
        return TRUE;
10300
 
    }
10301
 
 
10302
 
  /* Complain about various flag mismatches.  */
10303
 
  if (!elf32_arm_versions_compatible (EF_ARM_EABI_VERSION (in_flags),
10304
 
                                      EF_ARM_EABI_VERSION (out_flags)))
10305
 
    {
10306
 
      _bfd_error_handler
10307
 
        (_("error: Source object %B has EABI version %d, but target %B has EABI version %d"),
10308
 
         ibfd, obfd,
10309
 
         (in_flags & EF_ARM_EABIMASK) >> 24,
10310
 
         (out_flags & EF_ARM_EABIMASK) >> 24);
10311
 
      return FALSE;
10312
 
    }
10313
 
 
10314
 
  /* Not sure what needs to be checked for EABI versions >= 1.  */
10315
 
  /* VxWorks libraries do not use these flags.  */
10316
 
  if (get_elf_backend_data (obfd) != &elf32_arm_vxworks_bed
10317
 
      && get_elf_backend_data (ibfd) != &elf32_arm_vxworks_bed
10318
 
      && EF_ARM_EABI_VERSION (in_flags) == EF_ARM_EABI_UNKNOWN)
10319
 
    {
10320
 
      if ((in_flags & EF_ARM_APCS_26) != (out_flags & EF_ARM_APCS_26))
10321
 
        {
10322
 
          _bfd_error_handler
10323
 
            (_("error: %B is compiled for APCS-%d, whereas target %B uses APCS-%d"),
10324
 
             ibfd, obfd,
10325
 
             in_flags & EF_ARM_APCS_26 ? 26 : 32,
10326
 
             out_flags & EF_ARM_APCS_26 ? 26 : 32);
10327
 
          flags_compatible = FALSE;
10328
 
        }
10329
 
 
10330
 
      if ((in_flags & EF_ARM_APCS_FLOAT) != (out_flags & EF_ARM_APCS_FLOAT))
10331
 
        {
10332
 
          if (in_flags & EF_ARM_APCS_FLOAT)
10333
 
            _bfd_error_handler
10334
 
              (_("error: %B passes floats in float registers, whereas %B passes them in integer registers"),
10335
 
               ibfd, obfd);
10336
 
          else
10337
 
            _bfd_error_handler
10338
 
              (_("error: %B passes floats in integer registers, whereas %B passes them in float registers"),
10339
 
               ibfd, obfd);
10340
 
 
10341
 
          flags_compatible = FALSE;
10342
 
        }
10343
 
 
10344
 
      if ((in_flags & EF_ARM_VFP_FLOAT) != (out_flags & EF_ARM_VFP_FLOAT))
10345
 
        {
10346
 
          if (in_flags & EF_ARM_VFP_FLOAT)
10347
 
            _bfd_error_handler
10348
 
              (_("error: %B uses VFP instructions, whereas %B does not"),
10349
 
               ibfd, obfd);
10350
 
          else
10351
 
            _bfd_error_handler
10352
 
              (_("error: %B uses FPA instructions, whereas %B does not"),
10353
 
               ibfd, obfd);
10354
 
 
10355
 
          flags_compatible = FALSE;
10356
 
        }
10357
 
 
10358
 
      if ((in_flags & EF_ARM_MAVERICK_FLOAT) != (out_flags & EF_ARM_MAVERICK_FLOAT))
10359
 
        {
10360
 
          if (in_flags & EF_ARM_MAVERICK_FLOAT)
10361
 
            _bfd_error_handler
10362
 
              (_("error: %B uses Maverick instructions, whereas %B does not"),
10363
 
               ibfd, obfd);
10364
 
          else
10365
 
            _bfd_error_handler
10366
 
              (_("error: %B does not use Maverick instructions, whereas %B does"),
10367
 
               ibfd, obfd);
10368
 
 
10369
 
          flags_compatible = FALSE;
10370
 
        }
10371
 
 
10372
 
#ifdef EF_ARM_SOFT_FLOAT
10373
 
      if ((in_flags & EF_ARM_SOFT_FLOAT) != (out_flags & EF_ARM_SOFT_FLOAT))
10374
 
        {
10375
 
          /* We can allow interworking between code that is VFP format
10376
 
             layout, and uses either soft float or integer regs for
10377
 
             passing floating point arguments and results.  We already
10378
 
             know that the APCS_FLOAT flags match; similarly for VFP
10379
 
             flags.  */
10380
 
          if ((in_flags & EF_ARM_APCS_FLOAT) != 0
10381
 
              || (in_flags & EF_ARM_VFP_FLOAT) == 0)
10382
 
            {
10383
 
              if (in_flags & EF_ARM_SOFT_FLOAT)
10384
 
                _bfd_error_handler
10385
 
                  (_("error: %B uses software FP, whereas %B uses hardware FP"),
10386
 
                   ibfd, obfd);
10387
 
              else
10388
 
                _bfd_error_handler
10389
 
                  (_("error: %B uses hardware FP, whereas %B uses software FP"),
10390
 
                   ibfd, obfd);
10391
 
 
10392
 
              flags_compatible = FALSE;
10393
 
            }
10394
 
        }
10395
 
#endif
10396
 
 
10397
 
      /* Interworking mismatch is only a warning.  */
10398
 
      if ((in_flags & EF_ARM_INTERWORK) != (out_flags & EF_ARM_INTERWORK))
10399
 
        {
10400
 
          if (in_flags & EF_ARM_INTERWORK)
10401
 
            {
10402
 
              _bfd_error_handler
10403
 
                (_("Warning: %B supports interworking, whereas %B does not"),
10404
 
                 ibfd, obfd);
10405
 
            }
10406
 
          else
10407
 
            {
10408
 
              _bfd_error_handler
10409
 
                (_("Warning: %B does not support interworking, whereas %B does"),
10410
 
                 ibfd, obfd);
10411
 
            }
10412
 
        }
10413
 
    }
10414
 
 
10415
 
  return flags_compatible;
10416
 
}
 
10384
elf32_arm_merge_private_bfd_data (bfd * ibfd, bfd * obfd);
10417
10385
 
10418
10386
/* Display the flags field.  */
10419
10387
 
10609
10577
    return TRUE;
10610
10578
 
10611
10579
  globals = elf32_arm_hash_table (info);
 
10580
  if (globals == NULL)
 
10581
    return FALSE;
10612
10582
 
10613
10583
  elf_section_data (sec)->local_dynrel = NULL;
10614
10584
 
10655
10625
          break;
10656
10626
 
10657
10627
        case R_ARM_TLS_LDM32:
10658
 
          elf32_arm_hash_table (info)->tls_ldm_got.refcount -= 1;
 
10628
          globals->tls_ldm_got.refcount -= 1;
10659
10629
          break;
10660
10630
 
10661
10631
        case R_ARM_ABS32:
10751
10721
  BFD_ASSERT (is_arm_elf (abfd));
10752
10722
 
10753
10723
  htab = elf32_arm_hash_table (info);
 
10724
  if (htab == NULL)
 
10725
    return FALSE;
 
10726
 
10754
10727
  sreloc = NULL;
10755
10728
 
10756
10729
  /* Create dynamic sections for relocatable executables so that we can
10838
10811
 
10839
10812
                      size = symtab_hdr->sh_info;
10840
10813
                      size *= (sizeof (bfd_signed_vma) + sizeof (char));
10841
 
                      local_got_refcounts = bfd_zalloc (abfd, size);
 
10814
                      local_got_refcounts = (bfd_signed_vma *)
 
10815
                          bfd_zalloc (abfd, size);
10842
10816
                      if (local_got_refcounts == NULL)
10843
10817
                        return FALSE;
10844
10818
                      elf_local_got_refcounts (abfd) = local_got_refcounts;
11037
11011
                  {
11038
11012
                    bfd_size_type amt = sizeof *p;
11039
11013
 
11040
 
                    p = bfd_alloc (htab->root.dynobj, amt);
 
11014
                    p = (struct elf32_arm_relocs_copied *)
 
11015
                        bfd_alloc (htab->root.dynobj, amt);
11041
11016
                    if (p == NULL)
11042
11017
                      return FALSE;
11043
11018
                    p->next = *head;
11271
11246
  struct elf32_arm_link_hash_table *globals;
11272
11247
 
11273
11248
  globals = elf32_arm_hash_table (info);
 
11249
  if (globals == NULL)
 
11250
    return FALSE;
 
11251
 
11274
11252
  dynobj = elf_hash_table (info)->dynobj;
11275
11253
 
11276
11254
  /* Make sure we know what is going on here.  */
11409
11387
 
11410
11388
  info = (struct bfd_link_info *) inf;
11411
11389
  htab = elf32_arm_hash_table (info);
 
11390
  if (htab == NULL)
 
11391
    return FALSE;
11412
11392
 
11413
11393
  if (htab->root.dynamic_sections_created
11414
11394
      && h->plt.refcount > 0)
11638
11618
            }
11639
11619
        }
11640
11620
 
11641
 
      if (elf32_arm_hash_table (info)->vxworks_p)
 
11621
      if (htab->vxworks_p)
11642
11622
        {
11643
11623
          struct elf32_arm_relocs_copied **pp;
11644
11624
 
11759
11739
  struct elf32_arm_link_hash_table *globals;
11760
11740
 
11761
11741
  globals = elf32_arm_hash_table (info);
 
11742
  if (globals == NULL)
 
11743
    return;
 
11744
 
11762
11745
  globals->byteswap_code = byteswap_code;
11763
11746
}
11764
11747
 
11776
11759
  struct elf32_arm_link_hash_table *htab;
11777
11760
 
11778
11761
  htab = elf32_arm_hash_table (info);
 
11762
  if (htab == NULL)
 
11763
    return FALSE;
 
11764
 
11779
11765
  dynobj = elf_hash_table (info)->dynobj;
11780
11766
  BFD_ASSERT (dynobj != NULL);
11781
11767
  check_use_blx (htab);
11802
11788
      bfd_size_type locsymcount;
11803
11789
      Elf_Internal_Shdr *symtab_hdr;
11804
11790
      asection *srel;
11805
 
      bfd_boolean is_vxworks = elf32_arm_hash_table (info)->vxworks_p;
 
11791
      bfd_boolean is_vxworks = htab->vxworks_p;
11806
11792
 
11807
11793
      if (! is_arm_elf (ibfd))
11808
11794
        continue;
11811
11797
        {
11812
11798
          struct elf32_arm_relocs_copied *p;
11813
11799
 
11814
 
          for (p = elf_section_data (s)->local_dynrel; p != NULL; p = p->next)
 
11800
          for (p = (struct elf32_arm_relocs_copied *)
 
11801
                   elf_section_data (s)->local_dynrel; p != NULL; p = p->next)
11815
11802
            {
11816
11803
              if (!bfd_is_abs_section (p->section)
11817
11804
                  && bfd_is_abs_section (p->section->output_section))
11965
11952
        continue;
11966
11953
 
11967
11954
      /* Allocate memory for the section contents.  */
11968
 
      s->contents = bfd_zalloc (dynobj, s->size);
 
11955
      s->contents = (unsigned char *) bfd_zalloc (dynobj, s->size);
11969
11956
      if (s->contents == NULL)
11970
11957
        return FALSE;
11971
11958
    }
12049
12036
 
12050
12037
  dynobj = elf_hash_table (info)->dynobj;
12051
12038
  htab = elf32_arm_hash_table (info);
 
12039
  if (htab == NULL)
 
12040
    return FALSE;
 
12041
 
12052
12042
  eh = (struct elf32_arm_link_hash_entry *) h;
12053
12043
 
12054
12044
  if (h->plt.offset != (bfd_vma) -1)
12339
12329
  bfd * dynobj;
12340
12330
  asection * sgot;
12341
12331
  asection * sdyn;
 
12332
  struct elf32_arm_link_hash_table *htab;
 
12333
 
 
12334
  htab = elf32_arm_hash_table (info);
 
12335
  if (htab == NULL)
 
12336
    return FALSE;
12342
12337
 
12343
12338
  dynobj = elf_hash_table (info)->dynobj;
12344
12339
 
12345
12340
  sgot = bfd_get_section_by_name (dynobj, ".got.plt");
12346
 
  BFD_ASSERT (elf32_arm_hash_table (info)->symbian_p || sgot != NULL);
 
12341
  BFD_ASSERT (htab->symbian_p || sgot != NULL);
12347
12342
  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
12348
12343
 
12349
12344
  if (elf_hash_table (info)->dynamic_sections_created)
12350
12345
    {
12351
12346
      asection *splt;
12352
12347
      Elf32_External_Dyn *dyncon, *dynconend;
12353
 
      struct elf32_arm_link_hash_table *htab;
12354
12348
 
12355
 
      htab = elf32_arm_hash_table (info);
12356
12349
      splt = bfd_get_section_by_name (dynobj, ".plt");
12357
12350
      BFD_ASSERT (splt != NULL && sdyn != NULL);
12358
12351
 
12511
12504
        }
12512
12505
 
12513
12506
      /* Fill in the first entry in the procedure linkage table.  */
12514
 
      if (splt->size > 0 && elf32_arm_hash_table (info)->plt_header_size)
 
12507
      if (splt->size > 0 && htab->plt_header_size)
12515
12508
        {
12516
12509
          const bfd_vma *plt0_entry;
12517
12510
          bfd_vma got_address, plt_address, got_displacement;
12638
12631
  if (link_info)
12639
12632
    {
12640
12633
      globals = elf32_arm_hash_table (link_info);
12641
 
      if (globals->byteswap_code)
 
12634
      if (globals != NULL && globals->byteswap_code)
12642
12635
        i_ehdrp->e_flags |= EF_ARM_BE8;
12643
12636
    }
12644
12637
}
12760
12753
{
12761
12754
  struct section_list * entry;
12762
12755
 
12763
 
  entry = bfd_malloc (sizeof (* entry));
 
12756
  entry = (struct section_list *) bfd_malloc (sizeof (* entry));
12764
12757
  if (entry == NULL)
12765
12758
    return;
12766
12759
  entry->sec = sec;
12864
12857
                          bfd_vma offset)
12865
12858
{
12866
12859
  static const char *names[3] = {"$a", "$t", "$d"};
12867
 
  struct elf32_arm_link_hash_table *htab;
12868
12860
  Elf_Internal_Sym sym;
12869
12861
 
12870
 
  htab = elf32_arm_hash_table (osi->info);
12871
12862
  sym.st_value = osi->sec->output_section->vma
12872
12863
                 + osi->sec->output_offset
12873
12864
                 + offset;
12889
12880
  struct elf32_arm_link_hash_entry *eh;
12890
12881
  bfd_vma addr;
12891
12882
 
12892
 
  htab = elf32_arm_hash_table (osi->info);
12893
 
 
12894
12883
  if (h->root.type == bfd_link_hash_indirect)
12895
12884
    return TRUE;
12896
12885
 
12903
12892
  if (h->plt.offset == (bfd_vma) -1)
12904
12893
    return TRUE;
12905
12894
 
 
12895
  htab = elf32_arm_hash_table (osi->info);
 
12896
  if (htab == NULL)
 
12897
    return FALSE;
 
12898
 
12906
12899
  eh = (struct elf32_arm_link_hash_entry *) h;
12907
12900
  addr = h->plt.offset;
12908
12901
  if (htab->symbian_p)
12962
12955
elf32_arm_output_stub_sym (output_arch_syminfo *osi, const char *name,
12963
12956
                           bfd_vma offset, bfd_vma size)
12964
12957
{
12965
 
  struct elf32_arm_link_hash_table *htab;
12966
12958
  Elf_Internal_Sym sym;
12967
12959
 
12968
 
  htab = elf32_arm_hash_table (osi->info);
12969
12960
  sym.st_value = osi->sec->output_section->vma
12970
12961
                 + osi->sec->output_offset
12971
12962
                 + offset;
12982
12973
{
12983
12974
  struct elf32_arm_stub_hash_entry *stub_entry;
12984
12975
  struct bfd_link_info *info;
12985
 
  struct elf32_arm_link_hash_table *htab;
12986
12976
  asection *stub_sec;
12987
12977
  bfd_vma addr;
12988
12978
  char *stub_name;
12999
12989
 
13000
12990
  info = osi->info;
13001
12991
 
13002
 
  htab = elf32_arm_hash_table (info);
13003
12992
  stub_sec = stub_entry->stub_sec;
13004
12993
 
13005
12994
  /* Ensure this stub is attached to the current section being
13083
13072
  return TRUE;
13084
13073
}
13085
13074
 
13086
 
/* Output mapping symbols for linker generated sections.  */
 
13075
/* Output mapping symbols for linker generated sections,
 
13076
   and for those data-only sections that do not have a
 
13077
   $d.  */
13087
13078
 
13088
13079
static bfd_boolean
13089
13080
elf32_arm_output_arch_local_syms (bfd *output_bfd,
13098
13089
  struct elf32_arm_link_hash_table *htab;
13099
13090
  bfd_vma offset;
13100
13091
  bfd_size_type size;
 
13092
  bfd *input_bfd;
13101
13093
 
13102
13094
  htab = elf32_arm_hash_table (info);
 
13095
  if (htab == NULL)
 
13096
    return FALSE;
 
13097
 
13103
13098
  check_use_blx (htab);
13104
13099
 
13105
13100
  osi.finfo = finfo;
13106
13101
  osi.info = info;
13107
13102
  osi.func = func;
13108
13103
 
 
13104
  /* Add a $d mapping symbol to data-only sections that
 
13105
     don't have any mapping symbol.  This may result in (harmless) redundant
 
13106
     mapping symbols.  */
 
13107
  for (input_bfd = info->input_bfds;
 
13108
       input_bfd != NULL;
 
13109
       input_bfd = input_bfd->link_next)
 
13110
    {
 
13111
      if ((input_bfd->flags & (BFD_LINKER_CREATED | HAS_SYMS)) == HAS_SYMS)
 
13112
        for (osi.sec = input_bfd->sections;
 
13113
             osi.sec != NULL;
 
13114
             osi.sec = osi.sec->next)
 
13115
          {
 
13116
            if (osi.sec->output_section != NULL
 
13117
                && (osi.sec->flags & (SEC_HAS_CONTENTS | SEC_LINKER_CREATED))
 
13118
                   == SEC_HAS_CONTENTS
 
13119
                && get_arm_elf_section_data (osi.sec) != NULL
 
13120
                && get_arm_elf_section_data (osi.sec)->mapcount == 0)
 
13121
              {
 
13122
                osi.sec_shndx = _bfd_elf_section_from_bfd_section
 
13123
                  (output_bfd, osi.sec->output_section);
 
13124
                if (osi.sec_shndx != (int)SHN_BAD)
 
13125
                  elf32_arm_output_map_sym (&osi, ARM_MAP_DATA, 0);
 
13126
              }
 
13127
          }
 
13128
    }
 
13129
 
13109
13130
  /* ARM->Thumb glue.  */
13110
13131
  if (htab->arm_glue_size > 0)
13111
13132
    {
13224
13245
      _arm_elf_section_data *sdata;
13225
13246
      bfd_size_type amt = sizeof (*sdata);
13226
13247
 
13227
 
      sdata = bfd_zalloc (abfd, amt);
 
13248
      sdata = (_arm_elf_section_data *) bfd_zalloc (abfd, amt);
13228
13249
      if (sdata == NULL)
13229
13250
        return FALSE;
13230
13251
      sec->used_by_bfd = sdata;
13311
13332
  bfd_vma veneered_insn_loc, veneer_entry_loc;
13312
13333
  bfd_signed_vma branch_offset;
13313
13334
  bfd *abfd;
13314
 
  unsigned int index;
 
13335
  unsigned int target;
13315
13336
 
13316
13337
  stub_entry = (struct elf32_arm_stub_hash_entry *) gen_entry;
13317
13338
  data = (struct a8_branch_to_stub_data *) in_arg;
13336
13357
  branch_offset = veneer_entry_loc - veneered_insn_loc - 4;
13337
13358
 
13338
13359
  abfd = stub_entry->target_section->owner;
13339
 
  index = stub_entry->target_value;
 
13360
  target = stub_entry->target_value;
13340
13361
 
13341
13362
  /* We attempt to avoid this condition by setting stubs_always_after_branch
13342
13363
     in elf32_arm_size_stubs if we've enabled the Cortex-A8 erratum workaround.
13397
13418
      return FALSE;
13398
13419
    }
13399
13420
 
13400
 
  bfd_put_16 (abfd, (branch_insn >> 16) & 0xffff, &contents[index]);
13401
 
  bfd_put_16 (abfd, branch_insn & 0xffff, &contents[index + 2]);
 
13421
  bfd_put_16 (abfd, (branch_insn >> 16) & 0xffff, &contents[target]);
 
13422
  bfd_put_16 (abfd, branch_insn & 0xffff, &contents[target + 2]);
13402
13423
 
13403
13424
  return TRUE;
13404
13425
}
13423
13444
  bfd_byte tmp;
13424
13445
  unsigned int i;
13425
13446
 
 
13447
  if (globals == NULL)
 
13448
    return FALSE;
 
13449
 
13426
13450
  /* If this section has not been allocated an _arm_elf_section_data
13427
13451
     structure then we cannot record anything.  */
13428
13452
  arm_data = get_arm_elf_section_data (sec);
13440
13464
      for (errnode = arm_data->erratumlist; errnode != 0;
13441
13465
           errnode = errnode->next)
13442
13466
        {
13443
 
          bfd_vma index = errnode->vma - offset;
 
13467
          bfd_vma target = errnode->vma - offset;
13444
13468
 
13445
13469
          switch (errnode->type)
13446
13470
            {
13453
13477
                                  | 0x0a000000;
13454
13478
 
13455
13479
                /* The instruction is before the label.  */
13456
 
                index -= 4;
 
13480
                target -= 4;
13457
13481
 
13458
13482
                /* Above offset included in -4 below.  */
13459
13483
                branch_to_veneer = errnode->u.b.veneer->vma
13465
13489
                                           "range"), output_bfd);
13466
13490
 
13467
13491
                insn |= (branch_to_veneer >> 2) & 0xffffff;
13468
 
                contents[endianflip ^ index] = insn & 0xff;
13469
 
                contents[endianflip ^ (index + 1)] = (insn >> 8) & 0xff;
13470
 
                contents[endianflip ^ (index + 2)] = (insn >> 16) & 0xff;
13471
 
                contents[endianflip ^ (index + 3)] = (insn >> 24) & 0xff;
 
13492
                contents[endianflip ^ target] = insn & 0xff;
 
13493
                contents[endianflip ^ (target + 1)] = (insn >> 8) & 0xff;
 
13494
                contents[endianflip ^ (target + 2)] = (insn >> 16) & 0xff;
 
13495
                contents[endianflip ^ (target + 3)] = (insn >> 24) & 0xff;
13472
13496
              }
13473
13497
              break;
13474
13498
 
13488
13512
 
13489
13513
                /* Original instruction.  */
13490
13514
                insn = errnode->u.v.branch->u.b.vfp_insn;
13491
 
                contents[endianflip ^ index] = insn & 0xff;
13492
 
                contents[endianflip ^ (index + 1)] = (insn >> 8) & 0xff;
13493
 
                contents[endianflip ^ (index + 2)] = (insn >> 16) & 0xff;
13494
 
                contents[endianflip ^ (index + 3)] = (insn >> 24) & 0xff;
 
13515
                contents[endianflip ^ target] = insn & 0xff;
 
13516
                contents[endianflip ^ (target + 1)] = (insn >> 8) & 0xff;
 
13517
                contents[endianflip ^ (target + 2)] = (insn >> 16) & 0xff;
 
13518
                contents[endianflip ^ (target + 3)] = (insn >> 24) & 0xff;
13495
13519
 
13496
13520
                /* Branch back to insn after original insn.  */
13497
13521
                insn = 0xea000000 | ((branch_from_veneer >> 2) & 0xffffff);
13498
 
                contents[endianflip ^ (index + 4)] = insn & 0xff;
13499
 
                contents[endianflip ^ (index + 5)] = (insn >> 8) & 0xff;
13500
 
                contents[endianflip ^ (index + 6)] = (insn >> 16) & 0xff;
13501
 
                contents[endianflip ^ (index + 7)] = (insn >> 24) & 0xff;
 
13522
                contents[endianflip ^ (target + 4)] = insn & 0xff;
 
13523
                contents[endianflip ^ (target + 5)] = (insn >> 8) & 0xff;
 
13524
                contents[endianflip ^ (target + 6)] = (insn >> 16) & 0xff;
 
13525
                contents[endianflip ^ (target + 7)] = (insn >> 24) & 0xff;
13502
13526
              }
13503
13527
              break;
13504
13528
 
13516
13540
         size (before we merged duplicate entries and inserted EXIDX_CANTUNWIND
13517
13541
         markers) was sec->rawsize.  (This isn't the case if we perform no
13518
13542
         edits, then rawsize will be zero and we should use size).  */
13519
 
      bfd_byte *edited_contents = bfd_malloc (sec->size);
 
13543
      bfd_byte *edited_contents = (bfd_byte *) bfd_malloc (sec->size);
13520
13544
      unsigned int input_size = sec->rawsize ? sec->rawsize : sec->size;
13521
13545
      unsigned int in_index, out_index;
13522
13546
      bfd_vma add_to_offsets = 0;
13789
13813
        m = m->next;
13790
13814
      if (!m)
13791
13815
        {
13792
 
          m = bfd_zalloc (abfd, sizeof (struct elf_segment_map));
 
13816
          m = (struct elf_segment_map *)
 
13817
              bfd_zalloc (abfd, sizeof (struct elf_segment_map));
13793
13818
          if (m == NULL)
13794
13819
            return FALSE;
13795
13820
          m->p_type = PT_ARM_EXIDX;
14001
14026
#include "elf32-target.h"
14002
14027
 
14003
14028
 
 
14029
/* Merge backend specific data from an object file to the output
 
14030
   object file when linking.  */
 
14031
 
 
14032
static bfd_boolean
 
14033
elf32_arm_merge_private_bfd_data (bfd * ibfd, bfd * obfd)
 
14034
{
 
14035
  flagword out_flags;
 
14036
  flagword in_flags;
 
14037
  bfd_boolean flags_compatible = TRUE;
 
14038
  asection *sec;
 
14039
 
 
14040
  /* Check if we have the same endianess.  */
 
14041
  if (! _bfd_generic_verify_endian_match (ibfd, obfd))
 
14042
    return FALSE;
 
14043
 
 
14044
  if (! is_arm_elf (ibfd) || ! is_arm_elf (obfd))
 
14045
    return TRUE;
 
14046
 
 
14047
  if (!elf32_arm_merge_eabi_attributes (ibfd, obfd))
 
14048
    return FALSE;
 
14049
 
 
14050
  /* The input BFD must have had its flags initialised.  */
 
14051
  /* The following seems bogus to me -- The flags are initialized in
 
14052
     the assembler but I don't think an elf_flags_init field is
 
14053
     written into the object.  */
 
14054
  /* BFD_ASSERT (elf_flags_init (ibfd)); */
 
14055
 
 
14056
  in_flags  = elf_elfheader (ibfd)->e_flags;
 
14057
  out_flags = elf_elfheader (obfd)->e_flags;
 
14058
 
 
14059
  /* In theory there is no reason why we couldn't handle this.  However
 
14060
     in practice it isn't even close to working and there is no real
 
14061
     reason to want it.  */
 
14062
  if (EF_ARM_EABI_VERSION (in_flags) >= EF_ARM_EABI_VER4
 
14063
      && !(ibfd->flags & DYNAMIC)
 
14064
      && (in_flags & EF_ARM_BE8))
 
14065
    {
 
14066
      _bfd_error_handler (_("error: %B is already in final BE8 format"),
 
14067
                          ibfd);
 
14068
      return FALSE;
 
14069
    }
 
14070
 
 
14071
  if (!elf_flags_init (obfd))
 
14072
    {
 
14073
      /* If the input is the default architecture and had the default
 
14074
         flags then do not bother setting the flags for the output
 
14075
         architecture, instead allow future merges to do this.  If no
 
14076
         future merges ever set these flags then they will retain their
 
14077
         uninitialised values, which surprise surprise, correspond
 
14078
         to the default values.  */
 
14079
      if (bfd_get_arch_info (ibfd)->the_default
 
14080
          && elf_elfheader (ibfd)->e_flags == 0)
 
14081
        return TRUE;
 
14082
 
 
14083
      elf_flags_init (obfd) = TRUE;
 
14084
      elf_elfheader (obfd)->e_flags = in_flags;
 
14085
 
 
14086
      if (bfd_get_arch (obfd) == bfd_get_arch (ibfd)
 
14087
          && bfd_get_arch_info (obfd)->the_default)
 
14088
        return bfd_set_arch_mach (obfd, bfd_get_arch (ibfd), bfd_get_mach (ibfd));
 
14089
 
 
14090
      return TRUE;
 
14091
    }
 
14092
 
 
14093
  /* Determine what should happen if the input ARM architecture
 
14094
     does not match the output ARM architecture.  */
 
14095
  if (! bfd_arm_merge_machines (ibfd, obfd))
 
14096
    return FALSE;
 
14097
 
 
14098
  /* Identical flags must be compatible.  */
 
14099
  if (in_flags == out_flags)
 
14100
    return TRUE;
 
14101
 
 
14102
  /* Check to see if the input BFD actually contains any sections.  If
 
14103
     not, its flags may not have been initialised either, but it
 
14104
     cannot actually cause any incompatiblity.  Do not short-circuit
 
14105
     dynamic objects; their section list may be emptied by
 
14106
    elf_link_add_object_symbols.
 
14107
 
 
14108
    Also check to see if there are no code sections in the input.
 
14109
    In this case there is no need to check for code specific flags.
 
14110
    XXX - do we need to worry about floating-point format compatability
 
14111
    in data sections ?  */
 
14112
  if (!(ibfd->flags & DYNAMIC))
 
14113
    {
 
14114
      bfd_boolean null_input_bfd = TRUE;
 
14115
      bfd_boolean only_data_sections = TRUE;
 
14116
 
 
14117
      for (sec = ibfd->sections; sec != NULL; sec = sec->next)
 
14118
        {
 
14119
          /* Ignore synthetic glue sections.  */
 
14120
          if (strcmp (sec->name, ".glue_7")
 
14121
              && strcmp (sec->name, ".glue_7t"))
 
14122
            {
 
14123
              if ((bfd_get_section_flags (ibfd, sec)
 
14124
                   & (SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS))
 
14125
                  == (SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS))
 
14126
                only_data_sections = FALSE;
 
14127
 
 
14128
              null_input_bfd = FALSE;
 
14129
              break;
 
14130
            }
 
14131
        }
 
14132
 
 
14133
      if (null_input_bfd || only_data_sections)
 
14134
        return TRUE;
 
14135
    }
 
14136
 
 
14137
  /* Complain about various flag mismatches.  */
 
14138
  if (!elf32_arm_versions_compatible (EF_ARM_EABI_VERSION (in_flags),
 
14139
                                      EF_ARM_EABI_VERSION (out_flags)))
 
14140
    {
 
14141
      _bfd_error_handler
 
14142
        (_("error: Source object %B has EABI version %d, but target %B has EABI version %d"),
 
14143
         ibfd, obfd,
 
14144
         (in_flags & EF_ARM_EABIMASK) >> 24,
 
14145
         (out_flags & EF_ARM_EABIMASK) >> 24);
 
14146
      return FALSE;
 
14147
    }
 
14148
 
 
14149
  /* Not sure what needs to be checked for EABI versions >= 1.  */
 
14150
  /* VxWorks libraries do not use these flags.  */
 
14151
  if (get_elf_backend_data (obfd) != &elf32_arm_vxworks_bed
 
14152
      && get_elf_backend_data (ibfd) != &elf32_arm_vxworks_bed
 
14153
      && EF_ARM_EABI_VERSION (in_flags) == EF_ARM_EABI_UNKNOWN)
 
14154
    {
 
14155
      if ((in_flags & EF_ARM_APCS_26) != (out_flags & EF_ARM_APCS_26))
 
14156
        {
 
14157
          _bfd_error_handler
 
14158
            (_("error: %B is compiled for APCS-%d, whereas target %B uses APCS-%d"),
 
14159
             ibfd, obfd,
 
14160
             in_flags & EF_ARM_APCS_26 ? 26 : 32,
 
14161
             out_flags & EF_ARM_APCS_26 ? 26 : 32);
 
14162
          flags_compatible = FALSE;
 
14163
        }
 
14164
 
 
14165
      if ((in_flags & EF_ARM_APCS_FLOAT) != (out_flags & EF_ARM_APCS_FLOAT))
 
14166
        {
 
14167
          if (in_flags & EF_ARM_APCS_FLOAT)
 
14168
            _bfd_error_handler
 
14169
              (_("error: %B passes floats in float registers, whereas %B passes them in integer registers"),
 
14170
               ibfd, obfd);
 
14171
          else
 
14172
            _bfd_error_handler
 
14173
              (_("error: %B passes floats in integer registers, whereas %B passes them in float registers"),
 
14174
               ibfd, obfd);
 
14175
 
 
14176
          flags_compatible = FALSE;
 
14177
        }
 
14178
 
 
14179
      if ((in_flags & EF_ARM_VFP_FLOAT) != (out_flags & EF_ARM_VFP_FLOAT))
 
14180
        {
 
14181
          if (in_flags & EF_ARM_VFP_FLOAT)
 
14182
            _bfd_error_handler
 
14183
              (_("error: %B uses VFP instructions, whereas %B does not"),
 
14184
               ibfd, obfd);
 
14185
          else
 
14186
            _bfd_error_handler
 
14187
              (_("error: %B uses FPA instructions, whereas %B does not"),
 
14188
               ibfd, obfd);
 
14189
 
 
14190
          flags_compatible = FALSE;
 
14191
        }
 
14192
 
 
14193
      if ((in_flags & EF_ARM_MAVERICK_FLOAT) != (out_flags & EF_ARM_MAVERICK_FLOAT))
 
14194
        {
 
14195
          if (in_flags & EF_ARM_MAVERICK_FLOAT)
 
14196
            _bfd_error_handler
 
14197
              (_("error: %B uses Maverick instructions, whereas %B does not"),
 
14198
               ibfd, obfd);
 
14199
          else
 
14200
            _bfd_error_handler
 
14201
              (_("error: %B does not use Maverick instructions, whereas %B does"),
 
14202
               ibfd, obfd);
 
14203
 
 
14204
          flags_compatible = FALSE;
 
14205
        }
 
14206
 
 
14207
#ifdef EF_ARM_SOFT_FLOAT
 
14208
      if ((in_flags & EF_ARM_SOFT_FLOAT) != (out_flags & EF_ARM_SOFT_FLOAT))
 
14209
        {
 
14210
          /* We can allow interworking between code that is VFP format
 
14211
             layout, and uses either soft float or integer regs for
 
14212
             passing floating point arguments and results.  We already
 
14213
             know that the APCS_FLOAT flags match; similarly for VFP
 
14214
             flags.  */
 
14215
          if ((in_flags & EF_ARM_APCS_FLOAT) != 0
 
14216
              || (in_flags & EF_ARM_VFP_FLOAT) == 0)
 
14217
            {
 
14218
              if (in_flags & EF_ARM_SOFT_FLOAT)
 
14219
                _bfd_error_handler
 
14220
                  (_("error: %B uses software FP, whereas %B uses hardware FP"),
 
14221
                   ibfd, obfd);
 
14222
              else
 
14223
                _bfd_error_handler
 
14224
                  (_("error: %B uses hardware FP, whereas %B uses software FP"),
 
14225
                   ibfd, obfd);
 
14226
 
 
14227
              flags_compatible = FALSE;
 
14228
            }
 
14229
        }
 
14230
#endif
 
14231
 
 
14232
      /* Interworking mismatch is only a warning.  */
 
14233
      if ((in_flags & EF_ARM_INTERWORK) != (out_flags & EF_ARM_INTERWORK))
 
14234
        {
 
14235
          if (in_flags & EF_ARM_INTERWORK)
 
14236
            {
 
14237
              _bfd_error_handler
 
14238
                (_("Warning: %B supports interworking, whereas %B does not"),
 
14239
                 ibfd, obfd);
 
14240
            }
 
14241
          else
 
14242
            {
 
14243
              _bfd_error_handler
 
14244
                (_("Warning: %B does not support interworking, whereas %B does"),
 
14245
                 ibfd, obfd);
 
14246
            }
 
14247
        }
 
14248
    }
 
14249
 
 
14250
  return flags_compatible;
 
14251
}
 
14252
 
 
14253
 
14004
14254
/* Symbian OS Targets.  */
14005
14255
 
14006
14256
#undef  TARGET_LITTLE_SYM