~ubuntu-branches/debian/experimental/binutils/experimental

« back to all changes in this revision

Viewing changes to bfd/elf64-mmix.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-07-31 22:20:22 UTC
  • mfrom: (1.7.10)
  • Revision ID: package-import@ubuntu.com-20120731222022-0anxbeg8at8rnrx1
Tags: 2.22.90.20120731-1
New upstream snapshot (taken from the 2.23 branch).

Show diffs side-by-side

added added

removed removed

Lines of Context:
167
167
    struct bpo_reloc_request *reloc_request;
168
168
  };
169
169
 
170
 
static int mmix_elf_link_output_symbol_hook
171
 
  PARAMS ((struct bfd_link_info *, const char *, Elf_Internal_Sym *,
172
 
           asection *, struct elf_link_hash_entry *));
173
 
 
174
 
static bfd_reloc_status_type mmix_elf_reloc
175
 
  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
176
 
 
177
 
static reloc_howto_type *bfd_elf64_bfd_reloc_type_lookup
178
 
  PARAMS ((bfd *, bfd_reloc_code_real_type));
179
 
 
180
 
static void mmix_info_to_howto_rela
181
 
  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
182
 
 
183
 
static int mmix_elf_sort_relocs PARAMS ((const PTR, const PTR));
184
 
 
185
 
static bfd_boolean mmix_elf_new_section_hook
186
 
  PARAMS ((bfd *, asection *));
187
 
 
188
 
static bfd_boolean mmix_elf_check_relocs
189
 
  PARAMS ((bfd *, struct bfd_link_info *, asection *,
190
 
           const Elf_Internal_Rela *));
191
 
 
192
 
static bfd_boolean mmix_elf_check_common_relocs
193
 
  PARAMS ((bfd *, struct bfd_link_info *, asection *,
194
 
           const Elf_Internal_Rela *));
195
 
 
196
 
static bfd_boolean mmix_elf_relocate_section
197
 
  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
198
 
           Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
199
 
 
200
 
static bfd_reloc_status_type mmix_final_link_relocate
201
 
  (reloc_howto_type *, asection *, bfd_byte *, bfd_vma, bfd_signed_vma,
202
 
   bfd_vma, const char *, asection *, char **);
203
 
 
204
 
static bfd_reloc_status_type mmix_elf_perform_relocation
205
 
  (asection *, reloc_howto_type *, void *, bfd_vma, bfd_vma, char **);
206
 
 
207
 
static bfd_boolean mmix_elf_section_from_bfd_section
208
 
  PARAMS ((bfd *, asection *, int *));
209
 
 
210
 
static bfd_boolean mmix_elf_add_symbol_hook
211
 
  PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Sym *,
212
 
           const char **, flagword *, asection **, bfd_vma *));
213
 
 
214
 
static bfd_boolean mmix_elf_is_local_label_name
215
 
  PARAMS ((bfd *, const char *));
216
 
 
217
 
static int bpo_reloc_request_sort_fn PARAMS ((const PTR, const PTR));
218
 
 
219
 
static bfd_boolean mmix_elf_relax_section
220
 
  PARAMS ((bfd *abfd, asection *sec, struct bfd_link_info *link_info,
221
 
           bfd_boolean *again));
222
 
 
223
 
extern bfd_boolean mmix_elf_final_link PARAMS ((bfd *, struct bfd_link_info *));
224
 
 
225
 
extern void mmix_elf_symbol_processing PARAMS ((bfd *, asymbol *));
 
170
 
 
171
extern bfd_boolean mmix_elf_final_link (bfd *, struct bfd_link_info *);
 
172
 
 
173
extern void mmix_elf_symbol_processing (bfd *, asymbol *);
226
174
 
227
175
/* Only intended to be called from a debugger.  */
228
176
extern void mmix_dump_bpo_gregs
229
 
  PARAMS ((struct bfd_link_info *, bfd_error_handler_type));
 
177
  (struct bfd_link_info *, bfd_error_handler_type);
230
178
 
231
179
static void
232
 
mmix_set_relaxable_size
233
 
  PARAMS ((bfd *, asection *, void *));
 
180
mmix_set_relaxable_size (bfd *, asection *, void *);
 
181
static bfd_reloc_status_type
 
182
mmix_elf_reloc (bfd *, arelent *, asymbol *, void *,
 
183
                asection *, bfd *, char **);
 
184
static bfd_reloc_status_type
 
185
mmix_final_link_relocate (reloc_howto_type *, asection *, bfd_byte *, bfd_vma,
 
186
                          bfd_signed_vma, bfd_vma, const char *, asection *,
 
187
                          char **);
234
188
 
235
189
 
236
190
/* Watch out: this currently needs to have elements with the same index as
841
795
  };
842
796
 
843
797
static reloc_howto_type *
844
 
bfd_elf64_bfd_reloc_type_lookup (abfd, code)
845
 
     bfd *abfd ATTRIBUTE_UNUSED;
846
 
     bfd_reloc_code_real_type code;
 
798
bfd_elf64_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 
799
                                 bfd_reloc_code_real_type code)
847
800
{
848
801
  unsigned int i;
849
802
 
875
828
}
876
829
 
877
830
static bfd_boolean
878
 
mmix_elf_new_section_hook (abfd, sec)
879
 
     bfd *abfd;
880
 
     asection *sec;
 
831
mmix_elf_new_section_hook (bfd *abfd, asection *sec)
881
832
{
882
833
  if (!sec->used_by_bfd)
883
834
    {
1303
1254
/* Set the howto pointer for an MMIX ELF reloc (type RELA).  */
1304
1255
 
1305
1256
static void
1306
 
mmix_info_to_howto_rela (abfd, cache_ptr, dst)
1307
 
     bfd *abfd ATTRIBUTE_UNUSED;
1308
 
     arelent *cache_ptr;
1309
 
     Elf_Internal_Rela *dst;
 
1257
mmix_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
 
1258
                         arelent *cache_ptr,
 
1259
                         Elf_Internal_Rela *dst)
1310
1260
{
1311
1261
  unsigned int r_type;
1312
1262
 
1320
1270
   the reloc_table.  We don't get here for final pure ELF linking.  */
1321
1271
 
1322
1272
static bfd_reloc_status_type
1323
 
mmix_elf_reloc (abfd, reloc_entry, symbol, data, input_section,
1324
 
                output_bfd, error_message)
1325
 
     bfd *abfd;
1326
 
     arelent *reloc_entry;
1327
 
     asymbol *symbol;
1328
 
     PTR data;
1329
 
     asection *input_section;
1330
 
     bfd *output_bfd;
1331
 
     char **error_message;
 
1273
mmix_elf_reloc (bfd *abfd,
 
1274
                arelent *reloc_entry,
 
1275
                asymbol *symbol,
 
1276
                void * data,
 
1277
                asection *input_section,
 
1278
                bfd *output_bfd,
 
1279
                char **error_message)
1332
1280
{
1333
1281
  bfd_vma relocation;
1334
1282
  bfd_reloc_status_type r;
1398
1346
   for guidance if you're thinking of copying this.  */
1399
1347
 
1400
1348
static bfd_boolean
1401
 
mmix_elf_relocate_section (output_bfd, info, input_bfd, input_section,
1402
 
                           contents, relocs, local_syms, local_sections)
1403
 
     bfd *output_bfd ATTRIBUTE_UNUSED;
1404
 
     struct bfd_link_info *info;
1405
 
     bfd *input_bfd;
1406
 
     asection *input_section;
1407
 
     bfd_byte *contents;
1408
 
     Elf_Internal_Rela *relocs;
1409
 
     Elf_Internal_Sym *local_syms;
1410
 
     asection **local_sections;
 
1349
mmix_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
 
1350
                           struct bfd_link_info *info,
 
1351
                           bfd *input_bfd,
 
1352
                           asection *input_section,
 
1353
                           bfd_byte *contents,
 
1354
                           Elf_Internal_Rela *relocs,
 
1355
                           Elf_Internal_Sym *local_syms,
 
1356
                           asection **local_sections)
1411
1357
{
1412
1358
  Elf_Internal_Shdr *symtab_hdr;
1413
1359
  struct elf_link_hash_entry **sym_hashes;
1858
1804
/* Sort register relocs to come before expanding relocs.  */
1859
1805
 
1860
1806
static int
1861
 
mmix_elf_sort_relocs (p1, p2)
1862
 
     const PTR p1;
1863
 
     const PTR p2;
 
1807
mmix_elf_sort_relocs (const void * p1, const void * p2)
1864
1808
{
1865
1809
  const Elf_Internal_Rela *r1 = (const Elf_Internal_Rela *) p1;
1866
1810
  const Elf_Internal_Rela *r2 = (const Elf_Internal_Rela *) p2;
1893
1837
/* Subset of mmix_elf_check_relocs, common to ELF and mmo linking.  */
1894
1838
 
1895
1839
static bfd_boolean
1896
 
mmix_elf_check_common_relocs  (abfd, info, sec, relocs)
1897
 
     bfd *abfd;
1898
 
     struct bfd_link_info *info;
1899
 
     asection *sec;
1900
 
     const Elf_Internal_Rela *relocs;
 
1840
mmix_elf_check_common_relocs  (bfd *abfd,
 
1841
                               struct bfd_link_info *info,
 
1842
                               asection *sec,
 
1843
                               const Elf_Internal_Rela *relocs)
1901
1844
{
1902
1845
  bfd *bpo_greg_owner = NULL;
1903
1846
  asection *allocated_gregs_section = NULL;
1930
1873
          if (bpo_greg_owner == NULL)
1931
1874
            {
1932
1875
              bpo_greg_owner = abfd;
1933
 
              info->base_file = (PTR) bpo_greg_owner;
 
1876
              info->base_file = bpo_greg_owner;
1934
1877
            }
1935
1878
 
1936
1879
          if (allocated_gregs_section == NULL)
2026
1969
/* Look through the relocs for a section during the first phase.  */
2027
1970
 
2028
1971
static bfd_boolean
2029
 
mmix_elf_check_relocs (abfd, info, sec, relocs)
2030
 
     bfd *abfd;
2031
 
     struct bfd_link_info *info;
2032
 
     asection *sec;
2033
 
     const Elf_Internal_Rela *relocs;
 
1972
mmix_elf_check_relocs (bfd *abfd,
 
1973
                       struct bfd_link_info *info,
 
1974
                       asection *sec,
 
1975
                       const Elf_Internal_Rela *relocs)
2034
1976
{
2035
1977
  Elf_Internal_Shdr *symtab_hdr;
2036
1978
  struct elf_link_hash_entry **sym_hashes;
2042
1984
 
2043
1985
  /* First we sort the relocs so that any register relocs come before
2044
1986
     expansion-relocs to the same insn.  FIXME: Not done for mmo.  */
2045
 
  qsort ((PTR) relocs, sec->reloc_count, sizeof (Elf_Internal_Rela),
 
1987
  qsort ((void *) relocs, sec->reloc_count, sizeof (Elf_Internal_Rela),
2046
1988
         mmix_elf_sort_relocs);
2047
1989
 
2048
1990
  /* Do the common part.  */
2096
2038
   Copied from elf_link_add_object_symbols.  */
2097
2039
 
2098
2040
bfd_boolean
2099
 
_bfd_mmix_check_all_relocs (abfd, info)
2100
 
     bfd *abfd;
2101
 
     struct bfd_link_info *info;
 
2041
_bfd_mmix_check_all_relocs (bfd *abfd, struct bfd_link_info *info)
2102
2042
{
2103
2043
  asection *o;
2104
2044
 
2115
2055
        continue;
2116
2056
 
2117
2057
      internal_relocs
2118
 
        = _bfd_elf_link_read_relocs (abfd, o, (PTR) NULL,
 
2058
        = _bfd_elf_link_read_relocs (abfd, o, NULL,
2119
2059
                                     (Elf_Internal_Rela *) NULL,
2120
2060
                                     info->keep_memory);
2121
2061
      if (internal_relocs == NULL)
2138
2078
   number.  */
2139
2079
 
2140
2080
static int
2141
 
mmix_elf_link_output_symbol_hook (info, name, sym, input_sec, h)
2142
 
     struct bfd_link_info *info ATTRIBUTE_UNUSED;
2143
 
     const char *name ATTRIBUTE_UNUSED;
2144
 
     Elf_Internal_Sym *sym;
2145
 
     asection *input_sec;
2146
 
     struct elf_link_hash_entry *h ATTRIBUTE_UNUSED;
 
2081
mmix_elf_link_output_symbol_hook (struct bfd_link_info *info ATTRIBUTE_UNUSED,
 
2082
                                  const char *name ATTRIBUTE_UNUSED,
 
2083
                                  Elf_Internal_Sym *sym,
 
2084
                                  asection *input_sec,
 
2085
                                  struct elf_link_hash_entry *h ATTRIBUTE_UNUSED)
2147
2086
{
2148
2087
  if (input_sec != NULL
2149
2088
      && input_sec->name != NULL
2203
2142
   index.  */
2204
2143
 
2205
2144
static bfd_boolean
2206
 
mmix_elf_section_from_bfd_section (abfd, sec, retval)
2207
 
     bfd *                 abfd ATTRIBUTE_UNUSED;
2208
 
     asection *            sec;
2209
 
     int *                 retval;
 
2145
mmix_elf_section_from_bfd_section (bfd *       abfd ATTRIBUTE_UNUSED,
 
2146
                                   asection *  sec,
 
2147
                                   int *       retval)
2210
2148
{
2211
2149
  if (strcmp (bfd_get_section_name (abfd, sec), MMIX_REG_SECTION_NAME) == 0)
2212
2150
    *retval = SHN_REGISTER;
2223
2161
   symbols, since otherwise having two with the same value would cause
2224
2162
   them to be "merged", but with the contents serialized.  */
2225
2163
 
2226
 
bfd_boolean
2227
 
mmix_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
2228
 
     bfd *abfd;
2229
 
     struct bfd_link_info *info ATTRIBUTE_UNUSED;
2230
 
     Elf_Internal_Sym *sym;
2231
 
     const char **namep ATTRIBUTE_UNUSED;
2232
 
     flagword *flagsp ATTRIBUTE_UNUSED;
2233
 
     asection **secp;
2234
 
     bfd_vma *valp ATTRIBUTE_UNUSED;
 
2164
static bfd_boolean
 
2165
mmix_elf_add_symbol_hook (bfd *abfd,
 
2166
                          struct bfd_link_info *info ATTRIBUTE_UNUSED,
 
2167
                          Elf_Internal_Sym *sym,
 
2168
                          const char **namep ATTRIBUTE_UNUSED,
 
2169
                          flagword *flagsp ATTRIBUTE_UNUSED,
 
2170
                          asection **secp,
 
2171
                          bfd_vma *valp ATTRIBUTE_UNUSED)
2235
2172
{
2236
2173
  if (sym->st_shndx == SHN_REGISTER)
2237
2174
    {
2266
2203
 
2267
2204
/* We consider symbols matching "L.*:[0-9]+" to be local symbols.  */
2268
2205
 
2269
 
bfd_boolean
2270
 
mmix_elf_is_local_label_name (abfd, name)
2271
 
     bfd *abfd;
2272
 
     const char *name;
 
2206
static bfd_boolean
 
2207
mmix_elf_is_local_label_name (bfd *abfd, const char *name)
2273
2208
{
2274
2209
  const char *colpos;
2275
2210
  int digits;
2297
2232
/* We get rid of the register section here.  */
2298
2233
 
2299
2234
bfd_boolean
2300
 
mmix_elf_final_link (abfd, info)
2301
 
     bfd *abfd;
2302
 
     struct bfd_link_info *info;
 
2235
mmix_elf_final_link (bfd *abfd, struct bfd_link_info *info)
2303
2236
{
2304
2237
  /* We never output a register section, though we create one for
2305
2238
     temporary measures.  Check that nobody entered contents into it.  */
2346
2279
   section size.  This is expected to shrink during linker relaxation.  */
2347
2280
 
2348
2281
static void
2349
 
mmix_set_relaxable_size (abfd, sec, ptr)
2350
 
     bfd *abfd ATTRIBUTE_UNUSED;
2351
 
     asection *sec;
2352
 
     void *ptr;
 
2282
mmix_set_relaxable_size (bfd *abfd ATTRIBUTE_UNUSED,
 
2283
                         asection *sec,
 
2284
                         void *ptr)
2353
2285
{
2354
2286
  struct bfd_link_info *info = ptr;
2355
2287
 
2374
2306
   R_MMIX_BASE_PLUS_OFFSET relocs seen by the linker.  */
2375
2307
 
2376
2308
bfd_boolean
2377
 
_bfd_mmix_before_linker_allocation (abfd, info)
2378
 
     bfd *abfd ATTRIBUTE_UNUSED;
2379
 
     struct bfd_link_info *info;
 
2309
_bfd_mmix_before_linker_allocation (bfd *abfd ATTRIBUTE_UNUSED,
 
2310
                                    struct bfd_link_info *info)
2380
2311
{
2381
2312
  asection *bpo_gregs_section;
2382
2313
  bfd *bpo_greg_owner;
2453
2384
   calculated at this point; we just move the contents into place here.  */
2454
2385
 
2455
2386
bfd_boolean
2456
 
_bfd_mmix_after_linker_allocation (abfd, link_info)
2457
 
     bfd *abfd ATTRIBUTE_UNUSED;
2458
 
     struct bfd_link_info *link_info;
 
2387
_bfd_mmix_after_linker_allocation (bfd *abfd ATTRIBUTE_UNUSED,
 
2388
                                   struct bfd_link_info *link_info)
2459
2389
{
2460
2390
  asection *bpo_gregs_section;
2461
2391
  bfd *bpo_greg_owner;
2526
2456
   value.  */
2527
2457
 
2528
2458
static int
2529
 
bpo_reloc_request_sort_fn (p1, p2)
2530
 
     const PTR p1;
2531
 
     const PTR p2;
 
2459
bpo_reloc_request_sort_fn (const void * p1, const void * p2)
2532
2460
{
2533
2461
  const struct bpo_reloc_request *r1 = (const struct bpo_reloc_request *) p1;
2534
2462
  const struct bpo_reloc_request *r2 = (const struct bpo_reloc_request *) p2;
2619
2547
   Symbol- and reloc-reading infrastructure copied from elf-m10200.c.  */
2620
2548
 
2621
2549
static bfd_boolean
2622
 
mmix_elf_relax_section (abfd, sec, link_info, again)
2623
 
     bfd *abfd;
2624
 
     asection *sec;
2625
 
     struct bfd_link_info *link_info;
2626
 
     bfd_boolean *again;
 
2550
mmix_elf_relax_section (bfd *abfd,
 
2551
                        asection *sec,
 
2552
                        struct bfd_link_info *link_info,
 
2553
                        bfd_boolean *again)
2627
2554
{
2628
2555
  Elf_Internal_Shdr *symtab_hdr;
2629
2556
  Elf_Internal_Rela *internal_relocs;
2669
2596
 
2670
2597
  /* Get a copy of the native relocations.  */
2671
2598
  internal_relocs
2672
 
    = _bfd_elf_link_read_relocs (abfd, sec, (PTR) NULL,
 
2599
    = _bfd_elf_link_read_relocs (abfd, sec, NULL,
2673
2600
                                 (Elf_Internal_Rela *) NULL,
2674
2601
                                 link_info->keep_memory);
2675
2602
  if (internal_relocs == NULL)
2873
2800
      gregdata->n_remaining_bpo_relocs_this_relaxation_round
2874
2801
        = gregdata->n_bpo_relocs;
2875
2802
 
2876
 
      qsort ((PTR) gregdata->reloc_request,
 
2803
      qsort (gregdata->reloc_request,
2877
2804
             gregdata->n_max_bpo_relocs,
2878
2805
             sizeof (struct bpo_reloc_request),
2879
2806
             bpo_reloc_request_sort_fn);