~ubuntu-branches/debian/squeeze/binutils/squeeze

« back to all changes in this revision

Viewing changes to binutils/objdump.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-09-10 17:05:30 UTC
  • mfrom: (1.4.5 upstream) (6.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090910170530-wa6gpju9pq5c56on
Tags: 2.19.91.20090910-1
* Snapshot, taken from the 2.20 release branch 20090910, corresponding
  to the 2.19.90 upstream snapshot.
* Fix Thumb-2 shared libraries (Daniel Jacobowitz), patch taken
  from the trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
320
320
  exit_status = 1;
321
321
}
322
322
 
 
323
/* Returns TRUE if the specified section should be dumped.  */
 
324
 
 
325
static bfd_boolean
 
326
process_section_p (asection * section)
 
327
{
 
328
  size_t i;
 
329
 
 
330
  if (only == NULL)
 
331
    return TRUE;
 
332
 
 
333
  for (i = 0; i < only_used; i++)
 
334
    if (strcmp (only [i], section->name) == 0)
 
335
      return TRUE;
 
336
 
 
337
  return FALSE;
 
338
}
 
339
 
323
340
static void
324
341
dump_section_header (bfd *abfd, asection *section,
325
342
                     void *ignored ATTRIBUTE_UNUSED)
332
349
  if (section->flags & SEC_LINKER_CREATED)
333
350
    return;
334
351
 
 
352
  /* PR 10413: Skip sections that we are ignoring.  */
 
353
  if (! process_section_p (section))
 
354
    return;
 
355
 
335
356
  printf ("%3d %-13s %08lx  ", section->index,
336
357
          bfd_get_section_name (abfd, section),
337
358
          (unsigned long) bfd_section_size (abfd, section) / opb);
446
467
  if (storage < 0)
447
468
    bfd_fatal (bfd_get_filename (abfd));
448
469
  if (storage)
449
 
    sy = xmalloc (storage);
 
470
    sy = (asymbol **) xmalloc (storage);
450
471
 
451
472
  symcount = bfd_canonicalize_symtab (abfd, sy);
452
473
  if (symcount < 0)
475
496
      bfd_fatal (bfd_get_filename (abfd));
476
497
    }
477
498
  if (storage)
478
 
    sy = xmalloc (storage);
 
499
    sy = (asymbol **) xmalloc (storage);
479
500
 
480
501
  dynsymcount = bfd_canonicalize_dynamic_symtab (abfd, sy);
481
502
  if (dynsymcount < 0)
726
747
  aux = (struct objdump_disasm_info *) info->application_data;
727
748
  abfd = aux->abfd;
728
749
  sec = aux->sec;
729
 
  opb = bfd_octets_per_byte (abfd);
 
750
  opb = info->octets_per_byte;
730
751
 
731
752
  /* Perform a binary search looking for the closest symbol to the
732
753
     required value.  We are searching the range (min, max].  */
1019
1040
      return map; 
1020
1041
    }
1021
1042
#endif
1022
 
  map = malloc (*size);
 
1043
  map = (const char *) malloc (*size);
1023
1044
  if (!map || (size_t) read (fd, (char *)map, *size) != *size) 
1024
1045
    { 
1025
1046
      free ((void *)map);
1074
1095
          if (line_map_size < lineno + 1)
1075
1096
            line_map_size = lineno + 1;
1076
1097
          newsize = line_map_size * sizeof (char *);
1077
 
          linemap = xrealloc (linemap, newsize);
 
1098
          linemap = (const char **) xrealloc (linemap, newsize);
1078
1099
        }
1079
1100
 
1080
1101
      linemap[lineno++] = lstart; 
1093
1114
{
1094
1115
  struct print_file_list *p;
1095
1116
 
1096
 
  p = xmalloc (sizeof (struct print_file_list));
 
1117
  p = (struct print_file_list *) xmalloc (sizeof (struct print_file_list));
1097
1118
 
1098
1119
  p->map = slurp_file (modname, &p->mapsize);
1099
1120
  if (p->map == NULL)
1312
1333
    {
1313
1334
      if (prev_functionname != NULL)
1314
1335
        free (prev_functionname);
1315
 
      prev_functionname = xmalloc (strlen (functionname) + 1);
 
1336
      prev_functionname = (char *) xmalloc (strlen (functionname) + 1);
1316
1337
      strcpy (prev_functionname, functionname);
1317
1338
    }
1318
1339
 
1348
1369
        break;
1349
1370
      
1350
1371
      f->alloc = (f->alloc + n) * 2;
1351
 
      f->buffer = xrealloc (f->buffer, f->alloc);
 
1372
      f->buffer = (char *) xrealloc (f->buffer, f->alloc);
1352
1373
    }
1353
1374
  f->pos += n;
1354
1375
  
1355
1376
  return n;
1356
1377
}
1357
1378
 
1358
 
/* Returns TRUE if the specified section should be dumped.  */
1359
 
 
1360
 
static bfd_boolean
1361
 
process_section_p (asection * section)
1362
 
{
1363
 
  size_t i;
1364
 
 
1365
 
  if (only == NULL)
1366
 
    return TRUE;
1367
 
 
1368
 
  for (i = 0; i < only_used; i++)
1369
 
    if (strcmp (only [i], section->name) == 0)
1370
 
      return TRUE;
1371
 
 
1372
 
  return FALSE;
1373
 
}
1374
 
 
1375
 
 
1376
1379
/* The number of zeroes we want to see before we start skipping them.
1377
1380
   The number is arbitrarily chosen.  */
1378
1381
 
1416
1419
  section = aux->sec;
1417
1420
 
1418
1421
  sfile.alloc = 120;
1419
 
  sfile.buffer = xmalloc (sfile.alloc);
 
1422
  sfile.buffer = (char *) xmalloc (sfile.alloc);
1420
1423
  sfile.pos = 0;
1421
1424
  
1422
1425
  if (insn_width)
1832
1835
 
1833
1836
          if (relsize > 0)
1834
1837
            {
1835
 
              rel_ppstart = rel_pp = xmalloc (relsize);
 
1838
              rel_ppstart = rel_pp = (arelent **) xmalloc (relsize);
1836
1839
              rel_count = bfd_canonicalize_reloc (abfd, section, rel_pp, syms);
1837
1840
              if (rel_count < 0)
1838
1841
                bfd_fatal (bfd_get_filename (abfd));
1844
1847
    }
1845
1848
  rel_ppend = rel_pp + rel_count;
1846
1849
 
1847
 
  data = xmalloc (datasize);
 
1850
  data = (bfd_byte *) xmalloc (datasize);
1848
1851
 
1849
1852
  bfd_get_section_contents (abfd, section, data, 0, datasize);
1850
1853
 
1883
1886
 
1884
1887
  /* Find the nearest symbol forwards from our current position.  */
1885
1888
  paux->require_sec = TRUE;
1886
 
  sym = find_symbol_for_address (section->vma + addr_offset, info, &place);
 
1889
  sym = (asymbol *) find_symbol_for_address (section->vma + addr_offset,
 
1890
                                             (struct disassemble_info *) info,
 
1891
                                             &place);
1887
1892
  paux->require_sec = FALSE;
1888
1893
 
1889
1894
  /* PR 9774: If the target used signed 32-bit addresses then we must make
2020
2025
  /* We make a copy of syms to sort.  We don't want to sort syms
2021
2026
     because that will screw up the relocs.  */
2022
2027
  sorted_symcount = symcount ? symcount : dynsymcount;
2023
 
  sorted_syms = xmalloc ((sorted_symcount + synthcount) * sizeof (asymbol *));
 
2028
  sorted_syms = (asymbol **) xmalloc ((sorted_symcount + synthcount)
 
2029
                                      * sizeof (asymbol *));
2024
2030
  memcpy (sorted_syms, symcount ? syms : dynsyms,
2025
2031
          sorted_symcount * sizeof (asymbol *));
2026
2032
 
2061
2067
    {
2062
2068
      struct bfd_target *xvec;
2063
2069
 
2064
 
      xvec = xmalloc (sizeof (struct bfd_target));
 
2070
      xvec = (struct bfd_target *) xmalloc (sizeof (struct bfd_target));
2065
2071
      memcpy (xvec, abfd->xvec, sizeof (struct bfd_target));
2066
2072
      xvec->byteorder = endian;
2067
2073
      abfd->xvec = xvec;
2109
2115
 
2110
2116
      if (relsize > 0)
2111
2117
        {
2112
 
          aux.dynrelbuf = xmalloc (relsize);
 
2118
          aux.dynrelbuf = (arelent **) xmalloc (relsize);
2113
2119
          aux.dynrelcount = bfd_canonicalize_dynamic_reloc (abfd,
2114
2120
                                                            aux.dynrelbuf,
2115
2121
                                                            dynsyms);
2136
2142
                             asection *sec, void *file)
2137
2143
{
2138
2144
  struct dwarf_section *section = &debug_displays [debug].section;
2139
 
  bfd *abfd = file;
 
2145
  bfd *abfd = (bfd *) file;
2140
2146
  bfd_boolean ret;
2141
2147
  int section_is_compressed;
2142
2148
 
2148
2154
 
2149
2155
  section->address = 0;
2150
2156
  section->size = bfd_get_section_size (sec);
2151
 
  section->start = xmalloc (section->size);
 
2157
  section->start = (unsigned char *) xmalloc (section->size);
2152
2158
 
2153
2159
  if (is_relocatable && debug_displays [debug].relocate)
2154
2160
    ret = bfd_simple_get_relocated_section_contents (abfd,
2186
2192
load_debug_section (enum dwarf_section_display_enum debug, void *file)
2187
2193
{
2188
2194
  struct dwarf_section *section = &debug_displays [debug].section;
2189
 
  bfd *abfd = file;
 
2195
  bfd *abfd = (bfd *) file;
2190
2196
  asection *sec;
2191
2197
 
2192
2198
  /* If it is already loaded, do nothing.  */
2229
2235
{
2230
2236
  const char *name = bfd_get_section_name (abfd, section);
2231
2237
  const char *match;
2232
 
  enum dwarf_section_display_enum i;
 
2238
  int i;
2233
2239
 
2234
2240
  if (CONST_STRNEQ (name, ".gnu.linkonce.wi."))
2235
2241
    match = ".debug_info";
2248
2254
          sec->name = sec->uncompressed_name;
2249
2255
        else
2250
2256
          sec->name = sec->compressed_name;
2251
 
        if (load_specific_debug_section (i, section, abfd))
 
2257
        if (load_specific_debug_section ((enum dwarf_section_display_enum) i,
 
2258
                                         section, abfd))
2252
2259
          {
2253
2260
            debug_displays [i].display (sec, abfd);
2254
2261
            
2255
2262
            if (i != info && i != abbrev)
2256
 
              free_debug_section (i);
 
2263
              free_debug_section ((enum dwarf_section_display_enum) i);
2257
2264
          }
2258
2265
        break;
2259
2266
      }
2306
2313
    }
2307
2314
 
2308
2315
  size = bfd_section_size (abfd, stabsect);
2309
 
  contents  = xmalloc (size);
 
2316
  contents  = (char *) xmalloc (size);
2310
2317
 
2311
2318
  if (! bfd_get_section_contents (abfd, stabsect, contents, 0, size))
2312
2319
    {
2571
2578
            (unsigned long) (section->filepos + start_offset));
2572
2579
  printf ("\n");
2573
2580
 
2574
 
  data = xmalloc (datasize);
 
2581
  data = (bfd_byte *) xmalloc (datasize);
2575
2582
 
2576
2583
  bfd_get_section_contents (abfd, section, data, 0, datasize);
2577
2584
 
2862
2869
      return;
2863
2870
    }
2864
2871
 
2865
 
  relpp = xmalloc (relsize);
 
2872
  relpp = (arelent **) xmalloc (relsize);
2866
2873
  relcount = bfd_canonicalize_reloc (abfd, section, relpp, syms);
2867
2874
 
2868
2875
  if (relcount < 0)
2901
2908
    printf (" (none)\n\n");
2902
2909
  else
2903
2910
    {
2904
 
      relpp = xmalloc (relsize);
 
2911
      relpp = (arelent **) xmalloc (relsize);
2905
2912
      relcount = bfd_canonicalize_dynamic_reloc (abfd, relpp, dynsyms);
2906
2913
 
2907
2914
      if (relcount < 0)
2926
2933
  if (path[0] == 0)
2927
2934
    return;
2928
2935
  include_path_count++;
2929
 
  include_paths = xrealloc (include_paths,
2930
 
                            include_path_count * sizeof (*include_paths));
 
2936
  include_paths = (const char **)
 
2937
      xrealloc (include_paths, include_path_count * sizeof (*include_paths));
2931
2938
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
2932
2939
  if (path[1] == ':' && path[2] == 0)
2933
2940
    path = concat (path, ".", (const char *) 0);
3202
3209
          if (only_used == only_size)
3203
3210
            {
3204
3211
              only_size += 8;
3205
 
              only = xrealloc (only, only_size * sizeof (char *));
 
3212
              only = (char **) xrealloc (only, only_size * sizeof (char *));
3206
3213
            }
3207
3214
          only [only_used++] = optarg;
3208
3215
          break;