od-xcoff.c 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843
  1. /* od-xcoff.c -- dump information about an xcoff object file.
  2. Copyright (C) 2011-2015 Free Software Foundation, Inc.
  3. Written by Tristan Gingold, Adacore.
  4. This file is part of GNU Binutils.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3, or (at your option)
  8. any later version.
  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.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, 51 Franklin Street - Fifth Floor, Boston,
  16. MA 02110-1301, USA. */
  17. #include "sysdep.h"
  18. #include <stddef.h>
  19. #include <time.h>
  20. #include "safe-ctype.h"
  21. #include "bfd.h"
  22. #include "objdump.h"
  23. #include "bucomm.h"
  24. #include "bfdlink.h"
  25. /* Force the support of weak symbols. */
  26. #ifndef AIX_WEAK_SUPPORT
  27. #define AIX_WEAK_SUPPORT 1
  28. #endif
  29. #include "coff/internal.h"
  30. #include "coff/rs6000.h"
  31. #include "coff/xcoff.h"
  32. #include "libcoff.h"
  33. #include "libxcoff.h"
  34. /* Index of the options in the options[] array. */
  35. #define OPT_FILE_HEADER 0
  36. #define OPT_AOUT 1
  37. #define OPT_SECTIONS 2
  38. #define OPT_SYMS 3
  39. #define OPT_RELOCS 4
  40. #define OPT_LINENO 5
  41. #define OPT_LOADER 6
  42. #define OPT_EXCEPT 7
  43. #define OPT_TYPCHK 8
  44. #define OPT_TRACEBACK 9
  45. #define OPT_TOC 10
  46. #define OPT_LDINFO 11
  47. /* List of actions. */
  48. static struct objdump_private_option options[] =
  49. {
  50. { "header", 0 },
  51. { "aout", 0 },
  52. { "sections", 0 },
  53. { "syms", 0 },
  54. { "relocs", 0 },
  55. { "lineno", 0 },
  56. { "loader", 0 },
  57. { "except", 0 },
  58. { "typchk", 0 },
  59. { "traceback", 0 },
  60. { "toc", 0 },
  61. { "ldinfo", 0 },
  62. { NULL, 0 }
  63. };
  64. /* Display help. */
  65. static void
  66. xcoff_help (FILE *stream)
  67. {
  68. fprintf (stream, _("\
  69. For XCOFF files:\n\
  70. header Display the file header\n\
  71. aout Display the auxiliary header\n\
  72. sections Display the section headers\n\
  73. syms Display the symbols table\n\
  74. relocs Display the relocation entries\n\
  75. lineno Display the line number entries\n\
  76. loader Display loader section\n\
  77. except Display exception table\n\
  78. typchk Display type-check section\n\
  79. traceback Display traceback tags\n\
  80. toc Display toc symbols\n\
  81. ldinfo Display loader info in core files\n\
  82. "));
  83. }
  84. /* Return TRUE if ABFD is handled. */
  85. static int
  86. xcoff_filter (bfd *abfd)
  87. {
  88. return bfd_get_flavour (abfd) == bfd_target_xcoff_flavour;
  89. }
  90. /* Translation entry type. The last entry must be {0, NULL}. */
  91. struct xlat_table {
  92. unsigned int val;
  93. const char *name;
  94. };
  95. /* Display the list of name (from TABLE) for FLAGS, using comma to separate
  96. them. A name is displayed if FLAGS & VAL is not 0. */
  97. static void
  98. dump_flags (const struct xlat_table *table, unsigned int flags)
  99. {
  100. unsigned int r = flags;
  101. int first = 1;
  102. const struct xlat_table *t;
  103. for (t = table; t->name; t++)
  104. if ((flags & t->val) != 0)
  105. {
  106. r &= ~t->val;
  107. if (first)
  108. first = 0;
  109. else
  110. putchar (',');
  111. fputs (t->name, stdout);
  112. }
  113. /* Not decoded flags. */
  114. if (r != 0)
  115. {
  116. if (!first)
  117. putchar (',');
  118. printf ("0x%x", r);
  119. }
  120. }
  121. /* Display the name corresponding to VAL from TABLE, using at most
  122. MAXLEN char (possibly passed with spaces). */
  123. static void
  124. dump_value (const struct xlat_table *table, unsigned int val, int maxlen)
  125. {
  126. const struct xlat_table *t;
  127. for (t = table; t->name; t++)
  128. if (t->val == val)
  129. {
  130. printf ("%-*s", maxlen, t->name);
  131. return;
  132. }
  133. printf ("(%*x)", maxlen - 2, val);
  134. }
  135. /* Names of f_flags. */
  136. static const struct xlat_table f_flag_xlat[] =
  137. {
  138. { F_RELFLG, "no-rel" },
  139. { F_EXEC, "exec" },
  140. { F_LNNO, "lineno" },
  141. { F_LSYMS, "lsyms" },
  142. { F_FDPR_PROF, "fdpr-prof" },
  143. { F_FDPR_OPTI, "fdpr-opti" },
  144. { F_DSA, "dsa" },
  145. { F_VARPG, "varprg" },
  146. { F_DYNLOAD, "dynload" },
  147. { F_SHROBJ, "shrobj" },
  148. { F_NONEXEC, "nonexec" },
  149. { 0, NULL }
  150. };
  151. /* Names of s_flags. */
  152. static const struct xlat_table s_flag_xlat[] =
  153. {
  154. { STYP_PAD, "pad" },
  155. { STYP_DWARF, "dwarf" },
  156. { STYP_TEXT, "text" },
  157. { STYP_DATA, "data" },
  158. { STYP_BSS, "bss" },
  159. { STYP_EXCEPT, "except" },
  160. { STYP_INFO, "info" },
  161. { STYP_TDATA, "tdata" },
  162. { STYP_TBSS, "tbss" },
  163. { STYP_LOADER, "loader" },
  164. { STYP_DEBUG, "debug" },
  165. { STYP_TYPCHK, "typchk" },
  166. { STYP_OVRFLO, "ovrflo" },
  167. { 0, NULL }
  168. };
  169. /* Names of storage class. */
  170. static const struct xlat_table sc_xlat[] =
  171. {
  172. #define SC_ENTRY(X) { C_##X, #X }
  173. SC_ENTRY(NULL),
  174. SC_ENTRY(AUTO),
  175. SC_ENTRY(EXT),
  176. SC_ENTRY(STAT),
  177. SC_ENTRY(REG),
  178. SC_ENTRY(EXTDEF),
  179. SC_ENTRY(LABEL),
  180. SC_ENTRY(ULABEL),
  181. SC_ENTRY(MOS),
  182. SC_ENTRY(ARG),
  183. /* SC_ENTRY(STRARG), */
  184. SC_ENTRY(MOU),
  185. SC_ENTRY(UNTAG),
  186. SC_ENTRY(TPDEF),
  187. SC_ENTRY(USTATIC),
  188. SC_ENTRY(ENTAG),
  189. SC_ENTRY(MOE),
  190. SC_ENTRY(REGPARM),
  191. SC_ENTRY(FIELD),
  192. SC_ENTRY(BLOCK),
  193. SC_ENTRY(FCN),
  194. SC_ENTRY(EOS),
  195. SC_ENTRY(FILE),
  196. SC_ENTRY(LINE),
  197. SC_ENTRY(ALIAS),
  198. SC_ENTRY(HIDDEN),
  199. SC_ENTRY(HIDEXT),
  200. SC_ENTRY(BINCL),
  201. SC_ENTRY(EINCL),
  202. SC_ENTRY(INFO),
  203. SC_ENTRY(WEAKEXT),
  204. SC_ENTRY(DWARF),
  205. /* Stabs. */
  206. SC_ENTRY (GSYM),
  207. SC_ENTRY (LSYM),
  208. SC_ENTRY (PSYM),
  209. SC_ENTRY (RSYM),
  210. SC_ENTRY (RPSYM),
  211. SC_ENTRY (STSYM),
  212. SC_ENTRY (TCSYM),
  213. SC_ENTRY (BCOMM),
  214. SC_ENTRY (ECOML),
  215. SC_ENTRY (ECOMM),
  216. SC_ENTRY (DECL),
  217. SC_ENTRY (ENTRY),
  218. SC_ENTRY (FUN),
  219. SC_ENTRY (BSTAT),
  220. SC_ENTRY (ESTAT),
  221. { 0, NULL }
  222. #undef SC_ENTRY
  223. };
  224. /* Names for symbol type. */
  225. static const struct xlat_table smtyp_xlat[] =
  226. {
  227. { XTY_ER, "ER" },
  228. { XTY_SD, "SD" },
  229. { XTY_LD, "LD" },
  230. { XTY_CM, "CM" },
  231. { XTY_EM, "EM" },
  232. { XTY_US, "US" },
  233. { 0, NULL }
  234. };
  235. /* Names for storage-mapping class. */
  236. static const struct xlat_table smclas_xlat[] =
  237. {
  238. #define SMCLAS_ENTRY(X) { XMC_##X, #X }
  239. SMCLAS_ENTRY (PR),
  240. SMCLAS_ENTRY (RO),
  241. SMCLAS_ENTRY (DB),
  242. SMCLAS_ENTRY (TC),
  243. SMCLAS_ENTRY (UA),
  244. SMCLAS_ENTRY (RW),
  245. SMCLAS_ENTRY (GL),
  246. SMCLAS_ENTRY (XO),
  247. SMCLAS_ENTRY (SV),
  248. SMCLAS_ENTRY (BS),
  249. SMCLAS_ENTRY (DS),
  250. SMCLAS_ENTRY (UC),
  251. SMCLAS_ENTRY (TI),
  252. SMCLAS_ENTRY (TB),
  253. SMCLAS_ENTRY (TC0),
  254. SMCLAS_ENTRY (TD),
  255. SMCLAS_ENTRY (SV64),
  256. SMCLAS_ENTRY (SV3264),
  257. { 0, NULL }
  258. #undef SMCLAS_ENTRY
  259. };
  260. /* Names for relocation type. */
  261. static const struct xlat_table rtype_xlat[] =
  262. {
  263. #define RTYPE_ENTRY(X) { R_##X, #X }
  264. RTYPE_ENTRY (POS),
  265. RTYPE_ENTRY (NEG),
  266. RTYPE_ENTRY (REL),
  267. RTYPE_ENTRY (TOC),
  268. RTYPE_ENTRY (RTB),
  269. RTYPE_ENTRY (GL),
  270. RTYPE_ENTRY (TCL),
  271. RTYPE_ENTRY (BA),
  272. RTYPE_ENTRY (BR),
  273. RTYPE_ENTRY (RL),
  274. RTYPE_ENTRY (RLA),
  275. RTYPE_ENTRY (REF),
  276. RTYPE_ENTRY (TRL),
  277. RTYPE_ENTRY (TRLA),
  278. RTYPE_ENTRY (RRTBI),
  279. RTYPE_ENTRY (RRTBA),
  280. RTYPE_ENTRY (CAI),
  281. RTYPE_ENTRY (CREL),
  282. RTYPE_ENTRY (RBA),
  283. RTYPE_ENTRY (RBAC),
  284. RTYPE_ENTRY (RBR),
  285. RTYPE_ENTRY (RBRC),
  286. RTYPE_ENTRY (TLS),
  287. RTYPE_ENTRY (TLS_IE),
  288. RTYPE_ENTRY (TLS_LD),
  289. RTYPE_ENTRY (TLS_LE),
  290. RTYPE_ENTRY (TLSM),
  291. RTYPE_ENTRY (TLSML),
  292. RTYPE_ENTRY (TOCU),
  293. RTYPE_ENTRY (TOCL),
  294. { 0, NULL }
  295. };
  296. /* Simplified section header. */
  297. struct xcoff32_section
  298. {
  299. /* NUL terminated name. */
  300. char name[9];
  301. /* Section flags. */
  302. unsigned int flags;
  303. /* Offsets in file. */
  304. ufile_ptr scnptr;
  305. ufile_ptr relptr;
  306. ufile_ptr lnnoptr;
  307. /* Number of relocs and line numbers. */
  308. unsigned int nreloc;
  309. unsigned int nlnno;
  310. };
  311. /* Simplified symbol. */
  312. union xcoff32_symbol
  313. {
  314. union external_auxent aux;
  315. struct sym
  316. {
  317. /* Pointer to the NUL-terminated name. */
  318. char *name;
  319. /* XCOFF symbol fields. */
  320. unsigned int val;
  321. unsigned short scnum;
  322. unsigned short ntype;
  323. unsigned char sclass;
  324. unsigned char numaux;
  325. /* Buffer in case the name is local. */
  326. union
  327. {
  328. char name[9];
  329. unsigned int off;
  330. } raw;
  331. } sym;
  332. };
  333. /* Important fields to dump the file. */
  334. struct xcoff_dump
  335. {
  336. /* From file header. */
  337. unsigned short nscns;
  338. unsigned int symptr;
  339. unsigned int nsyms;
  340. unsigned short opthdr;
  341. /* Sections. */
  342. struct xcoff32_section *sects;
  343. /* Symbols. */
  344. union xcoff32_symbol *syms;
  345. char *strings;
  346. unsigned int strings_size;
  347. };
  348. /* Print a symbol (if possible). */
  349. static void
  350. xcoff32_print_symbol (struct xcoff_dump *data, unsigned int symndx)
  351. {
  352. if (data->syms != NULL
  353. && symndx < data->nsyms
  354. && data->syms[symndx].sym.name != NULL)
  355. printf ("%s", data->syms[symndx].sym.name);
  356. else
  357. printf ("%u", symndx);
  358. }
  359. /* Dump the file header. */
  360. static void
  361. dump_xcoff32_file_header (bfd *abfd, struct external_filehdr *fhdr,
  362. struct xcoff_dump *data)
  363. {
  364. unsigned int timdat = bfd_h_get_32 (abfd, fhdr->f_timdat);
  365. unsigned short flags = bfd_h_get_16 (abfd, fhdr->f_flags);
  366. printf (_(" nbr sections: %d\n"), data->nscns);
  367. printf (_(" time and date: 0x%08x - "), timdat);
  368. if (timdat == 0)
  369. printf (_("not set\n"));
  370. else
  371. {
  372. /* Not correct on all platforms, but works on unix. */
  373. time_t t = timdat;
  374. fputs (ctime (&t), stdout);
  375. }
  376. printf (_(" symbols off: 0x%08x\n"), data->symptr);
  377. printf (_(" nbr symbols: %d\n"), data->nsyms);
  378. printf (_(" opt hdr sz: %d\n"), data->opthdr);
  379. printf (_(" flags: 0x%04x "), flags);
  380. dump_flags (f_flag_xlat, flags);
  381. putchar ('\n');
  382. }
  383. /* Dump the a.out header. */
  384. static void
  385. dump_xcoff32_aout_header (bfd *abfd, struct xcoff_dump *data)
  386. {
  387. AOUTHDR auxhdr;
  388. unsigned short magic;
  389. unsigned int sz = data->opthdr;
  390. printf (_("Auxiliary header:\n"));
  391. if (data->opthdr == 0)
  392. {
  393. printf (_(" No aux header\n"));
  394. return;
  395. }
  396. if (data->opthdr > sizeof (auxhdr))
  397. {
  398. printf (_("warning: optional header size too large (> %d)\n"),
  399. (int)sizeof (auxhdr));
  400. sz = sizeof (auxhdr);
  401. }
  402. if (bfd_bread (&auxhdr, sz, abfd) != sz)
  403. {
  404. non_fatal (_("cannot read auxhdr"));
  405. return;
  406. }
  407. magic = bfd_h_get_16 (abfd, auxhdr.magic);
  408. /* We don't translate these strings as they are fields name. */
  409. printf (" o_mflag (magic): 0x%04x 0%04o\n", magic, magic);
  410. printf (" o_vstamp: 0x%04x\n",
  411. (unsigned short)bfd_h_get_16 (abfd, auxhdr.vstamp));
  412. printf (" o_tsize: 0x%08x\n",
  413. (unsigned int)bfd_h_get_32 (abfd, auxhdr.tsize));
  414. printf (" o_dsize: 0x%08x\n",
  415. (unsigned int)bfd_h_get_32 (abfd, auxhdr.dsize));
  416. printf (" o_entry: 0x%08x\n",
  417. (unsigned int)bfd_h_get_32 (abfd, auxhdr.entry));
  418. printf (" o_text_start: 0x%08x\n",
  419. (unsigned int)bfd_h_get_32 (abfd, auxhdr.text_start));
  420. printf (" o_data_start: 0x%08x\n",
  421. (unsigned int)bfd_h_get_32 (abfd, auxhdr.data_start));
  422. if (sz == offsetof (AOUTHDR, o_toc))
  423. return;
  424. printf (" o_toc: 0x%08x\n",
  425. (unsigned int)bfd_h_get_32 (abfd, auxhdr.o_toc));
  426. printf (" o_snentry: 0x%04x\n",
  427. (unsigned int)bfd_h_get_16 (abfd, auxhdr.o_snentry));
  428. printf (" o_sntext: 0x%04x\n",
  429. (unsigned int)bfd_h_get_16 (abfd, auxhdr.o_sntext));
  430. printf (" o_sndata: 0x%04x\n",
  431. (unsigned int)bfd_h_get_16 (abfd, auxhdr.o_sndata));
  432. printf (" o_sntoc: 0x%04x\n",
  433. (unsigned int)bfd_h_get_16 (abfd, auxhdr.o_sntoc));
  434. printf (" o_snloader: 0x%04x\n",
  435. (unsigned int)bfd_h_get_16 (abfd, auxhdr.o_snloader));
  436. printf (" o_snbss: 0x%04x\n",
  437. (unsigned int)bfd_h_get_16 (abfd, auxhdr.o_snbss));
  438. printf (" o_algntext: %u\n",
  439. (unsigned int)bfd_h_get_16 (abfd, auxhdr.o_algntext));
  440. printf (" o_algndata: %u\n",
  441. (unsigned int)bfd_h_get_16 (abfd, auxhdr.o_algndata));
  442. printf (" o_modtype: 0x%04x",
  443. (unsigned int)bfd_h_get_16 (abfd, auxhdr.o_modtype));
  444. if (ISPRINT (auxhdr.o_modtype[0]) && ISPRINT (auxhdr.o_modtype[1]))
  445. printf (" (%c%c)", auxhdr.o_modtype[0], auxhdr.o_modtype[1]);
  446. putchar ('\n');
  447. printf (" o_cputype: 0x%04x\n",
  448. (unsigned int)bfd_h_get_16 (abfd, auxhdr.o_cputype));
  449. printf (" o_maxstack: 0x%08x\n",
  450. (unsigned int)bfd_h_get_32 (abfd, auxhdr.o_maxstack));
  451. printf (" o_maxdata: 0x%08x\n",
  452. (unsigned int)bfd_h_get_32 (abfd, auxhdr.o_maxdata));
  453. #if 0
  454. printf (" o_debugger: 0x%08x\n",
  455. (unsigned int)bfd_h_get_32 (abfd, auxhdr.o_debugger));
  456. #endif
  457. }
  458. /* Dump the sections header. */
  459. static void
  460. dump_xcoff32_sections_header (bfd *abfd, struct xcoff_dump *data)
  461. {
  462. unsigned int i;
  463. unsigned int off;
  464. off = sizeof (struct external_filehdr) + data->opthdr;
  465. printf (_("Section headers (at %u+%u=0x%08x to 0x%08x):\n"),
  466. (unsigned int)sizeof (struct external_filehdr), data->opthdr, off,
  467. off + (unsigned int)sizeof (struct external_scnhdr) * data->nscns);
  468. if (data->nscns == 0)
  469. {
  470. printf (_(" No section header\n"));
  471. return;
  472. }
  473. if (bfd_seek (abfd, off, SEEK_SET) != 0)
  474. {
  475. non_fatal (_("cannot read section header"));
  476. return;
  477. }
  478. /* We don't translate this string as it consists in fields name. */
  479. printf (" # Name paddr vaddr size scnptr relptr lnnoptr nrel nlnno\n");
  480. for (i = 0; i < data->nscns; i++)
  481. {
  482. struct external_scnhdr scn;
  483. unsigned int flags;
  484. if (bfd_bread (&scn, sizeof (scn), abfd) != sizeof (scn))
  485. {
  486. non_fatal (_("cannot read section header"));
  487. return;
  488. }
  489. flags = bfd_h_get_32 (abfd, scn.s_flags);
  490. printf ("%2d %-8.8s %08x %08x %08x %08x %08x %08x %-5d %-5d\n",
  491. i + 1, scn.s_name,
  492. (unsigned int)bfd_h_get_32 (abfd, scn.s_paddr),
  493. (unsigned int)bfd_h_get_32 (abfd, scn.s_vaddr),
  494. (unsigned int)bfd_h_get_32 (abfd, scn.s_size),
  495. (unsigned int)bfd_h_get_32 (abfd, scn.s_scnptr),
  496. (unsigned int)bfd_h_get_32 (abfd, scn.s_relptr),
  497. (unsigned int)bfd_h_get_32 (abfd, scn.s_lnnoptr),
  498. (unsigned int)bfd_h_get_16 (abfd, scn.s_nreloc),
  499. (unsigned int)bfd_h_get_16 (abfd, scn.s_nlnno));
  500. printf (_(" Flags: %08x "), flags);
  501. if (~flags == 0)
  502. {
  503. /* Stripped executable ? */
  504. putchar ('\n');
  505. }
  506. else if (flags & STYP_OVRFLO)
  507. printf (_("overflow - nreloc: %u, nlnno: %u\n"),
  508. (unsigned int)bfd_h_get_32 (abfd, scn.s_paddr),
  509. (unsigned int)bfd_h_get_32 (abfd, scn.s_vaddr));
  510. else
  511. {
  512. dump_flags (s_flag_xlat, flags);
  513. putchar ('\n');
  514. }
  515. }
  516. }
  517. /* Read section table. */
  518. static void
  519. xcoff32_read_sections (bfd *abfd, struct xcoff_dump *data)
  520. {
  521. int i;
  522. if (bfd_seek (abfd, sizeof (struct external_filehdr) + data->opthdr,
  523. SEEK_SET) != 0)
  524. {
  525. non_fatal (_("cannot read section headers"));
  526. return;
  527. }
  528. data->sects = xmalloc (data->nscns * sizeof (struct xcoff32_section));
  529. for (i = 0; i < data->nscns; i++)
  530. {
  531. struct external_scnhdr scn;
  532. struct xcoff32_section *s = &data->sects[i];
  533. if (bfd_bread (&scn, sizeof (scn), abfd) != sizeof (scn))
  534. {
  535. non_fatal (_("cannot read section header"));
  536. free (data->sects);
  537. data->sects = NULL;
  538. return;
  539. }
  540. memcpy (s->name, scn.s_name, 8);
  541. s->name[8] = 0;
  542. s->flags = bfd_h_get_32 (abfd, scn.s_flags);
  543. s->scnptr = bfd_h_get_32 (abfd, scn.s_scnptr);
  544. s->relptr = bfd_h_get_32 (abfd, scn.s_relptr);
  545. s->lnnoptr = bfd_h_get_32 (abfd, scn.s_lnnoptr);
  546. s->nreloc = bfd_h_get_16 (abfd, scn.s_nreloc);
  547. s->nlnno = bfd_h_get_16 (abfd, scn.s_nlnno);
  548. if (s->flags == STYP_OVRFLO)
  549. {
  550. if (s->nreloc > 0 && s->nreloc <= data->nscns)
  551. data->sects[s->nreloc - 1].nreloc =
  552. bfd_h_get_32 (abfd, scn.s_paddr);
  553. if (s->nlnno > 0 && s->nlnno <= data->nscns)
  554. data->sects[s->nlnno - 1].nlnno =
  555. bfd_h_get_32 (abfd, scn.s_vaddr);
  556. }
  557. }
  558. }
  559. /* Read symbols. */
  560. static void
  561. xcoff32_read_symbols (bfd *abfd, struct xcoff_dump *data)
  562. {
  563. unsigned int i;
  564. char stsz_arr[4];
  565. unsigned int stptr;
  566. if (data->nsyms == 0)
  567. return;
  568. stptr = data->symptr
  569. + data->nsyms * (unsigned)sizeof (struct external_syment);
  570. /* Read string table. */
  571. if (bfd_seek (abfd, stptr, SEEK_SET) != 0
  572. || bfd_bread (&stsz_arr, sizeof (stsz_arr), abfd) != sizeof (stsz_arr))
  573. {
  574. non_fatal (_("cannot read strings table length"));
  575. data->strings_size = 0;
  576. }
  577. else
  578. {
  579. data->strings_size = bfd_h_get_32 (abfd, stsz_arr);
  580. if (data->strings_size > sizeof (stsz_arr))
  581. {
  582. unsigned int remsz = data->strings_size - sizeof (stsz_arr);
  583. data->strings = xmalloc (data->strings_size);
  584. memcpy (data->strings, stsz_arr, sizeof (stsz_arr));
  585. if (bfd_bread (data->strings + sizeof (stsz_arr), remsz, abfd)
  586. != remsz)
  587. {
  588. non_fatal (_("cannot read strings table"));
  589. goto clean;
  590. }
  591. }
  592. }
  593. if (bfd_seek (abfd, data->symptr, SEEK_SET) != 0)
  594. {
  595. non_fatal (_("cannot read symbol table"));
  596. goto clean;
  597. }
  598. data->syms = (union xcoff32_symbol *)
  599. xmalloc (data->nsyms * sizeof (union xcoff32_symbol));
  600. for (i = 0; i < data->nsyms; i++)
  601. {
  602. struct external_syment sym;
  603. int j;
  604. union xcoff32_symbol *s = &data->syms[i];
  605. if (bfd_bread (&sym, sizeof (sym), abfd) != sizeof (sym))
  606. {
  607. non_fatal (_("cannot read symbol entry"));
  608. goto clean;
  609. }
  610. s->sym.val = bfd_h_get_32 (abfd, sym.e_value);
  611. s->sym.scnum = bfd_h_get_16 (abfd, sym.e_scnum);
  612. s->sym.ntype = bfd_h_get_16 (abfd, sym.e_type);
  613. s->sym.sclass = bfd_h_get_8 (abfd, sym.e_sclass);
  614. s->sym.numaux = bfd_h_get_8 (abfd, sym.e_numaux);
  615. if (sym.e.e_name[0])
  616. {
  617. memcpy (s->sym.raw.name, sym.e.e_name, sizeof (sym.e.e_name));
  618. s->sym.raw.name[8] = 0;
  619. s->sym.name = s->sym.raw.name;
  620. }
  621. else
  622. {
  623. unsigned int soff = bfd_h_get_32 (abfd, sym.e.e.e_offset);
  624. if ((s->sym.sclass & DBXMASK) == 0 && soff < data->strings_size)
  625. s->sym.name = data->strings + soff;
  626. else
  627. {
  628. s->sym.name = NULL;
  629. s->sym.raw.off = soff;
  630. }
  631. }
  632. for (j = 0; j < s->sym.numaux; j++, i++)
  633. {
  634. if (bfd_bread (&s[j + 1].aux,
  635. sizeof (union external_auxent), abfd)
  636. != sizeof (union external_auxent))
  637. {
  638. non_fatal (_("cannot read symbol aux entry"));
  639. goto clean;
  640. }
  641. }
  642. }
  643. return;
  644. clean:
  645. free (data->syms);
  646. data->syms = NULL;
  647. free (data->strings);
  648. data->strings = NULL;
  649. }
  650. /* Dump xcoff symbols. */
  651. static void
  652. dump_xcoff32_symbols (bfd *abfd, struct xcoff_dump *data)
  653. {
  654. unsigned int i;
  655. asection *debugsec;
  656. char *debug = NULL;
  657. printf (_("Symbols table (strtable at 0x%08x)"),
  658. data->symptr
  659. + data->nsyms * (unsigned)sizeof (struct external_syment));
  660. if (data->nsyms == 0 || data->syms == NULL)
  661. {
  662. printf (_(":\n No symbols\n"));
  663. return;
  664. }
  665. /* Read strings table. */
  666. if (data->strings_size == 0)
  667. printf (_(" (no strings):\n"));
  668. else
  669. printf (_(" (strings size: %08x):\n"), data->strings_size);
  670. /* Read debug section. */
  671. debugsec = bfd_get_section_by_name (abfd, ".debug");
  672. if (debugsec != NULL)
  673. {
  674. bfd_size_type size;
  675. size = bfd_get_section_size (debugsec);
  676. debug = (char *) xmalloc (size);
  677. bfd_get_section_contents (abfd, debugsec, debug, 0, size);
  678. }
  679. /* Translators: 'sc' is for storage class, 'off' for offset. */
  680. printf (_(" # sc value section type aux name/off\n"));
  681. for (i = 0; i < data->nsyms; i++)
  682. {
  683. union xcoff32_symbol *s = &data->syms[i];
  684. int j;
  685. printf ("%3u ", i);
  686. dump_value (sc_xlat, s->sym.sclass, 10);
  687. printf (" %08x ", s->sym.val);
  688. if (s->sym.scnum > 0 && s->sym.scnum <= data->nscns)
  689. {
  690. if (data->sects != NULL)
  691. printf ("%-8s", data->sects[s->sym.scnum - 1].name);
  692. else
  693. printf ("%-8u", s->sym.scnum);
  694. }
  695. else
  696. switch ((signed short)s->sym.scnum)
  697. {
  698. case N_DEBUG:
  699. printf ("N_DEBUG ");
  700. break;
  701. case N_ABS:
  702. printf ("N_ABS ");
  703. break;
  704. case N_UNDEF:
  705. printf ("N_UNDEF ");
  706. break;
  707. default:
  708. printf ("(%04x) ", s->sym.scnum);
  709. }
  710. printf (" %04x %3u ", s->sym.ntype, s->sym.numaux);
  711. if (s->sym.name != NULL)
  712. printf ("%s", s->sym.name);
  713. else
  714. {
  715. if ((s->sym.sclass & DBXMASK) != 0 && debug != NULL)
  716. printf ("%s", debug + s->sym.raw.off);
  717. else
  718. printf ("%08x", s->sym.raw.off);
  719. }
  720. putchar ('\n');
  721. for (j = 0; j < s->sym.numaux; j++, i++)
  722. {
  723. union external_auxent *aux = &s[j + 1].aux;
  724. printf (" %3u ", i + 1);
  725. switch (s->sym.sclass)
  726. {
  727. case C_STAT:
  728. /* Section length, number of relocs and line number. */
  729. printf (_(" scnlen: %08x nreloc: %-6u nlinno: %-6u\n"),
  730. (unsigned)bfd_h_get_32 (abfd, aux->x_scn.x_scnlen),
  731. (unsigned)bfd_h_get_16 (abfd, aux->x_scn.x_nreloc),
  732. (unsigned)bfd_h_get_16 (abfd, aux->x_scn.x_nlinno));
  733. break;
  734. case C_DWARF:
  735. /* Section length and number of relocs. */
  736. printf (_(" scnlen: %08x nreloc: %-6u\n"),
  737. (unsigned)bfd_h_get_32 (abfd, aux->x_scn.x_scnlen),
  738. (unsigned)bfd_h_get_16 (abfd, aux->x_scn.x_nreloc));
  739. break;
  740. case C_EXT:
  741. case C_WEAKEXT:
  742. case C_HIDEXT:
  743. if (j == 0 && s->sym.numaux > 1)
  744. {
  745. /* Function aux entry (Do not translate). */
  746. printf (" exptr: %08x fsize: %08x lnnoptr: %08x endndx: %u\n",
  747. (unsigned)bfd_h_get_32 (abfd, aux->x_sym.x_tagndx),
  748. (unsigned)bfd_h_get_32
  749. (abfd, aux->x_sym.x_misc.x_fsize),
  750. (unsigned)bfd_h_get_32
  751. (abfd, aux->x_sym.x_fcnary.x_fcn.x_lnnoptr),
  752. (unsigned)bfd_h_get_32
  753. (abfd, aux->x_sym.x_fcnary.x_fcn.x_endndx));
  754. }
  755. else if (j == 1 || (j == 0 && s->sym.numaux == 1))
  756. {
  757. /* csect aux entry. */
  758. unsigned char smtyp;
  759. unsigned int scnlen;
  760. smtyp = bfd_h_get_8 (abfd, aux->x_csect.x_smtyp);
  761. scnlen = bfd_h_get_32 (abfd, aux->x_csect.x_scnlen);
  762. if (smtyp == XTY_LD)
  763. printf (" scnsym: %-8u", scnlen);
  764. else
  765. printf (" scnlen: %08x", scnlen);
  766. printf (" h: parm=%08x sn=%04x al: 2**%u",
  767. (unsigned)bfd_h_get_32 (abfd, aux->x_csect.x_parmhash),
  768. (unsigned)bfd_h_get_16 (abfd, aux->x_csect.x_snhash),
  769. SMTYP_ALIGN (smtyp));
  770. printf (" typ: ");
  771. dump_value (smtyp_xlat, SMTYP_SMTYP (smtyp), 2);
  772. printf (" cl: ");
  773. dump_value
  774. (smclas_xlat,
  775. (unsigned)bfd_h_get_8 (abfd, aux->x_csect.x_smclas), 6);
  776. putchar ('\n');
  777. }
  778. else
  779. /* Do not translate - generic field name. */
  780. printf ("aux\n");
  781. break;
  782. case C_FILE:
  783. {
  784. unsigned int off;
  785. printf (" ftype: %02x ",
  786. (unsigned)bfd_h_get_8 (abfd, aux->x_file.x_ftype));
  787. if (aux->x_file.x_n.x_fname[0] != 0)
  788. printf ("fname: %.14s", aux->x_file.x_n.x_fname);
  789. else
  790. {
  791. off = (unsigned)bfd_h_get_32
  792. (abfd, aux->x_file.x_n.x_n.x_offset);
  793. if (data->strings != NULL && off < data->strings_size)
  794. printf (" %s", data->strings + off);
  795. else
  796. printf (_("offset: %08x"), off);
  797. }
  798. putchar ('\n');
  799. }
  800. break;
  801. case C_BLOCK:
  802. case C_FCN:
  803. printf (" lnno: %u\n",
  804. (unsigned)bfd_h_get_16
  805. (abfd, aux->x_sym.x_misc.x_lnsz.x_lnno));
  806. break;
  807. default:
  808. /* Do not translate - generic field name. */
  809. printf ("aux\n");
  810. break;
  811. }
  812. }
  813. }
  814. free (debug);
  815. }
  816. /* Dump xcoff relocation entries. */
  817. static void
  818. dump_xcoff32_relocs (bfd *abfd, struct xcoff_dump *data)
  819. {
  820. unsigned int i;
  821. if (data->sects == NULL)
  822. {
  823. non_fatal (_("cannot read section headers"));
  824. return;
  825. }
  826. for (i = 0; i < data->nscns; i++)
  827. {
  828. struct xcoff32_section *sect = &data->sects[i];
  829. unsigned int nrel = sect->nreloc;
  830. unsigned int j;
  831. if (nrel == 0)
  832. continue;
  833. printf (_("Relocations for %s (%u)\n"), sect->name, nrel);
  834. if (bfd_seek (abfd, sect->relptr, SEEK_SET) != 0)
  835. {
  836. non_fatal (_("cannot read relocations"));
  837. continue;
  838. }
  839. /* Do not translate: fields name. */
  840. printf ("vaddr sgn mod sz type symndx symbol\n");
  841. for (j = 0; j < nrel; j++)
  842. {
  843. struct external_reloc rel;
  844. unsigned char rsize;
  845. unsigned int symndx;
  846. if (bfd_bread (&rel, sizeof (rel), abfd) != sizeof (rel))
  847. {
  848. non_fatal (_("cannot read relocation entry"));
  849. return;
  850. }
  851. rsize = bfd_h_get_8 (abfd, rel.r_size);
  852. printf ("%08x %c %c %-2u ",
  853. (unsigned int)bfd_h_get_32 (abfd, rel.r_vaddr),
  854. rsize & 0x80 ? 'S' : 'U',
  855. rsize & 0x40 ? 'm' : ' ',
  856. (rsize & 0x3f) + 1);
  857. dump_value (rtype_xlat, bfd_h_get_8 (abfd, rel.r_type), 6);
  858. symndx = bfd_h_get_32 (abfd, rel.r_symndx);
  859. printf ("%-6u ", symndx);
  860. xcoff32_print_symbol (data, symndx);
  861. putchar ('\n');
  862. }
  863. putchar ('\n');
  864. }
  865. }
  866. /* Dump xcoff line number entries. */
  867. static void
  868. dump_xcoff32_lineno (bfd *abfd, struct xcoff_dump *data)
  869. {
  870. unsigned int i;
  871. if (data->sects == NULL)
  872. {
  873. non_fatal (_("cannot read section headers"));
  874. return;
  875. }
  876. for (i = 0; i < data->nscns; i++)
  877. {
  878. struct xcoff32_section *sect = &data->sects[i];
  879. unsigned int nlnno = sect->nlnno;
  880. unsigned int j;
  881. if (nlnno == 0)
  882. continue;
  883. printf (_("Line numbers for %s (%u)\n"), sect->name, nlnno);
  884. if (bfd_seek (abfd, sect->lnnoptr, SEEK_SET) != 0)
  885. {
  886. non_fatal (_("cannot read line numbers"));
  887. continue;
  888. }
  889. /* Line number, symbol index and physical address. */
  890. printf (_("lineno symndx/paddr\n"));
  891. for (j = 0; j < nlnno; j++)
  892. {
  893. struct external_lineno ln;
  894. unsigned int no;
  895. if (bfd_bread (&ln, sizeof (ln), abfd) != sizeof (ln))
  896. {
  897. non_fatal (_("cannot read line number entry"));
  898. return;
  899. }
  900. no = bfd_h_get_16 (abfd, ln.l_lnno);
  901. printf (" %-6u ", no);
  902. if (no == 0)
  903. {
  904. unsigned int symndx = bfd_h_get_32 (abfd, ln.l_addr.l_symndx);
  905. xcoff32_print_symbol (data, symndx);
  906. }
  907. else
  908. printf ("0x%08x",
  909. (unsigned int)bfd_h_get_32 (abfd, ln.l_addr.l_paddr));
  910. putchar ('\n');
  911. }
  912. }
  913. }
  914. /* Dump xcoff loader section. */
  915. static void
  916. dump_xcoff32_loader (bfd *abfd)
  917. {
  918. asection *loader;
  919. bfd_size_type size = 0;
  920. struct external_ldhdr *lhdr;
  921. struct external_ldsym *ldsym;
  922. struct external_ldrel *ldrel;
  923. bfd_byte *ldr_data;
  924. unsigned int version;
  925. unsigned int ndsyms;
  926. unsigned int ndrel;
  927. unsigned int stlen;
  928. unsigned int stoff;
  929. unsigned int impoff;
  930. unsigned int nimpid;
  931. unsigned int i;
  932. const char *p;
  933. loader = bfd_get_section_by_name (abfd, ".loader");
  934. if (loader == NULL)
  935. {
  936. printf (_("no .loader section in file\n"));
  937. return;
  938. }
  939. size = bfd_get_section_size (loader);
  940. if (size < sizeof (*lhdr))
  941. {
  942. printf (_("section .loader is too short\n"));
  943. return;
  944. }
  945. ldr_data = (bfd_byte *) xmalloc (size);
  946. bfd_get_section_contents (abfd, loader, ldr_data, 0, size);
  947. lhdr = (struct external_ldhdr *)ldr_data;
  948. printf (_("Loader header:\n"));
  949. version = bfd_h_get_32 (abfd, lhdr->l_version);
  950. printf (_(" version: %u\n"), version);
  951. if (version != 1)
  952. {
  953. printf (_(" Unhandled version\n"));
  954. free (ldr_data);
  955. return;
  956. }
  957. ndsyms = bfd_h_get_32 (abfd, lhdr->l_nsyms);
  958. printf (_(" nbr symbols: %u\n"), ndsyms);
  959. ndrel = bfd_h_get_32 (abfd, lhdr->l_nreloc);
  960. printf (_(" nbr relocs: %u\n"), ndrel);
  961. /* Import string table length. */
  962. printf (_(" import strtab len: %u\n"),
  963. (unsigned) bfd_h_get_32 (abfd, lhdr->l_istlen));
  964. nimpid = bfd_h_get_32 (abfd, lhdr->l_nimpid);
  965. printf (_(" nbr import files: %u\n"), nimpid);
  966. impoff = bfd_h_get_32 (abfd, lhdr->l_impoff);
  967. printf (_(" import file off: %u\n"), impoff);
  968. stlen = bfd_h_get_32 (abfd, lhdr->l_stlen);
  969. printf (_(" string table len: %u\n"), stlen);
  970. stoff = bfd_h_get_32 (abfd, lhdr->l_stoff);
  971. printf (_(" string table off: %u\n"), stoff);
  972. ldsym = (struct external_ldsym *)(ldr_data + sizeof (*lhdr));
  973. printf (_("Dynamic symbols:\n"));
  974. /* Do not translate: field names. */
  975. printf (" # value sc IFEW ty class file pa name\n");
  976. for (i = 0; i < ndsyms; i++, ldsym++)
  977. {
  978. unsigned char smtype;
  979. printf (_(" %4u %08x %3u "), i,
  980. (unsigned)bfd_h_get_32 (abfd, ldsym->l_value),
  981. (unsigned)bfd_h_get_16 (abfd, ldsym->l_scnum));
  982. smtype = bfd_h_get_8 (abfd, ldsym->l_smtype);
  983. putchar (smtype & 0x40 ? 'I' : ' ');
  984. putchar (smtype & 0x20 ? 'F' : ' ');
  985. putchar (smtype & 0x10 ? 'E' : ' ');
  986. putchar (smtype & 0x08 ? 'W' : ' ');
  987. putchar (' ');
  988. dump_value (smtyp_xlat, SMTYP_SMTYP (smtype), 2);
  989. putchar (' ');
  990. dump_value
  991. (smclas_xlat, (unsigned)bfd_h_get_8 (abfd, ldsym->l_smclas), 6);
  992. printf (_(" %3u %3u "),
  993. (unsigned)bfd_h_get_32 (abfd, ldsym->l_ifile),
  994. (unsigned)bfd_h_get_32 (abfd, ldsym->l_parm));
  995. if (ldsym->_l._l_name[0] != 0)
  996. printf ("%-.8s", ldsym->_l._l_name);
  997. else
  998. {
  999. unsigned int off = bfd_h_get_32 (abfd, ldsym->_l._l_l._l_offset);
  1000. if (off > stlen)
  1001. printf (_("(bad offset: %u)"), off);
  1002. else
  1003. printf ("%s", ldr_data + stoff + off);
  1004. }
  1005. putchar ('\n');
  1006. }
  1007. printf (_("Dynamic relocs:\n"));
  1008. /* Do not translate fields name. */
  1009. printf (" vaddr sec sz typ sym\n");
  1010. ldrel = (struct external_ldrel *)(ldr_data + sizeof (*lhdr)
  1011. + ndsyms * sizeof (*ldsym));
  1012. for (i = 0; i < ndrel; i++, ldrel++)
  1013. {
  1014. unsigned int rsize;
  1015. unsigned int rtype;
  1016. unsigned int symndx;
  1017. rsize = bfd_h_get_8 (abfd, ldrel->l_rtype + 0);
  1018. rtype = bfd_h_get_8 (abfd, ldrel->l_rtype + 1);
  1019. printf (" %08x %3u %c%c %2u ",
  1020. (unsigned)bfd_h_get_32 (abfd, ldrel->l_vaddr),
  1021. (unsigned)bfd_h_get_16 (abfd, ldrel->l_rsecnm),
  1022. rsize & 0x80 ? 'S' : 'U',
  1023. rsize & 0x40 ? 'm' : ' ',
  1024. (rsize & 0x3f) + 1);
  1025. dump_value (rtype_xlat, rtype, 6);
  1026. symndx = bfd_h_get_32 (abfd, ldrel->l_symndx);
  1027. switch (symndx)
  1028. {
  1029. case 0:
  1030. printf (".text");
  1031. break;
  1032. case 1:
  1033. printf (".data");
  1034. break;
  1035. case 2:
  1036. printf (".bss");
  1037. break;
  1038. default:
  1039. printf ("%u", symndx - 3);
  1040. break;
  1041. }
  1042. putchar ('\n');
  1043. }
  1044. printf (_("Import files:\n"));
  1045. p = (char *)ldr_data + impoff;
  1046. for (i = 0; i < nimpid; i++)
  1047. {
  1048. int n1, n2, n3;
  1049. n1 = strlen (p);
  1050. n2 = strlen (p + n1 + 1);
  1051. n3 = strlen (p + n1 + 1 + n2+ 1);
  1052. printf (" %2u: %s,%s,%s\n", i,
  1053. p, p + n1 + 1, p + n1 + n2 + 2);
  1054. p += n1 + n2 + n3 + 3;
  1055. }
  1056. free (ldr_data);
  1057. }
  1058. /* Dump xcoff exception section. */
  1059. static void
  1060. dump_xcoff32_except (bfd *abfd, struct xcoff_dump *data)
  1061. {
  1062. asection *sec;
  1063. bfd_size_type size = 0;
  1064. bfd_byte *excp_data;
  1065. struct external_exceptab *exceptab;
  1066. unsigned int i;
  1067. sec = bfd_get_section_by_name (abfd, ".except");
  1068. if (sec == NULL)
  1069. {
  1070. printf (_("no .except section in file\n"));
  1071. return;
  1072. }
  1073. size = bfd_get_section_size (sec);
  1074. excp_data = (bfd_byte *) xmalloc (size);
  1075. bfd_get_section_contents (abfd, sec, excp_data, 0, size);
  1076. exceptab = (struct external_exceptab *)excp_data;
  1077. printf (_("Exception table:\n"));
  1078. /* Do not translate fields name. */
  1079. printf ("lang reason sym/addr\n");
  1080. for (i = 0; i * sizeof (*exceptab) < size; i++, exceptab++)
  1081. {
  1082. unsigned int reason;
  1083. unsigned int addr;
  1084. addr = bfd_get_32 (abfd, exceptab->e_addr.e_paddr);
  1085. reason = bfd_get_8 (abfd, exceptab->e_reason);
  1086. printf (" %02x %02x ",
  1087. (unsigned) bfd_get_8 (abfd, exceptab->e_lang), reason);
  1088. if (reason == 0)
  1089. xcoff32_print_symbol (data, addr);
  1090. else
  1091. printf ("@%08x", addr);
  1092. putchar ('\n');
  1093. }
  1094. free (excp_data);
  1095. }
  1096. /* Dump xcoff type-check section. */
  1097. static void
  1098. dump_xcoff32_typchk (bfd *abfd)
  1099. {
  1100. asection *sec;
  1101. bfd_size_type size = 0;
  1102. bfd_byte *data;
  1103. unsigned int i;
  1104. sec = bfd_get_section_by_name (abfd, ".typchk");
  1105. if (sec == NULL)
  1106. {
  1107. printf (_("no .typchk section in file\n"));
  1108. return;
  1109. }
  1110. size = bfd_get_section_size (sec);
  1111. data = (bfd_byte *) xmalloc (size);
  1112. bfd_get_section_contents (abfd, sec, data, 0, size);
  1113. printf (_("Type-check section:\n"));
  1114. /* Do not translate field names. */
  1115. printf ("offset len lang-id general-hash language-hash\n");
  1116. for (i = 0; i < size;)
  1117. {
  1118. unsigned int len;
  1119. len = bfd_get_16 (abfd, data + i);
  1120. printf ("%08x: %-4u ", i, len);
  1121. i += 2;
  1122. if (len == 10)
  1123. {
  1124. /* Expected format. */
  1125. printf ("%04x %08x %08x\n",
  1126. (unsigned) bfd_get_16 (abfd, data + i),
  1127. (unsigned) bfd_get_32 (abfd, data + i + 2),
  1128. (unsigned) bfd_get_32 (abfd, data + i + 2 + 4));
  1129. }
  1130. else
  1131. {
  1132. unsigned int j;
  1133. for (j = 0; j < len; j++)
  1134. {
  1135. if (j % 16 == 0)
  1136. printf ("\n ");
  1137. printf (" %02x", (unsigned char)data[i + j]);
  1138. }
  1139. putchar ('\n');
  1140. }
  1141. i += len;
  1142. }
  1143. free (data);
  1144. }
  1145. /* Dump xcoff traceback tags section. */
  1146. static void
  1147. dump_xcoff32_tbtags (bfd *abfd,
  1148. const char *text, bfd_size_type text_size,
  1149. unsigned int text_start, unsigned int func_start)
  1150. {
  1151. unsigned int i;
  1152. if (func_start - text_start > text_size)
  1153. {
  1154. printf (_(" address beyond section size\n"));
  1155. return;
  1156. }
  1157. for (i = func_start - text_start; i < text_size; i+= 4)
  1158. if (bfd_get_32 (abfd, text + i) == 0)
  1159. {
  1160. unsigned int tb1;
  1161. unsigned int tb2;
  1162. unsigned int off;
  1163. printf (_(" tags at %08x\n"), i + 4);
  1164. if (i + 8 >= text_size)
  1165. goto truncated;
  1166. tb1 = bfd_get_32 (abfd, text + i + 4);
  1167. tb2 = bfd_get_32 (abfd, text + i + 8);
  1168. off = i + 12;
  1169. printf (" version: %u, lang: %u, global_link: %u, is_eprol: %u, has_tboff: %u, int_proc: %u\n",
  1170. (tb1 >> 24) & 0xff,
  1171. (tb1 >> 16) & 0xff,
  1172. (tb1 >> 15) & 1,
  1173. (tb1 >> 14) & 1,
  1174. (tb1 >> 13) & 1,
  1175. (tb1 >> 12) & 1);
  1176. printf (" has_ctl: %u, tocless: %u, fp_pres: %u, log_abort: %u, int_hndl: %u\n",
  1177. (tb1 >> 11) & 1,
  1178. (tb1 >> 10) & 1,
  1179. (tb1 >> 9) & 1,
  1180. (tb1 >> 8) & 1,
  1181. (tb1 >> 7) & 1);
  1182. printf (" name_pres: %u, uses_alloca: %u, cl_dis_inv: %u, saves_cr: %u, saves_lr: %u\n",
  1183. (tb1 >> 6) & 1,
  1184. (tb1 >> 5) & 1,
  1185. (tb1 >> 2) & 7,
  1186. (tb1 >> 1) & 1,
  1187. (tb1 >> 0) & 1);
  1188. printf (" stores_bc: %u, fixup: %u, fpr_saved: %-2u, spare3: %u, gpr_saved: %-2u\n",
  1189. (tb2 >> 31) & 1,
  1190. (tb2 >> 30) & 1,
  1191. (tb2 >> 24) & 63,
  1192. (tb2 >> 22) & 3,
  1193. (tb2 >> 16) & 63);
  1194. printf (" fixparms: %-3u floatparms: %-3u parm_on_stk: %u\n",
  1195. (tb2 >> 8) & 0xff,
  1196. (tb2 >> 1) & 0x7f,
  1197. (tb2 >> 0) & 1);
  1198. if (((tb2 >> 1) & 0x7fff) != 0)
  1199. {
  1200. unsigned int parminfo;
  1201. if (off >= text_size)
  1202. goto truncated;
  1203. parminfo = bfd_get_32 (abfd, text + off);
  1204. off += 4;
  1205. printf (" parminfo: 0x%08x\n", parminfo);
  1206. }
  1207. if ((tb1 >> 13) & 1)
  1208. {
  1209. unsigned int tboff;
  1210. if (off >= text_size)
  1211. goto truncated;
  1212. tboff = bfd_get_32 (abfd, text + off);
  1213. off += 4;
  1214. printf (" tb_offset: 0x%08x (start=0x%08x)\n",
  1215. tboff, text_start + i - tboff);
  1216. }
  1217. if ((tb1 >> 7) & 1)
  1218. {
  1219. unsigned int hand_mask;
  1220. if (off >= text_size)
  1221. goto truncated;
  1222. hand_mask = bfd_get_32 (abfd, text + off);
  1223. off += 4;
  1224. printf (" hand_mask_offset: 0x%08x\n", hand_mask);
  1225. }
  1226. if ((tb1 >> 11) & 1)
  1227. {
  1228. unsigned int ctl_info;
  1229. unsigned int j;
  1230. if (off >= text_size)
  1231. goto truncated;
  1232. ctl_info = bfd_get_32 (abfd, text + off);
  1233. off += 4;
  1234. printf (_(" number of CTL anchors: %u\n"), ctl_info);
  1235. for (j = 0; j < ctl_info; j++)
  1236. {
  1237. if (off >= text_size)
  1238. goto truncated;
  1239. printf (" CTL[%u]: %08x\n",
  1240. j, (unsigned)bfd_get_32 (abfd, text + off));
  1241. off += 4;
  1242. }
  1243. }
  1244. if ((tb1 >> 6) & 1)
  1245. {
  1246. unsigned int name_len;
  1247. unsigned int j;
  1248. if (off >= text_size)
  1249. goto truncated;
  1250. name_len = bfd_get_16 (abfd, text + off);
  1251. off += 2;
  1252. printf (_(" Name (len: %u): "), name_len);
  1253. if (off + name_len >= text_size)
  1254. {
  1255. printf (_("[truncated]\n"));
  1256. goto truncated;
  1257. }
  1258. for (j = 0; j < name_len; j++)
  1259. if (ISPRINT (text[off + j]))
  1260. putchar (text[off + j]);
  1261. else
  1262. printf ("[%02x]", (unsigned char)text[off + j]);
  1263. putchar ('\n');
  1264. off += name_len;
  1265. }
  1266. if ((tb1 >> 5) & 1)
  1267. {
  1268. if (off >= text_size)
  1269. goto truncated;
  1270. printf (" alloca reg: %u\n",
  1271. (unsigned) bfd_get_8 (abfd, text + off));
  1272. off++;
  1273. }
  1274. printf (_(" (end of tags at %08x)\n"), text_start + off);
  1275. return;
  1276. }
  1277. printf (_(" no tags found\n"));
  1278. return;
  1279. truncated:
  1280. printf (_(" Truncated .text section\n"));
  1281. return;
  1282. }
  1283. static void
  1284. dump_xcoff32_traceback (bfd *abfd, struct xcoff_dump *data)
  1285. {
  1286. unsigned int i;
  1287. unsigned int scnum_text = -1;
  1288. unsigned int text_vma;
  1289. asection *text_sec;
  1290. bfd_size_type text_size;
  1291. char *text;
  1292. if (data->syms == NULL || data->sects == NULL)
  1293. return;
  1294. /* Read text section. */
  1295. text_sec = bfd_get_section_by_name (abfd, ".text");
  1296. if (text_sec == NULL)
  1297. return;
  1298. text_vma = bfd_get_section_vma (abfd, text_sec);
  1299. text_size = bfd_get_section_size (text_sec);
  1300. text = (char *) xmalloc (text_size);
  1301. bfd_get_section_contents (abfd, text_sec, text, 0, text_size);
  1302. for (i = 0; i < data->nscns; i++)
  1303. if (data->sects[i].flags == STYP_TEXT)
  1304. {
  1305. scnum_text = i + 1;
  1306. break;
  1307. }
  1308. if (scnum_text == (unsigned int)-1)
  1309. return;
  1310. for (i = 0; i < data->nsyms; i++)
  1311. {
  1312. union xcoff32_symbol *s = &data->syms[i];
  1313. switch (s->sym.sclass)
  1314. {
  1315. case C_EXT:
  1316. case C_HIDEXT:
  1317. case C_WEAKEXT:
  1318. if (s->sym.scnum == scnum_text
  1319. && s->sym.numaux > 0)
  1320. {
  1321. union external_auxent *aux = &s[s->sym.numaux].aux;
  1322. unsigned int smtyp;
  1323. unsigned int smclas;
  1324. smtyp = bfd_h_get_8 (abfd, aux->x_csect.x_smtyp);
  1325. smclas = bfd_h_get_8 (abfd, aux->x_csect.x_smclas);
  1326. if (SMTYP_SMTYP (smtyp) == XTY_LD
  1327. && (smclas == XMC_PR
  1328. || smclas == XMC_GL
  1329. || smclas == XMC_XO))
  1330. {
  1331. printf ("%08x: ", s->sym.val);
  1332. xcoff32_print_symbol (data, i);
  1333. putchar ('\n');
  1334. dump_xcoff32_tbtags (abfd, text, text_size,
  1335. text_vma, s->sym.val);
  1336. }
  1337. }
  1338. break;
  1339. default:
  1340. break;
  1341. }
  1342. i += s->sym.numaux;
  1343. }
  1344. free (text);
  1345. }
  1346. /* Dump the TOC symbols. */
  1347. static void
  1348. dump_xcoff32_toc (bfd *abfd, struct xcoff_dump *data)
  1349. {
  1350. unsigned int i;
  1351. unsigned int nbr_ent;
  1352. unsigned int size;
  1353. printf (_("TOC:\n"));
  1354. if (data->syms == NULL)
  1355. return;
  1356. nbr_ent = 0;
  1357. size = 0;
  1358. for (i = 0; i < data->nsyms; i++)
  1359. {
  1360. union xcoff32_symbol *s = &data->syms[i];
  1361. switch (s->sym.sclass)
  1362. {
  1363. case C_EXT:
  1364. case C_HIDEXT:
  1365. case C_WEAKEXT:
  1366. if (s->sym.numaux > 0)
  1367. {
  1368. union external_auxent *aux = &s[s->sym.numaux].aux;
  1369. unsigned int smclas;
  1370. unsigned int ent_sz;
  1371. smclas = bfd_h_get_8 (abfd, aux->x_csect.x_smclas);
  1372. if (smclas == XMC_TC
  1373. || smclas == XMC_TD
  1374. || smclas == XMC_TC0)
  1375. {
  1376. ent_sz = bfd_h_get_32 (abfd, aux->x_scn.x_scnlen);
  1377. printf ("%08x %08x ",
  1378. s->sym.val, ent_sz);
  1379. xcoff32_print_symbol (data, i);
  1380. putchar ('\n');
  1381. nbr_ent++;
  1382. size += ent_sz;
  1383. }
  1384. }
  1385. break;
  1386. default:
  1387. break;
  1388. }
  1389. i += s->sym.numaux;
  1390. }
  1391. printf (_("Nbr entries: %-8u Size: %08x (%u)\n"),
  1392. nbr_ent, size, size);
  1393. }
  1394. /* Handle an rs6000 xcoff file. */
  1395. static void
  1396. dump_xcoff32 (bfd *abfd, struct external_filehdr *fhdr)
  1397. {
  1398. struct xcoff_dump data;
  1399. data.nscns = bfd_h_get_16 (abfd, fhdr->f_nscns);
  1400. data.symptr = bfd_h_get_32 (abfd, fhdr->f_symptr);
  1401. data.nsyms = bfd_h_get_32 (abfd, fhdr->f_nsyms);
  1402. data.opthdr = bfd_h_get_16 (abfd, fhdr->f_opthdr);
  1403. data.sects = NULL;
  1404. data.syms = NULL;
  1405. data.strings = NULL;
  1406. data.strings_size = 0;
  1407. if (options[OPT_FILE_HEADER].selected)
  1408. dump_xcoff32_file_header (abfd, fhdr, &data);
  1409. if (options[OPT_AOUT].selected)
  1410. dump_xcoff32_aout_header (abfd, &data);
  1411. if (options[OPT_SYMS].selected
  1412. || options[OPT_RELOCS].selected
  1413. || options[OPT_LINENO].selected
  1414. || options[OPT_TRACEBACK].selected)
  1415. xcoff32_read_sections (abfd, &data);
  1416. if (options[OPT_SECTIONS].selected)
  1417. dump_xcoff32_sections_header (abfd, &data);
  1418. if (options[OPT_SYMS].selected
  1419. || options[OPT_RELOCS].selected
  1420. || options[OPT_LINENO].selected
  1421. || options[OPT_EXCEPT].selected
  1422. || options[OPT_TRACEBACK].selected
  1423. || options[OPT_TOC].selected)
  1424. xcoff32_read_symbols (abfd, &data);
  1425. if (options[OPT_SYMS].selected)
  1426. dump_xcoff32_symbols (abfd, &data);
  1427. if (options[OPT_RELOCS].selected)
  1428. dump_xcoff32_relocs (abfd, &data);
  1429. if (options[OPT_LINENO].selected)
  1430. dump_xcoff32_lineno (abfd, &data);
  1431. if (options[OPT_LOADER].selected)
  1432. dump_xcoff32_loader (abfd);
  1433. if (options[OPT_EXCEPT].selected)
  1434. dump_xcoff32_except (abfd, &data);
  1435. if (options[OPT_TYPCHK].selected)
  1436. dump_xcoff32_typchk (abfd);
  1437. if (options[OPT_TRACEBACK].selected)
  1438. dump_xcoff32_traceback (abfd, &data);
  1439. if (options[OPT_TOC].selected)
  1440. dump_xcoff32_toc (abfd, &data);
  1441. free (data.sects);
  1442. free (data.strings);
  1443. free (data.syms);
  1444. }
  1445. /* Dump ABFD (according to the options[] array). */
  1446. static void
  1447. xcoff_dump_obj (bfd *abfd)
  1448. {
  1449. struct external_filehdr fhdr;
  1450. unsigned short magic;
  1451. /* Read file header. */
  1452. if (bfd_seek (abfd, 0, SEEK_SET) != 0
  1453. || bfd_bread (&fhdr, sizeof (fhdr), abfd) != sizeof (fhdr))
  1454. {
  1455. non_fatal (_("cannot read header"));
  1456. return;
  1457. }
  1458. /* Decoding. We don't use the bfd/coff function to get all the fields. */
  1459. magic = bfd_h_get_16 (abfd, fhdr.f_magic);
  1460. if (options[OPT_FILE_HEADER].selected)
  1461. {
  1462. printf (_("File header:\n"));
  1463. printf (_(" magic: 0x%04x (0%04o) "), magic, magic);
  1464. switch (magic)
  1465. {
  1466. case U802WRMAGIC:
  1467. printf (_("(WRMAGIC: writable text segments)"));
  1468. break;
  1469. case U802ROMAGIC:
  1470. printf (_("(ROMAGIC: readonly sharablee text segments)"));
  1471. break;
  1472. case U802TOCMAGIC:
  1473. printf (_("(TOCMAGIC: readonly text segments and TOC)"));
  1474. break;
  1475. default:
  1476. printf (_("unknown magic"));
  1477. break;
  1478. }
  1479. putchar ('\n');
  1480. }
  1481. if (magic == U802ROMAGIC || magic == U802WRMAGIC || magic == U802TOCMAGIC)
  1482. dump_xcoff32 (abfd, &fhdr);
  1483. else
  1484. printf (_(" Unhandled magic\n"));
  1485. }
  1486. /* Handle an AIX dumpx core file. */
  1487. static void
  1488. dump_dumpx_core (bfd *abfd, struct external_core_dumpx *hdr)
  1489. {
  1490. if (options[OPT_FILE_HEADER].selected)
  1491. {
  1492. printf (" signal: %u\n", bfd_h_get_8 (abfd, hdr->c_signo));
  1493. printf (" flags: 0x%02x\n", bfd_h_get_8 (abfd, hdr->c_flag));
  1494. printf (" entries: %u\n",
  1495. (unsigned) bfd_h_get_16 (abfd, hdr->c_entries));
  1496. #ifdef BFD64
  1497. printf (" fdsinfox: offset: 0x%08" BFD_VMA_FMT "x\n",
  1498. bfd_h_get_64 (abfd, hdr->c_fdsinfox));
  1499. printf (" loader: offset: 0x%08" BFD_VMA_FMT "x, "
  1500. "size: 0x%" BFD_VMA_FMT"x\n",
  1501. bfd_h_get_64 (abfd, hdr->c_loader),
  1502. bfd_h_get_64 (abfd, hdr->c_lsize));
  1503. printf (" thr: offset: 0x%08" BFD_VMA_FMT "x, nbr: %u\n",
  1504. bfd_h_get_64 (abfd, hdr->c_thr),
  1505. (unsigned) bfd_h_get_32 (abfd, hdr->c_n_thr));
  1506. printf (" segregions: offset: 0x%08" BFD_VMA_FMT "x, "
  1507. "nbr: %" BFD_VMA_FMT "u\n",
  1508. bfd_h_get_64 (abfd, hdr->c_segregion),
  1509. bfd_h_get_64 (abfd, hdr->c_segs));
  1510. printf (" stack: offset: 0x%08" BFD_VMA_FMT "x, "
  1511. "org: 0x%" BFD_VMA_FMT"x, "
  1512. "size: 0x%" BFD_VMA_FMT"x\n",
  1513. bfd_h_get_64 (abfd, hdr->c_stack),
  1514. bfd_h_get_64 (abfd, hdr->c_stackorg),
  1515. bfd_h_get_64 (abfd, hdr->c_size));
  1516. printf (" data: offset: 0x%08" BFD_VMA_FMT "x, "
  1517. "org: 0x%" BFD_VMA_FMT"x, "
  1518. "size: 0x%" BFD_VMA_FMT"x\n",
  1519. bfd_h_get_64 (abfd, hdr->c_data),
  1520. bfd_h_get_64 (abfd, hdr->c_dataorg),
  1521. bfd_h_get_64 (abfd, hdr->c_datasize));
  1522. printf (" sdata: org: 0x%" BFD_VMA_FMT"x, "
  1523. "size: 0x%" BFD_VMA_FMT"x\n",
  1524. bfd_h_get_64 (abfd, hdr->c_sdorg),
  1525. bfd_h_get_64 (abfd, hdr->c_sdsize));
  1526. printf (" vmmregions: offset: 0x%" BFD_VMA_FMT"x, "
  1527. "num: 0x%" BFD_VMA_FMT"x\n",
  1528. bfd_h_get_64 (abfd, hdr->c_vmm),
  1529. bfd_h_get_64 (abfd, hdr->c_vmmregions));
  1530. printf (" impl: 0x%08x\n",
  1531. (unsigned) bfd_h_get_32 (abfd, hdr->c_impl));
  1532. printf (" cprs: 0x%" BFD_VMA_FMT "x\n",
  1533. bfd_h_get_64 (abfd, hdr->c_cprs));
  1534. #endif
  1535. }
  1536. if (options[OPT_LDINFO].selected)
  1537. {
  1538. #ifdef BFD64
  1539. file_ptr off = (file_ptr) bfd_h_get_64 (abfd, hdr->c_loader);
  1540. bfd_size_type len = (bfd_size_type) bfd_h_get_64 (abfd, hdr->c_lsize);
  1541. char *ldr;
  1542. ldr = xmalloc (len);
  1543. if (bfd_seek (abfd, off, SEEK_SET) != 0
  1544. || bfd_bread (ldr, len, abfd) != len)
  1545. non_fatal (_("cannot read loader info table"));
  1546. else
  1547. {
  1548. char *p;
  1549. printf ("\n"
  1550. "ld info:\n");
  1551. printf (" next core off textorg textsize dataorg datasize\n");
  1552. p = ldr;
  1553. while (1)
  1554. {
  1555. struct external_ld_info32 *l = (struct external_ld_info32 *)p;
  1556. unsigned int next;
  1557. size_t n1;
  1558. next = bfd_h_get_32 (abfd, l->ldinfo_next);
  1559. printf (" %08x %08x %08x %08x %08x %08x\n",
  1560. next,
  1561. (unsigned) bfd_h_get_32 (abfd, l->core_offset),
  1562. (unsigned) bfd_h_get_32 (abfd, l->ldinfo_textorg),
  1563. (unsigned) bfd_h_get_32 (abfd, l->ldinfo_textsize),
  1564. (unsigned) bfd_h_get_32 (abfd, l->ldinfo_dataorg),
  1565. (unsigned) bfd_h_get_32 (abfd, l->ldinfo_datasize));
  1566. n1 = strlen ((char *) l->ldinfo_filename);
  1567. printf (" %s %s\n",
  1568. l->ldinfo_filename, l->ldinfo_filename + n1 + 1);
  1569. if (next == 0)
  1570. break;
  1571. p += next;
  1572. }
  1573. }
  1574. #else
  1575. printf (_("\n"
  1576. "ldinfo dump not supported in 32 bits environments\n"));
  1577. #endif
  1578. }
  1579. }
  1580. /* Dump a core file. */
  1581. static void
  1582. xcoff_dump_core (bfd *abfd)
  1583. {
  1584. struct external_core_dumpx hdr;
  1585. unsigned int version;
  1586. /* Read file header. */
  1587. if (bfd_seek (abfd, 0, SEEK_SET) != 0
  1588. || bfd_bread (&hdr, sizeof (hdr), abfd) != sizeof (hdr))
  1589. {
  1590. non_fatal (_("cannot core read header"));
  1591. return;
  1592. }
  1593. version = bfd_h_get_32 (abfd, hdr.c_version);
  1594. if (options[OPT_FILE_HEADER].selected)
  1595. {
  1596. printf (_("Core header:\n"));
  1597. printf (_(" version: 0x%08x "), version);
  1598. switch (version)
  1599. {
  1600. case CORE_DUMPX_VERSION:
  1601. printf (_("(dumpx format - aix4.3 / 32 bits)"));
  1602. break;
  1603. case CORE_DUMPXX_VERSION:
  1604. printf (_("(dumpxx format - aix5.0 / 64 bits)"));
  1605. break;
  1606. default:
  1607. printf (_("unknown format"));
  1608. break;
  1609. }
  1610. putchar ('\n');
  1611. }
  1612. if (version == CORE_DUMPX_VERSION)
  1613. dump_dumpx_core (abfd, &hdr);
  1614. else
  1615. printf (_(" Unhandled magic\n"));
  1616. }
  1617. /* Dump an XCOFF file. */
  1618. static void
  1619. xcoff_dump (bfd *abfd)
  1620. {
  1621. /* We rely on BFD to decide if the file is a core file. Note that core
  1622. files are only supported on native environment by BFD. */
  1623. switch (bfd_get_format (abfd))
  1624. {
  1625. case bfd_core:
  1626. xcoff_dump_core (abfd);
  1627. break;
  1628. default:
  1629. xcoff_dump_obj (abfd);
  1630. break;
  1631. }
  1632. }
  1633. /* Vector for xcoff. */
  1634. const struct objdump_private_desc objdump_private_desc_xcoff =
  1635. {
  1636. xcoff_help,
  1637. xcoff_filter,
  1638. xcoff_dump,
  1639. options
  1640. };