1 /* objdump.c -- dump information about an object file.
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4 Free Software Foundation, Inc.
6 This file is part of GNU Binutils.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
28 #include "safe-ctype.h"
30 #include "libiberty.h"
35 /* Internal headers for the ELF .stab-dump code - sorry. */
36 #define BYTES_IN_WORD 32
37 #include "aout/aout64.h"
39 #ifdef NEED_DECLARATION_FPRINTF
40 /* This is needed by INIT_DISASSEMBLE_INFO. */
41 extern int fprintf
PARAMS ((FILE *, const char *, ...));
45 static int exit_status
= 0;
47 static char *default_target
= NULL
; /* default at runtime */
49 static int show_version
= 0; /* show the version number */
50 static int dump_section_contents
; /* -s */
51 static int dump_section_headers
; /* -h */
52 static boolean dump_file_header
; /* -f */
53 static int dump_symtab
; /* -t */
54 static int dump_dynamic_symtab
; /* -T */
55 static int dump_reloc_info
; /* -r */
56 static int dump_dynamic_reloc_info
; /* -R */
57 static int dump_ar_hdrs
; /* -a */
58 static int dump_private_headers
; /* -p */
59 static int prefix_addresses
; /* --prefix-addresses */
60 static int with_line_numbers
; /* -l */
61 static boolean with_source_code
; /* -S */
62 static int show_raw_insn
; /* --show-raw-insn */
63 static int dump_stab_section_info
; /* --stabs */
64 static int do_demangle
; /* -C, --demangle */
65 static boolean disassemble
; /* -d */
66 static boolean disassemble_all
; /* -D */
67 static int disassemble_zeroes
; /* --disassemble-zeroes */
68 static boolean formats_info
; /* -i */
69 static char *only
; /* -j secname */
70 static int wide_output
; /* -w */
71 static bfd_vma start_address
= (bfd_vma
) -1; /* --start-address */
72 static bfd_vma stop_address
= (bfd_vma
) -1; /* --stop-address */
73 static int dump_debugging
; /* --debugging */
74 static bfd_vma adjust_section_vma
= 0; /* --adjust-vma */
75 static int file_start_context
= 0; /* --file-start-context */
77 /* Extra info to pass to the disassembler address printing function. */
78 struct objdump_disasm_info
85 /* Architecture to disassemble for, or default if NULL. */
86 static char *machine
= (char *) NULL
;
88 /* Target specific options to the disassembler. */
89 static char *disassembler_options
= (char *) NULL
;
91 /* Endianness to disassemble for, or default if BFD_ENDIAN_UNKNOWN. */
92 static enum bfd_endian endian
= BFD_ENDIAN_UNKNOWN
;
94 /* The symbol table. */
95 static asymbol
**syms
;
97 /* Number of symbols in `syms'. */
98 static long symcount
= 0;
100 /* The sorted symbol table. */
101 static asymbol
**sorted_syms
;
103 /* Number of symbols in `sorted_syms'. */
104 static long sorted_symcount
= 0;
106 /* The dynamic symbol table. */
107 static asymbol
**dynsyms
;
109 /* Number of symbols in `dynsyms'. */
110 static long dynsymcount
= 0;
112 /* Static declarations. */
114 static void usage
PARAMS ((FILE *, int));
115 static void nonfatal
PARAMS ((const char *));
116 static void display_file
PARAMS ((char *filename
, char *target
));
117 static void dump_section_header
PARAMS ((bfd
*, asection
*, PTR
));
118 static void dump_headers
PARAMS ((bfd
*));
119 static void dump_data
PARAMS ((bfd
*abfd
));
120 static void dump_relocs
PARAMS ((bfd
*abfd
));
121 static void dump_dynamic_relocs
PARAMS ((bfd
* abfd
));
122 static void dump_reloc_set
PARAMS ((bfd
*, asection
*, arelent
**, long));
123 static void dump_symbols
PARAMS ((bfd
*abfd
, boolean dynamic
));
124 static void dump_bfd_header
PARAMS ((bfd
*));
125 static void dump_bfd_private_header
PARAMS ((bfd
*));
126 static void dump_bfd
PARAMS ((bfd
*));
127 static void display_bfd
PARAMS ((bfd
*abfd
));
128 static void display_target_list
PARAMS ((void));
129 static void display_info_table
PARAMS ((int, int));
130 static void display_target_tables
PARAMS ((void));
131 static void display_info
PARAMS ((void));
132 static void objdump_print_value
133 PARAMS ((bfd_vma
, struct disassemble_info
*, boolean
));
134 static void objdump_print_symname
135 PARAMS ((bfd
*, struct disassemble_info
*, asymbol
*));
136 static asymbol
*find_symbol_for_address
137 PARAMS ((bfd
*, asection
*, bfd_vma
, boolean
, long *));
138 static void objdump_print_addr_with_sym
139 PARAMS ((bfd
*, asection
*, asymbol
*, bfd_vma
,
140 struct disassemble_info
*, boolean
));
141 static void objdump_print_addr
142 PARAMS ((bfd_vma
, struct disassemble_info
*, boolean
));
143 static void objdump_print_address
144 PARAMS ((bfd_vma
, struct disassemble_info
*));
145 static int objdump_symbol_at_address
146 PARAMS ((bfd_vma
, struct disassemble_info
*));
147 static void show_line
PARAMS ((bfd
*, asection
*, bfd_vma
));
148 static void disassemble_bytes
149 PARAMS ((struct disassemble_info
*, disassembler_ftype
, boolean
,
150 bfd_byte
*, bfd_vma
, bfd_vma
, arelent
***, arelent
**));
151 static void disassemble_data
PARAMS ((bfd
*));
152 static const char *endian_string
PARAMS ((enum bfd_endian
));
153 static asymbol
** slurp_symtab
PARAMS ((bfd
*));
154 static asymbol
** slurp_dynamic_symtab
PARAMS ((bfd
*));
155 static long remove_useless_symbols
PARAMS ((asymbol
**, long));
156 static int compare_symbols
PARAMS ((const PTR
, const PTR
));
157 static int compare_relocs
PARAMS ((const PTR
, const PTR
));
158 static void dump_stabs
PARAMS ((bfd
*));
159 static boolean read_section_stabs
PARAMS ((bfd
*, const char *, const char *));
160 static void print_section_stabs
PARAMS ((bfd
*, const char *, const char *));
163 usage (stream
, status
)
167 fprintf (stream
, _("Usage: %s <option(s)> <file(s)>\n"), program_name
);
168 fprintf (stream
, _(" Display information from object <file(s)>.\n"));
169 fprintf (stream
, _(" At least one of the following switches must be given:\n"));
170 fprintf (stream
, _("\
171 -a, --archive-headers Display archive header information\n\
172 -f, --file-headers Display the contents of the overall file header\n\
173 -p, --private-headers Display object format specific file header contents\n\
174 -h, --[section-]headers Display the contents of the section headers\n\
175 -x, --all-headers Display the contents of all headers\n\
176 -d, --disassemble Display assembler contents of executable sections\n\
177 -D, --disassemble-all Display assembler contents of all sections\n\
178 -S, --source Intermix source code with disassembly\n\
179 -s, --full-contents Display the full contents of all sections requested\n\
180 -g, --debugging Display debug information in object file\n\
181 -G, --stabs Display (in raw form) any STABS info in the file\n\
182 -t, --syms Display the contents of the symbol table(s)\n\
183 -T, --dynamic-syms Display the contents of the dynamic symbol table\n\
184 -r, --reloc Display the relocation entries in the file\n\
185 -R, --dynamic-reloc Display the dynamic relocation entries in the file\n\
186 -v, --version Display this program's version number\n\
187 -i, --info List object formats and architectures supported\n\
188 -H, --help Display this information\n\
192 fprintf (stream
, _("\n The following switches are optional:\n"));
193 fprintf (stream
, _("\
194 -b, --target=BFDNAME Specify the target object format as BFDNAME\n\
195 -m, --architecture=MACHINE Specify the target architecture as MACHINE\n\
196 -j, --section=NAME Only display information for section NAME\n\
197 -M, --disassembler-options=OPT Pass text OPT on to the disassembler\n\
198 -EB --endian=big Assume big endian format when disassembling\n\
199 -EL --endian=little Assume little endian format when disassembling\n\
200 --file-start-context Include context from start of file (with -S)\n\
201 -l, --line-numbers Include line numbers and filenames in output\n\
202 -C, --demangle[=STYLE] Decode mangled/processed symbol names\n\
203 The STYLE, if specified, can be `auto', 'gnu',\n\
204 'lucid', 'arm', 'hp', 'edg', or 'gnu-v3'\n\
205 -w, --wide Format output for more than 80 columns\n\
206 -z, --disassemble-zeroes Do not skip blocks of zeroes when disassembling\n\
207 --start-address=ADDR Only process data whoes address is >= ADDR\n\
208 --stop-address=ADDR Only process data whoes address is <= ADDR\n\
209 --prefix-addresses Print complete address alongside disassembly\n\
210 --[no-]show-raw-insn Display hex alongside symbolic disassembly\n\
211 --adjust-vma=OFFSET Add OFFSET to all displayed section addresses\n\
213 list_supported_targets (program_name
, stream
);
214 list_supported_architectures (program_name
, stream
);
216 disassembler_usage (stream
);
219 fprintf (stream
, _("Report bugs to %s.\n"), REPORT_BUGS_TO
);
223 /* 150 isn't special; it's just an arbitrary non-ASCII char value. */
225 #define OPTION_ENDIAN (150)
226 #define OPTION_START_ADDRESS (OPTION_ENDIAN + 1)
227 #define OPTION_STOP_ADDRESS (OPTION_START_ADDRESS + 1)
228 #define OPTION_ADJUST_VMA (OPTION_STOP_ADDRESS + 1)
230 static struct option long_options
[]=
232 {"adjust-vma", required_argument
, NULL
, OPTION_ADJUST_VMA
},
233 {"all-headers", no_argument
, NULL
, 'x'},
234 {"private-headers", no_argument
, NULL
, 'p'},
235 {"architecture", required_argument
, NULL
, 'm'},
236 {"archive-headers", no_argument
, NULL
, 'a'},
237 {"debugging", no_argument
, NULL
, 'g'},
238 {"demangle", optional_argument
, NULL
, 'C'},
239 {"disassemble", no_argument
, NULL
, 'd'},
240 {"disassemble-all", no_argument
, NULL
, 'D'},
241 {"disassembler-options", required_argument
, NULL
, 'M'},
242 {"disassemble-zeroes", no_argument
, NULL
, 'z'},
243 {"dynamic-reloc", no_argument
, NULL
, 'R'},
244 {"dynamic-syms", no_argument
, NULL
, 'T'},
245 {"endian", required_argument
, NULL
, OPTION_ENDIAN
},
246 {"file-headers", no_argument
, NULL
, 'f'},
247 {"file-start-context", no_argument
, &file_start_context
, 1},
248 {"full-contents", no_argument
, NULL
, 's'},
249 {"headers", no_argument
, NULL
, 'h'},
250 {"help", no_argument
, NULL
, 'H'},
251 {"info", no_argument
, NULL
, 'i'},
252 {"line-numbers", no_argument
, NULL
, 'l'},
253 {"no-show-raw-insn", no_argument
, &show_raw_insn
, -1},
254 {"prefix-addresses", no_argument
, &prefix_addresses
, 1},
255 {"reloc", no_argument
, NULL
, 'r'},
256 {"section", required_argument
, NULL
, 'j'},
257 {"section-headers", no_argument
, NULL
, 'h'},
258 {"show-raw-insn", no_argument
, &show_raw_insn
, 1},
259 {"source", no_argument
, NULL
, 'S'},
260 {"stabs", no_argument
, NULL
, 'G'},
261 {"start-address", required_argument
, NULL
, OPTION_START_ADDRESS
},
262 {"stop-address", required_argument
, NULL
, OPTION_STOP_ADDRESS
},
263 {"syms", no_argument
, NULL
, 't'},
264 {"target", required_argument
, NULL
, 'b'},
265 {"version", no_argument
, NULL
, 'V'},
266 {"wide", no_argument
, NULL
, 'w'},
267 {0, no_argument
, 0, 0}
279 dump_section_header (abfd
, section
, ignored
)
280 bfd
*abfd ATTRIBUTE_UNUSED
;
282 PTR ignored ATTRIBUTE_UNUSED
;
285 unsigned int opb
= bfd_octets_per_byte (abfd
);
287 printf ("%3d %-13s %08lx ", section
->index
,
288 bfd_get_section_name (abfd
, section
),
289 (unsigned long) bfd_section_size (abfd
, section
) / opb
);
290 bfd_printf_vma (abfd
, bfd_get_section_vma (abfd
, section
));
292 bfd_printf_vma (abfd
, section
->lma
);
293 printf (" %08lx 2**%u", (unsigned long) section
->filepos
,
294 bfd_get_section_alignment (abfd
, section
));
300 if (section->flags & x) { printf ("%s%s", comma, y); comma = ", "; }
302 PF (SEC_HAS_CONTENTS
, "CONTENTS");
303 PF (SEC_ALLOC
, "ALLOC");
304 PF (SEC_CONSTRUCTOR
, "CONSTRUCTOR");
305 PF (SEC_LOAD
, "LOAD");
306 PF (SEC_RELOC
, "RELOC");
307 PF (SEC_READONLY
, "READONLY");
308 PF (SEC_CODE
, "CODE");
309 PF (SEC_DATA
, "DATA");
311 PF (SEC_DEBUGGING
, "DEBUGGING");
312 PF (SEC_NEVER_LOAD
, "NEVER_LOAD");
313 PF (SEC_EXCLUDE
, "EXCLUDE");
314 PF (SEC_SORT_ENTRIES
, "SORT_ENTRIES");
315 PF (SEC_BLOCK
, "BLOCK");
316 PF (SEC_CLINK
, "CLINK");
317 PF (SEC_SMALL_DATA
, "SMALL_DATA");
318 PF (SEC_SHARED
, "SHARED");
319 PF (SEC_ARCH_BIT_0
, "ARCH_BIT_0");
320 PF (SEC_THREAD_LOCAL
, "THREAD_LOCAL");
322 if ((section
->flags
& SEC_LINK_ONCE
) != 0)
326 switch (section
->flags
& SEC_LINK_DUPLICATES
)
330 case SEC_LINK_DUPLICATES_DISCARD
:
331 ls
= "LINK_ONCE_DISCARD";
333 case SEC_LINK_DUPLICATES_ONE_ONLY
:
334 ls
= "LINK_ONCE_ONE_ONLY";
336 case SEC_LINK_DUPLICATES_SAME_SIZE
:
337 ls
= "LINK_ONCE_SAME_SIZE";
339 case SEC_LINK_DUPLICATES_SAME_CONTENTS
:
340 ls
= "LINK_ONCE_SAME_CONTENTS";
343 printf ("%s%s", comma
, ls
);
345 if (section
->comdat
!= NULL
)
346 printf (" (COMDAT %s %ld)", section
->comdat
->name
,
347 section
->comdat
->symbol
);
360 printf (_("Sections:\n"));
363 printf (_("Idx Name Size VMA LMA File off Algn"));
365 /* With BFD64, non-ELF returns -1 and wants always 64 bit addresses. */
366 if (bfd_get_arch_size (abfd
) == 32)
367 printf (_("Idx Name Size VMA LMA File off Algn"));
369 printf (_("Idx Name Size VMA LMA File off Algn"));
373 printf (_(" Flags"));
374 if (abfd
->flags
& HAS_LOAD_PAGE
)
378 bfd_map_over_sections (abfd
, dump_section_header
, (PTR
) NULL
);
385 asymbol
**sy
= (asymbol
**) NULL
;
388 if (!(bfd_get_file_flags (abfd
) & HAS_SYMS
))
394 storage
= bfd_get_symtab_upper_bound (abfd
);
396 bfd_fatal (bfd_get_filename (abfd
));
398 sy
= (asymbol
**) xmalloc (storage
);
400 symcount
= bfd_canonicalize_symtab (abfd
, sy
);
402 bfd_fatal (bfd_get_filename (abfd
));
406 /* Read in the dynamic symbols. */
409 slurp_dynamic_symtab (abfd
)
412 asymbol
**sy
= (asymbol
**) NULL
;
415 storage
= bfd_get_dynamic_symtab_upper_bound (abfd
);
418 if (!(bfd_get_file_flags (abfd
) & DYNAMIC
))
420 non_fatal (_("%s: not a dynamic object"), bfd_get_filename (abfd
));
425 bfd_fatal (bfd_get_filename (abfd
));
428 sy
= (asymbol
**) xmalloc (storage
);
430 dynsymcount
= bfd_canonicalize_dynamic_symtab (abfd
, sy
);
432 bfd_fatal (bfd_get_filename (abfd
));
436 /* Filter out (in place) symbols that are useless for disassembly.
437 COUNT is the number of elements in SYMBOLS.
438 Return the number of useful symbols. */
441 remove_useless_symbols (symbols
, count
)
445 register asymbol
**in_ptr
= symbols
, **out_ptr
= symbols
;
449 asymbol
*sym
= *in_ptr
++;
451 if (sym
->name
== NULL
|| sym
->name
[0] == '\0')
453 if (sym
->flags
& (BSF_DEBUGGING
))
455 if (bfd_is_und_section (sym
->section
)
456 || bfd_is_com_section (sym
->section
))
461 return out_ptr
- symbols
;
464 /* Sort symbols into value order. */
467 compare_symbols (ap
, bp
)
471 const asymbol
*a
= *(const asymbol
**)ap
;
472 const asymbol
*b
= *(const asymbol
**)bp
;
476 flagword aflags
, bflags
;
478 if (bfd_asymbol_value (a
) > bfd_asymbol_value (b
))
480 else if (bfd_asymbol_value (a
) < bfd_asymbol_value (b
))
483 if (a
->section
> b
->section
)
485 else if (a
->section
< b
->section
)
488 an
= bfd_asymbol_name (a
);
489 bn
= bfd_asymbol_name (b
);
493 /* The symbols gnu_compiled and gcc2_compiled convey no real
494 information, so put them after other symbols with the same value. */
496 af
= (strstr (an
, "gnu_compiled") != NULL
497 || strstr (an
, "gcc2_compiled") != NULL
);
498 bf
= (strstr (bn
, "gnu_compiled") != NULL
499 || strstr (bn
, "gcc2_compiled") != NULL
);
506 /* We use a heuristic for the file name, to try to sort it after
507 more useful symbols. It may not work on non Unix systems, but it
508 doesn't really matter; the only difference is precisely which
509 symbol names get printed. */
511 #define file_symbol(s, sn, snl) \
512 (((s)->flags & BSF_FILE) != 0 \
513 || ((sn)[(snl) - 2] == '.' \
514 && ((sn)[(snl) - 1] == 'o' \
515 || (sn)[(snl) - 1] == 'a')))
517 af
= file_symbol (a
, an
, anl
);
518 bf
= file_symbol (b
, bn
, bnl
);
525 /* Try to sort global symbols before local symbols before function
526 symbols before debugging symbols. */
531 if ((aflags
& BSF_DEBUGGING
) != (bflags
& BSF_DEBUGGING
))
533 if ((aflags
& BSF_DEBUGGING
) != 0)
538 if ((aflags
& BSF_FUNCTION
) != (bflags
& BSF_FUNCTION
))
540 if ((aflags
& BSF_FUNCTION
) != 0)
545 if ((aflags
& BSF_LOCAL
) != (bflags
& BSF_LOCAL
))
547 if ((aflags
& BSF_LOCAL
) != 0)
552 if ((aflags
& BSF_GLOBAL
) != (bflags
& BSF_GLOBAL
))
554 if ((aflags
& BSF_GLOBAL
) != 0)
560 /* Symbols that start with '.' might be section names, so sort them
561 after symbols that don't start with '.'. */
562 if (an
[0] == '.' && bn
[0] != '.')
564 if (an
[0] != '.' && bn
[0] == '.')
567 /* Finally, if we can't distinguish them in any other way, try to
568 get consistent results by sorting the symbols by name. */
569 return strcmp (an
, bn
);
572 /* Sort relocs into address order. */
575 compare_relocs (ap
, bp
)
579 const arelent
*a
= *(const arelent
**)ap
;
580 const arelent
*b
= *(const arelent
**)bp
;
582 if (a
->address
> b
->address
)
584 else if (a
->address
< b
->address
)
587 /* So that associated relocations tied to the same address show up
588 in the correct order, we don't do any further sorting. */
597 /* Print VMA to STREAM. If SKIP_ZEROES is true, omit leading zeroes. */
600 objdump_print_value (vma
, info
, skip_zeroes
)
602 struct disassemble_info
*info
;
607 struct objdump_disasm_info
*aux
608 = (struct objdump_disasm_info
*) info
->application_data
;
610 bfd_sprintf_vma (aux
->abfd
, buf
, vma
);
615 for (p
= buf
; *p
== '0'; ++p
)
620 (*info
->fprintf_func
) (info
->stream
, "%s", p
);
623 /* Print the name of a symbol. */
626 objdump_print_symname (abfd
, info
, sym
)
628 struct disassemble_info
*info
;
635 name
= bfd_asymbol_name (sym
);
636 if (do_demangle
&& name
[0] != '\0')
638 /* Demangle the name. */
639 alloc
= demangle (abfd
, name
);
644 (*info
->fprintf_func
) (info
->stream
, "%s", name
);
652 /* Locate a symbol given a bfd, a section, and a VMA. If REQUIRE_SEC
653 is true, then always require the symbol to be in the section. This
654 returns NULL if there is no suitable symbol. If PLACE is not NULL,
655 then *PLACE is set to the index of the symbol in sorted_syms. */
658 find_symbol_for_address (abfd
, sec
, vma
, require_sec
, place
)
665 /* @@ Would it speed things up to cache the last two symbols returned,
666 and maybe their address ranges? For many processors, only one memory
667 operand can be present at a time, so the 2-entry cache wouldn't be
668 constantly churned by code doing heavy memory accesses. */
670 /* Indices in `sorted_syms'. */
672 long max
= sorted_symcount
;
674 unsigned int opb
= bfd_octets_per_byte (abfd
);
676 if (sorted_symcount
< 1)
679 /* Perform a binary search looking for the closest symbol to the
680 required value. We are searching the range (min, max]. */
681 while (min
+ 1 < max
)
685 thisplace
= (max
+ min
) / 2;
686 sym
= sorted_syms
[thisplace
];
688 if (bfd_asymbol_value (sym
) > vma
)
690 else if (bfd_asymbol_value (sym
) < vma
)
699 /* The symbol we want is now in min, the low end of the range we
700 were searching. If there are several symbols with the same
701 value, we want the first one. */
704 && (bfd_asymbol_value (sorted_syms
[thisplace
])
705 == bfd_asymbol_value (sorted_syms
[thisplace
- 1])))
708 /* If the file is relocateable, and the symbol could be from this
709 section, prefer a symbol from this section over symbols from
710 others, even if the other symbol's value might be closer.
712 Note that this may be wrong for some symbol references if the
713 sections have overlapping memory ranges, but in that case there's
714 no way to tell what's desired without looking at the relocation
717 if (sorted_syms
[thisplace
]->section
!= sec
719 || ((abfd
->flags
& HAS_RELOC
) != 0
720 && vma
>= bfd_get_section_vma (abfd
, sec
)
721 && vma
< (bfd_get_section_vma (abfd
, sec
)
722 + bfd_section_size (abfd
, sec
) / opb
))))
726 for (i
= thisplace
+ 1; i
< sorted_symcount
; i
++)
728 if (bfd_asymbol_value (sorted_syms
[i
])
729 != bfd_asymbol_value (sorted_syms
[thisplace
]))
735 if (sorted_syms
[i
]->section
== sec
737 || sorted_syms
[i
- 1]->section
!= sec
738 || (bfd_asymbol_value (sorted_syms
[i
])
739 != bfd_asymbol_value (sorted_syms
[i
- 1]))))
746 if (sorted_syms
[thisplace
]->section
!= sec
)
748 /* We didn't find a good symbol with a smaller value.
749 Look for one with a larger value. */
750 for (i
= thisplace
+ 1; i
< sorted_symcount
; i
++)
752 if (sorted_syms
[i
]->section
== sec
)
760 if (sorted_syms
[thisplace
]->section
!= sec
762 || ((abfd
->flags
& HAS_RELOC
) != 0
763 && vma
>= bfd_get_section_vma (abfd
, sec
)
764 && vma
< (bfd_get_section_vma (abfd
, sec
)
765 + bfd_section_size (abfd
, sec
)))))
767 /* There is no suitable symbol. */
775 return sorted_syms
[thisplace
];
778 /* Print an address to INFO symbolically. */
781 objdump_print_addr_with_sym (abfd
, sec
, sym
, vma
, info
, skip_zeroes
)
786 struct disassemble_info
*info
;
789 objdump_print_value (vma
, info
, skip_zeroes
);
795 (*info
->fprintf_func
) (info
->stream
, " <%s",
796 bfd_get_section_name (abfd
, sec
));
797 secaddr
= bfd_get_section_vma (abfd
, sec
);
800 (*info
->fprintf_func
) (info
->stream
, "-0x");
801 objdump_print_value (secaddr
- vma
, info
, true);
803 else if (vma
> secaddr
)
805 (*info
->fprintf_func
) (info
->stream
, "+0x");
806 objdump_print_value (vma
- secaddr
, info
, true);
808 (*info
->fprintf_func
) (info
->stream
, ">");
812 (*info
->fprintf_func
) (info
->stream
, " <");
813 objdump_print_symname (abfd
, info
, sym
);
814 if (bfd_asymbol_value (sym
) > vma
)
816 (*info
->fprintf_func
) (info
->stream
, "-0x");
817 objdump_print_value (bfd_asymbol_value (sym
) - vma
, info
, true);
819 else if (vma
> bfd_asymbol_value (sym
))
821 (*info
->fprintf_func
) (info
->stream
, "+0x");
822 objdump_print_value (vma
- bfd_asymbol_value (sym
), info
, true);
824 (*info
->fprintf_func
) (info
->stream
, ">");
828 /* Print VMA to INFO, symbolically if possible. If SKIP_ZEROES is
829 true, don't output leading zeroes. */
832 objdump_print_addr (vma
, info
, skip_zeroes
)
834 struct disassemble_info
*info
;
837 struct objdump_disasm_info
*aux
;
840 if (sorted_symcount
< 1)
842 (*info
->fprintf_func
) (info
->stream
, "0x");
843 objdump_print_value (vma
, info
, skip_zeroes
);
847 aux
= (struct objdump_disasm_info
*) info
->application_data
;
848 sym
= find_symbol_for_address (aux
->abfd
, aux
->sec
, vma
, aux
->require_sec
,
850 objdump_print_addr_with_sym (aux
->abfd
, aux
->sec
, sym
, vma
, info
,
854 /* Print VMA to INFO. This function is passed to the disassembler
858 objdump_print_address (vma
, info
)
860 struct disassemble_info
*info
;
862 objdump_print_addr (vma
, info
, ! prefix_addresses
);
865 /* Determine of the given address has a symbol associated with it. */
868 objdump_symbol_at_address (vma
, info
)
870 struct disassemble_info
* info
;
872 struct objdump_disasm_info
* aux
;
875 /* No symbols - do not bother checking. */
876 if (sorted_symcount
< 1)
879 aux
= (struct objdump_disasm_info
*) info
->application_data
;
880 sym
= find_symbol_for_address (aux
->abfd
, aux
->sec
, vma
, aux
->require_sec
,
883 return (sym
!= NULL
&& (bfd_asymbol_value (sym
) == vma
));
886 /* Hold the last function name and the last line number we displayed
889 static char *prev_functionname
;
890 static unsigned int prev_line
;
892 /* We keep a list of all files that we have seen when doing a
893 dissassembly with source, so that we know how much of the file to
894 display. This can be important for inlined functions. */
896 struct print_file_list
898 struct print_file_list
*next
;
904 static struct print_file_list
*print_files
;
906 /* The number of preceding context lines to show when we start
907 displaying a file for the first time. */
909 #define SHOW_PRECEDING_CONTEXT_LINES (5)
911 /* Skip ahead to a given line in a file, optionally printing each
915 skip_to_line
PARAMS ((struct print_file_list
*, unsigned int, boolean
));
918 skip_to_line (p
, line
, show
)
919 struct print_file_list
*p
;
923 while (p
->line
< line
)
927 if (fgets (buf
, sizeof buf
, p
->f
) == NULL
)
937 if (strchr (buf
, '\n') != NULL
)
942 /* Show the line number, or the source line, in a dissassembly
946 show_line (abfd
, section
, addr_offset
)
951 const char *filename
;
952 const char *functionname
;
955 if (! with_line_numbers
&& ! with_source_code
)
958 if (! bfd_find_nearest_line (abfd
, section
, syms
, addr_offset
, &filename
,
959 &functionname
, &line
))
962 if (filename
!= NULL
&& *filename
== '\0')
964 if (functionname
!= NULL
&& *functionname
== '\0')
967 if (with_line_numbers
)
969 if (functionname
!= NULL
970 && (prev_functionname
== NULL
971 || strcmp (functionname
, prev_functionname
) != 0))
972 printf ("%s():\n", functionname
);
973 if (line
> 0 && line
!= prev_line
)
974 printf ("%s:%u\n", filename
== NULL
? "???" : filename
, line
);
981 struct print_file_list
**pp
, *p
;
983 for (pp
= &print_files
; *pp
!= NULL
; pp
= &(*pp
)->next
)
984 if (strcmp ((*pp
)->filename
, filename
) == 0)
990 if (p
!= print_files
)
994 /* We have reencountered a file name which we saw
995 earlier. This implies that either we are dumping out
996 code from an included file, or the same file was
997 linked in more than once. There are two common cases
998 of an included file: inline functions in a header
999 file, and a bison or flex skeleton file. In the
1000 former case we want to just start printing (but we
1001 back up a few lines to give context); in the latter
1002 case we want to continue from where we left off. I
1003 can't think of a good way to distinguish the cases,
1004 so I used a heuristic based on the file name. */
1005 if (strcmp (p
->filename
+ strlen (p
->filename
) - 2, ".h") != 0)
1009 l
= line
- SHOW_PRECEDING_CONTEXT_LINES
;
1016 p
->f
= fopen (p
->filename
, "r");
1020 skip_to_line (p
, l
, false);
1022 if (print_files
->f
!= NULL
)
1024 fclose (print_files
->f
);
1025 print_files
->f
= NULL
;
1031 skip_to_line (p
, line
, true);
1033 p
->next
= print_files
;
1041 f
= fopen (filename
, "r");
1046 p
= ((struct print_file_list
*)
1047 xmalloc (sizeof (struct print_file_list
)));
1048 p
->filename
= xmalloc (strlen (filename
) + 1);
1049 strcpy (p
->filename
, filename
);
1053 if (print_files
!= NULL
&& print_files
->f
!= NULL
)
1055 fclose (print_files
->f
);
1056 print_files
->f
= NULL
;
1058 p
->next
= print_files
;
1061 if (file_start_context
)
1064 l
= line
- SHOW_PRECEDING_CONTEXT_LINES
;
1067 skip_to_line (p
, l
, false);
1069 skip_to_line (p
, line
, true);
1074 if (functionname
!= NULL
1075 && (prev_functionname
== NULL
1076 || strcmp (functionname
, prev_functionname
) != 0))
1078 if (prev_functionname
!= NULL
)
1079 free (prev_functionname
);
1080 prev_functionname
= xmalloc (strlen (functionname
) + 1);
1081 strcpy (prev_functionname
, functionname
);
1084 if (line
> 0 && line
!= prev_line
)
1088 /* Pseudo FILE object for strings. */
1096 /* sprintf to a "stream" */
1099 objdump_sprintf
VPARAMS ((SFILE
*f
, const char *format
, ...))
1104 VA_OPEN (args
, format
);
1105 VA_FIXEDARG (args
, SFILE
*, f
);
1106 VA_FIXEDARG (args
, const char *, format
);
1108 vasprintf (&buf
, format
, args
);
1113 fatal (_("Out of virtual memory"));
1118 while ((size_t) ((f
->buffer
+ f
->size
) - f
->current
) < n
+ 1)
1122 curroff
= f
->current
- f
->buffer
;
1124 f
->buffer
= xrealloc (f
->buffer
, f
->size
);
1125 f
->current
= f
->buffer
+ curroff
;
1128 memcpy (f
->current
, buf
, n
);
1130 f
->current
[0] = '\0';
1138 /* The number of zeroes we want to see before we start skipping them.
1139 The number is arbitrarily chosen. */
1142 #define SKIP_ZEROES (8)
1145 /* The number of zeroes to skip at the end of a section. If the
1146 number of zeroes at the end is between SKIP_ZEROES_AT_END and
1147 SKIP_ZEROES, they will be disassembled. If there are fewer than
1148 SKIP_ZEROES_AT_END, they will be skipped. This is a heuristic
1149 attempt to avoid disassembling zeroes inserted by section
1152 #ifndef SKIP_ZEROES_AT_END
1153 #define SKIP_ZEROES_AT_END (3)
1156 /* Disassemble some data in memory between given values. */
1159 disassemble_bytes (info
, disassemble_fn
, insns
, data
,
1160 start_offset
, stop_offset
, relppp
,
1162 struct disassemble_info
*info
;
1163 disassembler_ftype disassemble_fn
;
1166 bfd_vma start_offset
;
1167 bfd_vma stop_offset
;
1171 struct objdump_disasm_info
*aux
;
1173 int octets_per_line
;
1175 int skip_addr_chars
;
1176 bfd_vma addr_offset
;
1177 int opb
= info
->octets_per_byte
;
1179 aux
= (struct objdump_disasm_info
*) info
->application_data
;
1183 octets_per_line
= 4;
1185 octets_per_line
= 16;
1187 /* Figure out how many characters to skip at the start of an
1188 address, to make the disassembly look nicer. We discard leading
1189 zeroes in chunks of 4, ensuring that there is always a leading
1191 skip_addr_chars
= 0;
1192 if (! prefix_addresses
)
1200 + bfd_section_size (section
->owner
, section
) / opb
));
1202 while (s
[0] == '0' && s
[1] == '0' && s
[2] == '0' && s
[3] == '0'
1205 skip_addr_chars
+= 4;
1210 info
->insn_info_valid
= 0;
1213 addr_offset
= start_offset
;
1214 while (addr_offset
< stop_offset
)
1218 boolean need_nl
= false;
1220 /* If we see more than SKIP_ZEROES octets of zeroes, we just
1222 for (z
= addr_offset
* opb
; z
< stop_offset
* opb
; z
++)
1225 if (! disassemble_zeroes
1226 && (info
->insn_info_valid
== 0
1227 || info
->branch_delay_insns
== 0)
1228 && (z
- addr_offset
* opb
>= SKIP_ZEROES
1229 || (z
== stop_offset
* opb
&&
1230 z
- addr_offset
* opb
< SKIP_ZEROES_AT_END
)))
1234 /* If there are more nonzero octets to follow, we only skip
1235 zeroes in multiples of 4, to try to avoid running over
1236 the start of an instruction which happens to start with
1238 if (z
!= stop_offset
* opb
)
1239 z
= addr_offset
* opb
+ ((z
- addr_offset
* opb
) &~ 3);
1241 octets
= z
- addr_offset
* opb
;
1252 if (with_line_numbers
|| with_source_code
)
1253 /* The line number tables will refer to unadjusted
1254 section VMAs, so we must undo any VMA modifications
1255 when calling show_line. */
1256 show_line (aux
->abfd
, section
, addr_offset
- adjust_section_vma
);
1258 if (! prefix_addresses
)
1262 bfd_sprintf_vma (aux
->abfd
, buf
, section
->vma
+ addr_offset
);
1263 for (s
= buf
+ skip_addr_chars
; *s
== '0'; s
++)
1267 printf ("%s:\t", buf
+ skip_addr_chars
);
1271 aux
->require_sec
= true;
1272 objdump_print_address (section
->vma
+ addr_offset
, info
);
1273 aux
->require_sec
= false;
1280 sfile
.buffer
= xmalloc (sfile
.size
);
1281 sfile
.current
= sfile
.buffer
;
1282 info
->fprintf_func
= (fprintf_ftype
) objdump_sprintf
;
1283 info
->stream
= (FILE *) &sfile
;
1284 info
->bytes_per_line
= 0;
1285 info
->bytes_per_chunk
= 0;
1287 #ifdef DISASSEMBLER_NEEDS_RELOCS
1288 /* FIXME: This is wrong. It tests the number of octets
1289 in the last instruction, not the current one. */
1290 if (*relppp
< relppend
1291 && (**relppp
)->address
>= addr_offset
1292 && (**relppp
)->address
<= addr_offset
+ octets
/ opb
)
1293 info
->flags
= INSN_HAS_RELOC
;
1298 octets
= (*disassemble_fn
) (section
->vma
+ addr_offset
, info
);
1299 info
->fprintf_func
= (fprintf_ftype
) fprintf
;
1300 info
->stream
= stdout
;
1301 if (info
->bytes_per_line
!= 0)
1302 octets_per_line
= info
->bytes_per_line
;
1305 if (sfile
.current
!= sfile
.buffer
)
1306 printf ("%s\n", sfile
.buffer
);
1307 free (sfile
.buffer
);
1315 octets
= octets_per_line
;
1316 if (addr_offset
+ octets
/ opb
> stop_offset
)
1317 octets
= (stop_offset
- addr_offset
) * opb
;
1319 for (j
= addr_offset
* opb
; j
< addr_offset
* opb
+ octets
; ++j
)
1321 if (ISPRINT (data
[j
]))
1322 buf
[j
- addr_offset
* opb
] = data
[j
];
1324 buf
[j
- addr_offset
* opb
] = '.';
1326 buf
[j
- addr_offset
* opb
] = '\0';
1329 if (prefix_addresses
1331 : show_raw_insn
>= 0)
1335 /* If ! prefix_addresses and ! wide_output, we print
1336 octets_per_line octets per line. */
1338 if (pb
> octets_per_line
&& ! prefix_addresses
&& ! wide_output
)
1339 pb
= octets_per_line
;
1341 if (info
->bytes_per_chunk
)
1342 bpc
= info
->bytes_per_chunk
;
1346 for (j
= addr_offset
* opb
; j
< addr_offset
* opb
+ pb
; j
+= bpc
)
1349 if (bpc
> 1 && info
->display_endian
== BFD_ENDIAN_LITTLE
)
1351 for (k
= bpc
- 1; k
>= 0; k
--)
1352 printf ("%02x", (unsigned) data
[j
+ k
]);
1357 for (k
= 0; k
< bpc
; k
++)
1358 printf ("%02x", (unsigned) data
[j
+ k
]);
1363 for (; pb
< octets_per_line
; pb
+= bpc
)
1367 for (k
= 0; k
< bpc
; k
++)
1372 /* Separate raw data from instruction by extra space. */
1383 printf ("%s", sfile
.buffer
);
1384 free (sfile
.buffer
);
1387 if (prefix_addresses
1389 : show_raw_insn
>= 0)
1397 j
= addr_offset
* opb
+ pb
;
1399 bfd_sprintf_vma (aux
->abfd
, buf
, section
->vma
+ j
/ opb
);
1400 for (s
= buf
+ skip_addr_chars
; *s
== '0'; s
++)
1404 printf ("%s:\t", buf
+ skip_addr_chars
);
1406 pb
+= octets_per_line
;
1409 for (; j
< addr_offset
* opb
+ pb
; j
+= bpc
)
1413 if (bpc
> 1 && info
->display_endian
== BFD_ENDIAN_LITTLE
)
1415 for (k
= bpc
- 1; k
>= 0; k
--)
1416 printf ("%02x", (unsigned) data
[j
+ k
]);
1421 for (k
= 0; k
< bpc
; k
++)
1422 printf ("%02x", (unsigned) data
[j
+ k
]);
1435 if ((section
->flags
& SEC_RELOC
) != 0
1436 #ifndef DISASSEMBLER_NEEDS_RELOCS
1441 while ((*relppp
) < relppend
1442 && ((**relppp
)->address
>= (bfd_vma
) addr_offset
1443 && (**relppp
)->address
< (bfd_vma
) addr_offset
+ octets
/ opb
))
1444 #ifdef DISASSEMBLER_NEEDS_RELOCS
1445 if (! dump_reloc_info
)
1459 objdump_print_value (section
->vma
+ q
->address
, info
, true);
1461 printf (": %s\t", q
->howto
->name
);
1463 if (q
->sym_ptr_ptr
== NULL
|| *q
->sym_ptr_ptr
== NULL
)
1464 printf ("*unknown*");
1467 const char *sym_name
;
1469 sym_name
= bfd_asymbol_name (*q
->sym_ptr_ptr
);
1470 if (sym_name
!= NULL
&& *sym_name
!= '\0')
1471 objdump_print_symname (aux
->abfd
, info
, *q
->sym_ptr_ptr
);
1476 sym_sec
= bfd_get_section (*q
->sym_ptr_ptr
);
1477 sym_name
= bfd_get_section_name (aux
->abfd
, sym_sec
);
1478 if (sym_name
== NULL
|| *sym_name
== '\0')
1479 sym_name
= "*unknown*";
1480 printf ("%s", sym_name
);
1487 objdump_print_value (q
->addend
, info
, true);
1499 addr_offset
+= octets
/ opb
;
1503 /* Disassemble the contents of an object file. */
1506 disassemble_data (abfd
)
1509 unsigned long addr_offset
;
1510 disassembler_ftype disassemble_fn
;
1511 struct disassemble_info disasm_info
;
1512 struct objdump_disasm_info aux
;
1517 prev_functionname
= NULL
;
1520 /* We make a copy of syms to sort. We don't want to sort syms
1521 because that will screw up the relocs. */
1522 sorted_syms
= (asymbol
**) xmalloc (symcount
* sizeof (asymbol
*));
1523 memcpy (sorted_syms
, syms
, symcount
* sizeof (asymbol
*));
1525 sorted_symcount
= remove_useless_symbols (sorted_syms
, symcount
);
1527 /* Sort the symbols into section and symbol order */
1528 qsort (sorted_syms
, sorted_symcount
, sizeof (asymbol
*), compare_symbols
);
1530 INIT_DISASSEMBLE_INFO(disasm_info
, stdout
, fprintf
);
1531 disasm_info
.application_data
= (PTR
) &aux
;
1533 aux
.require_sec
= false;
1534 disasm_info
.print_address_func
= objdump_print_address
;
1535 disasm_info
.symbol_at_address_func
= objdump_symbol_at_address
;
1537 if (machine
!= (char *) NULL
)
1539 const bfd_arch_info_type
*info
= bfd_scan_arch (machine
);
1542 fatal (_("Can't use supplied machine %s"), machine
);
1544 abfd
->arch_info
= info
;
1547 if (endian
!= BFD_ENDIAN_UNKNOWN
)
1549 struct bfd_target
*xvec
;
1551 xvec
= (struct bfd_target
*) xmalloc (sizeof (struct bfd_target
));
1552 memcpy (xvec
, abfd
->xvec
, sizeof (struct bfd_target
));
1553 xvec
->byteorder
= endian
;
1557 disassemble_fn
= disassembler (abfd
);
1558 if (!disassemble_fn
)
1560 non_fatal (_("Can't disassemble for architecture %s\n"),
1561 bfd_printable_arch_mach (bfd_get_arch (abfd
), 0));
1566 opb
= bfd_octets_per_byte (abfd
);
1568 disasm_info
.flavour
= bfd_get_flavour (abfd
);
1569 disasm_info
.arch
= bfd_get_arch (abfd
);
1570 disasm_info
.mach
= bfd_get_mach (abfd
);
1571 disasm_info
.disassembler_options
= disassembler_options
;
1572 disasm_info
.octets_per_byte
= opb
;
1574 if (bfd_big_endian (abfd
))
1575 disasm_info
.display_endian
= disasm_info
.endian
= BFD_ENDIAN_BIG
;
1576 else if (bfd_little_endian (abfd
))
1577 disasm_info
.display_endian
= disasm_info
.endian
= BFD_ENDIAN_LITTLE
;
1579 /* ??? Aborting here seems too drastic. We could default to big or little
1581 disasm_info
.endian
= BFD_ENDIAN_UNKNOWN
;
1583 for (section
= abfd
->sections
;
1584 section
!= (asection
*) NULL
;
1585 section
= section
->next
)
1587 bfd_byte
*data
= NULL
;
1588 bfd_size_type datasize
= 0;
1589 arelent
**relbuf
= NULL
;
1590 arelent
**relpp
= NULL
;
1591 arelent
**relppend
= NULL
;
1592 unsigned long stop_offset
;
1593 asymbol
*sym
= NULL
;
1596 if ((section
->flags
& SEC_LOAD
) == 0
1597 || (! disassemble_all
1599 && (section
->flags
& SEC_CODE
) == 0))
1601 if (only
!= (char *) NULL
&& strcmp (only
, section
->name
) != 0)
1604 if ((section
->flags
& SEC_RELOC
) != 0
1605 #ifndef DISASSEMBLER_NEEDS_RELOCS
1612 relsize
= bfd_get_reloc_upper_bound (abfd
, section
);
1614 bfd_fatal (bfd_get_filename (abfd
));
1620 relbuf
= (arelent
**) xmalloc (relsize
);
1621 relcount
= bfd_canonicalize_reloc (abfd
, section
, relbuf
, syms
);
1623 bfd_fatal (bfd_get_filename (abfd
));
1625 /* Sort the relocs by address. */
1626 qsort (relbuf
, relcount
, sizeof (arelent
*), compare_relocs
);
1629 relppend
= relpp
+ relcount
;
1631 /* Skip over the relocs belonging to addresses below the
1633 if (start_address
!= (bfd_vma
) -1)
1635 while (relpp
< relppend
1636 && (*relpp
)->address
< start_address
)
1642 printf (_("Disassembly of section %s:\n"), section
->name
);
1644 datasize
= bfd_get_section_size_before_reloc (section
);
1648 data
= (bfd_byte
*) xmalloc ((size_t) datasize
);
1650 bfd_get_section_contents (abfd
, section
, data
, 0, datasize
);
1653 disasm_info
.buffer
= data
;
1654 disasm_info
.buffer_vma
= section
->vma
;
1655 disasm_info
.buffer_length
= datasize
;
1656 disasm_info
.section
= section
;
1657 if (start_address
== (bfd_vma
) -1
1658 || start_address
< disasm_info
.buffer_vma
)
1661 addr_offset
= start_address
- disasm_info
.buffer_vma
;
1662 if (stop_address
== (bfd_vma
) -1)
1663 stop_offset
= datasize
/ opb
;
1666 if (stop_address
< disasm_info
.buffer_vma
)
1669 stop_offset
= stop_address
- disasm_info
.buffer_vma
;
1670 if (stop_offset
> disasm_info
.buffer_length
/ opb
)
1671 stop_offset
= disasm_info
.buffer_length
/ opb
;
1674 sym
= find_symbol_for_address (abfd
, section
, section
->vma
+ addr_offset
,
1677 while (addr_offset
< stop_offset
)
1680 unsigned long nextstop_offset
;
1683 if (sym
!= NULL
&& bfd_asymbol_value (sym
) <= section
->vma
+ addr_offset
)
1688 (x
< sorted_symcount
1689 && bfd_asymbol_value (sorted_syms
[x
]) <= section
->vma
+ addr_offset
);
1692 disasm_info
.symbols
= & sorted_syms
[place
];
1693 disasm_info
.num_symbols
= x
- place
;
1696 disasm_info
.symbols
= NULL
;
1698 if (! prefix_addresses
)
1701 objdump_print_addr_with_sym (abfd
, section
, sym
,
1702 section
->vma
+ addr_offset
,
1708 if (sym
!= NULL
&& bfd_asymbol_value (sym
) > section
->vma
+ addr_offset
)
1710 else if (sym
== NULL
)
1714 /* Search forward for the next appropriate symbol in
1715 SECTION. Note that all the symbols are sorted
1716 together into one big array, and that some sections
1717 may have overlapping addresses. */
1718 while (place
< sorted_symcount
1719 && (sorted_syms
[place
]->section
!= section
1720 || (bfd_asymbol_value (sorted_syms
[place
])
1721 <= bfd_asymbol_value (sym
))))
1723 if (place
>= sorted_symcount
)
1726 nextsym
= sorted_syms
[place
];
1729 if (sym
!= NULL
&& bfd_asymbol_value (sym
) > section
->vma
+ addr_offset
)
1731 nextstop_offset
= bfd_asymbol_value (sym
) - section
->vma
;
1732 if (nextstop_offset
> stop_offset
)
1733 nextstop_offset
= stop_offset
;
1735 else if (nextsym
== NULL
)
1736 nextstop_offset
= stop_offset
;
1739 nextstop_offset
= bfd_asymbol_value (nextsym
) - section
->vma
;
1740 if (nextstop_offset
> stop_offset
)
1741 nextstop_offset
= stop_offset
;
1744 /* If a symbol is explicitly marked as being an object
1745 rather than a function, just dump the bytes without
1746 disassembling them. */
1749 || bfd_asymbol_value (sym
) > section
->vma
+ addr_offset
1750 || ((sym
->flags
& BSF_OBJECT
) == 0
1751 && (strstr (bfd_asymbol_name (sym
), "gnu_compiled")
1753 && (strstr (bfd_asymbol_name (sym
), "gcc2_compiled")
1755 || (sym
->flags
& BSF_FUNCTION
) != 0)
1760 disassemble_bytes (&disasm_info
, disassemble_fn
, insns
, data
,
1761 addr_offset
, nextstop_offset
, &relpp
, relppend
);
1763 addr_offset
= nextstop_offset
;
1775 /* Define a table of stab values and print-strings. We wish the initializer
1776 could be a direct-mapped table, but instead we build one the first
1779 static void dump_section_stabs
PARAMS ((bfd
*abfd
, char *stabsect_name
,
1780 char *strsect_name
));
1782 /* Dump the stabs sections from an object file that has a section that
1783 uses Sun stabs encoding. */
1789 dump_section_stabs (abfd
, ".stab", ".stabstr");
1790 dump_section_stabs (abfd
, ".stab.excl", ".stab.exclstr");
1791 dump_section_stabs (abfd
, ".stab.index", ".stab.indexstr");
1792 dump_section_stabs (abfd
, "$GDB_SYMBOLS$", "$GDB_STRINGS$");
1795 static bfd_byte
*stabs
;
1796 static bfd_size_type stab_size
;
1798 static char *strtab
;
1799 static bfd_size_type stabstr_size
;
1801 /* Read ABFD's stabs section STABSECT_NAME into `stabs'
1802 and string table section STRSECT_NAME into `strtab'.
1803 If the section exists and was read, allocate the space and return true.
1804 Otherwise return false. */
1807 read_section_stabs (abfd
, stabsect_name
, strsect_name
)
1809 const char *stabsect_name
;
1810 const char *strsect_name
;
1812 asection
*stabsect
, *stabstrsect
;
1814 stabsect
= bfd_get_section_by_name (abfd
, stabsect_name
);
1817 printf (_("No %s section present\n\n"), stabsect_name
);
1821 stabstrsect
= bfd_get_section_by_name (abfd
, strsect_name
);
1822 if (0 == stabstrsect
)
1824 non_fatal (_("%s has no %s section"),
1825 bfd_get_filename (abfd
), strsect_name
);
1830 stab_size
= bfd_section_size (abfd
, stabsect
);
1831 stabstr_size
= bfd_section_size (abfd
, stabstrsect
);
1833 stabs
= (bfd_byte
*) xmalloc (stab_size
);
1834 strtab
= (char *) xmalloc (stabstr_size
);
1836 if (! bfd_get_section_contents (abfd
, stabsect
, (PTR
) stabs
, 0, stab_size
))
1838 non_fatal (_("Reading %s section of %s failed: %s"),
1839 stabsect_name
, bfd_get_filename (abfd
),
1840 bfd_errmsg (bfd_get_error ()));
1847 if (! bfd_get_section_contents (abfd
, stabstrsect
, (PTR
) strtab
, 0,
1850 non_fatal (_("Reading %s section of %s failed: %s\n"),
1851 strsect_name
, bfd_get_filename (abfd
),
1852 bfd_errmsg (bfd_get_error ()));
1862 /* Stabs entries use a 12 byte format:
1863 4 byte string table index
1865 1 byte stab other field
1866 2 byte stab desc field
1868 FIXME: This will have to change for a 64 bit object format. */
1870 #define STRDXOFF (0)
1872 #define OTHEROFF (5)
1875 #define STABSIZE (12)
1877 /* Print ABFD's stabs section STABSECT_NAME (in `stabs'),
1878 using string table section STRSECT_NAME (in `strtab'). */
1881 print_section_stabs (abfd
, stabsect_name
, strsect_name
)
1883 const char *stabsect_name
;
1884 const char *strsect_name ATTRIBUTE_UNUSED
;
1887 unsigned file_string_table_offset
= 0, next_file_string_table_offset
= 0;
1888 bfd_byte
*stabp
, *stabs_end
;
1891 stabs_end
= stabp
+ stab_size
;
1893 printf (_("Contents of %s section:\n\n"), stabsect_name
);
1894 printf ("Symnum n_type n_othr n_desc n_value n_strx String\n");
1896 /* Loop through all symbols and print them.
1898 We start the index at -1 because there is a dummy symbol on
1899 the front of stabs-in-{coff,elf} sections that supplies sizes. */
1901 for (i
= -1; stabp
< stabs_end
; stabp
+= STABSIZE
, i
++)
1905 unsigned char type
, other
;
1906 unsigned short desc
;
1909 strx
= bfd_h_get_32 (abfd
, stabp
+ STRDXOFF
);
1910 type
= bfd_h_get_8 (abfd
, stabp
+ TYPEOFF
);
1911 other
= bfd_h_get_8 (abfd
, stabp
+ OTHEROFF
);
1912 desc
= bfd_h_get_16 (abfd
, stabp
+ DESCOFF
);
1913 value
= bfd_h_get_32 (abfd
, stabp
+ VALOFF
);
1915 printf ("\n%-6d ", i
);
1916 /* Either print the stab name, or, if unnamed, print its number
1917 again (makes consistent formatting for tools like awk). */
1918 name
= bfd_get_stab_name (type
);
1920 printf ("%-6s", name
);
1921 else if (type
== N_UNDF
)
1924 printf ("%-6d", type
);
1925 printf (" %-6d %-6d ", other
, desc
);
1926 bfd_printf_vma (abfd
, value
);
1927 printf (" %-6lu", strx
);
1929 /* Symbols with type == 0 (N_UNDF) specify the length of the
1930 string table associated with this file. We use that info
1931 to know how to relocate the *next* file's string table indices. */
1935 file_string_table_offset
= next_file_string_table_offset
;
1936 next_file_string_table_offset
+= value
;
1940 /* Using the (possibly updated) string table offset, print the
1941 string (if any) associated with this symbol. */
1943 if ((strx
+ file_string_table_offset
) < stabstr_size
)
1944 printf (" %s", &strtab
[strx
+ file_string_table_offset
]);
1953 dump_section_stabs (abfd
, stabsect_name
, strsect_name
)
1955 char *stabsect_name
;
1960 /* Check for section names for which stabsect_name is a prefix, to
1961 handle .stab0, etc. */
1962 for (s
= abfd
->sections
;
1968 len
= strlen (stabsect_name
);
1970 /* If the prefix matches, and the files section name ends with a
1971 nul or a digit, then we match. I.e., we want either an exact
1972 match or a section followed by a number. */
1973 if (strncmp (stabsect_name
, s
->name
, len
) == 0
1974 && (s
->name
[len
] == '\000'
1975 || ISDIGIT (s
->name
[len
])))
1977 if (read_section_stabs (abfd
, s
->name
, strsect_name
))
1979 print_section_stabs (abfd
, s
->name
, strsect_name
);
1988 dump_bfd_header (abfd
)
1993 printf (_("architecture: %s, "),
1994 bfd_printable_arch_mach (bfd_get_arch (abfd
),
1995 bfd_get_mach (abfd
)));
1996 printf (_("flags 0x%08x:\n"), abfd
->flags
);
1998 #define PF(x, y) if (abfd->flags & x) {printf("%s%s", comma, y); comma=", ";}
1999 PF (HAS_RELOC
, "HAS_RELOC");
2000 PF (EXEC_P
, "EXEC_P");
2001 PF (HAS_LINENO
, "HAS_LINENO");
2002 PF (HAS_DEBUG
, "HAS_DEBUG");
2003 PF (HAS_SYMS
, "HAS_SYMS");
2004 PF (HAS_LOCALS
, "HAS_LOCALS");
2005 PF (DYNAMIC
, "DYNAMIC");
2006 PF (WP_TEXT
, "WP_TEXT");
2007 PF (D_PAGED
, "D_PAGED");
2008 PF (BFD_IS_RELAXABLE
, "BFD_IS_RELAXABLE");
2009 PF (HAS_LOAD_PAGE
, "HAS_LOAD_PAGE");
2010 printf (_("\nstart address 0x"));
2011 bfd_printf_vma (abfd
, abfd
->start_address
);
2016 dump_bfd_private_header (abfd
)
2019 bfd_print_private_bfd_data (abfd
, stdout
);
2022 /* Dump selected contents of ABFD */
2028 /* If we are adjusting section VMA's, change them all now. Changing
2029 the BFD information is a hack. However, we must do it, or
2030 bfd_find_nearest_line will not do the right thing. */
2031 if (adjust_section_vma
!= 0)
2035 for (s
= abfd
->sections
; s
!= NULL
; s
= s
->next
)
2037 s
->vma
+= adjust_section_vma
;
2038 s
->lma
+= adjust_section_vma
;
2042 printf (_("\n%s: file format %s\n"), bfd_get_filename (abfd
),
2045 print_arelt_descr (stdout
, abfd
, true);
2046 if (dump_file_header
)
2047 dump_bfd_header (abfd
);
2048 if (dump_private_headers
)
2049 dump_bfd_private_header (abfd
);
2051 if (dump_section_headers
)
2052 dump_headers (abfd
);
2054 if (dump_symtab
|| dump_reloc_info
|| disassemble
|| dump_debugging
)
2055 syms
= slurp_symtab (abfd
);
2056 if (dump_dynamic_symtab
|| dump_dynamic_reloc_info
)
2057 dynsyms
= slurp_dynamic_symtab (abfd
);
2060 dump_symbols (abfd
, false);
2061 if (dump_dynamic_symtab
)
2062 dump_symbols (abfd
, true);
2063 if (dump_stab_section_info
)
2065 if (dump_reloc_info
&& ! disassemble
)
2067 if (dump_dynamic_reloc_info
)
2068 dump_dynamic_relocs (abfd
);
2069 if (dump_section_contents
)
2072 disassemble_data (abfd
);
2077 dhandle
= read_debugging_info (abfd
, syms
, symcount
);
2078 if (dhandle
!= NULL
)
2080 if (! print_debugging_info (stdout
, dhandle
))
2082 non_fatal (_("%s: printing debugging information failed"),
2083 bfd_get_filename (abfd
));
2108 if (bfd_check_format_matches (abfd
, bfd_object
, &matching
))
2114 if (bfd_get_error () == bfd_error_file_ambiguously_recognized
)
2116 nonfatal (bfd_get_filename (abfd
));
2117 list_matching_formats (matching
);
2122 if (bfd_get_error () != bfd_error_file_not_recognized
)
2124 nonfatal (bfd_get_filename (abfd
));
2128 if (bfd_check_format_matches (abfd
, bfd_core
, &matching
))
2134 nonfatal (bfd_get_filename (abfd
));
2136 if (bfd_get_error () == bfd_error_file_ambiguously_recognized
)
2138 list_matching_formats (matching
);
2144 display_file (filename
, target
)
2148 bfd
*file
, *arfile
= (bfd
*) NULL
;
2150 file
= bfd_openr (filename
, target
);
2153 nonfatal (filename
);
2157 if (bfd_check_format (file
, bfd_archive
) == true)
2159 bfd
*last_arfile
= NULL
;
2161 printf (_("In archive %s:\n"), bfd_get_filename (file
));
2164 bfd_set_error (bfd_error_no_error
);
2166 arfile
= bfd_openr_next_archived_file (file
, arfile
);
2169 if (bfd_get_error () != bfd_error_no_more_archived_files
)
2170 nonfatal (bfd_get_filename (file
));
2174 display_bfd (arfile
);
2176 if (last_arfile
!= NULL
)
2177 bfd_close (last_arfile
);
2178 last_arfile
= arfile
;
2181 if (last_arfile
!= NULL
)
2182 bfd_close (last_arfile
);
2190 /* Actually display the various requested regions */
2198 bfd_size_type datasize
= 0;
2199 bfd_size_type addr_offset
;
2200 bfd_size_type start_offset
, stop_offset
;
2201 unsigned int opb
= bfd_octets_per_byte (abfd
);
2203 for (section
= abfd
->sections
; section
!= NULL
; section
=
2208 if (only
== (char *) NULL
||
2209 strcmp (only
, section
->name
) == 0)
2211 if (section
->flags
& SEC_HAS_CONTENTS
)
2213 printf (_("Contents of section %s:\n"), section
->name
);
2215 if (bfd_section_size (abfd
, section
) == 0)
2217 data
= (bfd_byte
*) xmalloc ((size_t) bfd_section_size (abfd
, section
));
2218 datasize
= bfd_section_size (abfd
, section
);
2221 bfd_get_section_contents (abfd
, section
, (PTR
) data
, 0, bfd_section_size (abfd
, section
));
2223 if (start_address
== (bfd_vma
) -1
2224 || start_address
< section
->vma
)
2227 start_offset
= start_address
- section
->vma
;
2228 if (stop_address
== (bfd_vma
) -1)
2229 stop_offset
= bfd_section_size (abfd
, section
) / opb
;
2232 if (stop_address
< section
->vma
)
2235 stop_offset
= stop_address
- section
->vma
;
2236 if (stop_offset
> bfd_section_size (abfd
, section
) / opb
)
2237 stop_offset
= bfd_section_size (abfd
, section
) / opb
;
2239 for (addr_offset
= start_offset
;
2240 addr_offset
< stop_offset
; addr_offset
+= onaline
)
2244 printf (" %04lx ", (unsigned long int)
2245 (addr_offset
+ section
->vma
));
2246 for (j
= addr_offset
* opb
;
2247 j
< addr_offset
* opb
+ onaline
; j
++)
2249 if (j
< stop_offset
* opb
)
2250 printf ("%02x", (unsigned) (data
[j
]));
2258 for (j
= addr_offset
; j
< addr_offset
* opb
+ onaline
; j
++)
2260 if (j
>= stop_offset
* opb
)
2263 printf ("%c", ISPRINT (data
[j
]) ? data
[j
] : '.');
2273 /* Should perhaps share code and display with nm? */
2275 dump_symbols (abfd
, dynamic
)
2276 bfd
*abfd ATTRIBUTE_UNUSED
;
2287 printf ("DYNAMIC SYMBOL TABLE:\n");
2293 printf ("SYMBOL TABLE:\n");
2297 printf (_("no symbols\n"));
2299 for (count
= 0; count
< max
; count
++)
2303 bfd
*cur_bfd
= bfd_asymbol_bfd (*current
);
2305 if (cur_bfd
!= NULL
)
2310 name
= (*current
)->name
;
2312 if (do_demangle
&& name
!= NULL
&& *name
!= '\0')
2314 /* If we want to demangle the name, we demangle it
2315 here, and temporarily clobber it while calling
2316 bfd_print_symbol. FIXME: This is a gross hack. */
2318 alloc
= demangle (cur_bfd
, name
);
2319 (*current
)->name
= alloc
;
2322 bfd_print_symbol (cur_bfd
, stdout
, *current
,
2323 bfd_print_symbol_all
);
2325 (*current
)->name
= name
;
2346 for (a
= abfd
->sections
; a
!= (asection
*) NULL
; a
= a
->next
)
2350 if (bfd_is_abs_section (a
))
2352 if (bfd_is_und_section (a
))
2354 if (bfd_is_com_section (a
))
2359 if (strcmp (only
, a
->name
))
2362 else if ((a
->flags
& SEC_RELOC
) == 0)
2365 relsize
= bfd_get_reloc_upper_bound (abfd
, a
);
2367 bfd_fatal (bfd_get_filename (abfd
));
2369 printf ("RELOCATION RECORDS FOR [%s]:", a
->name
);
2373 printf (" (none)\n\n");
2377 relpp
= (arelent
**) xmalloc (relsize
);
2378 relcount
= bfd_canonicalize_reloc (abfd
, a
, relpp
, syms
);
2380 bfd_fatal (bfd_get_filename (abfd
));
2381 else if (relcount
== 0)
2383 printf (" (none)\n\n");
2388 dump_reloc_set (abfd
, a
, relpp
, relcount
);
2397 dump_dynamic_relocs (abfd
)
2404 relsize
= bfd_get_dynamic_reloc_upper_bound (abfd
);
2406 bfd_fatal (bfd_get_filename (abfd
));
2408 printf ("DYNAMIC RELOCATION RECORDS");
2412 printf (" (none)\n\n");
2416 relpp
= (arelent
**) xmalloc (relsize
);
2417 relcount
= bfd_canonicalize_dynamic_reloc (abfd
, relpp
, dynsyms
);
2419 bfd_fatal (bfd_get_filename (abfd
));
2420 else if (relcount
== 0)
2422 printf (" (none)\n\n");
2427 dump_reloc_set (abfd
, (asection
*) NULL
, relpp
, relcount
);
2435 dump_reloc_set (abfd
, sec
, relpp
, relcount
)
2442 char *last_filename
, *last_functionname
;
2443 unsigned int last_line
;
2445 /* Get column headers lined up reasonably. */
2451 bfd_sprintf_vma (abfd
, buf
, (bfd_vma
) -1);
2452 width
= strlen (buf
) - 7;
2454 printf ("OFFSET %*s TYPE %*s VALUE \n", width
, "", 12, "");
2457 last_filename
= NULL
;
2458 last_functionname
= NULL
;
2461 for (p
= relpp
; relcount
&& *p
!= (arelent
*) NULL
; p
++, relcount
--)
2464 const char *filename
, *functionname
;
2466 const char *sym_name
;
2467 const char *section_name
;
2469 if (start_address
!= (bfd_vma
) -1
2470 && q
->address
< start_address
)
2472 if (stop_address
!= (bfd_vma
) -1
2473 && q
->address
> stop_address
)
2476 if (with_line_numbers
2478 && bfd_find_nearest_line (abfd
, sec
, syms
, q
->address
,
2479 &filename
, &functionname
, &line
))
2481 if (functionname
!= NULL
2482 && (last_functionname
== NULL
2483 || strcmp (functionname
, last_functionname
) != 0))
2485 printf ("%s():\n", functionname
);
2486 if (last_functionname
!= NULL
)
2487 free (last_functionname
);
2488 last_functionname
= xstrdup (functionname
);
2491 && (line
!= last_line
2492 || (filename
!= NULL
2493 && last_filename
!= NULL
2494 && strcmp (filename
, last_filename
) != 0)))
2496 printf ("%s:%u\n", filename
== NULL
? "???" : filename
, line
);
2498 if (last_filename
!= NULL
)
2499 free (last_filename
);
2500 if (filename
== NULL
)
2501 last_filename
= NULL
;
2503 last_filename
= xstrdup (filename
);
2507 if (q
->sym_ptr_ptr
&& *q
->sym_ptr_ptr
)
2509 sym_name
= (*(q
->sym_ptr_ptr
))->name
;
2510 section_name
= (*(q
->sym_ptr_ptr
))->section
->name
;
2515 section_name
= NULL
;
2519 bfd_printf_vma (abfd
, q
->address
);
2521 printf (" %-16s ", q
->howto
->name
);
2523 printf (" %-16d ", q
->howto
->type
);
2524 objdump_print_symname (abfd
, (struct disassemble_info
*) NULL
,
2529 if (section_name
== (const char *) NULL
)
2530 section_name
= "*unknown*";
2531 bfd_printf_vma (abfd
, q
->address
);
2532 printf (" %-16s [%s]",
2539 bfd_printf_vma (abfd
, q
->addend
);
2545 /* The length of the longest architecture name + 1. */
2546 #define LONGEST_ARCH sizeof("powerpc:common")
2549 endian_string (endian
)
2550 enum bfd_endian endian
;
2552 if (endian
== BFD_ENDIAN_BIG
)
2553 return "big endian";
2554 else if (endian
== BFD_ENDIAN_LITTLE
)
2555 return "little endian";
2557 return "endianness unknown";
2560 /* List the targets that BFD is configured to support, each followed
2561 by its endianness and the architectures it supports. */
2564 display_target_list ()
2566 extern const bfd_target
*const *bfd_target_vector
;
2570 dummy_name
= make_temp_file (NULL
);
2571 for (t
= 0; bfd_target_vector
[t
]; t
++)
2573 const bfd_target
*p
= bfd_target_vector
[t
];
2574 bfd
*abfd
= bfd_openw (dummy_name
, p
->name
);
2577 printf ("%s\n (header %s, data %s)\n", p
->name
,
2578 endian_string (p
->header_byteorder
),
2579 endian_string (p
->byteorder
));
2583 nonfatal (dummy_name
);
2587 if (! bfd_set_format (abfd
, bfd_object
))
2589 if (bfd_get_error () != bfd_error_invalid_operation
)
2591 bfd_close_all_done (abfd
);
2595 for (a
= (int) bfd_arch_obscure
+ 1; a
< (int) bfd_arch_last
; a
++)
2596 if (bfd_set_arch_mach (abfd
, (enum bfd_architecture
) a
, 0))
2598 bfd_printable_arch_mach ((enum bfd_architecture
) a
, 0));
2599 bfd_close_all_done (abfd
);
2601 unlink (dummy_name
);
2605 /* Print a table showing which architectures are supported for entries
2606 FIRST through LAST-1 of bfd_target_vector (targets across,
2607 architectures down). */
2610 display_info_table (first
, last
)
2614 extern const bfd_target
*const *bfd_target_vector
;
2618 /* Print heading of target names. */
2619 printf ("\n%*s", (int) LONGEST_ARCH
, " ");
2620 for (t
= first
; t
< last
&& bfd_target_vector
[t
]; t
++)
2621 printf ("%s ", bfd_target_vector
[t
]->name
);
2624 dummy_name
= make_temp_file (NULL
);
2625 for (a
= (int) bfd_arch_obscure
+ 1; a
< (int) bfd_arch_last
; a
++)
2626 if (strcmp (bfd_printable_arch_mach (a
, 0), "UNKNOWN!") != 0)
2628 printf ("%*s ", (int) LONGEST_ARCH
- 1,
2629 bfd_printable_arch_mach (a
, 0));
2630 for (t
= first
; t
< last
&& bfd_target_vector
[t
]; t
++)
2632 const bfd_target
*p
= bfd_target_vector
[t
];
2634 bfd
*abfd
= bfd_openw (dummy_name
, p
->name
);
2644 if (! bfd_set_format (abfd
, bfd_object
))
2646 if (bfd_get_error () != bfd_error_invalid_operation
)
2654 if (! bfd_set_arch_mach (abfd
, a
, 0))
2659 printf ("%s ", p
->name
);
2662 int l
= strlen (p
->name
);
2668 bfd_close_all_done (abfd
);
2672 unlink (dummy_name
);
2676 /* Print tables of all the target-architecture combinations that
2677 BFD has been configured to support. */
2680 display_target_tables ()
2683 extern const bfd_target
*const *bfd_target_vector
;
2687 colum
= getenv ("COLUMNS");
2689 columns
= atoi (colum
);
2694 while (bfd_target_vector
[t
] != NULL
)
2698 wid
= LONGEST_ARCH
+ strlen (bfd_target_vector
[t
]->name
) + 1;
2700 while (wid
< columns
&& bfd_target_vector
[t
] != NULL
)
2704 newwid
= wid
+ strlen (bfd_target_vector
[t
]->name
) + 1;
2705 if (newwid
>= columns
)
2710 display_info_table (oldt
, t
);
2717 printf (_("BFD header file version %s\n"), BFD_VERSION_STRING
);
2718 display_target_list ();
2719 display_target_tables ();
2722 int main
PARAMS ((int, char **));
2730 char *target
= default_target
;
2731 boolean seenflag
= false;
2733 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
2734 setlocale (LC_MESSAGES
, "");
2736 #if defined (HAVE_SETLOCALE)
2737 setlocale (LC_CTYPE
, "");
2739 bindtextdomain (PACKAGE
, LOCALEDIR
);
2740 textdomain (PACKAGE
);
2742 program_name
= *argv
;
2743 xmalloc_set_program_name (program_name
);
2745 START_PROGRESS (program_name
, 0);
2748 set_default_bfd_target ();
2750 while ((c
= getopt_long (argc
, argv
, "pib:m:M:VvCdDlfaHhrRtTxsSj:wE:zgG",
2751 long_options
, (int *) 0))
2757 break; /* We've been given a long option. */
2762 disassembler_options
= optarg
;
2768 with_line_numbers
= true;
2777 enum demangling_styles style
;
2779 style
= cplus_demangle_name_to_style (optarg
);
2780 if (style
== unknown_demangling
)
2781 fatal (_("unknown demangling style `%s'"),
2784 cplus_demangle_set_style (style
);
2790 case OPTION_ADJUST_VMA
:
2791 adjust_section_vma
= parse_vma (optarg
, "--adjust-vma");
2793 case OPTION_START_ADDRESS
:
2794 start_address
= parse_vma (optarg
, "--start-address");
2796 case OPTION_STOP_ADDRESS
:
2797 stop_address
= parse_vma (optarg
, "--stop-address");
2800 if (strcmp (optarg
, "B") == 0)
2801 endian
= BFD_ENDIAN_BIG
;
2802 else if (strcmp (optarg
, "L") == 0)
2803 endian
= BFD_ENDIAN_LITTLE
;
2806 non_fatal (_("unrecognized -E option"));
2811 if (strncmp (optarg
, "big", strlen (optarg
)) == 0)
2812 endian
= BFD_ENDIAN_BIG
;
2813 else if (strncmp (optarg
, "little", strlen (optarg
)) == 0)
2814 endian
= BFD_ENDIAN_LITTLE
;
2817 non_fatal (_("unrecognized --endian type `%s'"), optarg
);
2823 dump_file_header
= true;
2827 formats_info
= true;
2831 dump_private_headers
= true;
2835 dump_private_headers
= true;
2837 dump_reloc_info
= true;
2838 dump_file_header
= true;
2839 dump_ar_hdrs
= true;
2840 dump_section_headers
= true;
2848 dump_dynamic_symtab
= true;
2856 disassemble_zeroes
= true;
2860 disassemble_all
= true;
2865 with_source_code
= true;
2873 dump_stab_section_info
= true;
2877 dump_section_contents
= true;
2881 dump_reloc_info
= true;
2885 dump_dynamic_reloc_info
= true;
2889 dump_ar_hdrs
= true;
2893 dump_section_headers
= true;
2901 show_version
= true;
2911 print_version ("objdump");
2913 if (seenflag
== false)
2921 display_file ("a.out", target
);
2923 for (; optind
< argc
;)
2924 display_file (argv
[optind
++], target
);
2927 END_PROGRESS (program_name
);