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. */
42 PARAMS ((FILE *, const char *, ...));
46 static int exit_status
= 0;
48 static char *default_target
= NULL
; /* default at runtime */
50 static int show_version
= 0; /* show the version number */
51 static int dump_section_contents
; /* -s */
52 static int dump_section_headers
; /* -h */
53 static bfd_boolean dump_file_header
; /* -f */
54 static int dump_symtab
; /* -t */
55 static int dump_dynamic_symtab
; /* -T */
56 static int dump_reloc_info
; /* -r */
57 static int dump_dynamic_reloc_info
; /* -R */
58 static int dump_ar_hdrs
; /* -a */
59 static int dump_private_headers
; /* -p */
60 static int prefix_addresses
; /* --prefix-addresses */
61 static int with_line_numbers
; /* -l */
62 static bfd_boolean with_source_code
; /* -S */
63 static int show_raw_insn
; /* --show-raw-insn */
64 static int dump_stab_section_info
; /* --stabs */
65 static int do_demangle
; /* -C, --demangle */
66 static bfd_boolean disassemble
; /* -d */
67 static bfd_boolean disassemble_all
; /* -D */
68 static int disassemble_zeroes
; /* --disassemble-zeroes */
69 static bfd_boolean formats_info
; /* -i */
70 static char *only
; /* -j secname */
71 static int wide_output
; /* -w */
72 static bfd_vma start_address
= (bfd_vma
) -1; /* --start-address */
73 static bfd_vma stop_address
= (bfd_vma
) -1; /* --stop-address */
74 static int dump_debugging
; /* --debugging */
75 static bfd_vma adjust_section_vma
= 0; /* --adjust-vma */
76 static int file_start_context
= 0; /* --file-start-context */
78 /* Extra info to pass to the disassembler address printing function. */
79 struct objdump_disasm_info
83 bfd_boolean require_sec
;
86 /* Architecture to disassemble for, or default if NULL. */
87 static char *machine
= (char *) NULL
;
89 /* Target specific options to the disassembler. */
90 static char *disassembler_options
= (char *) NULL
;
92 /* Endianness to disassemble for, or default if BFD_ENDIAN_UNKNOWN. */
93 static enum bfd_endian endian
= BFD_ENDIAN_UNKNOWN
;
95 /* The symbol table. */
96 static asymbol
**syms
;
98 /* Number of symbols in `syms'. */
99 static long symcount
= 0;
101 /* The sorted symbol table. */
102 static asymbol
**sorted_syms
;
104 /* Number of symbols in `sorted_syms'. */
105 static long sorted_symcount
= 0;
107 /* The dynamic symbol table. */
108 static asymbol
**dynsyms
;
110 /* Number of symbols in `dynsyms'. */
111 static long dynsymcount
= 0;
113 /* Static declarations. */
116 PARAMS ((FILE *, int));
118 PARAMS ((const char *));
119 static void display_file
120 PARAMS ((char *filename
, char *target
));
121 static void dump_section_header
122 PARAMS ((bfd
*, asection
*, PTR
));
123 static void dump_headers
125 static void dump_data
126 PARAMS ((bfd
*abfd
));
127 static void dump_relocs
128 PARAMS ((bfd
*abfd
));
129 static void dump_dynamic_relocs
130 PARAMS ((bfd
* abfd
));
131 static void dump_reloc_set
132 PARAMS ((bfd
*, asection
*, arelent
**, long));
133 static void dump_symbols
134 PARAMS ((bfd
*abfd
, bfd_boolean dynamic
));
135 static void dump_bfd_header
137 static void dump_bfd_private_header
141 static void display_bfd
142 PARAMS ((bfd
*abfd
));
143 static void display_target_list
145 static void display_info_table
147 static void display_target_tables
149 static void display_info
151 static void objdump_print_value
152 PARAMS ((bfd_vma
, struct disassemble_info
*, bfd_boolean
));
153 static void objdump_print_symname
154 PARAMS ((bfd
*, struct disassemble_info
*, asymbol
*));
155 static asymbol
*find_symbol_for_address
156 PARAMS ((bfd
*, asection
*, bfd_vma
, bfd_boolean
, long *));
157 static void objdump_print_addr_with_sym
158 PARAMS ((bfd
*, asection
*, asymbol
*, bfd_vma
,
159 struct disassemble_info
*, bfd_boolean
));
160 static void objdump_print_addr
161 PARAMS ((bfd_vma
, struct disassemble_info
*, bfd_boolean
));
162 static void objdump_print_address
163 PARAMS ((bfd_vma
, struct disassemble_info
*));
164 static int objdump_symbol_at_address
165 PARAMS ((bfd_vma
, struct disassemble_info
*));
166 static void show_line
167 PARAMS ((bfd
*, asection
*, bfd_vma
));
168 static void disassemble_bytes
169 PARAMS ((struct disassemble_info
*, disassembler_ftype
, bfd_boolean
,
170 bfd_byte
*, bfd_vma
, bfd_vma
, arelent
***, arelent
**));
171 static void disassemble_data
173 static const char *endian_string
174 PARAMS ((enum bfd_endian
));
175 static asymbol
** slurp_symtab
177 static asymbol
** slurp_dynamic_symtab
179 static long remove_useless_symbols
180 PARAMS ((asymbol
**, long));
181 static int compare_symbols
182 PARAMS ((const PTR
, const PTR
));
183 static int compare_relocs
184 PARAMS ((const PTR
, const PTR
));
185 static void dump_stabs
187 static bfd_boolean read_section_stabs
188 PARAMS ((bfd
*, const char *, const char *));
189 static void print_section_stabs
190 PARAMS ((bfd
*, const char *, const char *));
193 usage (stream
, status
)
197 fprintf (stream
, _("Usage: %s <option(s)> <file(s)>\n"), program_name
);
198 fprintf (stream
, _(" Display information from object <file(s)>.\n"));
199 fprintf (stream
, _(" At least one of the following switches must be given:\n"));
200 fprintf (stream
, _("\
201 -a, --archive-headers Display archive header information\n\
202 -f, --file-headers Display the contents of the overall file header\n\
203 -p, --private-headers Display object format specific file header contents\n\
204 -h, --[section-]headers Display the contents of the section headers\n\
205 -x, --all-headers Display the contents of all headers\n\
206 -d, --disassemble Display assembler contents of executable sections\n\
207 -D, --disassemble-all Display assembler contents of all sections\n\
208 -S, --source Intermix source code with disassembly\n\
209 -s, --full-contents Display the full contents of all sections requested\n\
210 -g, --debugging Display debug information in object file\n\
211 -G, --stabs Display (in raw form) any STABS info in the file\n\
212 -t, --syms Display the contents of the symbol table(s)\n\
213 -T, --dynamic-syms Display the contents of the dynamic symbol table\n\
214 -r, --reloc Display the relocation entries in the file\n\
215 -R, --dynamic-reloc Display the dynamic relocation entries in the file\n\
216 -v, --version Display this program's version number\n\
217 -i, --info List object formats and architectures supported\n\
218 -H, --help Display this information\n\
222 fprintf (stream
, _("\n The following switches are optional:\n"));
223 fprintf (stream
, _("\
224 -b, --target=BFDNAME Specify the target object format as BFDNAME\n\
225 -m, --architecture=MACHINE Specify the target architecture as MACHINE\n\
226 -j, --section=NAME Only display information for section NAME\n\
227 -M, --disassembler-options=OPT Pass text OPT on to the disassembler\n\
228 -EB --endian=big Assume big endian format when disassembling\n\
229 -EL --endian=little Assume little endian format when disassembling\n\
230 --file-start-context Include context from start of file (with -S)\n\
231 -l, --line-numbers Include line numbers and filenames in output\n\
232 -C, --demangle[=STYLE] Decode mangled/processed symbol names\n\
233 The STYLE, if specified, can be `auto', 'gnu',\n\
234 'lucid', 'arm', 'hp', 'edg', or 'gnu-v3'\n\
235 -w, --wide Format output for more than 80 columns\n\
236 -z, --disassemble-zeroes Do not skip blocks of zeroes when disassembling\n\
237 --start-address=ADDR Only process data whoes address is >= ADDR\n\
238 --stop-address=ADDR Only process data whoes address is <= ADDR\n\
239 --prefix-addresses Print complete address alongside disassembly\n\
240 --[no-]show-raw-insn Display hex alongside symbolic disassembly\n\
241 --adjust-vma=OFFSET Add OFFSET to all displayed section addresses\n\
243 list_supported_targets (program_name
, stream
);
244 list_supported_architectures (program_name
, stream
);
246 disassembler_usage (stream
);
249 fprintf (stream
, _("Report bugs to %s.\n"), REPORT_BUGS_TO
);
253 /* 150 isn't special; it's just an arbitrary non-ASCII char value. */
255 #define OPTION_ENDIAN (150)
256 #define OPTION_START_ADDRESS (OPTION_ENDIAN + 1)
257 #define OPTION_STOP_ADDRESS (OPTION_START_ADDRESS + 1)
258 #define OPTION_ADJUST_VMA (OPTION_STOP_ADDRESS + 1)
260 static struct option long_options
[]=
262 {"adjust-vma", required_argument
, NULL
, OPTION_ADJUST_VMA
},
263 {"all-headers", no_argument
, NULL
, 'x'},
264 {"private-headers", no_argument
, NULL
, 'p'},
265 {"architecture", required_argument
, NULL
, 'm'},
266 {"archive-headers", no_argument
, NULL
, 'a'},
267 {"debugging", no_argument
, NULL
, 'g'},
268 {"demangle", optional_argument
, NULL
, 'C'},
269 {"disassemble", no_argument
, NULL
, 'd'},
270 {"disassemble-all", no_argument
, NULL
, 'D'},
271 {"disassembler-options", required_argument
, NULL
, 'M'},
272 {"disassemble-zeroes", no_argument
, NULL
, 'z'},
273 {"dynamic-reloc", no_argument
, NULL
, 'R'},
274 {"dynamic-syms", no_argument
, NULL
, 'T'},
275 {"endian", required_argument
, NULL
, OPTION_ENDIAN
},
276 {"file-headers", no_argument
, NULL
, 'f'},
277 {"file-start-context", no_argument
, &file_start_context
, 1},
278 {"full-contents", no_argument
, NULL
, 's'},
279 {"headers", no_argument
, NULL
, 'h'},
280 {"help", no_argument
, NULL
, 'H'},
281 {"info", no_argument
, NULL
, 'i'},
282 {"line-numbers", no_argument
, NULL
, 'l'},
283 {"no-show-raw-insn", no_argument
, &show_raw_insn
, -1},
284 {"prefix-addresses", no_argument
, &prefix_addresses
, 1},
285 {"reloc", no_argument
, NULL
, 'r'},
286 {"section", required_argument
, NULL
, 'j'},
287 {"section-headers", no_argument
, NULL
, 'h'},
288 {"show-raw-insn", no_argument
, &show_raw_insn
, 1},
289 {"source", no_argument
, NULL
, 'S'},
290 {"stabs", no_argument
, NULL
, 'G'},
291 {"start-address", required_argument
, NULL
, OPTION_START_ADDRESS
},
292 {"stop-address", required_argument
, NULL
, OPTION_STOP_ADDRESS
},
293 {"syms", no_argument
, NULL
, 't'},
294 {"target", required_argument
, NULL
, 'b'},
295 {"version", no_argument
, NULL
, 'V'},
296 {"wide", no_argument
, NULL
, 'w'},
297 {0, no_argument
, 0, 0}
309 dump_section_header (abfd
, section
, ignored
)
310 bfd
*abfd ATTRIBUTE_UNUSED
;
312 PTR ignored ATTRIBUTE_UNUSED
;
315 unsigned int opb
= bfd_octets_per_byte (abfd
);
317 printf ("%3d %-13s %08lx ", section
->index
,
318 bfd_get_section_name (abfd
, section
),
319 (unsigned long) bfd_section_size (abfd
, section
) / opb
);
320 bfd_printf_vma (abfd
, bfd_get_section_vma (abfd
, section
));
322 bfd_printf_vma (abfd
, section
->lma
);
323 printf (" %08lx 2**%u", (unsigned long) section
->filepos
,
324 bfd_get_section_alignment (abfd
, section
));
330 if (section->flags & x) { printf ("%s%s", comma, y); comma = ", "; }
332 PF (SEC_HAS_CONTENTS
, "CONTENTS");
333 PF (SEC_ALLOC
, "ALLOC");
334 PF (SEC_CONSTRUCTOR
, "CONSTRUCTOR");
335 PF (SEC_LOAD
, "LOAD");
336 PF (SEC_RELOC
, "RELOC");
337 PF (SEC_READONLY
, "READONLY");
338 PF (SEC_CODE
, "CODE");
339 PF (SEC_DATA
, "DATA");
341 PF (SEC_DEBUGGING
, "DEBUGGING");
342 PF (SEC_NEVER_LOAD
, "NEVER_LOAD");
343 PF (SEC_EXCLUDE
, "EXCLUDE");
344 PF (SEC_SORT_ENTRIES
, "SORT_ENTRIES");
345 PF (SEC_BLOCK
, "BLOCK");
346 PF (SEC_CLINK
, "CLINK");
347 PF (SEC_SMALL_DATA
, "SMALL_DATA");
348 PF (SEC_SHARED
, "SHARED");
349 PF (SEC_ARCH_BIT_0
, "ARCH_BIT_0");
350 PF (SEC_THREAD_LOCAL
, "THREAD_LOCAL");
352 if ((section
->flags
& SEC_LINK_ONCE
) != 0)
356 switch (section
->flags
& SEC_LINK_DUPLICATES
)
360 case SEC_LINK_DUPLICATES_DISCARD
:
361 ls
= "LINK_ONCE_DISCARD";
363 case SEC_LINK_DUPLICATES_ONE_ONLY
:
364 ls
= "LINK_ONCE_ONE_ONLY";
366 case SEC_LINK_DUPLICATES_SAME_SIZE
:
367 ls
= "LINK_ONCE_SAME_SIZE";
369 case SEC_LINK_DUPLICATES_SAME_CONTENTS
:
370 ls
= "LINK_ONCE_SAME_CONTENTS";
373 printf ("%s%s", comma
, ls
);
375 if (section
->comdat
!= NULL
)
376 printf (" (COMDAT %s %ld)", section
->comdat
->name
,
377 section
->comdat
->symbol
);
390 printf (_("Sections:\n"));
393 printf (_("Idx Name Size VMA LMA File off Algn"));
395 /* With BFD64, non-ELF returns -1 and wants always 64 bit addresses. */
396 if (bfd_get_arch_size (abfd
) == 32)
397 printf (_("Idx Name Size VMA LMA File off Algn"));
399 printf (_("Idx Name Size VMA LMA File off Algn"));
403 printf (_(" Flags"));
404 if (abfd
->flags
& HAS_LOAD_PAGE
)
408 bfd_map_over_sections (abfd
, dump_section_header
, (PTR
) NULL
);
415 asymbol
**sy
= (asymbol
**) NULL
;
418 if (!(bfd_get_file_flags (abfd
) & HAS_SYMS
))
424 storage
= bfd_get_symtab_upper_bound (abfd
);
426 bfd_fatal (bfd_get_filename (abfd
));
428 sy
= (asymbol
**) xmalloc (storage
);
430 symcount
= bfd_canonicalize_symtab (abfd
, sy
);
432 bfd_fatal (bfd_get_filename (abfd
));
436 /* Read in the dynamic symbols. */
439 slurp_dynamic_symtab (abfd
)
442 asymbol
**sy
= (asymbol
**) NULL
;
445 storage
= bfd_get_dynamic_symtab_upper_bound (abfd
);
448 if (!(bfd_get_file_flags (abfd
) & DYNAMIC
))
450 non_fatal (_("%s: not a dynamic object"), bfd_get_filename (abfd
));
455 bfd_fatal (bfd_get_filename (abfd
));
458 sy
= (asymbol
**) xmalloc (storage
);
460 dynsymcount
= bfd_canonicalize_dynamic_symtab (abfd
, sy
);
462 bfd_fatal (bfd_get_filename (abfd
));
466 /* Filter out (in place) symbols that are useless for disassembly.
467 COUNT is the number of elements in SYMBOLS.
468 Return the number of useful symbols. */
471 remove_useless_symbols (symbols
, count
)
475 register asymbol
**in_ptr
= symbols
, **out_ptr
= symbols
;
479 asymbol
*sym
= *in_ptr
++;
481 if (sym
->name
== NULL
|| sym
->name
[0] == '\0')
483 if (sym
->flags
& (BSF_DEBUGGING
))
485 if (bfd_is_und_section (sym
->section
)
486 || bfd_is_com_section (sym
->section
))
491 return out_ptr
- symbols
;
494 /* Sort symbols into value order. */
497 compare_symbols (ap
, bp
)
501 const asymbol
*a
= *(const asymbol
**)ap
;
502 const asymbol
*b
= *(const asymbol
**)bp
;
506 flagword aflags
, bflags
;
508 if (bfd_asymbol_value (a
) > bfd_asymbol_value (b
))
510 else if (bfd_asymbol_value (a
) < bfd_asymbol_value (b
))
513 if (a
->section
> b
->section
)
515 else if (a
->section
< b
->section
)
518 an
= bfd_asymbol_name (a
);
519 bn
= bfd_asymbol_name (b
);
523 /* The symbols gnu_compiled and gcc2_compiled convey no real
524 information, so put them after other symbols with the same value. */
526 af
= (strstr (an
, "gnu_compiled") != NULL
527 || strstr (an
, "gcc2_compiled") != NULL
);
528 bf
= (strstr (bn
, "gnu_compiled") != NULL
529 || strstr (bn
, "gcc2_compiled") != NULL
);
536 /* We use a heuristic for the file name, to try to sort it after
537 more useful symbols. It may not work on non Unix systems, but it
538 doesn't really matter; the only difference is precisely which
539 symbol names get printed. */
541 #define file_symbol(s, sn, snl) \
542 (((s)->flags & BSF_FILE) != 0 \
543 || ((sn)[(snl) - 2] == '.' \
544 && ((sn)[(snl) - 1] == 'o' \
545 || (sn)[(snl) - 1] == 'a')))
547 af
= file_symbol (a
, an
, anl
);
548 bf
= file_symbol (b
, bn
, bnl
);
555 /* Try to sort global symbols before local symbols before function
556 symbols before debugging symbols. */
561 if ((aflags
& BSF_DEBUGGING
) != (bflags
& BSF_DEBUGGING
))
563 if ((aflags
& BSF_DEBUGGING
) != 0)
568 if ((aflags
& BSF_FUNCTION
) != (bflags
& BSF_FUNCTION
))
570 if ((aflags
& BSF_FUNCTION
) != 0)
575 if ((aflags
& BSF_LOCAL
) != (bflags
& BSF_LOCAL
))
577 if ((aflags
& BSF_LOCAL
) != 0)
582 if ((aflags
& BSF_GLOBAL
) != (bflags
& BSF_GLOBAL
))
584 if ((aflags
& BSF_GLOBAL
) != 0)
590 /* Symbols that start with '.' might be section names, so sort them
591 after symbols that don't start with '.'. */
592 if (an
[0] == '.' && bn
[0] != '.')
594 if (an
[0] != '.' && bn
[0] == '.')
597 /* Finally, if we can't distinguish them in any other way, try to
598 get consistent results by sorting the symbols by name. */
599 return strcmp (an
, bn
);
602 /* Sort relocs into address order. */
605 compare_relocs (ap
, bp
)
609 const arelent
*a
= *(const arelent
**)ap
;
610 const arelent
*b
= *(const arelent
**)bp
;
612 if (a
->address
> b
->address
)
614 else if (a
->address
< b
->address
)
617 /* So that associated relocations tied to the same address show up
618 in the correct order, we don't do any further sorting. */
627 /* Print VMA to STREAM. If SKIP_ZEROES is TRUE, omit leading zeroes. */
630 objdump_print_value (vma
, info
, skip_zeroes
)
632 struct disassemble_info
*info
;
633 bfd_boolean skip_zeroes
;
637 struct objdump_disasm_info
*aux
638 = (struct objdump_disasm_info
*) info
->application_data
;
640 bfd_sprintf_vma (aux
->abfd
, buf
, vma
);
645 for (p
= buf
; *p
== '0'; ++p
)
650 (*info
->fprintf_func
) (info
->stream
, "%s", p
);
653 /* Print the name of a symbol. */
656 objdump_print_symname (abfd
, info
, sym
)
658 struct disassemble_info
*info
;
665 name
= bfd_asymbol_name (sym
);
666 if (do_demangle
&& name
[0] != '\0')
668 /* Demangle the name. */
669 alloc
= demangle (abfd
, name
);
674 (*info
->fprintf_func
) (info
->stream
, "%s", name
);
682 /* Locate a symbol given a bfd, a section, and a VMA. If REQUIRE_SEC
683 is TRUE, then always require the symbol to be in the section. This
684 returns NULL if there is no suitable symbol. If PLACE is not NULL,
685 then *PLACE is set to the index of the symbol in sorted_syms. */
688 find_symbol_for_address (abfd
, sec
, vma
, require_sec
, place
)
692 bfd_boolean require_sec
;
695 /* @@ Would it speed things up to cache the last two symbols returned,
696 and maybe their address ranges? For many processors, only one memory
697 operand can be present at a time, so the 2-entry cache wouldn't be
698 constantly churned by code doing heavy memory accesses. */
700 /* Indices in `sorted_syms'. */
702 long max
= sorted_symcount
;
704 unsigned int opb
= bfd_octets_per_byte (abfd
);
706 if (sorted_symcount
< 1)
709 /* Perform a binary search looking for the closest symbol to the
710 required value. We are searching the range (min, max]. */
711 while (min
+ 1 < max
)
715 thisplace
= (max
+ min
) / 2;
716 sym
= sorted_syms
[thisplace
];
718 if (bfd_asymbol_value (sym
) > vma
)
720 else if (bfd_asymbol_value (sym
) < vma
)
729 /* The symbol we want is now in min, the low end of the range we
730 were searching. If there are several symbols with the same
731 value, we want the first one. */
734 && (bfd_asymbol_value (sorted_syms
[thisplace
])
735 == bfd_asymbol_value (sorted_syms
[thisplace
- 1])))
738 /* If the file is relocateable, and the symbol could be from this
739 section, prefer a symbol from this section over symbols from
740 others, even if the other symbol's value might be closer.
742 Note that this may be wrong for some symbol references if the
743 sections have overlapping memory ranges, but in that case there's
744 no way to tell what's desired without looking at the relocation
747 if (sorted_syms
[thisplace
]->section
!= sec
749 || ((abfd
->flags
& HAS_RELOC
) != 0
750 && vma
>= bfd_get_section_vma (abfd
, sec
)
751 && vma
< (bfd_get_section_vma (abfd
, sec
)
752 + bfd_section_size (abfd
, sec
) / opb
))))
756 for (i
= thisplace
+ 1; i
< sorted_symcount
; i
++)
758 if (bfd_asymbol_value (sorted_syms
[i
])
759 != bfd_asymbol_value (sorted_syms
[thisplace
]))
765 if (sorted_syms
[i
]->section
== sec
767 || sorted_syms
[i
- 1]->section
!= sec
768 || (bfd_asymbol_value (sorted_syms
[i
])
769 != bfd_asymbol_value (sorted_syms
[i
- 1]))))
776 if (sorted_syms
[thisplace
]->section
!= sec
)
778 /* We didn't find a good symbol with a smaller value.
779 Look for one with a larger value. */
780 for (i
= thisplace
+ 1; i
< sorted_symcount
; i
++)
782 if (sorted_syms
[i
]->section
== sec
)
790 if (sorted_syms
[thisplace
]->section
!= sec
792 || ((abfd
->flags
& HAS_RELOC
) != 0
793 && vma
>= bfd_get_section_vma (abfd
, sec
)
794 && vma
< (bfd_get_section_vma (abfd
, sec
)
795 + bfd_section_size (abfd
, sec
)))))
797 /* There is no suitable symbol. */
805 return sorted_syms
[thisplace
];
808 /* Print an address to INFO symbolically. */
811 objdump_print_addr_with_sym (abfd
, sec
, sym
, vma
, info
, skip_zeroes
)
816 struct disassemble_info
*info
;
817 bfd_boolean skip_zeroes
;
819 objdump_print_value (vma
, info
, skip_zeroes
);
825 (*info
->fprintf_func
) (info
->stream
, " <%s",
826 bfd_get_section_name (abfd
, sec
));
827 secaddr
= bfd_get_section_vma (abfd
, sec
);
830 (*info
->fprintf_func
) (info
->stream
, "-0x");
831 objdump_print_value (secaddr
- vma
, info
, TRUE
);
833 else if (vma
> secaddr
)
835 (*info
->fprintf_func
) (info
->stream
, "+0x");
836 objdump_print_value (vma
- secaddr
, info
, TRUE
);
838 (*info
->fprintf_func
) (info
->stream
, ">");
842 (*info
->fprintf_func
) (info
->stream
, " <");
843 objdump_print_symname (abfd
, info
, sym
);
844 if (bfd_asymbol_value (sym
) > vma
)
846 (*info
->fprintf_func
) (info
->stream
, "-0x");
847 objdump_print_value (bfd_asymbol_value (sym
) - vma
, info
, TRUE
);
849 else if (vma
> bfd_asymbol_value (sym
))
851 (*info
->fprintf_func
) (info
->stream
, "+0x");
852 objdump_print_value (vma
- bfd_asymbol_value (sym
), info
, TRUE
);
854 (*info
->fprintf_func
) (info
->stream
, ">");
858 /* Print VMA to INFO, symbolically if possible. If SKIP_ZEROES is
859 TRUE, don't output leading zeroes. */
862 objdump_print_addr (vma
, info
, skip_zeroes
)
864 struct disassemble_info
*info
;
865 bfd_boolean skip_zeroes
;
867 struct objdump_disasm_info
*aux
;
870 if (sorted_symcount
< 1)
872 (*info
->fprintf_func
) (info
->stream
, "0x");
873 objdump_print_value (vma
, info
, skip_zeroes
);
877 aux
= (struct objdump_disasm_info
*) info
->application_data
;
878 sym
= find_symbol_for_address (aux
->abfd
, aux
->sec
, vma
, aux
->require_sec
,
880 objdump_print_addr_with_sym (aux
->abfd
, aux
->sec
, sym
, vma
, info
,
884 /* Print VMA to INFO. This function is passed to the disassembler
888 objdump_print_address (vma
, info
)
890 struct disassemble_info
*info
;
892 objdump_print_addr (vma
, info
, ! prefix_addresses
);
895 /* Determine of the given address has a symbol associated with it. */
898 objdump_symbol_at_address (vma
, info
)
900 struct disassemble_info
* info
;
902 struct objdump_disasm_info
* aux
;
905 /* No symbols - do not bother checking. */
906 if (sorted_symcount
< 1)
909 aux
= (struct objdump_disasm_info
*) info
->application_data
;
910 sym
= find_symbol_for_address (aux
->abfd
, aux
->sec
, vma
, aux
->require_sec
,
913 return (sym
!= NULL
&& (bfd_asymbol_value (sym
) == vma
));
916 /* Hold the last function name and the last line number we displayed
919 static char *prev_functionname
;
920 static unsigned int prev_line
;
922 /* We keep a list of all files that we have seen when doing a
923 dissassembly with source, so that we know how much of the file to
924 display. This can be important for inlined functions. */
926 struct print_file_list
928 struct print_file_list
*next
;
934 static struct print_file_list
*print_files
;
936 /* The number of preceding context lines to show when we start
937 displaying a file for the first time. */
939 #define SHOW_PRECEDING_CONTEXT_LINES (5)
941 /* Skip ahead to a given line in a file, optionally printing each
944 static void skip_to_line
945 PARAMS ((struct print_file_list
*, unsigned int, bfd_boolean
));
948 skip_to_line (p
, line
, show
)
949 struct print_file_list
*p
;
953 while (p
->line
< line
)
957 if (fgets (buf
, sizeof buf
, p
->f
) == NULL
)
967 if (strchr (buf
, '\n') != NULL
)
972 /* Show the line number, or the source line, in a dissassembly
976 show_line (abfd
, section
, addr_offset
)
981 const char *filename
;
982 const char *functionname
;
985 if (! with_line_numbers
&& ! with_source_code
)
988 if (! bfd_find_nearest_line (abfd
, section
, syms
, addr_offset
, &filename
,
989 &functionname
, &line
))
992 if (filename
!= NULL
&& *filename
== '\0')
994 if (functionname
!= NULL
&& *functionname
== '\0')
997 if (with_line_numbers
)
999 if (functionname
!= NULL
1000 && (prev_functionname
== NULL
1001 || strcmp (functionname
, prev_functionname
) != 0))
1002 printf ("%s():\n", functionname
);
1003 if (line
> 0 && line
!= prev_line
)
1004 printf ("%s:%u\n", filename
== NULL
? "???" : filename
, line
);
1007 if (with_source_code
1011 struct print_file_list
**pp
, *p
;
1013 for (pp
= &print_files
; *pp
!= NULL
; pp
= &(*pp
)->next
)
1014 if (strcmp ((*pp
)->filename
, filename
) == 0)
1020 if (p
!= print_files
)
1024 /* We have reencountered a file name which we saw
1025 earlier. This implies that either we are dumping out
1026 code from an included file, or the same file was
1027 linked in more than once. There are two common cases
1028 of an included file: inline functions in a header
1029 file, and a bison or flex skeleton file. In the
1030 former case we want to just start printing (but we
1031 back up a few lines to give context); in the latter
1032 case we want to continue from where we left off. I
1033 can't think of a good way to distinguish the cases,
1034 so I used a heuristic based on the file name. */
1035 if (strcmp (p
->filename
+ strlen (p
->filename
) - 2, ".h") != 0)
1039 l
= line
- SHOW_PRECEDING_CONTEXT_LINES
;
1046 p
->f
= fopen (p
->filename
, "r");
1050 skip_to_line (p
, l
, FALSE
);
1052 if (print_files
->f
!= NULL
)
1054 fclose (print_files
->f
);
1055 print_files
->f
= NULL
;
1061 skip_to_line (p
, line
, TRUE
);
1063 p
->next
= print_files
;
1071 f
= fopen (filename
, "r");
1076 p
= ((struct print_file_list
*)
1077 xmalloc (sizeof (struct print_file_list
)));
1078 p
->filename
= xmalloc (strlen (filename
) + 1);
1079 strcpy (p
->filename
, filename
);
1083 if (print_files
!= NULL
&& print_files
->f
!= NULL
)
1085 fclose (print_files
->f
);
1086 print_files
->f
= NULL
;
1088 p
->next
= print_files
;
1091 if (file_start_context
)
1094 l
= line
- SHOW_PRECEDING_CONTEXT_LINES
;
1097 skip_to_line (p
, l
, FALSE
);
1099 skip_to_line (p
, line
, TRUE
);
1104 if (functionname
!= NULL
1105 && (prev_functionname
== NULL
1106 || strcmp (functionname
, prev_functionname
) != 0))
1108 if (prev_functionname
!= NULL
)
1109 free (prev_functionname
);
1110 prev_functionname
= xmalloc (strlen (functionname
) + 1);
1111 strcpy (prev_functionname
, functionname
);
1114 if (line
> 0 && line
!= prev_line
)
1118 /* Pseudo FILE object for strings. */
1126 /* sprintf to a "stream" */
1129 objdump_sprintf
VPARAMS ((SFILE
*f
, const char *format
, ...))
1134 VA_OPEN (args
, format
);
1135 VA_FIXEDARG (args
, SFILE
*, f
);
1136 VA_FIXEDARG (args
, const char *, format
);
1138 vasprintf (&buf
, format
, args
);
1143 fatal (_("Out of virtual memory"));
1148 while ((size_t) ((f
->buffer
+ f
->size
) - f
->current
) < n
+ 1)
1152 curroff
= f
->current
- f
->buffer
;
1154 f
->buffer
= xrealloc (f
->buffer
, f
->size
);
1155 f
->current
= f
->buffer
+ curroff
;
1158 memcpy (f
->current
, buf
, n
);
1160 f
->current
[0] = '\0';
1168 /* The number of zeroes we want to see before we start skipping them.
1169 The number is arbitrarily chosen. */
1172 #define SKIP_ZEROES (8)
1175 /* The number of zeroes to skip at the end of a section. If the
1176 number of zeroes at the end is between SKIP_ZEROES_AT_END and
1177 SKIP_ZEROES, they will be disassembled. If there are fewer than
1178 SKIP_ZEROES_AT_END, they will be skipped. This is a heuristic
1179 attempt to avoid disassembling zeroes inserted by section
1182 #ifndef SKIP_ZEROES_AT_END
1183 #define SKIP_ZEROES_AT_END (3)
1186 /* Disassemble some data in memory between given values. */
1189 disassemble_bytes (info
, disassemble_fn
, insns
, data
,
1190 start_offset
, stop_offset
, relppp
,
1192 struct disassemble_info
*info
;
1193 disassembler_ftype disassemble_fn
;
1196 bfd_vma start_offset
;
1197 bfd_vma stop_offset
;
1201 struct objdump_disasm_info
*aux
;
1203 int octets_per_line
;
1204 bfd_boolean done_dot
;
1205 int skip_addr_chars
;
1206 bfd_vma addr_offset
;
1207 int opb
= info
->octets_per_byte
;
1209 aux
= (struct objdump_disasm_info
*) info
->application_data
;
1213 octets_per_line
= 4;
1215 octets_per_line
= 16;
1217 /* Figure out how many characters to skip at the start of an
1218 address, to make the disassembly look nicer. We discard leading
1219 zeroes in chunks of 4, ensuring that there is always a leading
1221 skip_addr_chars
= 0;
1222 if (! prefix_addresses
)
1230 + bfd_section_size (section
->owner
, section
) / opb
));
1232 while (s
[0] == '0' && s
[1] == '0' && s
[2] == '0' && s
[3] == '0'
1235 skip_addr_chars
+= 4;
1240 info
->insn_info_valid
= 0;
1243 addr_offset
= start_offset
;
1244 while (addr_offset
< stop_offset
)
1248 bfd_boolean need_nl
= FALSE
;
1250 /* If we see more than SKIP_ZEROES octets of zeroes, we just
1252 for (z
= addr_offset
* opb
; z
< stop_offset
* opb
; z
++)
1255 if (! disassemble_zeroes
1256 && (info
->insn_info_valid
== 0
1257 || info
->branch_delay_insns
== 0)
1258 && (z
- addr_offset
* opb
>= SKIP_ZEROES
1259 || (z
== stop_offset
* opb
&&
1260 z
- addr_offset
* opb
< SKIP_ZEROES_AT_END
)))
1264 /* If there are more nonzero octets to follow, we only skip
1265 zeroes in multiples of 4, to try to avoid running over
1266 the start of an instruction which happens to start with
1268 if (z
!= stop_offset
* opb
)
1269 z
= addr_offset
* opb
+ ((z
- addr_offset
* opb
) &~ 3);
1271 octets
= z
- addr_offset
* opb
;
1282 if (with_line_numbers
|| with_source_code
)
1283 /* The line number tables will refer to unadjusted
1284 section VMAs, so we must undo any VMA modifications
1285 when calling show_line. */
1286 show_line (aux
->abfd
, section
, addr_offset
- adjust_section_vma
);
1288 if (! prefix_addresses
)
1292 bfd_sprintf_vma (aux
->abfd
, buf
, section
->vma
+ addr_offset
);
1293 for (s
= buf
+ skip_addr_chars
; *s
== '0'; s
++)
1297 printf ("%s:\t", buf
+ skip_addr_chars
);
1301 aux
->require_sec
= TRUE
;
1302 objdump_print_address (section
->vma
+ addr_offset
, info
);
1303 aux
->require_sec
= FALSE
;
1310 sfile
.buffer
= xmalloc (sfile
.size
);
1311 sfile
.current
= sfile
.buffer
;
1312 info
->fprintf_func
= (fprintf_ftype
) objdump_sprintf
;
1313 info
->stream
= (FILE *) &sfile
;
1314 info
->bytes_per_line
= 0;
1315 info
->bytes_per_chunk
= 0;
1317 #ifdef DISASSEMBLER_NEEDS_RELOCS
1318 /* FIXME: This is wrong. It tests the number of octets
1319 in the last instruction, not the current one. */
1320 if (*relppp
< relppend
1321 && (**relppp
)->address
>= addr_offset
1322 && (**relppp
)->address
<= addr_offset
+ octets
/ opb
)
1323 info
->flags
= INSN_HAS_RELOC
;
1328 octets
= (*disassemble_fn
) (section
->vma
+ addr_offset
, info
);
1329 info
->fprintf_func
= (fprintf_ftype
) fprintf
;
1330 info
->stream
= stdout
;
1331 if (info
->bytes_per_line
!= 0)
1332 octets_per_line
= info
->bytes_per_line
;
1335 if (sfile
.current
!= sfile
.buffer
)
1336 printf ("%s\n", sfile
.buffer
);
1337 free (sfile
.buffer
);
1345 octets
= octets_per_line
;
1346 if (addr_offset
+ octets
/ opb
> stop_offset
)
1347 octets
= (stop_offset
- addr_offset
) * opb
;
1349 for (j
= addr_offset
* opb
; j
< addr_offset
* opb
+ octets
; ++j
)
1351 if (ISPRINT (data
[j
]))
1352 buf
[j
- addr_offset
* opb
] = data
[j
];
1354 buf
[j
- addr_offset
* opb
] = '.';
1356 buf
[j
- addr_offset
* opb
] = '\0';
1359 if (prefix_addresses
1361 : show_raw_insn
>= 0)
1365 /* If ! prefix_addresses and ! wide_output, we print
1366 octets_per_line octets per line. */
1368 if (pb
> octets_per_line
&& ! prefix_addresses
&& ! wide_output
)
1369 pb
= octets_per_line
;
1371 if (info
->bytes_per_chunk
)
1372 bpc
= info
->bytes_per_chunk
;
1376 for (j
= addr_offset
* opb
; j
< addr_offset
* opb
+ pb
; j
+= bpc
)
1379 if (bpc
> 1 && info
->display_endian
== BFD_ENDIAN_LITTLE
)
1381 for (k
= bpc
- 1; k
>= 0; k
--)
1382 printf ("%02x", (unsigned) data
[j
+ k
]);
1387 for (k
= 0; k
< bpc
; k
++)
1388 printf ("%02x", (unsigned) data
[j
+ k
]);
1393 for (; pb
< octets_per_line
; pb
+= bpc
)
1397 for (k
= 0; k
< bpc
; k
++)
1402 /* Separate raw data from instruction by extra space. */
1413 printf ("%s", sfile
.buffer
);
1414 free (sfile
.buffer
);
1417 if (prefix_addresses
1419 : show_raw_insn
>= 0)
1427 j
= addr_offset
* opb
+ pb
;
1429 bfd_sprintf_vma (aux
->abfd
, buf
, section
->vma
+ j
/ opb
);
1430 for (s
= buf
+ skip_addr_chars
; *s
== '0'; s
++)
1434 printf ("%s:\t", buf
+ skip_addr_chars
);
1436 pb
+= octets_per_line
;
1439 for (; j
< addr_offset
* opb
+ pb
; j
+= bpc
)
1443 if (bpc
> 1 && info
->display_endian
== BFD_ENDIAN_LITTLE
)
1445 for (k
= bpc
- 1; k
>= 0; k
--)
1446 printf ("%02x", (unsigned) data
[j
+ k
]);
1451 for (k
= 0; k
< bpc
; k
++)
1452 printf ("%02x", (unsigned) data
[j
+ k
]);
1465 if ((section
->flags
& SEC_RELOC
) != 0
1466 #ifndef DISASSEMBLER_NEEDS_RELOCS
1471 while ((*relppp
) < relppend
1472 && ((**relppp
)->address
>= (bfd_vma
) addr_offset
1473 && (**relppp
)->address
< (bfd_vma
) addr_offset
+ octets
/ opb
))
1474 #ifdef DISASSEMBLER_NEEDS_RELOCS
1475 if (! dump_reloc_info
)
1489 objdump_print_value (section
->vma
+ q
->address
, info
, TRUE
);
1491 printf (": %s\t", q
->howto
->name
);
1493 if (q
->sym_ptr_ptr
== NULL
|| *q
->sym_ptr_ptr
== NULL
)
1494 printf ("*unknown*");
1497 const char *sym_name
;
1499 sym_name
= bfd_asymbol_name (*q
->sym_ptr_ptr
);
1500 if (sym_name
!= NULL
&& *sym_name
!= '\0')
1501 objdump_print_symname (aux
->abfd
, info
, *q
->sym_ptr_ptr
);
1506 sym_sec
= bfd_get_section (*q
->sym_ptr_ptr
);
1507 sym_name
= bfd_get_section_name (aux
->abfd
, sym_sec
);
1508 if (sym_name
== NULL
|| *sym_name
== '\0')
1509 sym_name
= "*unknown*";
1510 printf ("%s", sym_name
);
1517 objdump_print_value (q
->addend
, info
, TRUE
);
1529 addr_offset
+= octets
/ opb
;
1533 /* Disassemble the contents of an object file. */
1536 disassemble_data (abfd
)
1539 unsigned long addr_offset
;
1540 disassembler_ftype disassemble_fn
;
1541 struct disassemble_info disasm_info
;
1542 struct objdump_disasm_info aux
;
1547 prev_functionname
= NULL
;
1550 /* We make a copy of syms to sort. We don't want to sort syms
1551 because that will screw up the relocs. */
1552 sorted_syms
= (asymbol
**) xmalloc (symcount
* sizeof (asymbol
*));
1553 memcpy (sorted_syms
, syms
, symcount
* sizeof (asymbol
*));
1555 sorted_symcount
= remove_useless_symbols (sorted_syms
, symcount
);
1557 /* Sort the symbols into section and symbol order */
1558 qsort (sorted_syms
, sorted_symcount
, sizeof (asymbol
*), compare_symbols
);
1560 INIT_DISASSEMBLE_INFO(disasm_info
, stdout
, fprintf
);
1561 disasm_info
.application_data
= (PTR
) &aux
;
1563 aux
.require_sec
= FALSE
;
1564 disasm_info
.print_address_func
= objdump_print_address
;
1565 disasm_info
.symbol_at_address_func
= objdump_symbol_at_address
;
1567 if (machine
!= (char *) NULL
)
1569 const bfd_arch_info_type
*info
= bfd_scan_arch (machine
);
1572 fatal (_("Can't use supplied machine %s"), machine
);
1574 abfd
->arch_info
= info
;
1577 if (endian
!= BFD_ENDIAN_UNKNOWN
)
1579 struct bfd_target
*xvec
;
1581 xvec
= (struct bfd_target
*) xmalloc (sizeof (struct bfd_target
));
1582 memcpy (xvec
, abfd
->xvec
, sizeof (struct bfd_target
));
1583 xvec
->byteorder
= endian
;
1587 disassemble_fn
= disassembler (abfd
);
1588 if (!disassemble_fn
)
1590 non_fatal (_("Can't disassemble for architecture %s\n"),
1591 bfd_printable_arch_mach (bfd_get_arch (abfd
), 0));
1596 opb
= bfd_octets_per_byte (abfd
);
1598 disasm_info
.flavour
= bfd_get_flavour (abfd
);
1599 disasm_info
.arch
= bfd_get_arch (abfd
);
1600 disasm_info
.mach
= bfd_get_mach (abfd
);
1601 disasm_info
.disassembler_options
= disassembler_options
;
1602 disasm_info
.octets_per_byte
= opb
;
1604 if (bfd_big_endian (abfd
))
1605 disasm_info
.display_endian
= disasm_info
.endian
= BFD_ENDIAN_BIG
;
1606 else if (bfd_little_endian (abfd
))
1607 disasm_info
.display_endian
= disasm_info
.endian
= BFD_ENDIAN_LITTLE
;
1609 /* ??? Aborting here seems too drastic. We could default to big or little
1611 disasm_info
.endian
= BFD_ENDIAN_UNKNOWN
;
1613 for (section
= abfd
->sections
;
1614 section
!= (asection
*) NULL
;
1615 section
= section
->next
)
1617 bfd_byte
*data
= NULL
;
1618 bfd_size_type datasize
= 0;
1619 arelent
**relbuf
= NULL
;
1620 arelent
**relpp
= NULL
;
1621 arelent
**relppend
= NULL
;
1622 unsigned long stop_offset
;
1623 asymbol
*sym
= NULL
;
1626 if ((section
->flags
& SEC_LOAD
) == 0
1627 || (! disassemble_all
1629 && (section
->flags
& SEC_CODE
) == 0))
1631 if (only
!= (char *) NULL
&& strcmp (only
, section
->name
) != 0)
1634 if ((section
->flags
& SEC_RELOC
) != 0
1635 #ifndef DISASSEMBLER_NEEDS_RELOCS
1642 relsize
= bfd_get_reloc_upper_bound (abfd
, section
);
1644 bfd_fatal (bfd_get_filename (abfd
));
1650 relbuf
= (arelent
**) xmalloc (relsize
);
1651 relcount
= bfd_canonicalize_reloc (abfd
, section
, relbuf
, syms
);
1653 bfd_fatal (bfd_get_filename (abfd
));
1655 /* Sort the relocs by address. */
1656 qsort (relbuf
, relcount
, sizeof (arelent
*), compare_relocs
);
1659 relppend
= relpp
+ relcount
;
1661 /* Skip over the relocs belonging to addresses below the
1663 if (start_address
!= (bfd_vma
) -1)
1665 while (relpp
< relppend
1666 && (*relpp
)->address
< start_address
)
1672 printf (_("Disassembly of section %s:\n"), section
->name
);
1674 datasize
= bfd_get_section_size_before_reloc (section
);
1678 data
= (bfd_byte
*) xmalloc ((size_t) datasize
);
1680 bfd_get_section_contents (abfd
, section
, data
, 0, datasize
);
1683 disasm_info
.buffer
= data
;
1684 disasm_info
.buffer_vma
= section
->vma
;
1685 disasm_info
.buffer_length
= datasize
;
1686 disasm_info
.section
= section
;
1687 if (start_address
== (bfd_vma
) -1
1688 || start_address
< disasm_info
.buffer_vma
)
1691 addr_offset
= start_address
- disasm_info
.buffer_vma
;
1692 if (stop_address
== (bfd_vma
) -1)
1693 stop_offset
= datasize
/ opb
;
1696 if (stop_address
< disasm_info
.buffer_vma
)
1699 stop_offset
= stop_address
- disasm_info
.buffer_vma
;
1700 if (stop_offset
> disasm_info
.buffer_length
/ opb
)
1701 stop_offset
= disasm_info
.buffer_length
/ opb
;
1704 sym
= find_symbol_for_address (abfd
, section
, section
->vma
+ addr_offset
,
1707 while (addr_offset
< stop_offset
)
1710 unsigned long nextstop_offset
;
1713 if (sym
!= NULL
&& bfd_asymbol_value (sym
) <= section
->vma
+ addr_offset
)
1718 (x
< sorted_symcount
1719 && bfd_asymbol_value (sorted_syms
[x
]) <= section
->vma
+ addr_offset
);
1722 disasm_info
.symbols
= & sorted_syms
[place
];
1723 disasm_info
.num_symbols
= x
- place
;
1726 disasm_info
.symbols
= NULL
;
1728 if (! prefix_addresses
)
1731 objdump_print_addr_with_sym (abfd
, section
, sym
,
1732 section
->vma
+ addr_offset
,
1738 if (sym
!= NULL
&& bfd_asymbol_value (sym
) > section
->vma
+ addr_offset
)
1740 else if (sym
== NULL
)
1744 /* Search forward for the next appropriate symbol in
1745 SECTION. Note that all the symbols are sorted
1746 together into one big array, and that some sections
1747 may have overlapping addresses. */
1748 while (place
< sorted_symcount
1749 && (sorted_syms
[place
]->section
!= section
1750 || (bfd_asymbol_value (sorted_syms
[place
])
1751 <= bfd_asymbol_value (sym
))))
1753 if (place
>= sorted_symcount
)
1756 nextsym
= sorted_syms
[place
];
1759 if (sym
!= NULL
&& bfd_asymbol_value (sym
) > section
->vma
+ addr_offset
)
1761 nextstop_offset
= bfd_asymbol_value (sym
) - section
->vma
;
1762 if (nextstop_offset
> stop_offset
)
1763 nextstop_offset
= stop_offset
;
1765 else if (nextsym
== NULL
)
1766 nextstop_offset
= stop_offset
;
1769 nextstop_offset
= bfd_asymbol_value (nextsym
) - section
->vma
;
1770 if (nextstop_offset
> stop_offset
)
1771 nextstop_offset
= stop_offset
;
1774 /* If a symbol is explicitly marked as being an object
1775 rather than a function, just dump the bytes without
1776 disassembling them. */
1779 || bfd_asymbol_value (sym
) > section
->vma
+ addr_offset
1780 || ((sym
->flags
& BSF_OBJECT
) == 0
1781 && (strstr (bfd_asymbol_name (sym
), "gnu_compiled")
1783 && (strstr (bfd_asymbol_name (sym
), "gcc2_compiled")
1785 || (sym
->flags
& BSF_FUNCTION
) != 0)
1790 disassemble_bytes (&disasm_info
, disassemble_fn
, insns
, data
,
1791 addr_offset
, nextstop_offset
, &relpp
, relppend
);
1793 addr_offset
= nextstop_offset
;
1805 /* Define a table of stab values and print-strings. We wish the initializer
1806 could be a direct-mapped table, but instead we build one the first
1809 static void dump_section_stabs
1810 PARAMS ((bfd
*abfd
, char *stabsect_name
, char *strsect_name
));
1812 /* Dump the stabs sections from an object file that has a section that
1813 uses Sun stabs encoding. */
1819 dump_section_stabs (abfd
, ".stab", ".stabstr");
1820 dump_section_stabs (abfd
, ".stab.excl", ".stab.exclstr");
1821 dump_section_stabs (abfd
, ".stab.index", ".stab.indexstr");
1822 dump_section_stabs (abfd
, "$GDB_SYMBOLS$", "$GDB_STRINGS$");
1825 static bfd_byte
*stabs
;
1826 static bfd_size_type stab_size
;
1828 static char *strtab
;
1829 static bfd_size_type stabstr_size
;
1831 /* Read ABFD's stabs section STABSECT_NAME into `stabs'
1832 and string table section STRSECT_NAME into `strtab'.
1833 If the section exists and was read, allocate the space and return TRUE.
1834 Otherwise return FALSE. */
1837 read_section_stabs (abfd
, stabsect_name
, strsect_name
)
1839 const char *stabsect_name
;
1840 const char *strsect_name
;
1842 asection
*stabsect
, *stabstrsect
;
1844 stabsect
= bfd_get_section_by_name (abfd
, stabsect_name
);
1847 printf (_("No %s section present\n\n"), stabsect_name
);
1851 stabstrsect
= bfd_get_section_by_name (abfd
, strsect_name
);
1852 if (0 == stabstrsect
)
1854 non_fatal (_("%s has no %s section"),
1855 bfd_get_filename (abfd
), strsect_name
);
1860 stab_size
= bfd_section_size (abfd
, stabsect
);
1861 stabstr_size
= bfd_section_size (abfd
, stabstrsect
);
1863 stabs
= (bfd_byte
*) xmalloc (stab_size
);
1864 strtab
= (char *) xmalloc (stabstr_size
);
1866 if (! bfd_get_section_contents (abfd
, stabsect
, (PTR
) stabs
, 0, stab_size
))
1868 non_fatal (_("Reading %s section of %s failed: %s"),
1869 stabsect_name
, bfd_get_filename (abfd
),
1870 bfd_errmsg (bfd_get_error ()));
1877 if (! bfd_get_section_contents (abfd
, stabstrsect
, (PTR
) strtab
, 0,
1880 non_fatal (_("Reading %s section of %s failed: %s\n"),
1881 strsect_name
, bfd_get_filename (abfd
),
1882 bfd_errmsg (bfd_get_error ()));
1892 /* Stabs entries use a 12 byte format:
1893 4 byte string table index
1895 1 byte stab other field
1896 2 byte stab desc field
1898 FIXME: This will have to change for a 64 bit object format. */
1900 #define STRDXOFF (0)
1902 #define OTHEROFF (5)
1905 #define STABSIZE (12)
1907 /* Print ABFD's stabs section STABSECT_NAME (in `stabs'),
1908 using string table section STRSECT_NAME (in `strtab'). */
1911 print_section_stabs (abfd
, stabsect_name
, strsect_name
)
1913 const char *stabsect_name
;
1914 const char *strsect_name ATTRIBUTE_UNUSED
;
1917 unsigned file_string_table_offset
= 0, next_file_string_table_offset
= 0;
1918 bfd_byte
*stabp
, *stabs_end
;
1921 stabs_end
= stabp
+ stab_size
;
1923 printf (_("Contents of %s section:\n\n"), stabsect_name
);
1924 printf ("Symnum n_type n_othr n_desc n_value n_strx String\n");
1926 /* Loop through all symbols and print them.
1928 We start the index at -1 because there is a dummy symbol on
1929 the front of stabs-in-{coff,elf} sections that supplies sizes. */
1931 for (i
= -1; stabp
< stabs_end
; stabp
+= STABSIZE
, i
++)
1935 unsigned char type
, other
;
1936 unsigned short desc
;
1939 strx
= bfd_h_get_32 (abfd
, stabp
+ STRDXOFF
);
1940 type
= bfd_h_get_8 (abfd
, stabp
+ TYPEOFF
);
1941 other
= bfd_h_get_8 (abfd
, stabp
+ OTHEROFF
);
1942 desc
= bfd_h_get_16 (abfd
, stabp
+ DESCOFF
);
1943 value
= bfd_h_get_32 (abfd
, stabp
+ VALOFF
);
1945 printf ("\n%-6d ", i
);
1946 /* Either print the stab name, or, if unnamed, print its number
1947 again (makes consistent formatting for tools like awk). */
1948 name
= bfd_get_stab_name (type
);
1950 printf ("%-6s", name
);
1951 else if (type
== N_UNDF
)
1954 printf ("%-6d", type
);
1955 printf (" %-6d %-6d ", other
, desc
);
1956 bfd_printf_vma (abfd
, value
);
1957 printf (" %-6lu", strx
);
1959 /* Symbols with type == 0 (N_UNDF) specify the length of the
1960 string table associated with this file. We use that info
1961 to know how to relocate the *next* file's string table indices. */
1965 file_string_table_offset
= next_file_string_table_offset
;
1966 next_file_string_table_offset
+= value
;
1970 /* Using the (possibly updated) string table offset, print the
1971 string (if any) associated with this symbol. */
1973 if ((strx
+ file_string_table_offset
) < stabstr_size
)
1974 printf (" %s", &strtab
[strx
+ file_string_table_offset
]);
1983 dump_section_stabs (abfd
, stabsect_name
, strsect_name
)
1985 char *stabsect_name
;
1990 /* Check for section names for which stabsect_name is a prefix, to
1991 handle .stab0, etc. */
1992 for (s
= abfd
->sections
;
1998 len
= strlen (stabsect_name
);
2000 /* If the prefix matches, and the files section name ends with a
2001 nul or a digit, then we match. I.e., we want either an exact
2002 match or a section followed by a number. */
2003 if (strncmp (stabsect_name
, s
->name
, len
) == 0
2004 && (s
->name
[len
] == '\000'
2005 || ISDIGIT (s
->name
[len
])))
2007 if (read_section_stabs (abfd
, s
->name
, strsect_name
))
2009 print_section_stabs (abfd
, s
->name
, strsect_name
);
2018 dump_bfd_header (abfd
)
2023 printf (_("architecture: %s, "),
2024 bfd_printable_arch_mach (bfd_get_arch (abfd
),
2025 bfd_get_mach (abfd
)));
2026 printf (_("flags 0x%08x:\n"), abfd
->flags
);
2028 #define PF(x, y) if (abfd->flags & x) {printf("%s%s", comma, y); comma=", ";}
2029 PF (HAS_RELOC
, "HAS_RELOC");
2030 PF (EXEC_P
, "EXEC_P");
2031 PF (HAS_LINENO
, "HAS_LINENO");
2032 PF (HAS_DEBUG
, "HAS_DEBUG");
2033 PF (HAS_SYMS
, "HAS_SYMS");
2034 PF (HAS_LOCALS
, "HAS_LOCALS");
2035 PF (DYNAMIC
, "DYNAMIC");
2036 PF (WP_TEXT
, "WP_TEXT");
2037 PF (D_PAGED
, "D_PAGED");
2038 PF (BFD_IS_RELAXABLE
, "BFD_IS_RELAXABLE");
2039 PF (HAS_LOAD_PAGE
, "HAS_LOAD_PAGE");
2040 printf (_("\nstart address 0x"));
2041 bfd_printf_vma (abfd
, abfd
->start_address
);
2046 dump_bfd_private_header (abfd
)
2049 bfd_print_private_bfd_data (abfd
, stdout
);
2052 /* Dump selected contents of ABFD */
2058 /* If we are adjusting section VMA's, change them all now. Changing
2059 the BFD information is a hack. However, we must do it, or
2060 bfd_find_nearest_line will not do the right thing. */
2061 if (adjust_section_vma
!= 0)
2065 for (s
= abfd
->sections
; s
!= NULL
; s
= s
->next
)
2067 s
->vma
+= adjust_section_vma
;
2068 s
->lma
+= adjust_section_vma
;
2072 printf (_("\n%s: file format %s\n"), bfd_get_filename (abfd
),
2075 print_arelt_descr (stdout
, abfd
, TRUE
);
2076 if (dump_file_header
)
2077 dump_bfd_header (abfd
);
2078 if (dump_private_headers
)
2079 dump_bfd_private_header (abfd
);
2081 if (dump_section_headers
)
2082 dump_headers (abfd
);
2084 if (dump_symtab
|| dump_reloc_info
|| disassemble
|| dump_debugging
)
2085 syms
= slurp_symtab (abfd
);
2086 if (dump_dynamic_symtab
|| dump_dynamic_reloc_info
)
2087 dynsyms
= slurp_dynamic_symtab (abfd
);
2090 dump_symbols (abfd
, FALSE
);
2091 if (dump_dynamic_symtab
)
2092 dump_symbols (abfd
, TRUE
);
2093 if (dump_stab_section_info
)
2095 if (dump_reloc_info
&& ! disassemble
)
2097 if (dump_dynamic_reloc_info
)
2098 dump_dynamic_relocs (abfd
);
2099 if (dump_section_contents
)
2102 disassemble_data (abfd
);
2107 dhandle
= read_debugging_info (abfd
, syms
, symcount
);
2108 if (dhandle
!= NULL
)
2110 if (! print_debugging_info (stdout
, dhandle
))
2112 non_fatal (_("%s: printing debugging information failed"),
2113 bfd_get_filename (abfd
));
2138 if (bfd_check_format_matches (abfd
, bfd_object
, &matching
))
2144 if (bfd_get_error () == bfd_error_file_ambiguously_recognized
)
2146 nonfatal (bfd_get_filename (abfd
));
2147 list_matching_formats (matching
);
2152 if (bfd_get_error () != bfd_error_file_not_recognized
)
2154 nonfatal (bfd_get_filename (abfd
));
2158 if (bfd_check_format_matches (abfd
, bfd_core
, &matching
))
2164 nonfatal (bfd_get_filename (abfd
));
2166 if (bfd_get_error () == bfd_error_file_ambiguously_recognized
)
2168 list_matching_formats (matching
);
2174 display_file (filename
, target
)
2178 bfd
*file
, *arfile
= (bfd
*) NULL
;
2180 file
= bfd_openr (filename
, target
);
2183 nonfatal (filename
);
2187 if (bfd_check_format (file
, bfd_archive
))
2189 bfd
*last_arfile
= NULL
;
2191 printf (_("In archive %s:\n"), bfd_get_filename (file
));
2194 bfd_set_error (bfd_error_no_error
);
2196 arfile
= bfd_openr_next_archived_file (file
, arfile
);
2199 if (bfd_get_error () != bfd_error_no_more_archived_files
)
2200 nonfatal (bfd_get_filename (file
));
2204 display_bfd (arfile
);
2206 if (last_arfile
!= NULL
)
2207 bfd_close (last_arfile
);
2208 last_arfile
= arfile
;
2211 if (last_arfile
!= NULL
)
2212 bfd_close (last_arfile
);
2220 /* Actually display the various requested regions */
2228 bfd_size_type datasize
= 0;
2229 bfd_size_type addr_offset
;
2230 bfd_size_type start_offset
, stop_offset
;
2231 unsigned int opb
= bfd_octets_per_byte (abfd
);
2233 for (section
= abfd
->sections
; section
!= NULL
; section
=
2238 if (only
== (char *) NULL
||
2239 strcmp (only
, section
->name
) == 0)
2241 if (section
->flags
& SEC_HAS_CONTENTS
)
2243 printf (_("Contents of section %s:\n"), section
->name
);
2245 if (bfd_section_size (abfd
, section
) == 0)
2247 data
= (bfd_byte
*) xmalloc ((size_t) bfd_section_size (abfd
, section
));
2248 datasize
= bfd_section_size (abfd
, section
);
2251 bfd_get_section_contents (abfd
, section
, (PTR
) data
, 0, bfd_section_size (abfd
, section
));
2253 if (start_address
== (bfd_vma
) -1
2254 || start_address
< section
->vma
)
2257 start_offset
= start_address
- section
->vma
;
2258 if (stop_address
== (bfd_vma
) -1)
2259 stop_offset
= bfd_section_size (abfd
, section
) / opb
;
2262 if (stop_address
< section
->vma
)
2265 stop_offset
= stop_address
- section
->vma
;
2266 if (stop_offset
> bfd_section_size (abfd
, section
) / opb
)
2267 stop_offset
= bfd_section_size (abfd
, section
) / opb
;
2269 for (addr_offset
= start_offset
;
2270 addr_offset
< stop_offset
; addr_offset
+= onaline
/ opb
)
2274 printf (" %04lx ", (unsigned long int)
2275 (addr_offset
+ section
->vma
));
2276 for (j
= addr_offset
* opb
;
2277 j
< addr_offset
* opb
+ onaline
; j
++)
2279 if (j
< stop_offset
* opb
)
2280 printf ("%02x", (unsigned) (data
[j
]));
2288 for (j
= addr_offset
* opb
;
2289 j
< addr_offset
* opb
+ onaline
; j
++)
2291 if (j
>= stop_offset
* opb
)
2294 printf ("%c", ISPRINT (data
[j
]) ? data
[j
] : '.');
2304 /* Should perhaps share code and display with nm? */
2306 dump_symbols (abfd
, dynamic
)
2307 bfd
*abfd ATTRIBUTE_UNUSED
;
2308 bfd_boolean dynamic
;
2318 printf ("DYNAMIC SYMBOL TABLE:\n");
2324 printf ("SYMBOL TABLE:\n");
2328 printf (_("no symbols\n"));
2330 for (count
= 0; count
< max
; count
++)
2334 bfd
*cur_bfd
= bfd_asymbol_bfd (*current
);
2336 if (cur_bfd
!= NULL
)
2341 name
= (*current
)->name
;
2343 if (do_demangle
&& name
!= NULL
&& *name
!= '\0')
2345 /* If we want to demangle the name, we demangle it
2346 here, and temporarily clobber it while calling
2347 bfd_print_symbol. FIXME: This is a gross hack. */
2349 alloc
= demangle (cur_bfd
, name
);
2350 (*current
)->name
= alloc
;
2353 bfd_print_symbol (cur_bfd
, stdout
, *current
,
2354 bfd_print_symbol_all
);
2356 (*current
)->name
= name
;
2377 for (a
= abfd
->sections
; a
!= (asection
*) NULL
; a
= a
->next
)
2381 if (bfd_is_abs_section (a
))
2383 if (bfd_is_und_section (a
))
2385 if (bfd_is_com_section (a
))
2390 if (strcmp (only
, a
->name
))
2393 else if ((a
->flags
& SEC_RELOC
) == 0)
2396 relsize
= bfd_get_reloc_upper_bound (abfd
, a
);
2398 bfd_fatal (bfd_get_filename (abfd
));
2400 printf ("RELOCATION RECORDS FOR [%s]:", a
->name
);
2404 printf (" (none)\n\n");
2408 relpp
= (arelent
**) xmalloc (relsize
);
2409 relcount
= bfd_canonicalize_reloc (abfd
, a
, relpp
, syms
);
2411 bfd_fatal (bfd_get_filename (abfd
));
2412 else if (relcount
== 0)
2414 printf (" (none)\n\n");
2419 dump_reloc_set (abfd
, a
, relpp
, relcount
);
2428 dump_dynamic_relocs (abfd
)
2435 relsize
= bfd_get_dynamic_reloc_upper_bound (abfd
);
2437 bfd_fatal (bfd_get_filename (abfd
));
2439 printf ("DYNAMIC RELOCATION RECORDS");
2443 printf (" (none)\n\n");
2447 relpp
= (arelent
**) xmalloc (relsize
);
2448 relcount
= bfd_canonicalize_dynamic_reloc (abfd
, relpp
, dynsyms
);
2450 bfd_fatal (bfd_get_filename (abfd
));
2451 else if (relcount
== 0)
2453 printf (" (none)\n\n");
2458 dump_reloc_set (abfd
, (asection
*) NULL
, relpp
, relcount
);
2466 dump_reloc_set (abfd
, sec
, relpp
, relcount
)
2473 char *last_filename
, *last_functionname
;
2474 unsigned int last_line
;
2476 /* Get column headers lined up reasonably. */
2482 bfd_sprintf_vma (abfd
, buf
, (bfd_vma
) -1);
2483 width
= strlen (buf
) - 7;
2485 printf ("OFFSET %*s TYPE %*s VALUE \n", width
, "", 12, "");
2488 last_filename
= NULL
;
2489 last_functionname
= NULL
;
2492 for (p
= relpp
; relcount
&& *p
!= (arelent
*) NULL
; p
++, relcount
--)
2495 const char *filename
, *functionname
;
2497 const char *sym_name
;
2498 const char *section_name
;
2500 if (start_address
!= (bfd_vma
) -1
2501 && q
->address
< start_address
)
2503 if (stop_address
!= (bfd_vma
) -1
2504 && q
->address
> stop_address
)
2507 if (with_line_numbers
2509 && bfd_find_nearest_line (abfd
, sec
, syms
, q
->address
,
2510 &filename
, &functionname
, &line
))
2512 if (functionname
!= NULL
2513 && (last_functionname
== NULL
2514 || strcmp (functionname
, last_functionname
) != 0))
2516 printf ("%s():\n", functionname
);
2517 if (last_functionname
!= NULL
)
2518 free (last_functionname
);
2519 last_functionname
= xstrdup (functionname
);
2522 && (line
!= last_line
2523 || (filename
!= NULL
2524 && last_filename
!= NULL
2525 && strcmp (filename
, last_filename
) != 0)))
2527 printf ("%s:%u\n", filename
== NULL
? "???" : filename
, line
);
2529 if (last_filename
!= NULL
)
2530 free (last_filename
);
2531 if (filename
== NULL
)
2532 last_filename
= NULL
;
2534 last_filename
= xstrdup (filename
);
2538 if (q
->sym_ptr_ptr
&& *q
->sym_ptr_ptr
)
2540 sym_name
= (*(q
->sym_ptr_ptr
))->name
;
2541 section_name
= (*(q
->sym_ptr_ptr
))->section
->name
;
2546 section_name
= NULL
;
2550 bfd_printf_vma (abfd
, q
->address
);
2552 printf (" %-16s ", q
->howto
->name
);
2554 printf (" %-16d ", q
->howto
->type
);
2555 objdump_print_symname (abfd
, (struct disassemble_info
*) NULL
,
2560 if (section_name
== (const char *) NULL
)
2561 section_name
= "*unknown*";
2562 bfd_printf_vma (abfd
, q
->address
);
2563 printf (" %-16s [%s]",
2570 bfd_printf_vma (abfd
, q
->addend
);
2576 /* The length of the longest architecture name + 1. */
2577 #define LONGEST_ARCH sizeof("powerpc:common")
2580 endian_string (endian
)
2581 enum bfd_endian endian
;
2583 if (endian
== BFD_ENDIAN_BIG
)
2584 return "big endian";
2585 else if (endian
== BFD_ENDIAN_LITTLE
)
2586 return "little endian";
2588 return "endianness unknown";
2591 /* List the targets that BFD is configured to support, each followed
2592 by its endianness and the architectures it supports. */
2595 display_target_list ()
2597 extern const bfd_target
*const *bfd_target_vector
;
2601 dummy_name
= make_temp_file (NULL
);
2602 for (t
= 0; bfd_target_vector
[t
]; t
++)
2604 const bfd_target
*p
= bfd_target_vector
[t
];
2605 bfd
*abfd
= bfd_openw (dummy_name
, p
->name
);
2608 printf ("%s\n (header %s, data %s)\n", p
->name
,
2609 endian_string (p
->header_byteorder
),
2610 endian_string (p
->byteorder
));
2614 nonfatal (dummy_name
);
2618 if (! bfd_set_format (abfd
, bfd_object
))
2620 if (bfd_get_error () != bfd_error_invalid_operation
)
2622 bfd_close_all_done (abfd
);
2626 for (a
= (int) bfd_arch_obscure
+ 1; a
< (int) bfd_arch_last
; a
++)
2627 if (bfd_set_arch_mach (abfd
, (enum bfd_architecture
) a
, 0))
2629 bfd_printable_arch_mach ((enum bfd_architecture
) a
, 0));
2630 bfd_close_all_done (abfd
);
2632 unlink (dummy_name
);
2636 /* Print a table showing which architectures are supported for entries
2637 FIRST through LAST-1 of bfd_target_vector (targets across,
2638 architectures down). */
2641 display_info_table (first
, last
)
2645 extern const bfd_target
*const *bfd_target_vector
;
2649 /* Print heading of target names. */
2650 printf ("\n%*s", (int) LONGEST_ARCH
, " ");
2651 for (t
= first
; t
< last
&& bfd_target_vector
[t
]; t
++)
2652 printf ("%s ", bfd_target_vector
[t
]->name
);
2655 dummy_name
= make_temp_file (NULL
);
2656 for (a
= (int) bfd_arch_obscure
+ 1; a
< (int) bfd_arch_last
; a
++)
2657 if (strcmp (bfd_printable_arch_mach (a
, 0), "UNKNOWN!") != 0)
2659 printf ("%*s ", (int) LONGEST_ARCH
- 1,
2660 bfd_printable_arch_mach (a
, 0));
2661 for (t
= first
; t
< last
&& bfd_target_vector
[t
]; t
++)
2663 const bfd_target
*p
= bfd_target_vector
[t
];
2664 bfd_boolean ok
= TRUE
;
2665 bfd
*abfd
= bfd_openw (dummy_name
, p
->name
);
2675 if (! bfd_set_format (abfd
, bfd_object
))
2677 if (bfd_get_error () != bfd_error_invalid_operation
)
2685 if (! bfd_set_arch_mach (abfd
, a
, 0))
2690 printf ("%s ", p
->name
);
2693 int l
= strlen (p
->name
);
2699 bfd_close_all_done (abfd
);
2703 unlink (dummy_name
);
2707 /* Print tables of all the target-architecture combinations that
2708 BFD has been configured to support. */
2711 display_target_tables ()
2714 extern const bfd_target
*const *bfd_target_vector
;
2718 colum
= getenv ("COLUMNS");
2720 columns
= atoi (colum
);
2725 while (bfd_target_vector
[t
] != NULL
)
2729 wid
= LONGEST_ARCH
+ strlen (bfd_target_vector
[t
]->name
) + 1;
2731 while (wid
< columns
&& bfd_target_vector
[t
] != NULL
)
2735 newwid
= wid
+ strlen (bfd_target_vector
[t
]->name
) + 1;
2736 if (newwid
>= columns
)
2741 display_info_table (oldt
, t
);
2748 printf (_("BFD header file version %s\n"), BFD_VERSION_STRING
);
2749 display_target_list ();
2750 display_target_tables ();
2753 int main
PARAMS ((int, char **));
2761 char *target
= default_target
;
2762 bfd_boolean seenflag
= FALSE
;
2764 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
2765 setlocale (LC_MESSAGES
, "");
2767 #if defined (HAVE_SETLOCALE)
2768 setlocale (LC_CTYPE
, "");
2770 bindtextdomain (PACKAGE
, LOCALEDIR
);
2771 textdomain (PACKAGE
);
2773 program_name
= *argv
;
2774 xmalloc_set_program_name (program_name
);
2776 START_PROGRESS (program_name
, 0);
2779 set_default_bfd_target ();
2781 while ((c
= getopt_long (argc
, argv
, "pib:m:M:VvCdDlfaHhrRtTxsSj:wE:zgG",
2782 long_options
, (int *) 0))
2788 break; /* We've been given a long option. */
2793 disassembler_options
= optarg
;
2799 with_line_numbers
= TRUE
;
2808 enum demangling_styles style
;
2810 style
= cplus_demangle_name_to_style (optarg
);
2811 if (style
== unknown_demangling
)
2812 fatal (_("unknown demangling style `%s'"),
2815 cplus_demangle_set_style (style
);
2821 case OPTION_ADJUST_VMA
:
2822 adjust_section_vma
= parse_vma (optarg
, "--adjust-vma");
2824 case OPTION_START_ADDRESS
:
2825 start_address
= parse_vma (optarg
, "--start-address");
2827 case OPTION_STOP_ADDRESS
:
2828 stop_address
= parse_vma (optarg
, "--stop-address");
2831 if (strcmp (optarg
, "B") == 0)
2832 endian
= BFD_ENDIAN_BIG
;
2833 else if (strcmp (optarg
, "L") == 0)
2834 endian
= BFD_ENDIAN_LITTLE
;
2837 non_fatal (_("unrecognized -E option"));
2842 if (strncmp (optarg
, "big", strlen (optarg
)) == 0)
2843 endian
= BFD_ENDIAN_BIG
;
2844 else if (strncmp (optarg
, "little", strlen (optarg
)) == 0)
2845 endian
= BFD_ENDIAN_LITTLE
;
2848 non_fatal (_("unrecognized --endian type `%s'"), optarg
);
2854 dump_file_header
= TRUE
;
2858 formats_info
= TRUE
;
2862 dump_private_headers
= TRUE
;
2866 dump_private_headers
= TRUE
;
2868 dump_reloc_info
= TRUE
;
2869 dump_file_header
= TRUE
;
2870 dump_ar_hdrs
= TRUE
;
2871 dump_section_headers
= TRUE
;
2879 dump_dynamic_symtab
= TRUE
;
2887 disassemble_zeroes
= TRUE
;
2891 disassemble_all
= TRUE
;
2896 with_source_code
= TRUE
;
2904 dump_stab_section_info
= TRUE
;
2908 dump_section_contents
= TRUE
;
2912 dump_reloc_info
= TRUE
;
2916 dump_dynamic_reloc_info
= TRUE
;
2920 dump_ar_hdrs
= TRUE
;
2924 dump_section_headers
= TRUE
;
2932 show_version
= TRUE
;
2942 print_version ("objdump");
2952 display_file ("a.out", target
);
2954 for (; optind
< argc
;)
2955 display_file (argv
[optind
++], target
);
2958 END_PROGRESS (program_name
);