1 /* objdump -- dump information about an object file.
2 Copyright (C) 1988, 1991 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 1, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
23 * dump information about an object file. Until there is other documentation,
24 * refer to the manual page dump(1) in the system 5 program's reference manual
33 /* #define COFF_ENCAPSULATE 1 */
35 typedef FILHDR fileheader;
36 typedef struct exec fileheader;
39 static char *sym_pname(SYMENT *s);
40 static char *xmalloc(unsigned size);
41 static char *xrealloc(char *p, unsigned size);
42 static void doit(char *filename);
43 static void dump_data(fileheader *execp, FILE *f){};
44 static void dump_header(fileheader *execp, FILE *f);
45 static void dump_lnno(fileheader *execp, FILE *f);
46 static void dump_nstuff(fileheader *execp){};
47 static void dump_reloc(fileheader *execp, FILE *f);
48 static void dump_section_contents(fileheader *execp, FILE *f);
49 static void dump_section_headers(fileheader *execp, FILE *f);
50 static void dump_sym(fileheader *execp, FILE *f);
51 static void dump_text(fileheader *execp, FILE *f){};
52 static void hex_dump(void *buffer, int size);
57 static void read_symbols (execp, f)
59 read_symbols (execp, f)
63 static void read_section_headers(execp, f)
73 nsyms = execp->a_syms / sizeof (struct nlist);
76 if (section_headers || execp->f_nscns == 0) {
80 } /* already read them, or don't need to */
84 symtbl = (struct nlist *)xmalloc (nsyms * sizeof (struct nlist));
86 fseek(f, sizeof(*execp) + execp->f_opthdr, 0);
87 section_headers = (struct scnhdr *) xmalloc(execp->f_nscns * sizeof(*section_headers));
92 fseek(f, N_STROFF(*execp), 0);
93 if (fread((char *)&strsize, sizeof strsize, 1, f) != 1) {
94 fprintf(stderr, "%s: can not read string table size\n",
96 fseek (f, N_STROFF(*execp), 0);
97 if (fread ((char *)&strsize, sizeof strsize, 1, f) != 1) {
98 fprintf (stderr, "%s: can not read string table size\n",
103 strtbl = xmalloc (strsize);
105 fseek(f, N_STROFF (*execp), 0);
106 if (fread(strtbl, 1, strsize, f) != strsize) {
107 fprintf(stderr, "%s: error reading string table\n",
109 fseek (f, N_STROFF (*execp), 0);
110 if (fread (strtbl, 1, strsize, f) != strsize) {
111 fprintf (stderr, "%s: error reading string table\n",
112 #endif /* OBJ_BOUT */
117 if (fread(section_headers, execp->f_nscns * sizeof(*section_headers), 1, f) != 1) {
118 perror("error reading section headers");
121 #endif /* OBJ_COFF */
125 fseek(f, N_SYMOFF (*execp), 0);
126 if (fread((char *)symtbl, sizeof (struct nlist), nsyms, f) != nsyms) {
127 fprintf(stderr, "%s: error reading symbol table\n",
129 fseek (f, N_SYMOFF (*execp), 0);
130 if (fread ((char *)symtbl, sizeof (struct nlist), nsyms, f) != nsyms) {
131 fprintf (stderr, "%s: error reading symbol table\n",
132 #endif /* OBJ_BOUT */
138 } /* read_section_headers() */
139 #endif /* OBJ_COFF */
142 for (i = 0, sp = symtbl; i < nsyms; i++, sp++) {
143 if (sp->n_un.n_strx == 0)
144 sp->n_un.n_name = "";
145 else if (sp->n_un.n_strx < 0 || sp->n_un.n_strx > strsize)
146 sp->n_un.n_name = "<bad string table index>";
148 sp->n_un.n_name = strtbl + sp->n_un.n_strx;
151 } /* read_symbols() */
154 #endif /* OBJ_BOUT */
156 static SYMENT *symbols = NULL;
157 static int longest_symbol_name = SYMNMLEN;
158 #endif /* OBJ_COFF */
162 static void free_symbols ()
165 #endif /* OBJ_BOUT */
167 static void read_symbols(execp, f)
170 #endif /* OBJ_COFF */
174 int bufsiz = execp->f_nsyms * sizeof(struct syment);
177 if (symbols || bufsiz == 0) {
179 } /* already read, or don't need to */
181 symbols = (SYMENT *) xmalloc(bufsiz);
184 fseek(f, execp->f_symptr, 0);
185 if (fread(symbols, bufsiz, 1, f) != 1) {
186 fprintf(stderr, "error reading symbol table.\n");
191 fseek(f, 0, 2); /* find end of file */
193 if (here != ftell(f)) {
194 /* find string table size */
196 if (fread(&strsize, sizeof(strsize), 1, f) != 1) {
197 perror("error reading string table size");
201 /* read string table if there is one */
203 strtbl = xmalloc(strsize);
204 fseek(f, -sizeof(strsize), 1); /* backup over size count */
206 if (fread(strtbl, strsize, 1, f) != 1) {
207 perror("error reading string table");
211 /* then connect the dots. */
212 for (s = symbols; s < symbols + execp->f_nsyms; ++s) {
216 s->n_offset = (long) strtbl + s->n_offset;
217 l = strlen((char *) s->n_offset);
218 if (l > longest_symbol_name) {
219 longest_symbol_name = l;
223 s += s->n_numaux; /* skip aux entries */
224 } /* walk the symbol table */
226 fprintf(stderr, "Well, now that's weird. I have a string table whose size is zero?\n");
227 } /* if there is a string table */
228 } /* if there is a string table */
230 } /* read_symbols() */
233 static void free_symbols() {
234 #endif /* OBJ_COFF */
243 #endif /* OBJ_COFF */
244 } /* free_symbols() */
248 #endif /* OBJ_BOUT */
251 #endif /* OBJ_COFF */
259 #endif /* OBJ_BOUT */
263 static void usage() {
264 #endif /* OBJ_COFF */
265 (void) fprintf(stderr, "Usage: %s\n", program_name);
266 (void) fprintf(stderr, "\t[-ahnrt] [+all] [+header] [+nstuff]\n");
267 (void) fprintf(stderr, "\t[+reloc] [+symbols] [+text] [+data]\n");
268 (void) fprintf(stderr, "\t[+omit-symbol-numbers] [+omit-reloc-numbers]\n");
269 (void) fprintf(stderr, "\tfile...\n");
273 Usage: %s [-hnrt] [+header] [+nstuff] [+reloc] [+symbols] file...\n",
275 #endif /* OBJ_BOUT */
276 #endif /* OBJ_COFF */
282 #endif /* OBJ_COFF */
286 #endif /* OBJ_COFF */
287 static int aflag = 0;
288 static int hflag = 0;
290 static int lflag = 0;
291 #endif /* OBJ_COFF */
292 static int nflag = 0;
293 static int rflag = 0;
295 static int sflag = 0;
296 #endif /* OBJ_COFF */
297 static int tflag = 0;
298 static int Dflag = 0;
299 static int Tflag = 0;
300 static int omit_reloc_numbers_flag = 0;
301 static int omit_sym_numbers_flag = 0;
308 #endif /* OBJ_BOUT */
310 static int section_headers_flag = 0;
311 static int section_contents_flag = 0;
312 #endif /* OBJ_COFF */
314 /* Size of a page. Required by N_DATADDR in a.out.gnu.h [VAX]. */
319 int main (argc, argv)
322 #endif /* OBJ_COFF */
327 #endif /* OBJ_BOUT */
328 #endif /* OBJ_COFF */
334 #endif /* OBJ_COFF */
335 /* extern char *optarg; */
339 #endif /* OBJ_BOUT */
340 #endif /* OBJ_COFF */
346 #endif /* OBJ_COFF */
347 static struct option long_options[] = {
349 {"line-numbers", 0, &lflag, 1},
350 {"section-contents", 0, §ion_contents_flag, 1},
351 {"section-headers", 0, §ion_headers_flag, 1},
352 #endif /* OBJ_COFF */
353 {"symbols", 0, &tflag, 1},
354 {"reloc", 0, &rflag, 1},
355 {"nstuff", 0, &nflag, 1},
356 {"header", 0, &hflag, 1},
357 {"data", 0, &Dflag, 1},
358 {"text", 0, &Tflag, 1},
359 {"omit-relocation-numbers", 0, &omit_reloc_numbers_flag, 1},
360 {"omit-symbol-numbers", 0, &omit_sym_numbers_flag, 1},
361 {"all", 0, &aflag, 1},
366 static struct option long_options[] =
368 {"symbols", 0, &tflag, 1},
369 {"reloc", 0, &rflag, 1},
370 {"nstuff", 0, &nflag, 1},
371 {"header", 0, &hflag, 1},
374 #endif /* OBJ_BOUT */
375 #endif /* OBJ_COFF */
378 page_size = getpagesize ();
380 #endif /* OBJ_COFF */
381 program_name = argv[0];
385 while ((c = getopt_long (argc, argv, "ahnrt", long_options, &ind)) != EOF) {
387 while ((c = getopt_long (argc, argv, "hnrt", long_options, &ind))
389 #endif /* OBJ_BOUT */
391 while ((c = getopt_long (argc, argv, "ahlonrt", long_options, &ind)) != EOF) {
392 #endif /* OBJ_COFF */
396 #endif /* OBJ_COFF */
399 #endif /* OBJ_BOUT */
400 #endif /* OBJ_COFF */
402 case 0 : break; /* we've been given a long option */
405 #endif /* OBJ_COFF */
406 case 'a': aflag = 1; break;
407 case 'h': hflag = 1; break;
409 case 'o': hflag = 1; break;
410 case 'l': lflag = 1; break;
411 #endif /* OBJ_COFF */
412 case 'n': nflag = 1; break;
413 case 'r': rflag = 1; break;
415 #endif /* OBJ_BOUT */
416 #endif /* OBJ_COFF */
417 case 't': tflag = 1; break;
420 case 'r': rflag = 1; break;
421 case 'n': nflag = 1; break;
422 case 'h': hflag = 1; break;
423 #endif /* OBJ_BOUT */
424 #endif /* OBJ_COFF */
429 #endif /* OBJ_COFF */
430 } /* switch on option */
431 } /* while there are options */
436 #endif /* OBJ_BOUT */
437 #endif /* OBJ_COFF */
439 if (seenflag == 0 || optind == argc)
444 #endif /* OBJ_COFF */
449 #endif /* OBJ_COFF */
456 section_headers_flag = 1;
457 section_contents_flag = 1;
458 #endif /* OBJ_COFF */
462 #endif /* OBJ_BOUT */
463 #endif /* OBJ_COFF */
464 while (optind < argc)
466 doit (argv[optind++]);
469 doit(argv[optind++]);
470 #endif /* OBJ_COFF */
477 #endif /* OBJ_BOUT */
478 #endif /* OBJ_COFF */
482 static void doit (name)
485 #endif /* OBJ_BOUT */
487 static void doit(name)
488 #endif /* OBJ_COFF */
498 if (section_headers) {
499 free(section_headers);
500 section_headers = NULL;
501 } /* free section headers */
508 #endif /* OBJ_COFF */
509 printf("%s:\n", name);
512 printf ("%s:\n", name);
513 #endif /* OBJ_BOUT */
514 #endif /* OBJ_COFF */
515 f = fopen (name, "r");
519 #endif /* OBJ_COFF */
520 fprintf(stderr, "%s: can not open ", program_name);
523 fprintf (stderr, "%s: can not open ", program_name);
524 #endif /* OBJ_BOUT */
525 #endif /* OBJ_COFF */
534 if (fread((char *)&exec, sizeof exec, 1, f) != 1) {
536 if (fread((char *)&exec, sizeof(exec), 1, f) != 1) {
537 #endif /* OBJ_COFF */
538 fprintf(stderr, "%s: can not read header for %s\n",
541 if (fread ((char *)&exec, sizeof exec, 1, f) != 1) {
542 fprintf (stderr, "%s: can not read header for %s\n",
543 #endif /* OBJ_BOUT */
544 #endif /* OBJ_COFF */
551 #define N_BADMAG I960BADMAG
552 #endif /* I960ROMAGIC */
554 #endif /* OBJ_COFF */
555 if (N_BADMAG (exec)) {
558 #endif /* OBJ_COFF */
559 fprintf(stderr, "%s: %s is not a%s object file\n",
569 fprintf (stderr, "%s: %s is not an object file\n",
571 #endif /* OBJ_BOUT */
572 #endif /* OBJ_COFF */
578 #endif /* OBJ_COFF */
579 if (hflag) dump_header(&exec, f);
581 if (lflag) dump_lnno(&exec, f);
582 #endif /* OBJ_COFF */
583 if (nflag) dump_nstuff(&exec);
585 if (section_headers_flag) dump_section_headers(&exec, f);
586 if (section_contents_flag) dump_section_contents(&exec, f);
587 if (sflag) dump_section_contents(&exec, f);
588 #endif /* OBJ_COFF */
589 if (Tflag) dump_text(&exec, f);
590 if (Dflag) dump_data(&exec, f);
591 if (tflag) dump_sym(&exec, f);
592 if (rflag) dump_reloc(&exec, f);
597 #endif /* OBJ_COFF */
602 #endif /* OBJ_BOUT */
608 #endif /* OBJ_COFF */
616 #endif /* OBJ_BOUT */
618 static void dump_lnno(execp, f)
622 int i = execp->f_nscns;
623 struct scnhdr *section;
628 printf("Line numbers:\n");
629 read_section_headers(execp, f);
630 read_symbols(execp, f);
632 for (section = section_headers; i; ++section, --i) {
633 int size = section->s_nlnno * LINESZ;
638 buffer = xrealloc(buffer, bufsiz = size);
640 buffer = xmalloc(bufsiz = size);
641 } /* if we had allocated anything before */
642 } /* if bigger than our old buffer */
644 printf("%8.8s:", section->s_name);
645 fseek(f, section->s_lnnoptr, 0);
650 if (fread(buffer, size, 1, f) != 1) {
651 printf(" (error reading lnno)\n");
653 } /* on read error */
657 for (r = (LINENO *) buffer, j = 0; j < section->s_nlnno; ++j, ++r) {
658 printf("lnno = %d,", r->l_lnno);
661 printf(" paddr = 0x%lx", (unsigned long) r->l_addr.l_paddr);
663 printf(" symndx = %ld, \"%s\"",
665 sym_pname(symbols + r->l_addr.l_symndx));
666 } /* if not symbol'd */
668 if (r->padding[0] || r->padding[1]) {
669 printf(" (padding = %2x %2x)",
670 (unsigned) r->padding[0],
671 (unsigned) r->padding[1]);
672 } /* if padding not zero'd */
673 #endif /* OBJ_COFF */
679 } /* for each lnno record */
681 printf(" (section has no line numbers.)\n");
682 } /* if there really is something in the section */
683 } /* for each section */
685 printf("No Sections.\n");
686 } /* if there are sections */
690 #endif /* OBJ_COFF */
696 dump_reloc (&exec, f);
697 #endif /* OBJ_BOUT */
700 #endif /* OBJ_COFF */
704 static void dump_header(execp, f)
708 static void dump_reloc(execp, f)
712 int i = execp->f_nscns;
713 struct scnhdr *section;
718 read_section_headers(execp, f);
720 printf("Relocations:\n");
721 for (section = section_headers; i; ++section, --i) {
722 int size = section->s_nreloc * RELSZ;
727 buffer = xrealloc(buffer, bufsiz = size);
729 buffer = xmalloc(bufsiz = size);
730 } /* if we had allocated anything before */
731 } /* if bigger than our old buffer */
733 printf("%8.8s:", section->s_name);
734 fseek(f, section->s_relptr, 0);
739 if (fread(buffer, size, 1, f) != 1) {
740 printf(" (error reading reloc)\n");
742 } /* on read error */
746 for (r = (RELOC *) buffer, j = 0; j < section->s_nreloc; ++j, ++r) {
747 printf("vaddr = 0x%lx, symndx = %ld, r_type = ",
748 (unsigned long) r->r_vaddr,
752 case R_RELLONG: printf(" RELLONG"); break;
753 case R_IPRSHORT: printf("IPRSHORT"); break;
754 case R_IPRMED: printf(" IPRMED"); break;
755 case R_IPRLONG: printf(" IPRLONG"); break;
756 case R_OPTCALL: printf(" OPTCALL"); break;
757 case R_OPTCALLX: printf("OPTCALLX"); break;
758 case R_GETSEG: printf(" GETSEG"); break;
759 case R_GETPA: printf(" GETPA"); break;
760 case R_TAGWORD: printf(" TAGWORD"); break;
761 default: printf("unrecognized"); break;
762 } /* switch on reloc type */
766 if (r->pad[0] || r->pad[1]) {
767 printf(" (padding = %2x %2x)",
768 (unsigned) r->pad[0],
769 (unsigned) r->pad[1]);
770 } /* if padding isn't zero */
773 } /* for each reloc record */
775 printf(" (section has no relocations.)\n");
776 } /* if there really is something in the section */
777 } /* for each section */
779 printf("No Sections.\n");
780 } /* if there are sections */
787 static void dump_section_contents(execp, f)
791 int i = execp->f_nscns;
792 struct scnhdr *section;
797 read_section_headers(execp, f);
798 printf("Section Contents:\n");
800 for (section = section_headers; i; ++section, --i) {
801 if (section->s_size > bufsiz) {
803 buffer = xrealloc(buffer, bufsiz = section->s_size);
805 buffer = xmalloc(bufsiz = section->s_size);
806 } /* if we had allocated anything before */
807 } /* if bigger than our old buffer */
809 printf("%8.8s:", section->s_name);
811 if (section->s_flags & STYP_BSS) {
812 printf(" bss sections have no contents.\n");
814 fseek(f, section->s_scnptr, 0);
816 if (section->s_size) {
817 if (fread(buffer, section->s_size, 1, f) != 1) {
818 printf(" (error reading section contents)\n");
819 } /* on read error */
822 hex_dump(buffer, section->s_size);
825 printf(" (section has a size of zero.)\n");
826 } /* if there really is a section */
827 } /* if bss else dump */
828 } /* for each section */
830 printf("No Sections.\n");
831 } /* if there are sections */
836 } /* dump_section_contents() */
838 static void dump_section_headers(execp, f)
842 int i = execp->f_nscns;
843 struct scnhdr *section;
846 read_section_headers(execp, f);
847 printf("Section Headers:\n");
849 for (section = section_headers; i; ++section, --i) {
850 long flags = section->s_flags;
852 printf("\"%8.8s\"", section->s_name);
854 printf(" physical address: 0x%x vma: 0x%x size: 0x%x (%ld)",
855 (unsigned) section->s_paddr,
856 (unsigned) section->s_vaddr,
857 (unsigned) section->s_size,
860 printf(" relocs: %d linenos: %d alignment: 0x%lx (%ld)",
864 (long) section->s_align);
866 printf(" flags: 0x%x = ", (unsigned) section->s_flags);
868 if (flags & STYP_REG) {
873 if (flags & STYP_DSECT) {
875 flags &= ~STYP_DSECT;
878 if (flags & STYP_NOLOAD) {
880 flags &= ~STYP_NOLOAD;
883 if (flags & STYP_GROUP) {
885 flags &= ~STYP_GROUP;
888 if (flags & STYP_PAD) {
893 if (flags & STYP_COPY) {
898 if (flags & STYP_TEXT) {
903 if (flags & S_SHRSEG) {
908 if (flags & STYP_DATA) {
913 if (flags & STYP_BSS) {
918 if (flags & S_NEWFCN) {
923 if (flags & STYP_INFO) {
928 if (flags & STYP_OVER) {
933 if (flags & STYP_LIB) {
938 if (flags & STYP_MERGE) {
940 flags &= ~STYP_MERGE;
943 if (flags & STYP_REVERSE_PAD) {
944 printf(" REVERSE_PAD");
945 flags &= ~STYP_REVERSE_PAD;
946 } /* STYP_REVERSE_PAD */
953 } /* for each section header */
955 printf("No section headers.\n");
956 } /* if there are any sections */
957 #endif /* OBJ_COFF */
964 } /* dump_section_headers() */
965 #endif /* OBJ_COFF */
969 #endif /* OBJ_BOUT */
973 static void dump_header(execp, f)
975 #endif /* OBJ_COFF */
978 #endif /* OBJ_BOUT */
979 #endif /* OBJ_COFF */
983 printf("magic: 0x%x (%o) ", (unsigned) execp->f_magic, (unsigned) execp->f_magic);
984 printf("number of sections: %d number of syms: %ld ", execp->f_nscns, execp->f_nsyms);
985 printf("time stamp: %s", ctime(&(execp->f_timdat)));
988 if (execp->f_flags & F_RELFLG) {
992 if (execp->f_flags & F_EXEC) {
996 if (execp->f_flags & F_LNNO) {
1000 if (execp->f_flags & F_LSYMS) {
1004 if (execp->f_flags & F_AR32WR) {
1008 assert(F_I960KB == F_I960SB);
1009 assert(F_I960KA == F_I960SA);
1011 switch (execp->f_flags & F_I960TYPE) {
1012 case F_I960CORE: printf(" I960CORE"); break;
1013 case F_I960KB: printf(" I960KB (== I960SB)"); break;
1014 case F_I960MC: printf(" I960MC"); break;
1015 case F_I960XA: printf(" I960XA"); break;
1016 case F_I960CA: printf(" I960CA"); break;
1017 case F_I960KA: printf(" I960KA (== I960SA)"); break;
1018 default: printf(" I960Unknown"); break;
1019 } /* switch on i960 type */
1021 if (execp->f_flags & ~(F_RELFLG | F_EXEC | F_LNNO | F_LSYMS | F_AR32WR | F_I960TYPE)) {
1022 printf(" +unrecognized");
1023 } /* unrecognized */
1027 if (execp->f_opthdr) {
1028 if (execp->f_opthdr == sizeof(AOUTHDR)) {
1031 fseek(f, sizeof(*execp), 0);
1032 if (fread(&hdr, sizeof(AOUTHDR), 1, f) == 1) {
1033 printf("aouthdr:\n");
1034 printf("magic: 0x%x (%o)", (unsigned) hdr.magic, (unsigned) hdr.magic);
1035 printf(" vstamp: 0x%ld\n", (long) hdr.vstamp);
1037 printf("sizes: text 0x%lx (%ld), data 0x%lx (%ld), bss 0x%lx (%ld)\n",
1045 printf("entry point: 0x%lx, starts: text 0x%lx (%ld), data 0x%lx (%ld)\n",
1048 (long) hdr.text_start,
1050 (long) hdr.data_start);
1052 printf("tag entries: %ld\n",
1053 (long) hdr.tagentries);
1055 fprintf(stderr, "%s: error reading optional header", program_name);
1060 printf("opthder != sizeof aouthdr?");
1061 } /* size mismatch */
1064 printf("No optional header.");
1065 } /* print optional header */
1069 #endif /* OBJ_COFF */
1072 #if defined (__GNU_EXEC_MACROS__) && !defined (__STRUCT_EXEC_OVERRIDE__)
1075 #endif /* OBJ_COFF */
1076 printf("magic: 0x%x (%o)", N_MAGIC(*execp), N_MAGIC(*execp));
1077 printf("machine type: %d", N_MACHTYPE(*execp));
1078 printf("flags: 0x%x", N_FLAGS(*execp));
1081 printf ("magic: 0x%x (%o)", N_MAGIC(*execp), N_MAGIC(*execp));
1082 printf ("machine type: %d", N_MACHTYPE(*execp));
1083 printf ("flags: 0x%x", N_FLAGS(*execp));
1084 #endif /* OBJ_BOUT */
1085 #endif /* OBJ_COFF */
1086 #else /* non-gnu struct exec. */
1089 #endif /* OBJ_COFF */
1090 printf("magic: 0x%x (%o) ", (unsigned) execp->a_magic, (unsigned) execp->a_magic);
1093 printf ("magic: 0x%x (%o) ", execp->a_magic, execp->a_magic);
1094 #endif /* OBJ_BOUT */
1095 #endif /* OBJ_COFF */
1096 #endif /* non-gnu struct exec. */
1099 #endif /* OBJ_COFF */
1100 printf("text 0x%x ", (unsigned) execp->a_text);
1101 printf("data 0x%x ", (unsigned) execp->a_data);
1102 printf("bss 0x%x\n", (unsigned) execp->a_bss);
1103 printf("nsyms %ld", (long) (execp->a_syms / sizeof(struct nlist)));
1104 x = execp->a_syms % sizeof(struct nlist);
1107 printf ("text 0x%x ", execp->a_text);
1108 printf ("data 0x%x ", execp->a_data);
1109 printf ("bss 0x%x\n", execp->a_bss);
1110 printf ("nsyms %d", execp->a_syms / sizeof (struct nlist));
1111 x = execp->a_syms % sizeof (struct nlist);
1112 #endif /* OBJ_BOUT */
1113 #endif /* OBJ_COFF */
1117 #endif /* OBJ_COFF */
1118 printf(" (+ %d bytes)", x);
1119 printf(" entry 0x%lx ", execp->a_entry);
1122 printf(" talign 0x%x", (unsigned) execp->a_talign);
1123 printf(" dalign 0x%x", (unsigned) execp->a_dalign);
1124 printf(" balign 0x%x", (unsigned) execp->a_balign);
1125 printf(" unused 0x%x", (unsigned) execp->unused);
1128 printf(" trsize 0x%lx", execp->a_trsize);
1129 printf(" drsize 0x%lx", execp->a_drsize);
1131 if (N_TXTOFF(*execp) != 0 && N_TXTOFF(*execp) != sizeof(*execp)) {
1134 int size = N_TXTOFF(*execp) - sizeof(*execp);
1136 buffer = xmalloc(size);
1138 fseek(f, sizeof(*execp), 0);
1139 if (fread(buffer, size, 1, f) != 1) {
1140 fprintf(stderr, "%s: error reading between header and text", program_name);
1144 for (i = buffer; i < (buffer + size); ++i) {
1146 printf(" (garbage follows header)");
1149 } /* walk the buffer looking for garbage */
1150 } /* check for garbage following header */
1153 #endif /* OBJ_COFF */
1157 } /* dump_header() */
1161 #endif /* OBJ_COFF */
1162 static void dump_nstuff(execp)
1167 #endif /* OBJ_COFF */
1169 printf("N_BADMAG %d\n", N_BADMAG(*execp));
1170 printf("N_TXTOFF 0x%x\n", N_TXTOFF(*execp));
1171 printf("N_SYMOFF 0x%lx\n", N_SYMOFF(*execp));
1172 printf("N_STROFF 0x%lx\n", N_STROFF(*execp));
1173 printf("N_TXTADDR 0x%x\n", (unsigned) N_TXTADDR(*execp));
1174 printf("N_DATADDR 0x%lx\n", N_DATADDR(*execp));
1177 } /* dump_nstuff() */
1180 printf (" (+ %d bytes)", x);
1181 printf (" entry 0x%x ", execp->a_entry);
1182 #endif /* OBJ_BOUT */
1183 #endif /* OBJ_COFF */
1187 #endif /* OBJ_COFF */
1188 static void dump_text(execp, f)
1193 #endif /* OBJ_COFF */
1198 if (execp->a_text) {
1199 buffer = xmalloc(execp->a_text);
1200 fseek(f, N_TXTOFF(*execp), 0);
1202 if (fread(buffer, execp->a_text, 1, f) != 1) {
1203 fprintf(stderr, "%s: error reading text section.\n", program_name);
1208 printf (" talign 0x%x ", execp->a_talign);
1209 printf (" dalign 0x%x ", execp->a_dalign);
1210 printf (" balign 0x%x ", execp->a_balign);
1211 printf (" unused 0x%x ", execp->unused);
1212 #endif /* OBJ_BOUT */
1213 #endif /* OBJ_COFF */
1217 #endif /* OBJ_COFF */
1218 hex_dump(buffer, execp->a_text);
1221 printf("No text section.\n");
1222 } /* if there is text */
1228 printf ("trsize 0x%x ", execp->a_trsize);
1229 printf ("drsize 0x%x\n", execp->a_drsize);
1231 #endif /* OBJ_BOUT */
1232 #endif /* OBJ_COFF */
1236 #endif /* OBJ_COFF */
1237 static void dump_data(execp, f)
1241 #endif /* OBJ_BOUT */
1246 #endif /* OBJ_COFF */
1251 if (execp->a_data) {
1252 buffer = xmalloc(execp->a_data);
1253 fseek(f, N_TXTOFF(*execp), 0);
1255 if (fread(buffer, execp->a_data, 1, f) != 1) {
1256 fprintf(stderr, "%s: error reading data section.\n", program_name);
1260 hex_dump(buffer, execp->a_data);
1263 printf("No data section.\n");
1264 } /* if there is data */
1269 #endif /* comment */
1270 #endif /* OBJ_COFF */
1272 static void hex_dump(buffer, size)
1276 #endif /* OBJ_BOUT */
1277 #endif /* OBJ_COFF */
1281 #endif /* OBJ_COFF */
1285 if ((f = popen("od -x +0x0", "w")) != NULL) {
1289 if ((f = popen("hexl", "w")) != NULL) {
1290 #endif /* OBJ_COFF */
1291 if (fwrite(buffer, size, 1, f) != 1) {
1292 (void) fprintf(stderr, "%s: error writing to od(1) pipe:", program_name);
1296 (void) fprintf(stderr, "%s: error opening pipe to od(1):", program_name);
1298 } /* on successful popen */
1303 #endif /* OBJ_COFF */
1308 printf ("N_BADMAG %d\n", N_BADMAG (*execp));
1309 printf ("N_TXTOFF 0x%x\n", N_TXTOFF (*execp));
1310 printf ("N_SYMOFF 0x%x\n", N_SYMOFF (*execp));
1311 printf ("N_STROFF 0x%x\n", N_STROFF (*execp));
1312 printf ("N_TXTADDR 0x%x\n", N_TXTADDR (*execp));
1313 printf ("N_DATADDR 0x%x\n", N_DATADDR (*execp));
1315 #endif /* OBJ_BOUT */
1318 char *sym_class_pname(class)
1322 case C_EFCN: return("EFCN");
1323 case C_NULL: return("NULL");
1324 case C_AUTO: return("AUTO");
1325 case C_EXT: return("EXT");
1326 case C_STAT: return("STAT");
1327 case C_REG: return("REG");
1328 case C_EXTDEF: return("EXTDEF");
1329 case C_LABEL: return("LABEL");
1330 case C_ULABEL: return("ULABEL");
1331 case C_MOS: return("MOS");
1332 case C_ARG: return("ARG");
1333 case C_STRTAG: return("STRTAG");
1334 case C_MOU: return("MOU");
1335 case C_UNTAG: return("UNTAG");
1336 case C_TPDEF: return("TPDEF");
1337 case C_USTATIC: return("USTATIC");
1338 case C_ENTAG: return("ENTAG");
1339 case C_MOE: return("MOE");
1340 case C_REGPARM: return("REGPARM");
1341 case C_FIELD: return("FIELD");
1342 case C_BLOCK: return("BLOCK");
1343 case C_FCN: return("FCN");
1344 case C_EOS: return("EOS");
1345 case C_FILE: return("FILE");
1346 case C_LINE: return("LINE");
1347 case C_ALIAS: return("ALIAS");
1348 case C_HIDDEN: return("HIDDEN");
1350 case C_SCALL: return("SCALL");
1351 case C_LEAFEXT: return("LEAFEXT");
1352 case C_OPTVAR: return("OPTVAR");
1353 case C_DEFINE: return("DEFINE");
1354 case C_PRAGMA: return("PRAGMA");
1355 case C_SEGMENT: return("SEGMENT");
1356 case C_LEAFSTAT:return("LEAFSTAT");
1357 case C_AUTOARG: return("AUTOARG");
1359 default: return("(???)");
1360 } /* switch on class */
1361 } /* sym_class_pname() */
1363 char *sym_type_pname(type)
1367 case T_NULL: return("NULL");
1368 case T_VOID: return("VOID");
1369 case T_CHAR: return("CHAR");
1370 case T_SHORT: return("SHORT");
1371 case T_INT: return("INT");
1372 case T_LONG: return("LONG");
1373 case T_FLOAT: return("FLOAT");
1374 case T_DOUBLE: return("DOUBLE");
1375 case T_STRUCT: return("STRUCT");
1376 case T_UNION: return("UNION");
1377 case T_ENUM: return("ENUM");
1378 case T_MOE: return("MOE");
1379 case T_UCHAR: return("UCHAR");
1380 case T_USHORT: return("USHORT");
1381 case T_UINT: return("UINT");
1382 case T_ULONG: return("ULONG");
1383 case T_LNGDBL: return("LNGDBL");
1385 default: return("(???)");
1386 } /* switch on type */
1387 } /* sym_type_pname() */
1389 char *sym_section_pname(scnum, execp)
1394 case N_UNDEF: return("UNDEF");
1395 case N_ABS: return("ABS");
1396 case N_DEBUG: return("DEBUG");
1397 case N_TV: return("NTV");
1398 case P_TV: return("PTV");
1401 assert(0 <= (scnum-1));
1402 assert((scnum-1) < execp->f_nscns);
1403 return(section_headers[scnum-1].s_name);
1404 } /* switch on scnum */
1405 } /* sym_section_pname() */
1407 static char *sym_pname(s)
1410 static char buffer[SYMNMLEN + 1];
1412 bzero(buffer, SYMNMLEN + 1);
1413 bcopy(s->n_name, buffer, SYMNMLEN);
1416 return((char *) s->n_offset);
1417 } /* if "short" name */
1421 * Notes: .file must be first, .text, .data, .bss must be last.
1424 static void dump_aux_fcn(aux)
1427 /* function symbol */
1428 printf(" tagndx %ld,", aux->x_sym.x_tagndx);
1429 printf(" size %ld,", aux->x_sym.x_misc.x_fsize);
1430 printf(" lnnoptr 0x%lx,", (unsigned long) aux->x_sym.x_fcnary.x_fcn.x_lnnoptr);
1431 printf(" endndx %ld", aux->x_sym.x_fcnary.x_fcn.x_endndx);
1432 printf(" tvndx 0x%x,", (unsigned) aux->x_sym.x_tvndx);
1434 } /* dump_aux_fcn() */
1436 static void dump_aux_tagmember(aux)
1439 printf(" tagndx %ld,", aux->x_sym.x_tagndx);
1440 printf(" size %d,", aux->x_sym.x_misc.x_lnsz.x_size);
1442 } /* dump_aux_tagmember() */
1444 static void dump_aux_array(aux)
1448 #endif /* OBJ_COFF */
1453 printf(" size %d, ", aux->x_sym.x_misc.x_lnsz.x_size);
1455 for (i = 0; i < 4; ++i) {
1456 printf("[%d]", aux->x_sym.x_fcnary.x_ary.x_dimen[i]);
1457 } /* four dimensions */
1460 } /* dump_aux_array() */
1462 #endif /* OBJ_COFF */
1463 static void dump_sym(execp, f)
1467 #endif /* OBJ_BOUT */
1471 #endif /* OBJ_COFF */
1479 #endif /* OBJ_COFF */
1483 read_symbols(execp, f);
1485 read_symbols (execp, f);
1486 #endif /* OBJ_BOUT */
1490 read_section_headers(execp, f);
1492 if (execp->f_nsyms == 0) {
1493 #endif /* OBJ_COFF */
1494 printf("no symbols\n");
1497 printf ("no symbols\n");
1498 #endif /* OBJ_BOUT */
1499 #endif /* OBJ_COFF */
1504 } /* if there are any */
1506 read_symbols(execp, f);
1507 printf("Symbols:\n");
1508 #endif /* OBJ_COFF */
1512 #endif /* OBJ_COFF */
1513 if (!omit_sym_numbers_flag) {
1515 printf("%3s: ", "#");
1517 printf("%3s:", "#");
1518 #endif /* OBJ_COFF */
1519 } /* printing symbol numbers */
1522 printf("%4s %5s %4s %8s\n",
1523 "type", "other", "desc", "val");
1525 printf(" %*.*s %8.8s %3.3s %8.8s %7.7s %3.3s %s\n",
1526 SYMNMLEN, SYMNMLEN, "name",
1527 "value", "num", "sec-name", "class", "aux", "type");
1528 #endif /* OBJ_COFF */
1532 printf ("%3s: %4s %5s %4s %8s\n",
1533 "#", "type", "other", "desc", "val");
1534 #endif /* OBJ_BOUT */
1535 for (i = 0, sp = symtbl; i < nsyms; i++, sp++) {
1538 for (i = 0, sp = symbols; sp < symbols + execp->f_nsyms; ++sp, ++i) {
1539 #endif /* OBJ_COFF */
1540 if (!omit_sym_numbers_flag) {
1545 #endif /* OBJ_COFF */
1546 } /* printing symbol numbers */
1549 printf("%4x %5x %4x %8lx %s",
1550 (unsigned) (sp->n_type & 0xff),
1551 (unsigned) (sp->n_other & 0xff),
1552 (unsigned) (sp->n_desc & 0xffff),
1554 printf ("%3d: %4x %5x %4x %8x %s",
1558 sp->n_desc & 0xffff,
1559 #endif /* OBJ_BOUT */
1564 printf(" %*.*s", SYMNMLEN, SYMNMLEN, (sp->n_zeroes) ? sp->n_name : "");
1565 #endif /* OBJ_COFF */
1570 #endif /* OBJ_BOUT */
1571 if (sp->n_type & N_EXT) printf(" N_EXT");
1572 if (sp->n_type & N_STAB) printf(" N_STAB");
1575 printf(" %8lx", (unsigned long) sp->n_value);
1576 printf(" %3d", sp->n_scnum);
1577 printf(" %8.8s", sym_section_pname(sp->n_scnum, execp));
1578 printf(" %7.7s", sym_class_pname(sp->n_sclass));
1579 printf(" %1d", sp->n_numaux);
1580 #endif /* OBJ_COFF */
1585 #endif /* OBJ_BOUT */
1586 if ((sp->n_type & N_TYPE) == N_UNDF) {
1589 if (sp->n_type & N_ABS) printf(" N_ABS");
1590 if (sp->n_type & N_TEXT) printf(" N_TEXT");
1591 if (sp->n_type & N_DATA) printf(" N_DATA");
1592 if (sp->n_type & N_BSS) printf(" N_BSS");
1593 if (sp->n_type & N_FN) printf(" N_FN");
1594 } /* if not undefined */
1597 printf(" %s", sym_type_pname(BTYPE(sp->n_type)));
1598 #endif /* OBJ_COFF */
1604 #endif /* OBJ_BOUT */
1610 printf("%s", (ISPTR(sp->n_type)
1612 : (ISFCN(sp->n_type)
1614 : (ISARY(sp->n_type)
1618 if (sp->n_type & ~(N_BTMASK | N_TMASK)) {
1620 } /* if type isn't all */
1622 if (!sp->n_zeroes) {
1623 printf(" \"%s\"", sym_pname(sp));
1624 } /* if "long" name */
1626 /* FIXME do something with the flags field */
1628 if (sp->pad1[0] != 0 || sp->pad1[1] != 0) {
1629 printf(" (pad1 %2.2x%2.2x)", (unsigned) sp->pad1[0], (unsigned) sp->pad1[1]);
1630 } /* if padding not zeroed */
1631 #endif /* comment */
1633 if (sp->pad2[0] != 0 || sp->pad2[1] != 0) {
1634 printf(" (pad2 %2.2x%2.2x)", (unsigned) sp->pad2[0], (unsigned) sp->pad2[1]);
1635 } /* if padding not zeroed */
1637 #define DTYPE(x) (((x) & N_TMASK) >> N_BTSHFT)
1639 if (sp->n_numaux > 0) {
1640 int auxcountshouldbe = 1;
1641 AUXENT *aux = (AUXENT *) (sp + 1);
1642 AUXENT *aux2 = (AUXENT *) (sp + 2);
1643 #endif /* OBJ_COFF */
1648 switch (sp->n_sclass) {
1650 case C_FILE: /* file symbol */
1651 printf(" filename \"%s\"", aux->x_file.x_fname);
1657 if (DTYPE(sp->n_type) == DT_NON
1658 && (BTYPE(sp->n_type) == T_NULL
1659 || BTYPE(sp->n_type) == T_STRUCT
1660 || BTYPE(sp->n_type) == T_UNION
1661 || BTYPE(sp->n_type) == T_ENUM)) {
1662 printf(" size %d,", aux->x_sym.x_misc.x_lnsz.x_size);
1663 printf(" endndx %ld", aux->x_sym.x_fcnary.x_fcn.x_endndx);
1665 printf(" (don't know why this tag has an auxent)");
1667 } /* if I understand */
1673 if (BTYPE(sp->n_type) == DT_NON && BTYPE(sp->n_type) == T_NULL) {
1674 printf(" tagndx %ld,", aux->x_sym.x_tagndx);
1675 printf(" size %d,", aux->x_sym.x_misc.x_lnsz.x_size);
1677 printf(" (don't know why this eos has an auxent)");
1679 } /* if I understand */
1685 if (BTYPE(sp->n_type) == DT_NON && BTYPE(sp->n_type) == T_NULL) {
1686 if (!strcmp(sp->n_name, ".bb") || !strcmp(sp->n_name, ".bf")) {
1687 printf(" lnno %d", aux->x_sym.x_misc.x_lnsz.x_lnno);
1688 printf(" endndx %ld", aux->x_sym.x_fcnary.x_fcn.x_endndx);
1691 } else if (!strcmp(sp->n_name, ".eb") || !strcmp(sp->n_name, ".ef")) {
1692 printf(" lnno %d", aux->x_sym.x_misc.x_lnsz.x_lnno);
1695 } /* beginning or ending */
1696 } /* if I understand */
1698 printf(" (don't know why this fcn or block has an auxent)");
1701 } /* begin/end blocks */
1707 assert(BTYPE(sp->n_type) != T_MOE);
1709 if (ISFCN(sp->n_type)
1710 || BTYPE(sp->n_type) == T_NULL) {
1713 if (sp->n_sclass == C_SCALL) {
1714 printf(" stindx %ld", aux2->x_sc.x_stindx);
1715 auxcountshouldbe = 2;
1716 } else if (sp->n_sclass == C_LEAFEXT
1717 || sp->n_sclass == C_LEAFSTAT) {
1718 printf(" balentry 0x%lx", aux2->x_bal.x_balntry);
1719 auxcountshouldbe = 2;
1720 } /* special functions */
1721 } else if (ISARY(sp->n_type)) {
1722 dump_aux_array(aux);
1723 } else if (BTYPE(sp->n_type) == T_STRUCT) {
1724 printf(" tagndx %ld,", aux->x_sym.x_tagndx);
1725 printf(" size %d,", aux->x_sym.x_misc.x_lnsz.x_size);
1734 switch (DTYPE(sp->n_type)) {
1736 switch (BTYPE(sp->n_type)) {
1737 case T_NULL: /* section symbol */
1738 printf(" length 0x%lx, relocs %d, lnnos %d",
1739 (unsigned long) aux->x_scn.x_scnlen,
1740 aux->x_scn.x_nreloc,
1741 aux->x_scn.x_nlinno);
1746 dump_aux_tagmember(aux);
1749 printf(" (confused).");
1751 } /* switch on btype */
1754 case DT_FCN: /* function */
1755 if (BTYPE(sp->n_type) == T_MOE) {
1756 printf(" (confused).");
1760 } /* if I understand */
1764 assert(BTYPE(sp->n_type) != T_MOE);
1765 dump_aux_array(aux);
1766 /* intentional fall through */
1768 assert(BTYPE(sp->n_type) == T_STRUCT
1769 || BTYPE(sp->n_type) == T_UNION
1770 || BTYPE(sp->n_type) == T_ENUM);
1771 dump_aux_tagmember(aux);
1775 printf(" (confused.)");
1777 } /* switch on derived type */
1786 if (DTYPE(sp->n_type) == DT_ARY) {
1787 assert(BTYPE(sp->n_type) != T_MOE);
1788 dump_aux_array(aux);
1790 dump_aux_tagmember(aux);
1793 #endif /* OBJ_COFF */
1796 #endif /* OBJ_BOUT */
1797 if (sp->n_other == N_CALLNAME) {
1798 printf(" N_CALLNAME");
1799 } else if (sp->n_other == N_BALNAME) {
1800 printf(" N_BALNAME");
1801 } else if (1 <= sp->n_other && sp->n_other <= 32) {
1802 printf(" \"trap\"");
1804 printf(" !!!invalid \"other\" field");
1809 printf(" tagndx %ld,", aux->x_sym.x_tagndx);
1810 printf(" size %d,", aux->x_sym.x_misc.x_lnsz.x_size);
1814 printf(" (don't know why this symbol has aux entries.)");
1817 } /* switch on class */
1818 #endif /* OBJ_COFF */
1823 #endif /* OBJ_BOUT */
1829 if (sp->n_numaux != auxcountshouldbe) {
1830 printf(" (expecting %d auxents here)", auxcountshouldbe);
1833 } /* do aux entries */
1837 #endif /* OBJ_COFF */
1840 } /* for each symbol */
1842 #endif /* OBJ_BOUT */
1843 #endif /* OBJ_COFF */
1849 #endif /* OBJ_COFF */
1857 #endif /* OBJ_BOUT */
1858 #endif /* OBJ_COFF */
1864 #endif /* OBJ_COFF */
1865 static void dump_reloc (execp, f)
1868 dump_reloc (execp, f)
1869 #endif /* OBJ_BOUT */
1873 #endif /* OBJ_COFF */
1877 read_symbols (execp, f);
1879 read_symbols(execp, f);
1880 #endif /* OBJ_COFF */
1881 if (execp->a_trsize) {
1884 #endif /* OBJ_COFF */
1885 printf("text reloc\n");
1888 printf ("text reloc\n");
1889 #endif /* OBJ_BOUT */
1890 #endif /* OBJ_COFF */
1891 dump_reloc1 (execp, f, N_TRELOFF (*execp), execp->a_trsize);
1893 if (execp->a_drsize) {
1896 #endif /* OBJ_COFF */
1897 printf("data reloc\n");
1900 printf ("data reloc\n");
1901 #endif /* OBJ_BOUT */
1902 #endif /* OBJ_COFF */
1903 dump_reloc1 (execp, f, N_DRELOFF (*execp), execp->a_drsize);
1907 #endif /* OBJ_COFF */
1910 } /* dump_reloc() */
1914 #endif /* OBJ_BOUT */
1915 #endif /* OBJ_COFF */
1919 #endif /* OBJ_COFF */
1920 static void dump_reloc1 (execp, f, off, size)
1923 dump_reloc1 (execp, f, off, size)
1924 #endif /* OBJ_BOUT */
1928 #endif /* OBJ_COFF */
1932 #endif /* OBJ_COFF */
1936 #endif /* OBJ_BOUT */
1937 #endif /* OBJ_COFF */
1940 struct relocation_info reloc;
1943 nreloc = size / sizeof (struct relocation_info);
1947 #endif /* OBJ_COFF */
1948 if (!omit_reloc_numbers_flag) {
1949 printf("%3s: ", "#");
1950 } /* if printing numbers */
1953 printf("%3s ", "len");
1956 printf("%8s %4s\n", "adr", "sym");
1962 printf ("%3s: %3s %8s %4s\n", "#", "len", "adr", "sym");
1964 #endif /* OBJ_BOUT */
1965 #endif /* OBJ_COFF */
1966 for (i = 0; i < nreloc; i++) {
1969 #endif /* OBJ_COFF */
1970 if (fread((char *)&reloc, sizeof reloc, 1, f) != 1) {
1971 fprintf(stderr, "%s: error reading reloc\n",
1974 if (fread ((char *)&reloc, sizeof reloc, 1, f) != 1) {
1975 fprintf (stderr, "%s: error reading reloc\n",
1976 #endif /* OBJ_BOUT */
1977 #endif /* OBJ_COFF */
1983 #endif /* OBJ_COFF */
1985 if (!omit_reloc_numbers_flag) {
1987 } /* if printing numbers */
1990 printf("%3d ", 1 << reloc.r_length);
1993 printf("%8lx ", (long unsigned) reloc.r_address);
1998 printf ("%3d: %3d %8x ", i, 1 << reloc.r_length,
2002 #endif /* OBJ_BOUT */
2003 #endif /* OBJ_COFF */
2004 if (reloc.r_extern) {
2007 #endif /* OBJ_COFF */
2008 if (!omit_sym_numbers_flag) {
2009 (void) printf("%4d ", reloc.r_symbolnum);
2012 } /* if printing sym numbers */
2016 printf ("%4d ", reloc.r_symbolnum);
2017 #endif /* OBJ_BOUT */
2018 #endif /* OBJ_COFF */
2019 if (reloc.r_symbolnum < nsyms)
2022 #endif /* OBJ_COFF */
2023 printf("%s ", symtbl[reloc.r_symbolnum].n_un.n_name);
2027 symtbl[reloc.r_symbolnum].n_un.n_name);
2028 #endif /* OBJ_BOUT */
2029 #endif /* OBJ_COFF */
2033 #endif /* OBJ_COFF */
2038 #endif /* OBJ_BOUT */
2039 #endif /* OBJ_COFF */
2040 switch (reloc.r_symbolnum & ~N_EXT) {
2043 #endif /* OBJ_COFF */
2044 case N_TEXT: printf(".text "); break;
2045 case N_DATA: printf(".data "); break;
2046 case N_BSS: printf(".bss "); break;
2047 case N_ABS: printf(".abs "); break;
2048 default: printf("base %x ", (unsigned) reloc.r_symbolnum); break;
2051 case N_TEXT: printf (".text "); break;
2052 case N_DATA: printf (".data "); break;
2053 case N_BSS: printf (".bss "); break;
2054 case N_ABS: printf (".abs "); break;
2055 default: printf ("base %x ", reloc.r_symbolnum); break;
2056 #endif /* OBJ_BOUT */
2057 #endif /* OBJ_COFF */
2062 #endif /* OBJ_COFF */
2063 #endif /* not B_OUT */
2066 if (reloc.r_addend) printf("+0x%x ", (unsigned) reloc.r_addend);
2068 switch (reloc.r_type) {
2069 case RELOC_8: printf("R8 "); break;
2070 case RELOC_16: printf("R16 "); break;
2071 case RELOC_32: printf("R32 "); break;
2072 case RELOC_DISP8: printf("DISP8 "); break;
2073 case RELOC_DISP16: printf("DISP16 "); break;
2074 case RELOC_DISP32: printf("DISP32 "); break;
2075 case RELOC_WDISP30: printf("WDISP30 "); break;
2076 case RELOC_WDISP22: printf("WDISP22 "); break;
2077 case RELOC_HI22: printf("HI22 "); break;
2078 case RELOC_22: printf("R22 "); break;
2079 case RELOC_13: printf("R13 "); break;
2080 case RELOC_LO10: printf("LO10 "); break;
2081 case RELOC_SFA_BASE: printf("SFA_BASE "); break;
2082 case RELOC_SFA_OFF13: printf("SFA_OFF13 "); break;
2083 case RELOC_BASE10: printf("BASE10 "); break;
2084 case RELOC_BASE13: printf("BASE13 "); break;
2085 case RELOC_BASE22: printf("BASE22 "); break;
2086 case RELOC_PC10: printf("PC10 "); break;
2087 case RELOC_PC22: printf("PC22 "); break;
2088 case RELOC_JMP_TBL: printf("JMP_TBL "); break;
2089 case RELOC_SEGOFF16: printf("SEGOFF16 "); break;
2090 case RELOC_GLOB_DAT: printf("GLOB_DAT "); break;
2091 case RELOC_JMP_SLOT: printf("JMP_SLOT "); break;
2092 case RELOC_RELATIVE: printf("RELATIVE "); break;
2093 } /* switch on reloc type */
2095 if (reloc.r_pcrel) printf("PCREL ");
2099 if (reloc.r_bsr) printf("BSR ");
2100 if (reloc.r_disp) printf("DISP ");
2101 if (reloc.r_callj) printf("CALLJ ");
2102 if (reloc.nuthin) printf("NUTHIN ");
2107 struct reloc_info_sparc spare;
2109 bzero(&spare, sizeof(spare));
2111 reloc.r_address = 0;
2117 if (bcmp(&reloc, &spare, sizeof(spare))) {
2118 printf("(garbage in spare bits) ");
2119 } /* if garbage in spare bits */
2126 if (reloc.r_pcrel) printf ("PCREL ");
2127 if (reloc.r_bsr) printf ("BSR ");
2128 if (reloc.r_disp) printf ("DISP ");
2129 if (reloc.r_callj) printf ("CALLJ ");
2130 if (reloc.nuthin) printf ("NUTHIN ");
2131 #endif /* OBJ_BOUT */
2132 #endif /* OBJ_COFF */
2136 #endif /* OBJ_COFF */
2137 if (reloc.r_pad) printf("PAD %x ", reloc.r_pad);
2140 if (reloc.r_pad) printf ("PAD %x ", reloc.r_pad);
2141 #endif /* OBJ_BOUT */
2142 #endif /* OBJ_COFF */
2146 #endif /* OBJ_COFF */
2148 } /* for each reloc record */
2151 } /* dump_reloc1() */
2157 #endif /* OBJ_BOUT */
2159 #endif /* comment */
2160 #endif /* OBJ_COFF */
2162 /* Allocate `n' bytes of memory dynamically, with error checking. */
2175 fprintf(stderr, "%s: virtual memory exhausted\n", program_name);
2177 fprintf (stderr, "%s: virtual memory exhausted\n", program_name);
2178 #endif /* OBJ_BOUT */
2183 #endif /* OBJ_BOUT */
2187 static char *xmalloc (n)
2195 fprintf(stderr, "%s: virtual memory exhausted\n", program_name);
2200 #endif /* OBJ_COFF */
2204 static char *xrealloc(p, size)
2208 p = realloc(p, size);
2211 fprintf(stderr, "%s: virtual memory exhausted\n", program_name);
2213 } /* on malloc failure */
2219 #endif /* OBJ_COFF */
2227 /* end of objdump.c */
2231 #endif /* OBJ_BOUT */
2232 #endif /* OBJ_COFF */