1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651
|
/*
Copyright (C) 2000,2002,2004,2005 Silicon Graphics, Inc. All Rights Reserved.
Portions Copyright (C) 2007-2020 David Anderson. All Rights Reserved.
Portions Copyright 2007-2010 Sun Microsystems, Inc. All rights reserved.
Portions Copyright 2012 SN Systems Ltd. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of version 2 of the GNU General
Public License as published by the Free Software Foundation.
This program is distributed in the hope that it would be
useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
Further, this software is distributed without any warranty
that it is free of the rightful claim of any third person
regarding infringement or the like. Any license provided
herein, whether implied or otherwise, applies only to this
software file. Patent licenses, if any, provided herein
do not apply to combinations of this program with other
software, or any other product whatsoever.
You should have received a copy of the GNU General Public
License along with this program; if not, write the Free
Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
Boston MA 02110-1301, USA.
*/
/* The address of the Free Software Foundation is
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Boston, MA 02110-1301, USA.
SGI has moved from the Crittenden Lane address.
*/
#include "globals.h"
/* for 'open' */
#ifdef SYS_TYPES_H
#include <sys/types.h>
#endif /* SYS_TYPES_H */
#ifdef SYS_STAT_H
#include <sys/stat.h>
#endif /* SYS_STAT_H */
#include <fcntl.h>
#include <limits.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h> /* for dup2() */
#elif defined(_WIN32) && defined(_MSC_VER)
#include <io.h>
#endif
#include "makename.h"
#include "macrocheck.h"
#include "dwconf.h"
#include "dwconf_using_functions.h"
#include "common.h"
#include "helpertree.h"
#include "esb.h" /* For flexible string buffer. */
#include "esb_using_functions.h"
#include "sanitized.h"
#include "tag_common.h"
#include "addrmap.h"
#include "print_debug_gnu.h"
#include "naming.h" /* for get_FORM_name() */
#include "libdwarf_version.h" /* for DW_VERSION_DATE_STR */
#include "command_options.h"
#include "compiler_info.h"
#ifndef O_RDONLY
/* This is for a Windows environment */
# define O_RDONLY _O_RDONLY
#endif
#ifdef _O_BINARY
/* This is for a Windows environment */
#define O_BINARY _O_BINARY
#else
# ifndef O_BINARY
# define O_BINARY 0 /* So it does nothing in Linux/Unix */
# endif
#endif /* O_BINARY */
#ifdef HAVE_ELF_OPEN
extern int elf_open(const char *name,int mode);
#endif /* HAVE_ELF_OPEN */
#ifdef HAVE_CUSTOM_LIBELF
extern int elf_is_custom_format(void *header, size_t headerlen, size_t *size,
unsigned *endian, unsigned *offsetsize, int *errcode);
#endif /* HAVE_CUSTOM_LIBELF */
#define BYTES_PER_INSTRUCTION 4
/* The type of Bucket. */
#define KIND_RANGES_INFO 1
#define KIND_SECTIONS_INFO 2
#define KIND_VISITED_INFO 3
/* Build section information */
void build_linkonce_info(Dwarf_Debug dbg);
struct glflags_s glflags;
/* Functions used to manage the unique errors table */
static void allocate_unique_errors_table(void);
static void release_unique_errors_table(void);
#ifdef TESTING
static void dump_unique_errors_table(void);
#endif
static boolean add_to_unique_errors_table(char * error_text);
static struct esb_s esb_short_cu_name;
static struct esb_s esb_long_cu_name;
static struct esb_s dwarf_error_line;
static int global_basefd = -1;
static int global_tiedfd = -1;
static struct esb_s global_file_name;
static struct esb_s global_tied_file_name;
static int process_one_file(int fd, int tiedfd,
Elf *efp, Elf * tiedfp,
const char * file_name,
const char * tied_file_name,
char * tempbuf,
unsigned int tempbuflen,
#ifdef DWARF_WITH_LIBELF
int archive,
#endif
struct dwconf_s *conf);
static int print_gnu_debuglink(Dwarf_Debug dbg,Dwarf_Error *err);
static int
open_a_file(const char * name)
{
/* Set to a file number that cannot be legal. */
int fd = -1;
#if HAVE_ELF_OPEN
/* It is not possible to share file handles
between applications or DLLs. Each application has its own
file-handle table. For two applications to use the same file
using a DLL, they must both open the file individually.
Let the 'libelf' dll open and close the file. */
fd = elf_open(name, O_RDONLY | O_BINARY);
#else
fd = open(name, O_RDONLY | O_BINARY);
#endif
return fd;
}
static void
close_a_file(int f)
{
if (f != -1) {
close(f);
}
}
static void
global_destructors(void)
{
makename_destructor();
uri_data_destructor();
esb_destructor(&esb_long_cu_name);
esb_destructor(&esb_short_cu_name);
esb_destructor(&dwarf_error_line);
esb_destructor(glflags.newprogname);
esb_destructor(&global_file_name);
esb_destructor(&global_tied_file_name);
free_all_dwconf(glflags.config_file_data);
sanitized_string_destructor();
ranges_esb_string_destructor();
/* Global flags initialization and esb-buffers destruction. */
reset_global_flags();
close_a_file(global_basefd);
close_a_file(global_tiedfd);
#ifdef _WIN32
/* Close the null device used during formatting printing */
esb_close_null_device();
#endif /* _WIN32 */
if (glflags.gf_global_debuglink_paths) {
unsigned int i = 0;
for ( ; i < glflags.gf_global_debuglink_count ; ++i ) {
free(glflags.gf_global_debuglink_paths[i]);
glflags.gf_global_debuglink_paths[i] = 0;
}
free(glflags.gf_global_debuglink_paths);
glflags.gf_global_debuglink_paths = 0;
}
glflags.gf_global_debuglink_count = 0;
}
#ifdef DWARF_WITH_LIBELF
static int
is_it_known_elf_header(Elf *elf)
{
Elf32_Ehdr *eh32;
eh32 = elf32_getehdr(elf);
if (eh32) {
return 1;
}
#ifdef HAVE_ELF64_GETEHDR
{
Elf64_Ehdr *eh64;
/* not a 32-bit obj */
eh64 = elf64_getehdr(elf);
if (eh64) {
return 1;
}
}
#endif /* HAVE_ELF64_GETEHDR */
/* Not something we can handle. */
return 0;
}
#endif /* DWARF_WITH_LIBELF */
static void
check_for_major_errors(void)
{
long int ect = glflags.gf_count_major_errors;
const char *w = "was";
const char *e = "error";
if (!ect) {
return;
}
if (ect > 1) {
w = "were";
e = "errors";
}
printf("There %s %ld DWARF %s reported: "
"see ERROR above.\n",
w, glflags.gf_count_major_errors,e);
}
static void
flag_data_pre_allocation(void)
{
memset(glflags.section_high_offsets_global,0,
sizeof(*glflags.section_high_offsets_global));
/* If we are checking .debug_line, .debug_ranges, .debug_aranges,
or .debug_loc build the tables containing
the pairs LowPC and HighPC. It is safer (and not
expensive) to build all
of these at once so mistakes in options do not lead
to coredumps (like -ka -p did once). */
if (glflags.gf_check_decl_file || glflags.gf_check_ranges ||
glflags.gf_check_locations ||
glflags.gf_do_check_dwarf ||
glflags.gf_check_self_references) {
glflags.pRangesInfo = AllocateBucketGroup(KIND_RANGES_INFO);
glflags.pLinkonceInfo = AllocateBucketGroup(KIND_SECTIONS_INFO);
glflags.pVisitedInfo = AllocateBucketGroup(KIND_VISITED_INFO);
}
/* Create the unique error table */
if (glflags.gf_print_unique_errors) {
allocate_unique_errors_table();
}
/* Allocate range array to be used by all CUs */
if (glflags.gf_check_ranges) {
allocate_range_array_info();
}
}
static void flag_data_post_cleanup(void)
{
#ifdef DWARF_WITH_LIBELF
clean_up_syms_malloc_data();
#endif /* DWARF_WITH_LIBELF */
if (glflags.pRangesInfo) {
ReleaseBucketGroup(glflags.pRangesInfo);
glflags.pRangesInfo = 0;
}
if (glflags.pLinkonceInfo) {
ReleaseBucketGroup(glflags.pLinkonceInfo);
glflags.pLinkonceInfo = 0;
}
if (glflags.pVisitedInfo) {
ReleaseBucketGroup(glflags.pVisitedInfo);
glflags.pVisitedInfo = 0;
}
/* Release range array to be used by all CUs */
if (glflags.gf_check_ranges) {
release_range_array_info();
}
/* Delete the unique error set */
if (glflags.gf_print_unique_errors) {
release_unique_errors_table();
}
clean_up_compilers_detected();
destruct_abbrev_array();
}
#ifdef DWARF_WITH_LIBELF
static int
process_using_libelf(int fd, int tiedfd,
const char *file_name,
const char *tied_file_name,
int archive)
{
Elf_Cmd cmd = 0;
Elf *arf = 0;
Elf *elf = 0;
Elf *elftied = 0;
int archmemnum = 0;
(void) elf_version(EV_NONE);
if (elf_version(EV_CURRENT) == EV_NONE) {
(void) fprintf(stderr,
"dwarfdump: libelf.a out of date.\n");
exit(FAILED);
}
/* We will use libelf to process an archive
so long as is convienient.
we don't intend to ever write our own
archive reader. Archive support was never
tested and may disappear. */
cmd = ELF_C_READ;
arf = elf_begin(fd, cmd, (Elf *) 0);
if (!arf) {
fprintf(stderr, "%s ERROR: "
"Unable to obtain ELF descriptor for %s\n",
glflags.program_name,
file_name);
return (FAILED);
}
if (esb_string_len(glflags.config_file_tiedpath) > 0) {
int isknown = 0;
if (tiedfd == -1) {
fprintf(stderr, "%s ERROR: "
"can't open tied file.... %s\n",
glflags.program_name,
tied_file_name);
return (FAILED);
}
elftied = elf_begin(tiedfd, cmd, (Elf *) 0);
if (elf_kind(elftied) == ELF_K_AR) {
fprintf(stderr, "%s ERROR: tied file %s is "
"an archive. Not allowed. Giving up.\n",
glflags.program_name,
tied_file_name);
return (FAILED);
}
isknown = is_it_known_elf_header(elftied);
if (!isknown) {
fprintf(stderr,
"Cannot process tied file %s: unknown format\n",
tied_file_name);
return FAILED;
}
}
while ((elf = elf_begin(fd, cmd, arf)) != 0) {
int isknown = is_it_known_elf_header(elf);
if (!isknown) {
/* not a 64-bit obj either! */
/* dwarfdump is almost-quiet when not an object */
if (archive) {
Elf_Arhdr *mem_header = elf_getarhdr(elf);
const char *memname =
(mem_header && mem_header->ar_name)?
mem_header->ar_name:"";
/* / and // archive entries are not archive
objects, but are not errors.
For the ATT/USL type of archive. */
if (strcmp(memname,"/") && strcmp(memname,"//")) {
fprintf(stderr, "Can't process archive member "
"%d %s of %s: unknown format\n",
archmemnum,
sanitized(memname),
file_name);
}
} else {
fprintf(stderr, "Can't process %s: unknown format\n",
file_name);
}
glflags.check_error = 1;
cmd = elf_next(elf);
elf_end(elf);
continue;
}
flag_data_pre_allocation();
process_one_file(fd,tiedfd,
elf,elftied,
file_name,
tied_file_name,
0,0,
archive,
glflags.config_file_data);
flag_data_post_cleanup();
cmd = elf_next(elf);
elf_end(elf);
archmemnum += 1;
}
elf_end(arf);
if (elftied) {
elf_end(elftied);
elftied = 0;
}
return 0; /* normal return. */
}
#endif /* DWARF_WITH_LIBELF */
void _dwarf_alloc_tree_counts(Dwarf_Unsigned *allocount,
Dwarf_Unsigned *allosum,
Dwarf_Unsigned *treecount,
Dwarf_Unsigned *treesum,
Dwarf_Unsigned *earlydealloccount,
Dwarf_Unsigned *earlydeallocsize,
Dwarf_Unsigned *unused1,
Dwarf_Unsigned *unused2,
Dwarf_Unsigned *unused3);
/* This intended for dwarfdump testing only
by the developers. It's quite odd,
really.
See regressiontests/scripts/analyzedwalloc.py
But handy for some performance analysis. */
static void
print_libdwarf_alloc_values(const char *file_name,
int argc,char **argv)
{
Dwarf_Unsigned alloct = 0;
Dwarf_Unsigned allosum = 0;
Dwarf_Unsigned treect = 0;
Dwarf_Unsigned treesum = 0;
Dwarf_Unsigned earlydelct = 0;
Dwarf_Unsigned earlydelsum = 0;
FILE *out = 0;
int i = 1;
_dwarf_alloc_tree_counts(&alloct,
&allosum,&treect,&treesum,
&earlydelct,&earlydelsum,
0,0,0);
out = fopen("libdwallocs","a");
if (!out) {
return;
}
fprintf(out,"==== %s ",file_name);
for ( ; i < argc; ++i) {
fprintf(out," %s",argv[i]);
}
fprintf(out,"\n");
fprintf(out,"%" DW_PR_DSd " ",
alloct);
fprintf(out,"%" DW_PR_DSd " ",
allosum);
fprintf(out,"%" DW_PR_DSd " ",
treect);
fprintf(out,"%" DW_PR_DSd " ",
treesum);
fprintf(out,"%" DW_PR_DSd " ",
earlydelct);
fprintf(out,"%" DW_PR_DSd " ",
earlydelsum);
fprintf(out,"\n");
fclose(out);
}
/*
Iterate through dwarf and print all info.
*/
int
main(int argc, char *argv[])
{
const char * file_name = 0;
unsigned ftype = 0;
unsigned endian = 0;
unsigned offsetsize = 0;
Dwarf_Unsigned filesize = 0;
int errcode = 0;
char *temp_path_buf = 0;
unsigned temp_path_buf_len = 0;
int res = 0;
/* path_source will be DW_PATHSOURCE_basic */
unsigned char path_source = DW_PATHSOURCE_unspecified;
#ifdef _WIN32
/* Open the null device used during formatting printing */
if (!esb_open_null_device()) {
fprintf(stderr,"dwarfdump: Unable to open null device.\n");
exit(FAILED);
}
#endif /* _WIN32 */
/* Global flags initialization and esb-buffers construction. */
init_global_flags();
set_checks_off();
uri_data_constructor();
esb_constructor(&esb_short_cu_name);
esb_constructor(&esb_long_cu_name);
esb_constructor(&dwarf_error_line);
#ifdef _WIN32
/* Often we redirect the output to a file, but we have found
issues due to the buffering associated with stdout. Some issues
were fixed just by the use of 'fflush', but the main issued
remained.
The stdout stream is buffered, so will only display what's in the
buffer after it reaches a newline (or when it's told to). We have a
few options to print immediately:
- Print to stderr instead using fprintf.
- Print to stdout and flush stdout whenever we need it to using fflush.
- We can also disable buffering on stdout by using setbuf:
setbuf(stdout,NULL);
Make stdout unbuffered; this seems to work for all cases.
The problem is no longer present. September 2018.
*/
/* Calling setbuf() with NULL argument, it turns off
all buffering for the specified stream.
Then writing to and/or reading from the stream
will be exactly as directed by the program.
But if dwarfdump is used over a network drive,
it shows a dramatic
slowdown when sending the output to a file.
An operation that takes
couple of seconds, it was taking few hours. */
/* setbuf(stdout,NULL); */
/* Redirect stderr to stdout. */
dup2(fileno(stdout),fileno(stderr));
#endif /* _WIN32 */
print_version_details(argv[0],FALSE);
file_name = process_args(argc, argv);
print_args(argc,argv);
/* Redirect stdout and stderr to an specific file */
if (glflags.output_file) {
if (NULL == freopen(glflags.output_file,"w",stdout)) {
fprintf(stderr,
"dwarfdump: Unable to redirect output to '%s'\n",
glflags.output_file);
global_destructors();
exit(FAILED);
}
dup2(fileno(stdout),fileno(stderr));
/* Record version and arguments in the output file */
print_version_details(argv[0],FALSE);
print_args(argc,argv);
}
/* Allow the user to hide some warnings by using
command line options */
{
Dwarf_Cmdline_Options wcmd;
/* The struct has just one field!. */
wcmd.check_verbose_mode = glflags.gf_check_verbose_mode;
dwarf_record_cmdline_options(wcmd);
}
/* ======= BEGIN FINDING NAMES AND OPENING FDs ===== */
/* The 200+2 etc is more than suffices for the expansion that a
MacOS dsym or a GNU debuglink might need, we hope. */
temp_path_buf_len = strlen(file_name)*3 + 200 + 2;
temp_path_buf = malloc(temp_path_buf_len);
if(!temp_path_buf) {
fprintf(stderr, "%s ERROR: Unable to malloc %lu bytes "
"for possible path string %s.\n",
glflags.program_name,(unsigned long)temp_path_buf_len,
file_name);
return (FAILED);
}
temp_path_buf[0] = 0;
/* This data scan is to find Elf objects and
unknown objects early. If the user
asks for libelf with certain options
that will rule out handling GNU_debuglink
on that object. This does not concern itself
with dSYM or debuglink at all. */
res = dwarf_object_detector_path_b(file_name,
0,0,
0,0,
&ftype,&endian,&offsetsize,&filesize,
&path_source,&errcode);
if ( res != DW_DLV_OK) {
fprintf(stderr, "%s ERROR: Can't open %s\n",
glflags.program_name, sanitized(file_name));
global_destructors();
free(temp_path_buf);
return (FAILED);
}
esb_append(&global_file_name,file_name);
temp_path_buf[0] = 0;
global_basefd = open_a_file(esb_get_string(
&global_file_name));
if (global_basefd == -1) {
fprintf(stderr, "%s ERROR: can't open.. %s\n",
glflags.program_name,
esb_get_string(&global_file_name));
global_destructors();
free(temp_path_buf);
return (FAILED);
}
if (esb_string_len(glflags.config_file_tiedpath) > 0) {
unsigned tftype = 0;
unsigned tendian = 0;
unsigned toffsetsize = 0;
Dwarf_Unsigned tfilesize = 0;
const char * tied_file_name = 0;
/* path_source will be DW_PATHSOURCE_basic */
unsigned char tpath_source = 0;
temp_path_buf[0] = 0;
tied_file_name = esb_get_string(glflags.config_file_tiedpath);
/* A genuine tiedpath cannot be dsym or debuglink. */
res = dwarf_object_detector_path_b (tied_file_name,
0,0,
0,0,
&tftype,&tendian,&toffsetsize,&tfilesize,
&tpath_source,&errcode);
if ( res != DW_DLV_OK) {
if (res == DW_DLV_ERROR) {
char *errmsg = dwarf_errmsg_by_number(errcode);
fprintf(stderr, "%s ERROR: can't open tied file.. %s:"
" %s\n",
glflags.program_name, sanitized(tied_file_name),
errmsg);
} else {
fprintf(stderr,
"%s ERROR: tied file not an object file '%s'.\n",
glflags.program_name, sanitized(tied_file_name));
}
global_destructors();
free(temp_path_buf);
return (FAILED);
}
if (ftype != tftype || endian != tendian ||
offsetsize != toffsetsize) {
fprintf(stderr, "%s ERROR: tied file \'%s\' and "
"main file \'%s\' not "
"the same kind of object!\n",
glflags.program_name,
sanitized(tied_file_name),
esb_get_string(&global_file_name));
free(temp_path_buf);
global_destructors();
return (FAILED);
}
esb_append(&global_tied_file_name,tied_file_name);
global_tiedfd = open_a_file(esb_get_string(
&global_tied_file_name));
if (global_tiedfd == -1) {
fprintf(stderr, "%s ERROR: can't open tied file... %s\n",
glflags.program_name,
sanitized(esb_get_string(&global_tied_file_name)));
global_destructors();
free(temp_path_buf);
return (FAILED);
}
}
/* ======= end FINDING NAMES AND OPENING FDs ===== */
temp_path_buf[0] = 0;
/* ======= BEGIN PROCESSING OBJECT FILES BY TYPE ===== */
if ( (ftype == DW_FTYPE_ELF && (glflags.gf_reloc_flag ||
glflags.gf_header_flag)) ||
#ifdef HAVE_CUSTOM_LIBELF
ftype == DW_FTYPE_CUSTOM_ELF ||
#endif /* HAVE_CUSTOM_LIBELF */
ftype == DW_FTYPE_ARCHIVE) {
#ifdef DWARF_WITH_LIBELF
int excode = 0;
excode = process_using_libelf(global_basefd,
global_tiedfd,
esb_get_string(&global_file_name),
esb_get_string(&global_tied_file_name),
(ftype == DW_FTYPE_ARCHIVE)? TRUE:FALSE);
if (excode) {
free(temp_path_buf);
global_destructors();
flag_data_post_cleanup();
return(excode);
}
#else /* !DWARF_WITH_LIBELF */
fprintf(stderr, "Can't process %s: archives and "
"printing elf headers not supported in this dwarfdump "
"--disable-libelf build.\n",
file_name);
#endif /* DWARF_WITH_LIBELF */
} else if (ftype == DW_FTYPE_ELF ||
ftype == DW_FTYPE_MACH_O ||
ftype == DW_FTYPE_PE ) {
flag_data_pre_allocation();
close_a_file(global_basefd);
global_basefd = -1;
close_a_file(global_tiedfd);
global_tiedfd = -1;
process_one_file(-1,-1,
0,0,
esb_get_string(&global_file_name),
esb_get_string(&global_tied_file_name),
temp_path_buf, temp_path_buf_len,
#ifdef DWARF_WITH_LIBELF
0 /* elf_archive */,
#endif
glflags.config_file_data);
flag_data_post_cleanup();
} else {
fprintf(stderr, "Can't process %s: unhandled format\n",
file_name);
}
free(temp_path_buf);
temp_path_buf = 0;
temp_path_buf_len = 0;
if (glflags.gf_print_alloc_sums) {
print_libdwarf_alloc_values(file_name,argc,argv);
}
/* ======= END PROCESSING OBJECT FILES BY TYPE ===== */
/* These cleanups only necessary once all
objects processed. */
#ifdef HAVE_REGEX
if (glflags.search_regex_text) {
regfree(glflags.search_re);
}
#endif
/* In case of a serious DWARF error
we try to get here, we try not
to exit(1) by using print_error() */
check_for_major_errors();
flag_data_post_cleanup();
global_destructors();
free(temp_path_buf);
/* As the tool have reached this point, it means there are
no internal errors and we should return an OKAY condition,
regardless if the file being processed has
minor errors. */
return OKAY;
}
void
print_any_harmless_errors(Dwarf_Debug dbg)
{
#define LOCAL_PTR_ARY_COUNT 50
/* We do not need to initialize the local array,
libdwarf does it. */
const char *buf[LOCAL_PTR_ARY_COUNT];
unsigned totalcount = 0;
unsigned i = 0;
unsigned printcount = 0;
int res = dwarf_get_harmless_error_list(dbg,LOCAL_PTR_ARY_COUNT,buf,
&totalcount);
if (res == DW_DLV_NO_ENTRY) {
return;
}
if (totalcount > 0) {
printf("\n*** HARMLESS ERROR COUNT: %u ***\n",totalcount);
}
for (i = 0 ; buf[i]; ++i) {
++printcount;
DWARF_CHECK_COUNT(harmless_result,1);
DWARF_CHECK_ERROR(harmless_result,buf[i]);
}
if (totalcount > printcount) {
/*harmless_result.checks += (totalcount - printcount); */
DWARF_CHECK_COUNT(harmless_result,(totalcount - printcount));
/*harmless_result.errors += (totalcount - printcount); */
DWARF_ERROR_COUNT(harmless_result,(totalcount - printcount));
}
}
/* Print a summary of search results */
static void
print_search_results(void)
{
const char *search_type = 0;
const char *search_text = 0;
if (glflags.search_any_text) {
search_type = "any";
search_text = glflags.search_any_text;
} else {
if (glflags.search_match_text) {
search_type = "match";
search_text = glflags.search_match_text;
} else {
search_type = "regex";
search_text = glflags.search_regex_text;
}
}
fflush(stdout);
fflush(stderr);
printf("\nSearch type : '%s'\n",search_type);
printf("Pattern searched : '%s'\n",search_text);
printf("Occurrences Found: %d\n",glflags.search_occurrences);
fflush(stdout);
}
/* This is for dwarf_print_lines() */
static void
printf_callback_for_libdwarf(UNUSEDARG void *userdata,
const char *data)
{
printf("%s",sanitized(data));
}
int
get_address_size_and_max(Dwarf_Debug dbg,
Dwarf_Half * size,
Dwarf_Addr * max,
Dwarf_Error *aerr)
{
int dres = 0;
Dwarf_Half lsize = 4;
/* Get address size and largest representable address */
dres = dwarf_get_address_size(dbg,&lsize,aerr);
if (dres != DW_DLV_OK) {
return dres;
}
if(max) {
*max = (lsize == 8 ) ? 0xffffffffffffffffULL : 0xffffffff;
}
if(size) {
*size = lsize;
}
return DW_DLV_OK;
}
/* dbg is often null when dbgtied was passed in. */
static void
dbgsetup(Dwarf_Debug dbg,struct dwconf_s *setup_config_file_data)
{
if (!dbg) {
return;
}
dwarf_set_frame_rule_initial_value(dbg,
setup_config_file_data->cf_initial_rule_value);
dwarf_set_frame_rule_table_size(dbg,
setup_config_file_data->cf_table_entry_count);
dwarf_set_frame_cfa_value(dbg,
setup_config_file_data->cf_cfa_reg);
dwarf_set_frame_same_value(dbg,
setup_config_file_data->cf_same_val);
dwarf_set_frame_undefined_value(dbg,
setup_config_file_data->cf_undefined_val);
if (setup_config_file_data->cf_address_size) {
dwarf_set_default_address_size(dbg,
setup_config_file_data->cf_address_size);
}
dwarf_set_harmless_error_list_size(dbg,50);
}
/* Callable at any time, Sets section sizes with the sizes
known as of the call.
Repeat whenever about to reference a size that might not
have been set as of the last call. */
static void
set_global_section_sizes(Dwarf_Debug dbg)
{
dwarf_get_section_max_offsets_c(dbg,
&glflags.section_high_offsets_global->debug_info_size,
&glflags.section_high_offsets_global->debug_abbrev_size,
&glflags.section_high_offsets_global->debug_line_size,
&glflags.section_high_offsets_global->debug_loc_size,
&glflags.section_high_offsets_global->debug_aranges_size,
&glflags.section_high_offsets_global->debug_macinfo_size,
&glflags.section_high_offsets_global->debug_pubnames_size,
&glflags.section_high_offsets_global->debug_str_size,
&glflags.section_high_offsets_global->debug_frame_size,
&glflags.section_high_offsets_global->debug_ranges_size,
&glflags.section_high_offsets_global->debug_pubtypes_size,
&glflags.section_high_offsets_global->debug_types_size,
&glflags.section_high_offsets_global->debug_macro_size,
&glflags.section_high_offsets_global->debug_str_offsets_size,
&glflags.section_high_offsets_global->debug_sup_size,
&glflags.section_high_offsets_global->debug_cu_index_size,
&glflags.section_high_offsets_global->debug_tu_index_size);
}
/* Set limits for Ranges Information.
The linker may
put parts of the text(code) in additional sections
such as .init .fini __libc_freeres_fn
.rodata __libc_subfreeres __libc_atexit too. */
#define LIKELYNAMESMAX 3
static const char *likely_ns[LIKELYNAMESMAX] = {
/* .text is first as it is often the only thing.See below. */
".init",
".text",
".fini"
};
#define ORIGLKLYTEXTINDEX 1
struct likely_names_s {
const char * name;
int origindex;
Dwarf_Unsigned low;
Dwarf_Unsigned size;
Dwarf_Unsigned end;
};
static struct likely_names_s likely_names[LIKELYNAMESMAX];
#if 0 /* FOR DEBUG ONLY */
static void
printlnrec(const char *msg,struct likely_names_s * ln,
int line,char * fn)
{
printf("%s: name %s origindx %d "
"low 0x%lx "
"size 0x%lx "
"end 0x%lx "
" line %d %s\n",msg,
ln->name,ln->origindex,
(unsigned long)ln->low,
(unsigned long)ln->size,
(unsigned long)ln->end,line,fn);
}
#endif /* 0 */
static int
likelycmp(const void *l_in, const void *r_in)
{
struct likely_names_s *l = (struct likely_names_s *)l_in;
struct likely_names_s *r = (struct likely_names_s *)r_in;
if (l->low < r->low) {
return -1;
}
if (l->low > r->low ) {
return 1;
}
if (l->end < r->end) {
return -1;
}
if (l->end > r->end) {
return 1;
}
return 0;
}
/* This is a bit slow, but happens only once for a dbg.
It is not as much help as I expected in avoiding
line table content CHECK warnings because, so far,
those come from .init csu code and the DWARF has
no subprogram information nor any high/low pc
information at all. */
static int
calculate_likely_limits_of_code(Dwarf_Debug dbg,
Dwarf_Unsigned *lower,
Dwarf_Unsigned *size)
{
struct likely_names_s * ln = 0;
int ct = 0;
Dwarf_Unsigned baselow = 0;
Dwarf_Unsigned basesize = 0;
Dwarf_Unsigned baseend = 0;
int lnindex = 0;
int lncount = 0;
memset(likely_names,0,sizeof(likely_names));
for (ct = 0 ; ct < LIKELYNAMESMAX; ct++) {
Dwarf_Unsigned clow = 0;
Dwarf_Unsigned csize = 0;
int res = 0;
Dwarf_Error err = 0;
const char *name = likely_ns[ct];
ln = likely_names + lnindex;
res = dwarf_get_section_info_by_name(dbg,name,
&clow,&csize,&err);
if (res == DW_DLV_ERROR) {
dwarf_dealloc_error(dbg,err);
if (ct == ORIGLKLYTEXTINDEX) {
return DW_DLV_NO_ENTRY;
}
continue;
}
if (res == DW_DLV_NO_ENTRY) {
if (ct == ORIGLKLYTEXTINDEX) {
return DW_DLV_NO_ENTRY;
}
continue;
}
ln->name = name;
ln->low = clow;
ln->size = csize;
ln->end = csize +clow;
ln->origindex = ct;
if (ct == ORIGLKLYTEXTINDEX) {
basesize = csize;
baselow = clow;
baseend = csize+clow;
}
++lnindex;
}
if (lnindex == 0) {
return DW_DLV_NO_ENTRY;
}
if (lnindex == 1) {
*lower = baselow;
*size = basesize;
return DW_DLV_OK;
}
lncount = lnindex;
qsort(likely_names,lncount,sizeof(struct likely_names_s),
likelycmp);
ln = likely_names;
baselow =ln->low;
basesize =ln->size;
baseend = ln->end;
for (lnindex = 1; lnindex<lncount; ++lnindex) {
ln = likely_names+lnindex;
if (ln->end > baseend) {
baseend = ln->end;
basesize = (baseend - baselow);
}
}
*lower = baselow;
*size = basesize;
return DW_DLV_OK;
}
/*
Given a file which we know is an elf file, process
the dwarf data.
*/
static int
process_one_file(
UNUSEDARG int fd,
UNUSEDARG int tiedfd,
Elf *elf, Elf *tiedelf,
const char * file_name,
const char * tied_file_name,
char * temp_path_buf,
unsigned int temp_path_buf_len,
#ifdef DWARF_WITH_LIBELF
int archive,
#endif
struct dwconf_s *l_config_file_data)
{
Dwarf_Debug dbg = 0;
Dwarf_Debug dbgtied = 0;
int dres = 0;
struct Dwarf_Printf_Callback_Info_s printfcallbackdata;
Dwarf_Half elf_address_size = 0; /* Target pointer size */
Dwarf_Error onef_err = 0;
const char *title = 0;
unsigned char path_source = 0;
/* If using a tied file group number should be
2 DW_GROUPNUMBER_DWO
but in a dwp or separate-split-dwarf object then
0 will find the .dwo data automatically. */
if (elf) {
title = "dwarf_elf_init_b fails exit dwarfdump";
dres = dwarf_elf_init_b(elf, DW_DLC_READ,
glflags.group_number,
NULL, NULL, &dbg, &onef_err);
if (dres == DW_DLV_OK) {
int pres = 0;
pres = dwarf_add_file_path(dbg,file_name,&onef_err);
if (pres != DW_DLV_OK) {
print_error(dbg,"Unable to add file path "
"to object file data", pres, onef_err);
}
}
} else {
/* This will go for the real main file, whether
an underlying dSYM or via debuglink or
if those find nothing then the original. */
char *tb = temp_path_buf;
unsigned tblen = temp_path_buf_len;
title = "dwarf_init_path_dl fails exit dwarfdump";
if (glflags.gf_no_follow_debuglink) {
tb = 0;
tblen = 0;
}
dres = dwarf_init_path_dl(file_name,
tb,tblen,
DW_DLC_READ,
glflags.group_number,
NULL, NULL, &dbg,
glflags.gf_global_debuglink_paths,
glflags.gf_global_debuglink_count,
&path_source,
0,0,0,
&onef_err);
}
if (dres == DW_DLV_NO_ENTRY) {
if (glflags.group_number > 0) {
printf("No DWARF information present in %s "
"for section group %d \n",
file_name,glflags.group_number);
} else {
printf("No DWARF information present in %s\n",file_name);
}
return dres;
}
if (dres == DW_DLV_ERROR) {
/* Prints error, cleans up Dwarf_Error data. Never returns*/
print_error_and_continue(dbg,
title,dres,onef_err);
DROP_ERROR_INSTANCE(dbg,dres,onef_err);
return DW_DLV_ERROR;
}
if (path_source == DW_PATHSOURCE_dsym) {
printf("Filename by dSYM is %s\n",
sanitized(temp_path_buf));
} else if (path_source == DW_PATHSOURCE_debuglink) {
printf("Filename by debuglink is %s\n",
sanitized(temp_path_buf));
glflags.gf_gnu_debuglink_flag = TRUE;
}
if (tied_file_name && strlen(tied_file_name)) {
if (tiedelf) {
dres = dwarf_elf_init_b(tiedelf, DW_DLC_READ,
DW_GROUPNUMBER_BASE, NULL, NULL, &dbgtied,
&onef_err);
if (dres == DW_DLV_OK) {
int pres = 0;
pres = dwarf_add_file_path(dbgtied,
tied_file_name,&onef_err);
if (pres != DW_DLV_ERROR) {
/* Prints error, cleans up Dwarf_Error data if
any. Never returns */
print_error(dbg,
"Unable to add tied file name "
"to tied file",
pres, onef_err);
}
}
} else {
/* The tied file we define as group 1, BASE.
Cannot follow debuglink or dSYM,
is a tied file */
dres = dwarf_init_path(tied_file_name,
0,0, /* ignore dSYM & debuglink */
DW_DLC_READ,
DW_GROUPNUMBER_BASE,
0,0,
&dbgtied,
0,0,0,
&onef_err);
/* path_source = DW_PATHSOURCE_basic; */
}
if (dres == DW_DLV_NO_ENTRY) {
printf("No DWARF information present in tied file: %s\n",
tied_file_name);
return dres;
}
if (dres == DW_DLV_ERROR) {
/* Prints error, cleans up Dwarf_Error data.
Never returns*/
print_error(dbg,
"dwarf_elf_init on tied_file",
dres, onef_err);
}
}
memset(&printfcallbackdata,0,sizeof(printfcallbackdata));
printfcallbackdata.dp_fptr = printf_callback_for_libdwarf;
dwarf_register_printf_callback(dbg,&printfcallbackdata);
if (dbgtied) {
dwarf_register_printf_callback(dbgtied,&printfcallbackdata);
}
memset(&printfcallbackdata,0,sizeof(printfcallbackdata));
dbgsetup(dbg,l_config_file_data);
dbgsetup(dbgtied,l_config_file_data);
dres = get_address_size_and_max(dbg,&elf_address_size,0,
&onef_err);
if (dres != DW_DLV_OK) {
print_error(dbg,"Unable to read address"
" size so unable to continue",
dres,onef_err);
}
#ifdef DWARF_WITH_LIBELF
if (archive) {
Elf_Arhdr *mem_header = elf_getarhdr(elf);
const char *memname =
(mem_header && mem_header->ar_name)?
mem_header->ar_name:"";
printf("\narchive member %s\n",sanitized(memname));
}
#endif /* DWARF_WITH_LIBELF */
/* Ok for dbgtied to be NULL. */
dres = dwarf_set_tied_dbg(dbg,dbgtied,&onef_err);
if (dres != DW_DLV_OK) {
print_error(dbg, "dwarf_set_tied_dbg() failed",
dres, onef_err);
}
/* Get .text and .debug_ranges info if in check mode */
if (glflags.gf_do_check_dwarf) {
Dwarf_Addr lower = 0;
Dwarf_Addr upper = 0;
Dwarf_Unsigned size = 0;
Dwarf_Debug dbg_with_code = dbg;
int res = 0;
if (dbgtied) {
/* Assuming tied is exectuable main is dwo/dwp */
dbg_with_code = dbgtied;
}
res = calculate_likely_limits_of_code(dbg_with_code,
&lower,&size);
upper = lower + size;
/* Set limits for Ranges Information.
Some objects have CUs for startup code
and the expanded range here turns out
not to actually help. */
if (res == DW_DLV_OK && glflags.pRangesInfo) {
SetLimitsBucketGroup(glflags.pRangesInfo,lower,upper);
AddEntryIntoBucketGroup(glflags.pRangesInfo,
1,
lower,lower,
upper,
".text",
TRUE);
}
/* Build section information
linkonce is an SNR thing, we*/
build_linkonce_info(dbg);
}
if (glflags.gf_header_flag && elf) {
#ifdef DWARF_WITH_LIBELF
int res = 0;
Dwarf_Error err = 0;
res = print_object_header(dbg,&err);
if (res == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"printing Elf object Header had a problem.",
res,err);
DROP_ERROR_INSTANCE(dbg,res,err);
}
#endif /* DWARF_WITH_LIBELF */
}
if (glflags.gf_section_groups_flag) {
int res = 0;
Dwarf_Error err = 0;
res = print_section_groups_data(dbg,&err);
if (res == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"printing section groups had a problem.",
res,err);
DROP_ERROR_INSTANCE(dbg,res,err);
}
/* If groupnum > 2 this turns off some
of the gf_flags here so we don't print
section names of things we do not
want to print. */
update_section_flags_per_groups(dbg);
}
reset_overall_CU_error_data();
if (glflags.gf_info_flag || glflags.gf_line_flag ||
glflags.gf_types_flag ||
glflags.gf_check_macros || glflags.gf_macinfo_flag ||
glflags.gf_macro_flag ||
glflags.gf_cu_name_flag || glflags.gf_search_is_on ||
glflags.gf_producer_children_flag) {
Dwarf_Error err = 0;
int res = 0;
reset_overall_CU_error_data();
res = print_infos(dbg,TRUE,&err);
if (res == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"printing .debug_info had a problem.",
res,err);
DROP_ERROR_INSTANCE(dbg,res,err);
}
reset_overall_CU_error_data();
res = print_infos(dbg,FALSE,&err);
if (res == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"printing .debug_types had a problem.",
res,err);
DROP_ERROR_INSTANCE(dbg,res,err);
}
if (glflags.gf_check_macros) {
set_global_section_sizes(dbg);
if(macro_check_tree) {
/* Fake item representing end of section. */
/* Length of the fake item is zero. */
print_macro_statistics("DWARF5 .debug_macro",
¯o_check_tree,
glflags.section_high_offsets_global->debug_macro_size,
&err);
}
if(macinfo_check_tree) {
/* Fake item representing end of section. */
/* Length of the fake item is zero. */
print_macro_statistics("DWARF2 .debug_macinfo",
&macinfo_check_tree,
glflags.section_high_offsets_global->debug_macinfo_size,
&err);
}
}
clear_macro_statistics(¯o_check_tree);
clear_macro_statistics(&macinfo_check_tree);
}
if (glflags.gf_gdbindex_flag) {
int res = 0;
Dwarf_Error err = 0;
reset_overall_CU_error_data();
/* By definition if gdb_index is present
then "cu" and "tu" will not be. And vice versa. */
res = print_gdb_index(dbg,&err);
if (res == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"printing the gdb index section had a problem "
,res,err);
}
res = print_debugfission_index(dbg,"cu",&err);
if (res == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"printing the debugfission cu section "
"had a problem "
,res,err);
}
res = print_debugfission_index(dbg,"tu",&err);
if (res == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"printing the debugfission tu section "
"had a problem "
,res,err);
}
}
if (glflags.gf_pubnames_flag) {
int res = 0;
Dwarf_Error err = 0;
reset_overall_CU_error_data();
res = print_pubnames(dbg,&err);
if (res == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"printing pubnames data had a problem ",res,err);
DROP_ERROR_INSTANCE(dbg,res,err);
}
}
if (glflags.gf_loc_flag) {
int locres = 0;
Dwarf_Error locerr = 0;
reset_overall_CU_error_data();
locres = print_locs(dbg,&locerr);
if (locres == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"printing location data had a problem ",locres,locerr);
}
}
if (glflags.gf_abbrev_flag) {
Dwarf_Error err = 0;
int res = 0;
reset_overall_CU_error_data();
res = print_abbrevs(dbg,&err);
if (res == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"printing the .debug_abbrev section"
" had a problem.",res,err);
DROP_ERROR_INSTANCE(dbg,res,err);
}
}
if (glflags.gf_string_flag) {
Dwarf_Error err = 0;
int res = 0;
reset_overall_CU_error_data();
res = print_strings(dbg,&err);
if (res == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"printing the .debug_str section"
" had a problem.",res,err);
DROP_ERROR_INSTANCE(dbg,res,err);
}
}
if (glflags.gf_aranges_flag) {
Dwarf_Error err = 0;
int res = 0;
reset_overall_CU_error_data();
res = print_aranges(dbg,&err);
if (res == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"printing the aranges section"
" had a problem.",res,err);
DROP_ERROR_INSTANCE(dbg,res,err);
}
}
if (glflags.gf_ranges_flag) {
int res = 0;
Dwarf_Error err = 0;
reset_overall_CU_error_data();
res = print_ranges(dbg,&err);
if (res == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"printing the ranges section"
" had a problem.",res,err);
DROP_ERROR_INSTANCE(dbg,res,err);
}
}
if (glflags.gf_print_raw_loclists) {
int res = 0;
Dwarf_Error err = 0;
reset_overall_CU_error_data();
res = print_raw_all_loclists(dbg,&err);
if (res == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"printing the raw .debug_loclists section"
" had a problem.",res,err);
DROP_ERROR_INSTANCE(dbg,res,err);
}
}
if (glflags.gf_print_raw_rnglists) {
int res = 0;
Dwarf_Error err = 0;
reset_overall_CU_error_data();
res = print_raw_all_rnglists(dbg,&err);
if (res == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"printing the raw .debug_rnglists section"
" had a problem.",res,err);
DROP_ERROR_INSTANCE(dbg,res,err);
}
}
if (glflags.gf_frame_flag || glflags.gf_eh_frame_flag) {
int sres = 0;
Dwarf_Error err = 0;
int want_eh = 0;
/* These three shared .eh_frame and .debug_frame
as they are about the DIEs, not about frames. */
Dwarf_Die cu_die_for_print_frames = 0;
void *map_lowpc_to_name = 0;
void *lowpcSet = 0;
reset_overall_CU_error_data();
if (glflags.gf_frame_flag) {
want_eh = 0;
sres = print_frames(dbg,want_eh,
l_config_file_data,
&cu_die_for_print_frames,
&map_lowpc_to_name,
&lowpcSet,
&err);
if (sres == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"printing standard frame data had a problem.",
sres,err);
DROP_ERROR_INSTANCE(dbg,sres,err);
}
}
if (glflags.gf_eh_frame_flag) {
want_eh = 1;
sres = print_frames(dbg, want_eh,
l_config_file_data,
&cu_die_for_print_frames,
&map_lowpc_to_name,
&lowpcSet,
&err);
if (sres == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"printing eh frame data had a problem.",sres,
err);
DROP_ERROR_INSTANCE(dbg,sres,err);
}
}
addr_map_destroy(lowpcSet);
addr_map_destroy(map_lowpc_to_name);
if (cu_die_for_print_frames) {
dwarf_dealloc_die(cu_die_for_print_frames);
}
}
if (glflags.gf_static_func_flag) {
int sres = 0;
Dwarf_Error err = 0;
reset_overall_CU_error_data();
sres = print_static_funcs(dbg,&err);
if (sres == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"printing SGI static funcs had a problem.",sres,err);
DROP_ERROR_INSTANCE(dbg,sres,err);
}
}
if (glflags.gf_static_var_flag) {
int sres = 0;
Dwarf_Error err = 0;
reset_overall_CU_error_data();
sres = print_static_vars(dbg,&err);
if (sres == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"printing SGI static vars had a problem.",sres,err);
DROP_ERROR_INSTANCE(dbg,sres,err);
}
}
/* DWARF_PUBTYPES is the standard typenames dwarf section.
SGI_TYPENAME is the same concept but is SGI specific ( it was
defined 10 years before dwarf pubtypes). */
if (glflags.gf_pubtypes_flag) {
Dwarf_Error err = 0;
int tres = 0;
reset_overall_CU_error_data();
tres = print_types(dbg, DWARF_PUBTYPES,&err);
if (tres == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"printing pubtypes had a problem.",tres,err);
DROP_ERROR_INSTANCE(dbg,tres,err);
}
reset_overall_CU_error_data();
tres = print_types(dbg, SGI_TYPENAME,&err);
if (tres == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"printing SGI typenames had a problem.",tres,err);
DROP_ERROR_INSTANCE(dbg,tres,err);
}
}
if (glflags.gf_weakname_flag) {
Dwarf_Error err = 0;
int res3 = 0;
reset_overall_CU_error_data();
res3 = print_weaknames(dbg, &err);
if (res3 == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"printing weaknames had a problem.",res3,err);
DROP_ERROR_INSTANCE(dbg,res3,err);
}
}
if (glflags.gf_reloc_flag && elf) {
#ifdef DWARF_WITH_LIBELF
int leres = 0;
Dwarf_Error err = 0;
reset_overall_CU_error_data();
leres = print_relocinfo(dbg,&err);
if (leres == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"printing relocinfo had a problem.",leres,err);
DROP_ERROR_INSTANCE(dbg,leres,err);
}
#else
reset_overall_CU_error_data();
#endif /* DWARF_WITH_LIBELF */
}
if (glflags.gf_debug_names_flag) {
int nres = 0;
Dwarf_Error err = 0;
reset_overall_CU_error_data();
nres = print_debug_names(dbg,&err);
if (nres == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"print .debug_names section failed", nres, err);
DROP_ERROR_INSTANCE(dbg,nres,err);
}
}
/* Print search results */
if (glflags.gf_search_print_results && glflags.gf_search_is_on) {
/* No dwarf errors possible in this function. */
print_search_results();
}
/* The right time to do this is unclear. But we need to do it. */
if (glflags.gf_check_harmless) {
/* No dwarf errors possible in this function. */
print_any_harmless_errors(dbg);
}
/* Print error report only if errors have been detected
Print error report if the -kd option.
No errors possible in this function. */
print_checks_results();
/* Print the detailed attribute usage space
and free the attributes_encoding data allocated. */
if (glflags.gf_check_attr_encoding) {
int ares = 0;
Dwarf_Error aerr = 0;
ares = print_attributes_encoding(dbg,&aerr);
if (ares == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"print attributes encoding failed", ares, aerr);
DROP_ERROR_INSTANCE(dbg,ares,aerr);
}
}
/* Print the tags and attribute usage */
if (glflags.gf_print_usage_tag_attr) {
int tres = 0;
Dwarf_Error err = 0;
tres = print_tag_attributes_usage(dbg,&err);
if (tres == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"print tag attributes usage failed", tres, err);
DROP_ERROR_INSTANCE(dbg,tres,err);
}
}
if (glflags.gf_print_str_offsets) {
/* print the .debug_str_offsets section, if any. */
int lres = 0;
Dwarf_Error err = 0;
lres = print_str_offsets_section(dbg,&err);
if (lres == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"print .debug_str_offsets failed", lres, err);
DROP_ERROR_INSTANCE(dbg,lres,err);
}
}
/* prints nothing unless section .gnu_debuglink is present.
Lets print for a few critical sections. */
if( glflags.gf_gnu_debuglink_flag) {
int lres = 0;
Dwarf_Error err = 0;
lres = print_gnu_debuglink(dbg,&err);
if (lres == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"print gnu_debuglink data failed", lres, err);
DROP_ERROR_INSTANCE(dbg,lres,err);
}
}
if( glflags.gf_debug_gnu_flag) {
int lres = 0;
Dwarf_Error err = 0;
lres = print_debug_gnu(dbg,&err);
if (lres == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"print .debug_gnu* section failed", lres, err);
DROP_ERROR_INSTANCE(dbg,lres,err);
}
}
if( glflags.gf_debug_sup_flag) {
int lres = 0;
Dwarf_Error err = 0;
lres = print_debug_sup(dbg,&err);
if (lres == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"print .debug_sup* section failed", lres, err);
DROP_ERROR_INSTANCE(dbg,lres,err);
}
}
if (glflags.gf_debug_addr_missing_search_by_address) {
printf("\nERROR: At some point "
"the .debug_addr section was needed but missing, "
"meaning some frame information was missing "
"relevant function names. See the dwarfdump "
" option --file-tied=</path/to/executable> .");
}
if (glflags.gf_error_code_in_name_search_by_address) {
printf("\nERROR: At some point "
"There was some data corruption in frame data "
"so at least the following error occurred: "
"%s .\n",
dwarf_errmsg_by_number(
glflags.gf_error_code_in_name_search_by_address));
}
/* Could finish dbg first. Either order ok. */
if (dbgtied) {
dres = dwarf_finish(dbgtied,&onef_err);
if (dres != DW_DLV_OK) {
print_error_and_continue(dbg,
"dwarf_finish failed on tied dbg", dres, onef_err);
DROP_ERROR_INSTANCE(dbg,dres,onef_err);
}
dbgtied = 0;
}
groups_restore_subsidiary_flags();
dres = dwarf_finish(dbg, &onef_err);
if (dres != DW_DLV_OK) {
print_error_and_continue(dbg,
"dwarf_finish failed", dres, onef_err);
DROP_ERROR_INSTANCE(dbg,dres,onef_err);
dbg = 0;
}
printf("\n");
#ifdef DWARF_WITH_LIBELF
clean_up_syms_malloc_data();
#endif /* DWARF_WITH_LIBELF */
destruct_abbrev_array();
esb_close_null_device();
release_range_array_info();
helpertree_clear_statistics(&helpertree_offsets_base_info);
helpertree_clear_statistics(&helpertree_offsets_base_types);
return 0;
}
/* Generic constants for debugging */
#define DUMP_RANGES_INFO 1 /* Dump RangesInfo Table. */
#define DUMP_LOCATION_SECTION_INFO 2 /* Dump Location (.debug_loc) Info. */
#define DUMP_RANGES_SECTION_INFO 3 /* Dump Ranges (.debug_ranges) Info. */
#define DUMP_LINKONCE_INFO 4 /* Dump Linkonce Table. */
#define DUMP_VISITED_INFO 5 /* Dump Visited Info. */
/* ==============START of dwarfdump error print functions. */
int
simple_err_return_msg_either_action(int res,const char *msg)
{
/*const char *msg = "\nERROR: dwarf_get_address_size() fails.";*/
const char *etype = "No-entry";
if (res == DW_DLV_ERROR) {
etype="Major error";
}
glflags.gf_count_major_errors++;
printf("%s fails. %s\n",msg,etype);
return res;
}
int
simple_err_return_action(int res,const char *msg)
{
if (res == DW_DLV_ERROR) {
const char *etype = "Major error";
glflags.gf_count_major_errors++;
printf("%s %s\n",msg, etype);
}
return res;
}
int
simple_err_only_return_action(int res,const char *msg)
{
const char *etype="Major error";
/*const char *msg = "\nERROR: dwarf_get_address_size() fails."; */
glflags.gf_count_major_errors++;
printf("%s %s\n",msg,etype);
return res;
}
/* ARGSUSED */
static void
print_error_maybe_continue(UNUSEDARG Dwarf_Debug dbg,
const char * msg,
int dwarf_ret_val,
Dwarf_Error lerr,
Dwarf_Bool do_continue)
{
unsigned long realmajorerr = glflags.gf_count_major_errors;
printf("\n");
if (dwarf_ret_val == DW_DLV_ERROR) {
/* We do not dwarf_dealloc the error` here. */
char * errmsg = dwarf_errmsg(lerr);
/* We now (April 2016) guarantee the
error number is in
the error string so we do not need to print
the dwarf_errno() value to show the number. */
if (do_continue) {
printf(
"%s ERROR: %s: %s. "
"Attempting to continue.\n",
glflags.program_name, msg, errmsg);
} else {
printf( "%s ERROR: %s: %s\n",
glflags.program_name, msg, errmsg);
}
} else if (dwarf_ret_val == DW_DLV_NO_ENTRY) {
printf("%s NO ENTRY: %s: \n",
glflags.program_name, msg);
} else if (dwarf_ret_val == DW_DLV_OK) {
printf("%s: %s \n", glflags.program_name, msg);
} else {
printf("%s InternalError: %s: code %d\n",
glflags.program_name, msg, dwarf_ret_val);
}
/* Display compile unit name */
PRINT_CU_INFO();
glflags.gf_count_major_errors = realmajorerr;
}
void
print_error(Dwarf_Debug dbg,
const char * msg,
int dwarf_ret_val,
Dwarf_Error lerr)
{
print_error_maybe_continue(dbg,msg,dwarf_ret_val,lerr,FALSE);
glflags.gf_count_major_errors++;
if (dwarf_ret_val == DW_DLV_ERROR) {
Dwarf_Error ignored_err = 0;
/* If dbg was never initialized
this still cleans up the Error data. */
DROP_ERROR_INSTANCE(dbg,dwarf_ret_val,lerr);
dwarf_finish(dbg, &ignored_err);
check_for_major_errors();
}
global_destructors();
flag_data_post_cleanup();
exit(FAILED);
}
/* ARGSUSED */
void
print_error_and_continue(Dwarf_Debug dbg,
const char * msg,
int dwarf_ret_val,
Dwarf_Error lerr)
{
glflags.gf_count_major_errors++;
print_error_maybe_continue(dbg,
msg,dwarf_ret_val,lerr,TRUE);
}
/* ==============END of dwarfdump error print functions. */
static boolean
is_a_string_form(int sf)
{
switch(sf){
case DW_FORM_string:
case DW_FORM_GNU_strp_alt:
case DW_FORM_strp_sup:
case DW_FORM_GNU_str_index:
case DW_FORM_strx:
case DW_FORM_strx1:
case DW_FORM_strx2:
case DW_FORM_strx3:
case DW_FORM_strx4:
case DW_FORM_strp:
case DW_FORM_line_strp:
/* There is some hope we can actually get
the string itself, depending on
other factors */
return TRUE;
}
/* Nope. No string is possible */
return FALSE;
}
/* Always sets the return argument *should_skip,
whether it returns DW_DLV_NO_ENTRY or
DW_DLV_ERROR or DW_DLV_OK.
determines if the CU should be
skipped as the DW_AT_name of the CU
does not match the command-line-supplied
cu name. The two callers ignore the
return value.
This suppresses any errors it finds, no
Dwarf_Error is lost and none is returned. */
int
should_skip_this_cu(Dwarf_Debug dbg, boolean*should_skip,
Dwarf_Die cu_die)
{
Dwarf_Half tag = 0;
Dwarf_Attribute attrib = 0;
Dwarf_Half theform = 0;
Dwarf_Error skperr;
int dares = 0;
int tres = 0;
int fres = 0;
tres = dwarf_tag(cu_die, &tag, &skperr);
if (tres != DW_DLV_OK) {
print_error_and_continue(dbg, "ERROR: "
"Cannot get the TAG of the cu_die to check "
" if we should skip this CU or not.",
tres, skperr);
*should_skip = FALSE;
DROP_ERROR_INSTANCE(dbg,tres,skperr);
return tres;
}
dares = dwarf_attr(cu_die, DW_AT_name, &attrib, &skperr);
if (dares != DW_DLV_OK) {
print_error_and_continue(dbg, "should skip this cu? "
" cu die has no DW_AT_name attribute!",
dares, skperr);
*should_skip = FALSE;
DROP_ERROR_INSTANCE(dbg,dares,skperr);
return dares;
}
fres = dwarf_whatform(attrib, &theform, &skperr);
if (fres == DW_DLV_OK) {
if (is_a_string_form(theform)) {
char * temps = 0;
int sres = dwarf_formstring(attrib, &temps,
&skperr);
if (sres == DW_DLV_OK) {
char *lcun = esb_get_string(glflags.cu_name);
char *p = temps;
if (lcun[0] != '/') {
p = strrchr(temps, '/');
if (p == NULL) {
p = temps;
} else {
p++;
}
}
/* Ignore case if Windows */
#if _WIN32
if (stricmp(lcun, p)) {
/* skip this cu. */
dwarf_dealloc_attribute(attrib);
*should_skip = TRUE;
return DW_DLV_OK;
}
#else
if (strcmp(lcun, p)) {
/* skip this cu. */
dwarf_dealloc_attribute(attrib);
*should_skip = TRUE;
return DW_DLV_OK;
}
#endif /* _WIN32 */
} else if (sres == DW_DLV_ERROR) {
struct esb_s m;
int dwarf_names_print_on_error = 1;
dwarf_dealloc_attribute(attrib);
esb_constructor(&m);
esb_append(&m,"In determining if we should "
"skip this CU dwarf_formstring "
"gets an error on form ");
esb_append(&m,get_FORM_name(theform,
dwarf_names_print_on_error));
esb_append(&m,".");
print_error_and_continue(dbg,
esb_get_string(&m),
sres, skperr);
*should_skip = FALSE;
esb_destructor(&m);
return sres;
} else {
/* DW_DLV_NO_ENTRY on the string itself */
dwarf_dealloc_attribute(attrib);
*should_skip = FALSE;
return sres;
}
}
} else if (fres == DW_DLV_ERROR) {
/* DW_DLV_ERROR */
print_error_and_continue(dbg,
"dwarf_whatform failed on a CU_die when"
" attempting to determine if this CU should"
" be skipped.",
fres, skperr);
} /* else DW_DLV_NO_ENTRY */
dwarf_dealloc_attribute(attrib);
*should_skip = FALSE;
return fres;
}
/* Returns the cu of the CUn the name fields when it can,
else a no-entry
else DW_DLV_ERROR. */
int
get_cu_name(Dwarf_Debug dbg, Dwarf_Die cu_die,
Dwarf_Off dieprint_cu_offset,
char * *short_name, char * *long_name,
Dwarf_Error *lerr)
{
Dwarf_Attribute name_attr = 0;
int ares = 0;
ares = dwarf_attr(cu_die, DW_AT_name, &name_attr, lerr);
if (ares == DW_DLV_ERROR) {
print_error_and_continue(dbg,
"dwarf_attr fails on DW_AT_name on the CU die",
ares, *lerr);
return ares;
} else if (ares == DW_DLV_NO_ENTRY) {
*short_name = "<unknown name>";
*long_name = "<unknown name>";
} else {
/* DW_DLV_OK */
/* The string return is valid until the next call to this
function; so if the caller needs to keep the returned
string, the string must be copied (makename()). */
char *filename = 0;
esb_empty_string(&esb_long_cu_name);
ares = get_attr_value(dbg, DW_TAG_compile_unit,
cu_die, /* die_indent */ 0, dieprint_cu_offset,
name_attr, NULL, 0, &esb_long_cu_name,
0 /*show_form_used*/,0 /* verbose */,lerr);
if (ares != DW_DLV_OK) {
*short_name = "<unknown name>";
*long_name = "<unknown name>";
return ares;
}
*long_name = esb_get_string(&esb_long_cu_name);
/* Generate the short name (filename) */
filename = strrchr(*long_name,'/');
if (!filename) {
filename = strrchr(*long_name,'\\');
}
if (filename) {
++filename;
} else {
filename = *long_name;
}
esb_empty_string(&esb_short_cu_name);
esb_append(&esb_short_cu_name,filename);
*short_name = esb_get_string(&esb_short_cu_name);
dwarf_dealloc_attribute(name_attr);
}
return ares;
}
/* Returns the producer of the CU
Caller must ensure producernameout is
a valid, constructed, empty esb_s instance before calling.
*/
int
get_producer_name(Dwarf_Debug dbg, Dwarf_Die cu_die,
Dwarf_Off dieprint_cu_offset,
struct esb_s *producernameout,
Dwarf_Error *err)
{
Dwarf_Attribute producer_attr = 0;
int ares = 0;
if (!cu_die) {
glflags.gf_count_major_errors++;
esb_append(producernameout,
"\"<ERROR:CU-missing-DW_AT_producer (null cu_die)>\"");
return DW_DLV_NO_ENTRY;
}
ares = dwarf_attr(cu_die, DW_AT_producer,
&producer_attr, err);
if (ares == DW_DLV_ERROR) {
glflags.gf_count_major_errors++;
esb_append(producernameout,
"\"<ERROR:on-DW_AT_producer>\"");
return ares;
}
if (ares == DW_DLV_NO_ENTRY) {
/* We add extra quotes so it looks more like
the names for real producers that get_attr_value
produces. */
esb_append(producernameout,
"\"<ERROR: CU-missing-DW_AT_producer>\"");
dwarf_dealloc_attribute(producer_attr);
return ares;
}
/* DW_DLV_OK */
ares = get_attr_value(dbg, DW_TAG_compile_unit,
cu_die,/* die_indent*/ 0, dieprint_cu_offset,
producer_attr, NULL, 0, producernameout,
0 /*show_form_used*/,0 /* verbose */,err);
dwarf_dealloc_attribute(producer_attr);
return ares;
}
void
print_secname(Dwarf_Debug dbg,const char *secname)
{
if (glflags.gf_do_print_dwarf) {
struct esb_s truename;
char buf[DWARF_SECNAME_BUFFER_SIZE];
esb_constructor_fixed(&truename,buf,sizeof(buf));
get_true_section_name(dbg,secname,
&truename,TRUE);
printf("\n%s\n",sanitized(esb_get_string(&truename)));
esb_destructor(&truename);
}
}
/* We'll check for errors when checking.
print only if printing (as opposed to checking). */
static int
print_gnu_debuglink(Dwarf_Debug dbg, Dwarf_Error *err)
{
int res = 0;
char * name = 0;
unsigned char *crcbytes = 0;
char * link_path = 0;
unsigned link_path_len = 0;
unsigned buildidtype = 0;
char *buildidowner = 0;
unsigned char *buildidbyteptr = 0;
unsigned buildidlength = 0;
char **paths_array = 0;
unsigned paths_array_length = 0;
res = dwarf_gnu_debuglink(dbg,
&name,
&crcbytes,
&link_path, /* free this */
&link_path_len,
&buildidtype,
&buildidowner,
&buildidbyteptr, &buildidlength,
&paths_array, /* free this */
&paths_array_length,
err);
if (res == DW_DLV_NO_ENTRY) {
return res;
} else if (res == DW_DLV_ERROR) {
print_secname(dbg,".gnu_debuglink");
return res;
}
if (crcbytes) {
print_secname(dbg,".gnu_debuglink");
/* Done with error checking, so print if we are printing. */
if (glflags.gf_do_print_dwarf) {
printf(" Debuglink name : %s",sanitized(name));
{
unsigned char *crc = 0;
unsigned char *end = 0;
crc = crcbytes;
end = crcbytes +4;
printf(" crc 0X: ");
for (; crc < end; crc++) {
printf("%02x ", *crc);
}
}
printf("\n");
if (link_path_len) {
printf(" Debuglink target: %s\n",sanitized(link_path));
}
}
}
if (buildidlength) {
print_secname(dbg,".note.gnu.build-id");
if (glflags.gf_do_print_dwarf) {
printf(" Build-id type : %u\n", buildidtype);
printf(" Build-id ownername: %s\n",
sanitized(buildidowner));
printf(" Build-id length : %u\n",buildidlength);
printf(" Build-id : ");
{
const unsigned char *cur = 0;
const unsigned char *end = 0;
cur = buildidbyteptr;
end = cur + buildidlength;
for (; cur < end; cur++) {
printf("%02x", (unsigned char)*cur);
}
}
printf("\n");
}
}
if (paths_array_length) {
unsigned i = 0;
printf(" Possible "
".gnu_debuglink/.note.gnu.build-id pathnames for\n");
printf(" an alternate object file with more detailed DWARF\n");
for( ; i < paths_array_length; ++i) {
char *path = paths_array[i];
char outpath[2000];
unsigned long outpathlen = sizeof(outpath);
unsigned int ftype = 0;
unsigned int endian = 0;
unsigned int offsetsize = 0;
Dwarf_Unsigned filesize = 0;
int errcode = 0;
printf(" [%u] %s\n",i,sanitized(path));
res = dwarf_object_detector_path(path,
outpath,outpathlen,&ftype,&endian,&offsetsize,
&filesize, &errcode);
if (res == DW_DLV_NO_ENTRY) {
if (glflags.verbose) {
printf(" file above does not exist\n");
}
continue;
}
if (res == DW_DLV_ERROR) {
printf(" access attempt of the above leads"
" to error %s\n",
dwarf_errmsg_by_number(errcode));
continue;
}
switch(ftype) {
case DW_FTYPE_ELF:
printf(" file above is an Elf object\n");
break;
case DW_FTYPE_MACH_O:
printf(" file above is a Mach-O object\n");
break;
case DW_FTYPE_PE:
printf(" file above is a PE object");
break;
case DW_FTYPE_CUSTOM_ELF:
printf(" file above is a custom elf object");
break;
case DW_FTYPE_ARCHIVE:
if (glflags.verbose) {
printf(" file above is an archive "
"so ignore it.\n");
}
continue;
default:
if (glflags.verbose) {
printf(" file above is not"
" any object type we recognize\n");
}
continue;
}
}
printf("\n");
}
free(link_path);
free(paths_array);
return DW_DLV_OK;
}
/* GCC linkonce names */
char *lo_text = ".text."; /*".gnu.linkonce.t.";*/
char *lo_debug_abbr = ".gnu.linkonce.wa.";
char *lo_debug_aranges = ".gnu.linkonce.wr.";
char *lo_debug_frame_1 = ".gnu.linkonce.wf.";
char *lo_debug_frame_2 = ".gnu.linkonce.wF.";
char *lo_debug_info = ".gnu.linkonce.wi.";
char *lo_debug_line = ".gnu.linkonce.wl.";
char *lo_debug_macinfo = ".gnu.linkonce.wm.";
char *lo_debug_loc = ".gnu.linkonce.wo.";
char *lo_debug_pubnames = ".gnu.linkonce.wp.";
char *lo_debug_ranges = ".gnu.linkonce.wR.";
char *lo_debug_str = ".gnu.linkonce.ws.";
/* SNC compiler/linker linkonce names */
char *nlo_text = ".text.";
char *nlo_debug_abbr = ".debug.wa.";
char *nlo_debug_aranges = ".debug.wr.";
char *nlo_debug_frame_1 = ".debug.wf.";
char *nlo_debug_frame_2 = ".debug.wF.";
char *nlo_debug_info = ".debug.wi.";
char *nlo_debug_line = ".debug.wl.";
char *nlo_debug_macinfo = ".debug.wm.";
char *nlo_debug_loc = ".debug.wo.";
char *nlo_debug_pubnames = ".debug.wp.";
char *nlo_debug_ranges = ".debug.wR.";
char *nlo_debug_str = ".debug.ws.";
/* Build linkonce section information */
void
build_linkonce_info(Dwarf_Debug dbg)
{
int nCount = 0;
int section_index = 0;
int res = 0;
static char **linkonce_names[] = {
&lo_text, /* .text */
&nlo_text, /* .text */
&lo_debug_abbr, /* .debug_abbr */
&nlo_debug_abbr, /* .debug_abbr */
&lo_debug_aranges, /* .debug_aranges */
&nlo_debug_aranges, /* .debug_aranges */
&lo_debug_frame_1, /* .debug_frame */
&nlo_debug_frame_1, /* .debug_frame */
&lo_debug_frame_2, /* .debug_frame */
&nlo_debug_frame_2, /* .debug_frame */
&lo_debug_info, /* .debug_info */
&nlo_debug_info, /* .debug_info */
&lo_debug_line, /* .debug_line */
&nlo_debug_line, /* .debug_line */
&lo_debug_macinfo, /* .debug_macinfo */
&nlo_debug_macinfo, /* .debug_macinfo */
&lo_debug_loc, /* .debug_loc */
&nlo_debug_loc, /* .debug_loc */
&lo_debug_pubnames, /* .debug_pubnames */
&nlo_debug_pubnames, /* .debug_pubnames */
&lo_debug_ranges, /* .debug_ranges */
&nlo_debug_ranges, /* .debug_ranges */
&lo_debug_str, /* .debug_str */
&nlo_debug_str, /* .debug_str */
NULL
};
const char *section_name = NULL;
Dwarf_Addr section_addr = 0;
Dwarf_Unsigned section_size = 0;
Dwarf_Error error = 0;
int nIndex = 0;
nCount = dwarf_get_section_count(dbg);
/* Ignore section with index=0 */
for (section_index = 1; section_index < nCount; ++section_index) {
res = dwarf_get_section_info_by_index(dbg,section_index,
§ion_name,
§ion_addr,
§ion_size,
&error);
if (res == DW_DLV_OK) {
for (nIndex = 0; linkonce_names[nIndex]; ++nIndex) {
if (section_name == strstr(section_name,
*linkonce_names[nIndex])) {
/* Insert only linkonce sections */
AddEntryIntoBucketGroup(glflags.pLinkonceInfo,
section_index,
section_addr,section_addr,
section_addr + section_size,
section_name,
TRUE);
break;
}
}
}
}
if (dump_linkonce_info) {
PrintBucketGroup(glflags.pLinkonceInfo,TRUE);
}
}
/* Check for specific TAGs and initialize some
information used by '-k' options */
void
tag_specific_checks_setup(Dwarf_Debug dbg,
Dwarf_Half val,int die_indent_level)
{
switch (val) {
/* DW_TAG_type unit will not have addresses */
/* DW_TAG_skeleton unit will have addresses, but
likely no children. But they are useful
as marking glflags.seen_CU TRUE is useful */
case DW_TAG_partial_unit:
case DW_TAG_compile_unit:
case DW_TAG_type_unit:
case DW_TAG_skeleton_unit:
/* To help getting the compile unit name */
glflags.seen_CU = TRUE;
/* If we are checking line information, build
the table containing the pairs LowPC and HighPC */
if (glflags.gf_check_decl_file ||
glflags.gf_check_ranges ||
glflags.gf_check_locations) {
Dwarf_Debug td = 0;
if (!dbg) {
ResetBucketGroup(glflags.pRangesInfo);
} else {
/* Only returns DW_DLV_OK */
dwarf_get_tied_dbg(dbg,&td,0);
/* With a tied-dbg we do not have
detailed address ranges, so
do not reset the single .text-size
bucket group */
if (!td) {
ResetBucketGroup(glflags.pRangesInfo);
}
}
}
/* The following flag indicate that only
low_pc and high_pc
values found in DW_TAG_subprograms
are going to be considered when
building the address table used to check
ranges, lines, etc */
glflags.need_PU_valid_code = TRUE;
break;
case DW_TAG_subprogram:
/* Keep track of a PU */
if (die_indent_level == 1) {
/* A DW_TAG_subprogram can be nested,
when is used to
declare a member function for a
local class; process the DIE
only if we are at level zero in the DIEs tree */
glflags.seen_PU = TRUE;
glflags.seen_PU_base_address = FALSE;
glflags.seen_PU_high_address = FALSE;
glflags.PU_name[0] = 0;
glflags.need_PU_valid_code = TRUE;
}
break;
}
}
/* Print CU basic information but
use the local DIE for the offsets. */
void PRINT_CU_INFO(void)
{
Dwarf_Unsigned loff = glflags.DIE_offset;
Dwarf_Unsigned goff = glflags.DIE_overall_offset;
char lbuf[50];
char hbuf[50];
if (glflags.current_section_id == DEBUG_LINE ||
glflags.current_section_id == DEBUG_FRAME ||
glflags.current_section_id == DEBUG_FRAME_EH_GNU ||
glflags.current_section_id == DEBUG_ARANGES ||
glflags.current_section_id == DEBUG_MACRO ||
glflags.current_section_id == DEBUG_PUBNAMES ||
glflags.current_section_id == DEBUG_MACINFO ) {
/* These sections involve the CU die, so
use the CU offsets.
The DEBUG_MAC* cases are logical but
not yet useful (Dec 2015).
In other cases the local DIE offset makes
more sense. */
loff = glflags.DIE_CU_offset;
goff = glflags.DIE_CU_overall_offset;
}
if (!cu_data_is_set()) {
return;
}
printf("\n");
printf("CU Name = %s\n",sanitized(glflags.CU_name));
printf("CU Producer = %s\n",sanitized(glflags.CU_producer));
printf("DIE OFF = 0x%" DW_PR_XZEROS DW_PR_DUx
" GOFF = 0x%" DW_PR_XZEROS DW_PR_DUx,
loff,goff);
/* We used to print leftover and incorrect values at times. */
if (glflags.need_CU_high_address) {
safe_strcpy(hbuf,sizeof(hbuf),"unknown ",10);
} else {
/* safe, hbuf is large enough. */
sprintf(hbuf,
"0x%" DW_PR_XZEROS DW_PR_DUx,glflags.CU_high_address);
}
if (glflags.need_CU_base_address) {
safe_strcpy(lbuf,sizeof(lbuf),"unknown ",10);
} else {
/* safe, lbuf is large enough. */
sprintf(lbuf,
"0x%" DW_PR_XZEROS DW_PR_DUx,glflags.CU_low_address);
}
printf(", Low PC = %s, High PC = %s", lbuf,hbuf);
printf("\n");
}
void DWARF_CHECK_ERROR_PRINT_CU()
{
if (glflags.gf_check_verbose_mode) {
if (glflags.gf_print_unique_errors) {
if (!glflags.gf_found_error_message) {
PRINT_CU_INFO();
}
} else {
PRINT_CU_INFO();
}
}
glflags.check_error++;
glflags.gf_record_dwarf_error = TRUE;
}
/* Sometimes is useful, just to know the kind of errors
in an object file; not much interest in the number
of errors; the specific case is just to have a general
idea about the DWARF quality in the file */
char ** set_unique_errors = NULL;
unsigned int set_unique_errors_entries = 0;
unsigned int set_unique_errors_size = 0;
#define SET_UNIQUE_ERRORS_DELTA 64
/* Create the space to store the unique error messages */
void
allocate_unique_errors_table(void)
{
if (!set_unique_errors) {
set_unique_errors = (char **)
malloc(SET_UNIQUE_ERRORS_DELTA * sizeof(char*));
set_unique_errors_size = SET_UNIQUE_ERRORS_DELTA;
set_unique_errors_entries = 0;
}
}
#ifdef TESTING
/* Just for debugging purposes, dump the unique errors table */
void
dump_unique_errors_table(void)
{
unsigned int index;
printf("*** Unique Errors Table ***\n");
printf("Delta : %d\n",SET_UNIQUE_ERRORS_DELTA);
printf("Size : %d\n",set_unique_errors_size);
printf("Entries: %d\n",set_unique_errors_entries);
for (index = 0; index < set_unique_errors_entries; ++index) {
printf("%3d: '%s'\n",index,set_unique_errors[index]);
}
}
#endif
/* Release the space used to store the unique error messages */
void
release_unique_errors_table(void)
{
unsigned int index;
for (index = 0; index < set_unique_errors_entries; ++index) {
free(set_unique_errors[index]);
}
free(set_unique_errors);
set_unique_errors = 0;
set_unique_errors_entries = 0;
set_unique_errors_size = 0;
}
/* Returns TRUE if the text is already in the set; otherwise FALSE */
boolean
add_to_unique_errors_table(char * error_text)
{
unsigned int index;
size_t len;
char * stored_text;
char * filtered_text;
char * start = NULL;
char * end = NULL;
char * pattern = "0x";
char * white = " ";
char * question = "?";
/* Create a copy of the incoming text */
filtered_text = makename(error_text);
len = strlen(filtered_text);
/* Remove from the error_text, any hexadecimal numbers (start with 0x),
because for some errors, an additional information is given in the
form of addresses; we are interested just in the general error. */
start = strstr(filtered_text,pattern);
while (start) {
/* We have found the start of the pattern; look for a space */
end = strstr(start,white);
if (!end) {
/* Preserve any line terminator */
end = filtered_text + len -1;
}
memset(start,*question,end - start);
start = strstr(filtered_text,pattern);
}
/* Check if the error text is already in the table */
for (index = 0; index < set_unique_errors_entries; ++index) {
stored_text = set_unique_errors[index];
if (!strcmp(stored_text,filtered_text)) {
return TRUE;
}
}
/* Store the new text; check if we have space
to store the error text */
if (set_unique_errors_entries + 1 == set_unique_errors_size) {
set_unique_errors_size += SET_UNIQUE_ERRORS_DELTA;
set_unique_errors = (char **)realloc(set_unique_errors,
set_unique_errors_size * sizeof(char*));
}
set_unique_errors[set_unique_errors_entries] = filtered_text;
++set_unique_errors_entries;
return FALSE;
}
/*
Print a DWARF error message and if in "reduced" output
only print one error of each kind; this feature is useful,
when we are interested only in the kind of errors and
not on the number of errors.
PRECONDITION: if s3 non-null so are s1,s2.
If s2 is non-null so is s1.
s1 is always non-null. */
static void
print_dwarf_check_error(const char *s1,
const char *s2,
const char *s3)
{
static boolean do_init = TRUE;
boolean found = FALSE;
char * error_text = NULL;
static char *leader = "\n*** DWARF CHECK: ";
static char *trailer = " ***\n";
if (do_init) {
esb_constructor(&dwarf_error_line);
do_init = FALSE;
}
esb_empty_string(&dwarf_error_line);
esb_append(&dwarf_error_line,leader);
if (s3) {
esb_append(&dwarf_error_line,s1);
esb_append(&dwarf_error_line," -> ");
esb_append(&dwarf_error_line,s2);
esb_append(&dwarf_error_line,": ");
esb_append(&dwarf_error_line,s3);
} else if (s2) {
esb_append(&dwarf_error_line,s1);
esb_append(&dwarf_error_line,": ");
esb_append(&dwarf_error_line,s2);
} else {
esb_append(&dwarf_error_line,s1);
}
esb_append(&dwarf_error_line,trailer);
error_text = esb_get_string(&dwarf_error_line);
if (glflags.gf_print_unique_errors) {
found = add_to_unique_errors_table(error_text);
if (!found) {
printf("%s",error_text);
}
} else {
printf("%s",error_text);
}
/* To indicate if the current error message has
been found or not */
glflags.gf_found_error_message = found;
}
void
DWARF_CHECK_ERROR3(Dwarf_Check_Categories category,
const char *str1, const char *str2, const char *strexpl)
{
if (checking_this_compiler()) {
DWARF_ERROR_COUNT(category,1);
if (glflags.gf_check_verbose_mode) {
print_dwarf_check_error(str1, str2,strexpl);
}
DWARF_CHECK_ERROR_PRINT_CU();
}
}
/* This is too much to put in the DROP_ERROR_INSTANCE macro,
so we put it here rather arbitrarily. */
void
report_caller_error_drop_error(int dwdlv,
int line, char *fname)
{
printf("\nERROR in dwarfdump:"
" The value passed to the macro DROP_ERROR_INSTANCE "
"is not one of the three allowed values, but is "
"%d. dwarfdump has a bug. "
" See line %d file %s\n",dwdlv,line,fname);
glflags.gf_count_major_errors++;
}
|