1 /* objdump.c -- dump information about an object file.
2 Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
4 This file is part of GNU Binutils.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
27 #define ELF_STAB_DISPLAY /* This code works, but uses internal
28 bfd and elf stuff. Flip this define
29 off if you need to just use generic
32 #ifdef ELF_STAB_DISPLAY
33 /* Internal headers for the ELF .stab-dump code - sorry. */
34 #define BYTES_IN_WORD 32
35 #include "aout/aout64.h"
36 #include "elf/internal.h"
37 extern Elf_Internal_Shdr *bfd_elf_find_section();
38 #endif /* ELF_STAB_DISPLAY */
40 extern char *xmalloc ();
41 extern int fprintf PARAMS ((FILE *, CONST char *, ...));
43 char *default_target = NULL; /* default at runtime */
45 extern *program_version;
46 char *program_name = NULL;
48 int show_version = 0; /* show the version number */
49 int dump_section_contents; /* -s */
50 int dump_section_headers; /* -h */
51 boolean dump_file_header; /* -f */
52 int dump_symtab; /* -t */
53 int dump_reloc_info; /* -r */
54 int dump_ar_hdrs; /* -a */
55 int with_line_numbers; /* -l */
56 int dump_stab_section_info; /* -stabs */
57 boolean disassemble; /* -d */
58 boolean info; /* -i */
59 char *only; /* -j secname */
61 struct objdump_disasm_info {
66 char *machine = (char *) NULL;
71 unsigned int symcount = 0;
73 /* Forward declarations. */
76 display_file PARAMS ((char *filename, char *target));
79 dump_data PARAMS ((bfd *abfd));
82 dump_relocs PARAMS ((bfd *abfd));
85 dump_symbols PARAMS ((bfd *abfd));
88 usage (stream, status)
93 Usage: %s [-ahifdrtxsl] [-m machine] [-j section_name] [-b bfdname]\n\
94 [--syms] [--reloc] [--header] [--version] [--help] objfile...\n\
95 at least one option besides -l must be given\n",
100 static struct option long_options[]=
102 {"syms", no_argument, &dump_symtab, 1},
103 {"reloc", no_argument, &dump_reloc_info, 1},
104 {"header", no_argument, &dump_section_headers, 1},
105 {"version", no_argument, &show_version, 1},
106 {"help", no_argument, 0, 'H'},
107 #ifdef ELF_STAB_DISPLAY
108 {"stabs", no_argument, &dump_stab_section_info, 1},
110 {0, no_argument, 0, 0}
120 for (section = abfd->sections;
121 section != (asection *) NULL;
122 section = section->next)
127 if (section->flags & x) { printf("%s%s",comma,y); comma = ", "; }
130 printf ("SECTION %d [%s]\t: size %08x",
133 (unsigned) bfd_get_section_size_before_reloc (section));
135 printf_vma (section->vma);
136 printf (" align 2**%u\n ",
137 section->alignment_power);
138 PF (SEC_ALLOC, "ALLOC");
139 PF (SEC_CONSTRUCTOR, "CONSTRUCTOR");
140 PF (SEC_CONSTRUCTOR_TEXT, "CONSTRUCTOR TEXT");
141 PF (SEC_CONSTRUCTOR_DATA, "CONSTRUCTOR DATA");
142 PF (SEC_CONSTRUCTOR_BSS, "CONSTRUCTOR BSS");
143 PF (SEC_LOAD, "LOAD");
144 PF (SEC_RELOC, "RELOC");
146 PF (SEC_BALIGN, "BALIGN");
148 PF (SEC_READONLY, "READONLY");
149 PF (SEC_CODE, "CODE");
150 PF (SEC_DATA, "DATA");
158 DEFUN (slurp_symtab, (abfd),
161 asymbol **sy = (asymbol **) NULL;
163 if (!(bfd_get_file_flags (abfd) & HAS_SYMS))
165 (void) printf ("No symbols in \"%s\".\n", bfd_get_filename (abfd));
169 storage = get_symtab_upper_bound (abfd);
172 sy = (asymbol **) malloc (storage);
175 fprintf (stderr, "%s: out of memory.\n", program_name);
179 symcount = bfd_canonicalize_symtab (abfd, sy);
182 fprintf (stderr, "%s: Bad symbol table in \"%s\".\n",
183 program_name, bfd_get_filename (abfd));
189 /* Filter out (in place) symbols that are useless for dis-assemble.
190 Return count of useful symbols. */
192 int remove_useless_symbols (syms, count)
196 register asymbol **in_ptr = syms;
197 register asymbol **out_ptr = syms;
199 while ( --count >= 0 )
201 asymbol *sym = *in_ptr++;
203 if (sym->name == NULL || sym->name[0] == '\0')
205 if (sym->flags & (BSF_DEBUGGING))
207 if (sym->section == &bfd_und_section
208 || bfd_is_com_section (sym->section))
213 return out_ptr - syms;
217 /* Sort symbols into value order */
223 asymbol *a = *(asymbol **)ap;
224 asymbol *b = *(asymbol **)bp;
226 if (a->value > b->value)
228 else if (a->value < b->value)
231 if (a->section > b->section)
233 else if (a->section < b->section)
238 /* Print the supplied address symbolically if possible */
240 objdump_print_address (vma, info)
242 struct disassemble_info *info;
244 /* Perform a binary search looking for the closest symbol to
245 the required value. */
246 /* @@ For relocateable files, should filter out symbols belonging to
247 the wrong section. Unfortunately, not enough information is supplied
248 to this routine to determine the correct section in all cases. */
249 /* @@ Would it speed things up to cache the last two symbols returned,
250 and maybe their address ranges? For many processors, only one memory
251 operand can be present at a time, so the 2-entry cache wouldn't be
252 constantly churned by code doing heavy memory accesses. */
254 unsigned int min = 0;
255 unsigned int max = symcount;
257 unsigned int thisplace = 1;
258 unsigned int oldthisplace;
262 fprintf_vma (info->stream, vma);
268 asymbol *sym; asection *sym_sec;
269 oldthisplace = thisplace;
270 thisplace = (max + min) / 2;
271 if (thisplace == oldthisplace)
273 sym = syms[thisplace];
274 vardiff = sym->value - vma;
275 sym_sec = sym->section;
279 else if (vardiff < 0)
284 /* We've run out of places to look, print the symbol before this one
285 see if this or the symbol before describes this location the best */
289 if (syms[thisplace - 1]->value - vma >
290 syms[thisplace]->value - vma)
292 /* Previous symbol is in correct section and is closer */
299 bfd_vma val = syms[thisplace]->value;
301 if (syms[thisplace]->flags & (BSF_LOCAL|BSF_DEBUGGING))
302 for (i = thisplace - 1; i >= 0; i--)
304 if (syms[i]->value == val
305 && (!(syms[i]->flags & (BSF_LOCAL|BSF_DEBUGGING))
306 || ((syms[thisplace]->flags & BSF_DEBUGGING)
307 && !(syms[i]->flags & BSF_DEBUGGING))))
313 if (syms[thisplace]->flags & (BSF_LOCAL|BSF_DEBUGGING))
314 for (i = thisplace + 1; i < symcount; i++)
316 if (syms[i]->value == val
317 && (!(syms[i]->flags & (BSF_LOCAL|BSF_DEBUGGING))
318 || ((syms[thisplace]->flags & BSF_DEBUGGING)
319 && !(syms[i]->flags & BSF_DEBUGGING))))
327 /* If the file is relocateable, and the symbol could be from this
328 section, prefer a symbol from this section over symbols from
329 others, even if the other symbol's value might be closer.
331 Note that this may be wrong for some symbol references if the
332 sections have overlapping memory ranges, but in that case there's
333 no way to tell what's desired without looking at the relocation
335 struct objdump_disasm_info *aux;
338 aux = (struct objdump_disasm_info *) info->application_data;
339 if (aux->abfd->flags & HAS_RELOC
340 && vma >= bfd_get_section_vma (aux->abfd, aux->sec)
341 && vma < (bfd_get_section_vma (aux->abfd, aux->sec)
342 + bfd_get_section_size_before_reloc (aux->sec))
343 && syms[thisplace]->section != aux->sec)
345 for (i = thisplace + 1; i < symcount; i++)
346 if (syms[i]->value != syms[thisplace]->value)
349 if (syms[i]->section == aux->sec)
356 fprintf (info->stream, " <%s", syms[thisplace]->name);
357 if (syms[thisplace]->value > vma)
359 char buf[30], *p = buf;
360 sprintf_vma (buf, syms[thisplace]->value - vma);
363 fprintf (info->stream, "-%s", p);
365 else if (vma > syms[thisplace]->value)
367 char buf[30], *p = buf;
368 sprintf_vma (buf, vma - syms[thisplace]->value);
371 fprintf (info->stream, "+%s", p);
373 fprintf (info->stream, ">");
394 disassemble_data (abfd)
397 bfd_byte *data = NULL;
398 bfd_arch_info_type *info;
399 bfd_size_type datasize = 0;
401 unsigned int (*print) ()= 0; /* Old style */
402 disassembler_ftype disassemble = 0; /* New style */
403 enum bfd_architecture a;
404 struct disassemble_info disasm_info;
405 struct objdump_disasm_info aux;
408 CONST char *prev_function = "";
412 /* Replace symbol section relative values with abs values */
413 boolean done_dot = false;
415 INIT_DISASSEMBLE_INFO(disasm_info, stdout);
416 disasm_info.application_data = (PTR) &aux;
418 disasm_info.print_address_func = objdump_print_address;
420 for (i = 0; i < symcount; i++)
422 syms[i]->value += syms[i]->section->vma;
425 symcount = remove_useless_symbols (syms, symcount);
427 /* Sort the symbols into section and symbol order */
428 (void) qsort (syms, symcount, sizeof (asymbol *), comp);
430 if (machine != (char *) NULL)
432 info = bfd_scan_arch (machine);
435 fprintf (stderr, "%s: Can't use supplied machine %s\n",
440 abfd->arch_info = info;
443 /* See if we can disassemble using bfd */
445 if (abfd->arch_info->disassemble)
447 print = abfd->arch_info->disassemble;
451 a = bfd_get_arch (abfd);
454 /* If you add a case to this table, also add it to the
455 ARCH_all definition right above this function. */
458 /* As far as I know we only handle big-endian 29k objects. */
459 disassemble = print_insn_big_a29k;
464 disassemble = print_insn_alpha;
469 if (bfd_get_mach(abfd) == bfd_mach_h8300h)
470 disassemble = print_insn_h8300h;
472 disassemble = print_insn_h8300;
477 disassemble = print_insn_h8500;
482 disassemble = print_insn_hppa;
487 disassemble = print_insn_i386;
492 disassemble = print_insn_i960;
497 disassemble = print_insn_m68k;
502 disassemble = print_insn_m88k;
507 if (abfd->xvec->byteorder_big_p)
508 disassemble = print_insn_big_mips;
510 disassemble = print_insn_little_mips;
515 disassemble = print_insn_sh;
520 disassemble = print_insn_sparc;
525 if (bfd_get_mach(abfd) == bfd_mach_z8001)
526 disassemble = print_insn_z8001;
528 disassemble = print_insn_z8002;
532 fprintf (stderr, "%s: Can't disassemble for architecture %s\n",
534 bfd_printable_arch_mach (bfd_get_arch (abfd), 0));
540 for (section = abfd->sections;
541 section != (asection *) NULL;
542 section = section->next)
546 if ((section->flags & SEC_LOAD)
547 && (only == (char *) NULL || strcmp (only, section->name) == 0))
549 printf ("Disassembly of section %s:\n", section->name);
551 if (bfd_get_section_size_before_reloc (section) == 0)
554 data = (bfd_byte *) malloc ((size_t) bfd_get_section_size_before_reloc (section));
556 if (data == (bfd_byte *) NULL)
558 fprintf (stderr, "%s: memory exhausted.\n", program_name);
561 datasize = bfd_get_section_size_before_reloc (section);
563 bfd_get_section_contents (abfd, section, data, 0, bfd_get_section_size_before_reloc (section));
565 disasm_info.buffer = data;
566 disasm_info.buffer_vma = section->vma;
567 disasm_info.buffer_length =
568 bfd_get_section_size_before_reloc (section);
570 while (i < disasm_info.buffer_length)
572 if (data[i] == 0 && data[i + 1] == 0 && data[i + 2] == 0 &&
575 if (done_dot == false)
585 if (with_line_numbers)
587 CONST char *filename;
588 CONST char *functionname;
591 if (bfd_find_nearest_line (abfd,
599 if (functionname && *functionname
600 && strcmp(functionname, prev_function))
602 printf ("%s():\n", functionname);
603 prev_function = functionname;
607 if (line && line != prevline)
609 printf ("%s:%u\n", filename, line);
614 objdump_print_address (section->vma + i, &disasm_info);
617 if (disassemble) /* New style */
619 int bytes = (*disassemble)(section->vma + i,
626 i += print (section->vma + i,
637 #ifdef ELF_STAB_DISPLAY
639 /* Define a table of stab values and print-strings. We wish the initializer
640 could be a direct-mapped table, but instead we build one the first
643 #define STAB_STRING_LENGTH 6
645 char stab_name[256][STAB_STRING_LENGTH];
649 char string[STAB_STRING_LENGTH];
652 struct stab_print stab_print[] = {
653 #define __define_stab(NAME, CODE, STRING) {CODE, STRING},
654 #include "aout/stab.def"
659 void dump_elf_stabs_1 ();
661 /* This is a kludge for dumping the stabs section from an ELF file that
662 uses Sun stabs encoding. It has to use some hooks into BFD because
663 string table sections are not normally visible to BFD callers. */
666 dump_elf_stabs (abfd)
671 /* Initialize stab name array if first time. */
672 if (stab_name[0][0] == 0)
674 /* Fill in numeric values for all possible strings. */
675 for (i = 0; i < 256; i++)
677 sprintf (stab_name[i], "%d", i);
679 for (i = 0; stab_print[i].string[0]; i++)
680 strcpy (stab_name[stab_print[i].value], stab_print[i].string);
683 if (0 != strncmp ("elf", abfd->xvec->name, 3))
685 fprintf (stderr, "%s: %s is not in ELF format.\n", program_name,
690 dump_elf_stabs_1 (abfd, ".stab", ".stabstr");
691 dump_elf_stabs_1 (abfd, ".stab.excl", ".stab.exclstr");
692 dump_elf_stabs_1 (abfd, ".stab.index", ".stab.indexstr");
696 dump_elf_stabs_1 (abfd, name1, name2)
698 char *name1; /* Section name of .stab */
699 char *name2; /* Section name of its string section */
701 Elf_Internal_Shdr *stab_hdr, *stabstr_hdr;
703 struct internal_nlist *stabs, *stabs_end;
705 unsigned file_string_table_offset, next_file_string_table_offset;
707 stab_hdr = bfd_elf_find_section (abfd, name1);
710 printf ("Contents of %s section: none.\n\n", name1);
714 stabstr_hdr = bfd_elf_find_section (abfd, name2);
715 if (0 == stabstr_hdr)
717 fprintf (stderr, "%s: %s has no %s section.\n", program_name,
718 abfd->filename, name2);
722 stabs = (struct internal_nlist *) xmalloc (stab_hdr ->sh_size);
723 strtab = (char *) xmalloc (stabstr_hdr->sh_size);
724 stabs_end = (struct internal_nlist *) (stab_hdr->sh_size + (char *)stabs);
726 if (bfd_seek (abfd, stab_hdr->sh_offset, SEEK_SET) < 0 ||
727 stab_hdr->sh_size != bfd_read ((PTR)stabs, stab_hdr->sh_size, 1, abfd))
729 fprintf (stderr, "%s: reading %s section of %s failed.\n",
735 if (bfd_seek (abfd, stabstr_hdr->sh_offset, SEEK_SET) < 0 ||
736 stabstr_hdr->sh_size != bfd_read ((PTR)strtab, stabstr_hdr->sh_size,
739 fprintf (stderr, "%s: reading %s section of %s failed.\n",
745 #define SWAP_SYMBOL(symp, abfd) \
747 (symp)->n_strx = bfd_h_get_32(abfd, \
748 (unsigned char *)&(symp)->n_strx); \
749 (symp)->n_desc = bfd_h_get_16 (abfd, \
750 (unsigned char *)&(symp)->n_desc); \
751 (symp)->n_value = bfd_h_get_32 (abfd, \
752 (unsigned char *)&(symp)->n_value); \
755 printf ("Contents of %s section:\n\n", name1);
756 printf ("Symnum n_type n_othr n_desc n_value n_strx String\n");
758 file_string_table_offset = 0;
759 next_file_string_table_offset = 0;
761 /* Loop through all symbols and print them.
763 We start the index at -1 because there is a dummy symbol on
764 the front of Sun's stabs-in-elf sections. */
766 for (i = -1; stabs < stabs_end; stabs++, i++)
768 SWAP_SYMBOL (stabs, abfd);
769 printf ("\n%-6d %-6s %-6d %-6d %08x %-6d", i,
770 stab_name [stabs->n_type],
771 stabs->n_other, stabs->n_desc, stabs->n_value,
774 /* Symbols with type == 0 (N_UNDF) specify the length of the
775 string table associated with this file. We use that info
776 to know how to relocate the *next* file's string table indices. */
778 if (stabs->n_type == N_UNDF)
780 file_string_table_offset = next_file_string_table_offset;
781 next_file_string_table_offset += stabs->n_value;
784 /* Now, using the possibly updated string table offset, print the
785 string (if any) associated with this symbol. */
787 if ((stabs->n_strx + file_string_table_offset) < stabstr_hdr->sh_size)
788 printf (" %s", &strtab[stabs->n_strx + file_string_table_offset]);
794 #endif /* ELF_STAB_DISPLAY */
800 if (!bfd_check_format (abfd, bfd_object))
802 fprintf (stderr, "%s:%s: %s\n", program_name, abfd->filename,
803 bfd_errmsg (bfd_error));
806 printf ("\n%s: file format %s\n", abfd->filename, abfd->xvec->name);
808 print_arelt_descr (stdout, abfd, true);
810 if (dump_file_header)
814 printf ("architecture: %s, ",
815 bfd_printable_arch_mach (bfd_get_arch (abfd),
816 bfd_get_mach (abfd)));
817 printf ("flags 0x%08x:\n", abfd->flags);
819 #define PF(x, y) if (abfd->flags & x) {printf("%s%s", comma, y); comma=", ";}
820 PF (HAS_RELOC, "HAS_RELOC");
821 PF (EXEC_P, "EXEC_P");
822 PF (HAS_LINENO, "HAS_LINENO");
823 PF (HAS_DEBUG, "HAS_DEBUG");
824 PF (HAS_SYMS, "HAS_SYMS");
825 PF (HAS_LOCALS, "HAS_LOCALS");
826 PF (DYNAMIC, "DYNAMIC");
827 PF (WP_TEXT, "WP_TEXT");
828 PF (D_PAGED, "D_PAGED");
829 PF (BFD_IS_RELAXABLE, "BFD_IS_RELAXABLE");
830 printf ("\nstart address 0x");
831 printf_vma (abfd->start_address);
835 if (dump_section_headers)
837 if (dump_symtab || dump_reloc_info || disassemble)
839 syms = slurp_symtab (abfd);
843 #ifdef ELF_STAB_DISPLAY
844 if (dump_stab_section_info)
845 dump_elf_stabs (abfd);
849 if (dump_section_contents)
851 /* Note that disassemble_data re-orders the syms table, but that is
852 safe - as long as it is done last! */
854 disassemble_data (abfd);
858 display_file (filename, target)
862 bfd *file, *arfile = (bfd *) NULL;
864 file = bfd_openr (filename, target);
867 fprintf (stderr, "%s: ", program_name);
868 bfd_perror (filename);
872 if (bfd_check_format (file, bfd_archive) == true)
874 printf ("In archive %s:\n", bfd_get_filename (file));
877 bfd_error = no_error;
879 arfile = bfd_openr_next_archived_file (file, arfile);
882 if (bfd_error != no_more_archived_files)
884 fprintf (stderr, "%s: ", program_name);
885 bfd_perror (bfd_get_filename (file));
890 display_bfd (arfile);
891 /* Don't close the archive elements; we need them for next_archive */
900 /* Actually display the various requested regions */
908 bfd_size_type datasize = 0;
911 for (section = abfd->sections; section != NULL; section =
916 if (only == (char *) NULL ||
917 strcmp (only, section->name) == 0)
919 if (section->flags & SEC_HAS_CONTENTS)
921 printf ("Contents of section %s:\n", section->name);
923 if (bfd_get_section_size_before_reloc (section) == 0)
925 data = (bfd_byte *) malloc ((size_t) bfd_get_section_size_before_reloc (section));
926 if (data == (bfd_byte *) NULL)
928 fprintf (stderr, "%s: memory exhausted.\n", program_name);
931 datasize = bfd_get_section_size_before_reloc (section);
934 bfd_get_section_contents (abfd, section, (PTR) data, 0, bfd_get_section_size_before_reloc (section));
936 for (i = 0; i < bfd_get_section_size_before_reloc (section); i += onaline)
940 printf (" %04lx ", (unsigned long int) (i + section->vma));
941 for (j = i; j < i + onaline; j++)
943 if (j < bfd_get_section_size_before_reloc (section))
944 printf ("%02x", (unsigned) (data[j]));
952 for (j = i; j < i + onaline; j++)
954 if (j >= bfd_get_section_size_before_reloc (section))
957 printf ("%c", isprint (data[j]) ? data[j] : '.');
967 /* Should perhaps share code and display with nm? */
974 asymbol **current = syms;
976 printf ("SYMBOL TABLE:\n");
978 for (count = 0; count < symcount; count++)
983 bfd *cur_bfd = bfd_asymbol_bfd(*current);
986 bfd_print_symbol (cur_bfd,
988 *current, bfd_print_symbol_all);
1004 unsigned int relcount;
1007 for (a = abfd->sections; a != (asection *) NULL; a = a->next)
1009 if (a == &bfd_abs_section)
1011 if (a == &bfd_und_section)
1013 if (bfd_is_com_section (a))
1018 if (strcmp (only, a->name))
1021 else if ((a->flags & SEC_RELOC) == 0)
1024 printf ("RELOCATION RECORDS FOR [%s]:", a->name);
1026 if (bfd_get_reloc_upper_bound (abfd, a) == 0)
1028 printf (" (none)\n\n");
1034 relpp = (arelent **) xmalloc (bfd_get_reloc_upper_bound (abfd, a));
1035 /* Note that this must be done *before* we sort the syms table. */
1036 relcount = bfd_canonicalize_reloc (abfd, a, relpp, syms);
1039 printf (" (none)\n\n");
1044 /* Get column headers lined up reasonably. */
1050 sprintf_vma (buf, (bfd_vma) -1);
1051 width = strlen (buf) - 7;
1053 printf ("OFFSET %*s TYPE %*s VALUE \n", width, "", 12, "");
1056 for (p = relpp; relcount && *p != (arelent *) NULL; p++,
1060 CONST char *sym_name;
1061 CONST char *section_name = (*(q->sym_ptr_ptr))->section->name;
1063 if (q->sym_ptr_ptr && *q->sym_ptr_ptr)
1065 sym_name = (*(q->sym_ptr_ptr))->name;
1073 printf_vma (q->address);
1074 printf (" %-16s %s",
1080 printf_vma (q->address);
1081 printf (" %-16s [%s]",
1088 printf_vma (q->addend);
1101 #define _DUMMY_NAME_ "/dev/null"
1103 #define _DUMMY_NAME_ "##dummy"
1106 DEFUN (display_info_table, (first, last),
1107 int first AND int last)
1110 extern bfd_target *target_vector[];
1112 printf ("\n%12s", " ");
1113 for (i = first; i++ < last && target_vector[i];)
1114 printf ("%s ", target_vector[i]->name);
1117 for (j = (int) bfd_arch_obscure + 1; (int) j < (int) bfd_arch_last; j++)
1118 if (strcmp (bfd_printable_arch_mach (j, 0), "UNKNOWN!") != 0)
1120 printf ("%11s ", bfd_printable_arch_mach (j, 0));
1121 for (i = first; i++ < last && target_vector[i];)
1123 bfd_target *p = target_vector[i];
1124 bfd *abfd = bfd_openw (_DUMMY_NAME_, p->name);
1125 int l = strlen (p->name);
1127 bfd_set_format (abfd, bfd_object);
1128 ok = bfd_set_arch_mach (abfd, j, 0);
1131 printf ("%s ", p->name);
1135 printf ("%c", ok ? '*' : '-');
1144 DEFUN_VOID (display_info)
1147 unsigned int i, j, columns;
1148 extern bfd_target *target_vector[];
1149 extern char *getenv ();
1151 printf ("BFD header file version %s\n", BFD_VERSION);
1152 for (i = 0; target_vector[i]; i++)
1154 bfd_target *p = target_vector[i];
1155 bfd *abfd = bfd_openw (_DUMMY_NAME_, p->name);
1156 bfd_set_format (abfd, bfd_object);
1157 printf ("%s\n (header %s, data %s)\n", p->name,
1158 p->header_byteorder_big_p ? "big endian" : "little endian",
1159 p->byteorder_big_p ? "big endian" : "little endian");
1160 for (j = (int) bfd_arch_obscure + 1; j < (int) bfd_arch_last; j++)
1161 if (bfd_set_arch_mach (abfd, (enum bfd_architecture) j, 0))
1163 bfd_printable_arch_mach ((enum bfd_architecture) j, 0));
1166 if (colum = getenv ("COLUMNS"))
1167 columns = atoi (colum);
1170 for (i = 0; target_vector[i];)
1174 for (j = 12; target_vector[i] && j < columns; i++)
1175 j += strlen (target_vector[i]->name) + 1;
1179 display_info_table (old, i);
1183 /** main and like trivia */
1191 extern char *optarg;
1192 char *target = default_target;
1193 boolean seenflag = false;
1196 program_name = *argv;
1198 while ((c = getopt_long (argc, argv, "ib:m:Vdlfahrtxsj:", long_options,
1206 break; /* we've been given a long option */
1214 with_line_numbers = 1;
1220 dump_file_header = true;
1227 dump_reloc_info = 1;
1228 dump_file_header = true;
1230 dump_section_headers = 1;
1239 dump_section_contents = 1;
1242 dump_reloc_info = 1;
1248 dump_section_headers = 1;
1262 printf ("GNU %s version %s\n", program_name, program_version);
1266 if (seenflag == false)
1276 display_file ("a.out", target);
1278 for (; optind < argc;)
1279 display_file (argv[optind++], target);