aboutsummaryrefslogtreecommitdiff
path: root/gprofng/src/Stabs.cc
blob: 28a6a3d2c5efa8997065273b480055ad92f203fc (plain)
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
/* Copyright (C) 2021-2024 Free Software Foundation, Inc.
   Contributed by Oracle.

   This file is part of GNU Binutils.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, 51 Franklin Street - Fifth Floor, Boston,
   MA 02110-1301, USA.  */

#include "config.h"
#include <sys/param.h>

#include "util.h"
#include "Elf.h"
#include "Dwarf.h"
#include "stab.h"
#include "DbeSession.h"
#include "CompCom.h"
#include "Stabs.h"
#include "LoadObject.h"
#include "Module.h"
#include "Function.h"
#include "info.h"
#include "StringBuilder.h"
#include "DbeFile.h"
#include "StringMap.h"

#define DISASM_REL_NONE     0     /* symtab search only */
#define DISASM_REL_ONLY     1     /* relocation search only */
#define DISASM_REL_TARG     2     /* relocatoin then symtab */

///////////////////////////////////////////////////////////////////////////////
// class StabReader
class StabReader
{
public:
  StabReader (Elf *_elf, Platform_t platform, int StabSec, int StabStrSec);
  ~StabReader () { };
  char *get_type_name (int t);
  char *get_stab (struct stab *np, bool comdat);
  void parse_N_OPT (Module *mod, char *str);
  int stabCnt;
  int stabNum;

private:
  Elf *elf;
  char *StabData;
  char *StabStrtab;
  char *StabStrtabEnd;
  int StrTabSize;
  int StabEntSize;
};

///////////////////////////////////////////////////////////////////////////////
// class Symbol

class Symbol
{
public:
  Symbol (Vector<Symbol*> *vec = NULL);

  ~Symbol ()
  {
    free (name);
  }

  inline Symbol *
  cardinal ()
  {
    return alias ? alias : this;
  }

  static void dump (Vector<Symbol*> *vec, char*msg);

  Function *func;
  Sp_lang_code lang_code;
  uint64_t value; // st_value used in sym_name()
  uint64_t save;
  int64_t size;
  uint64_t img_offset; // image offset in the ELF file
  char *name;
  Symbol *alias;
  int local_ind;
  int flags;
  bool defined;
};

Symbol::Symbol (Vector<Symbol*> *vec)
{
  func = NULL;
  lang_code = Sp_lang_unknown;
  value = 0;
  save = 0;
  size = 0;
  img_offset = 0;
  name = NULL;
  alias = NULL;
  local_ind = -1;
  flags = 0;
  defined = false;
  if (vec)
    vec->append (this);
}

void
Symbol::dump (Vector<Symbol*> *vec, char*msg)
{
  if (!DUMP_ELF_SYM || vec == NULL || vec->size () == 0)
    return;
  printf (NTXT ("======= Symbol::dump: %s =========\n"
		"         value |    img_offset     | flags|local_ind|\n"), msg);
  for (int i = 0; i < vec->size (); i++)
    {
      Symbol *sp = vec->fetch (i);
      printf (NTXT ("  %3d %8lld |0x%016llx |%5d |%8d |%s\n"),
	      i, (long long) sp->value, (long long) sp->img_offset, sp->flags,
	      sp->local_ind, sp->name ? sp->name : NTXT ("NULL"));
    }
  printf (NTXT ("\n===== END of Symbol::dump: %s =========\n\n"), msg);
}

// end of class Symbol
///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////
// class Reloc
class Reloc
{
public:
  Reloc ();
  ~Reloc ();
  uint64_t type;
  uint64_t value;
  uint64_t addend;
  char *name;
};

Reloc::Reloc ()
{
  type = 0;
  value = 0;
  addend = 0;
  name = NULL;
}

Reloc::~Reloc ()
{
  free (name);
}
// end of class Reloc
///////////////////////////////////////////////////////////////////////////////

enum
{
  SYM_PLT       = 1 << 0,
  SYM_UNDEF     = 1 << 1
};

enum Section_type
{
  COMM1_SEC = 0x10000000,
  COMM_SEC  = 0x20000000,
  INFO_SEC  = 0x30000000,
  LOOP_SEC  = 0x40000000
};

struct cpf_stabs_t
{
  uint32_t type;    // Archive::AnalyzerInfoType
  uint32_t offset;  // offset in .__analyzer_info
  Module *module;   // table for appropriate Module
};

static char *get_info_com (int type, int32_t copy_inout);
static char *get_lp_com (unsigned hints, int parallel, char *dep);
static int ComCmp (const void *a, const void *b);
static ino64_t _src_inode = 0;
static char *_src_name;

// Comparing name
static int
SymNameCmp (const void *a, const void *b)
{
  Symbol *item1 = *((Symbol **) a);
  Symbol *item2 = *((Symbol **) b);
  return (item1->name == NULL) ? -1 :
	  (item2->name == NULL) ? 1 : strcmp (item1->name, item2->name);
}

// Comparing value: for sorting
static int
SymValueCmp (const void *a, const void *b)
{
  Symbol *item1 = *((Symbol **) a);
  Symbol *item2 = *((Symbol **) b);
  return (item1->value > item2->value) ? 1 :
	  (item1->value == item2->value) ? SymNameCmp (a, b) : -1;
}

// Comparing value: for searching (source name is always NULL)
static int
SymFindCmp (const void *a, const void *b)
{
  Symbol *item1 = *((Symbol **) a);
  Symbol *item2 = *((Symbol **) b);
  if (item1->value < item2->value)
    return -1;
  if (item1->value < item2->value + item2->size
      || item1->value == item2->value) // item2->size == 0
    return 0;
  return 1;
}

// Comparing value for sorting. It is used only for searching aliases.
static int
SymImgOffsetCmp (const void *a, const void *b)
{
  Symbol *item1 = *((Symbol **) a);
  Symbol *item2 = *((Symbol **) b);
  return (item1->img_offset > item2->img_offset) ? 1 :
	  (item1->img_offset == item2->img_offset) ? SymNameCmp (a, b) : -1;
}

static int
RelValueCmp (const void *a, const void *b)
{
  Reloc *item1 = *((Reloc **) a);
  Reloc *item2 = *((Reloc **) b);
  return (item1->value > item2->value) ? 1 :
	  (item1->value == item2->value) ? 0 : -1;
}

Stabs *
Stabs::NewStabs (char *_path, char *lo_name)
{
  Stabs *stabs = new Stabs (_path, lo_name);
  if (stabs->status != Stabs::DBGD_ERR_NONE)
    {
      delete stabs;
      return NULL;
    }
  return stabs;
}

Stabs::Stabs (char *_path, char *_lo_name)
{
  path = dbe_strdup (_path);
  lo_name = dbe_strdup (_lo_name);
  SymLstByName = NULL;
  pltSym = NULL;
  SymLst = new Vector<Symbol*>;
  RelLst = new Vector<Reloc*>;
  RelPLTLst = new Vector<Reloc*>;
  LocalLst = new Vector<Symbol*>;
  LocalFile = new Vector<char*>;
  LocalFileIdx = new Vector<int>;
  last_PC_to_sym = NULL;
  dwarf = NULL;
  elfDbg = NULL;
  elfDis = NULL;
  stabsModules = NULL;
  textsz = 0;
  wsize = Wnone;
  st_check_symtab = st_check_relocs = false;
  status = DBGD_ERR_NONE;

  if (openElf (false) == NULL)
    return;
  switch (elfDis->elf_getclass ())
    {
    case ELFCLASS32:
      wsize = W32;
      break;
    case ELFCLASS64:
      wsize = W64;
      break;
    }
  isRelocatable = elfDis->elf_getehdr ()->e_type == ET_REL;
  for (unsigned int pnum = 0; pnum < elfDis->elf_getehdr ()->e_phnum; pnum++)
    {
      Elf_Internal_Phdr *phdr = elfDis->get_phdr (pnum);
      if (phdr->p_type == PT_LOAD && phdr->p_flags == (PF_R | PF_X))
	{
	  if (textsz == 0)
	    textsz = phdr->p_memsz;
	  else
	    {
	      textsz = 0;
	      break;
	    }
	}
    }
}

Stabs::~Stabs ()
{
  delete SymLstByName;
  Destroy (SymLst);
  Destroy (RelLst);
  Destroy (RelPLTLst);
  Destroy (LocalFile);
  delete elfDis;
  delete dwarf;
  delete LocalLst;
  delete LocalFileIdx;
  delete stabsModules;
  free (path);
  free (lo_name);
}

Elf *
Stabs::openElf (char *fname, Stab_status &st)
{
  Elf::Elf_status elf_status;
  Elf *elf = Elf::elf_begin (fname, &elf_status);
  if (elf == NULL)
    {
      switch (elf_status)
	{
	case Elf::ELF_ERR_CANT_OPEN_FILE:
	case Elf::ELF_ERR_CANT_MMAP:
	case Elf::ELF_ERR_BIG_FILE:
	  st = DBGD_ERR_CANT_OPEN_FILE;
	  break;
	case Elf::ELF_ERR_BAD_ELF_FORMAT:
	default:
	  st = DBGD_ERR_BAD_ELF_FORMAT;
	  break;
	}
      return NULL;
    }
  if (elf->elf_version (EV_CURRENT) == EV_NONE)
    {
      // ELF library out of date
      delete elf;
      st = DBGD_ERR_BAD_ELF_LIB;
      return NULL;
    }

  Elf_Internal_Ehdr *ehdrp = elf->elf_getehdr ();
  if (ehdrp == NULL)
    {
      // check machine
      delete elf;
      st = DBGD_ERR_BAD_ELF_FORMAT;
      return NULL;
    }
  switch (ehdrp->e_machine)
    {
    case EM_SPARC:
      platform = Sparc;
      break;
    case EM_SPARC32PLUS:
      platform = Sparcv8plus;
      break;
    case EM_SPARCV9:
      platform = Sparcv9;
      break;
    case EM_386:
      //    case EM_486:
      platform = Intel;
      break;
    case EM_X86_64:
      platform = Amd64;
      break;
    case EM_AARCH64:
      platform = Aarch64;
      break;
    default:
      platform = Unknown;
      break;
    }
  return elf;
}

Elf *
Stabs::openElf (bool dbg_info)
{
  if (status != DBGD_ERR_NONE)
    return NULL;
  if (elfDis == NULL)
    {
      elfDis = openElf (path, status);
      if (elfDis == NULL)
	return NULL;
    }
  if (!dbg_info)
    return elfDis;
  if (elfDbg == NULL)
    {
      elfDbg = elfDis->find_ancillary_files (lo_name);
      if (elfDbg == NULL)
	elfDbg = elfDis;
    }
  return elfDbg;
}

bool
Stabs::read_symbols (Vector<Function*> *functions)
{
  if (openElf (true) == NULL)
    return false;
  check_Symtab ();
  check_Relocs ();
  if (functions)
    {
      Function *fp;
      int index;
      Vec_loop (Function*, functions, index, fp)
      {
	fp->img_fname = path;
      }
    }
  return true;
}

char *
Stabs::sym_name (uint64_t target, uint64_t instr, int flag)
{
  long index;
  if (flag == DISASM_REL_ONLY || flag == DISASM_REL_TARG)
    {
      Reloc *relptr = new Reloc;
      relptr->value = instr;
      index = RelLst->bisearch (0, -1, &relptr, RelValueCmp);
      if (index >= 0)
	{
	  delete relptr;
	  return RelLst->fetch (index)->name;
	}
      if (!is_relocatable ())
	{
	  relptr->value = target;
	  index = RelPLTLst->bisearch (0, -1, &relptr, RelValueCmp);
	  if (index >= 0)
	    {
	      delete relptr;
	      return RelPLTLst->fetch (index)->name;
	    }
	}
      delete relptr;
    }
  if (flag == DISASM_REL_NONE || flag == DISASM_REL_TARG || !is_relocatable ())
    {
      Symbol *sptr;
      sptr = map_PC_to_sym (target);
      if (sptr && sptr->value == target)
	return sptr->name;
    }
  return NULL;
}

Symbol *
Stabs::map_PC_to_sym (uint64_t pc)
{
  if (pc == 0)
    return NULL;
  if (last_PC_to_sym && last_PC_to_sym->value <= pc
      && last_PC_to_sym->value + last_PC_to_sym->size > pc)
    return last_PC_to_sym;
  Symbol *sym = new Symbol;
  sym->value = pc;
  long index = SymLst->bisearch (0, -1, &sym, SymFindCmp);
  delete sym;
  if (index >= 0)
    {
      last_PC_to_sym = SymLst->fetch (index)->cardinal ();
      return last_PC_to_sym;
    }
  return NULL;
}

Function *
Stabs::map_PC_to_func (uint64_t pc, uint64_t &low_pc, Vector<Function*> *functions)
{
  int index;
  Function *func;
  Symbol *sptr = map_PC_to_sym (pc);
  if (sptr == NULL)
    return NULL;
  if (sptr->func)
    {
      low_pc = sptr->value;
      return sptr->func;
    }
  if (functions)
    {
      Vec_loop (Function*, functions, index, func)
      {
	if (func->img_offset == sptr->img_offset)
	  {
	    sptr->func = func->cardinal ();
	    low_pc = sptr->value;
	    return sptr->func;
	  }
      }
    }
  return NULL;
}

Stabs::Stab_status
Stabs::read_stabs (ino64_t srcInode, Module *module, Vector<ComC*> *comComs,
		   bool readDwarf)
{
  if (module)
    module->setIncludeFile (NULL);

  if (openElf (true) == NULL)
    return status;
  check_Symtab ();

  // read compiler commentary from .compcom1, .compcom,
  // .info, .loops, and .loopview sections
  if (comComs)
    {
      _src_inode = srcInode;
      _src_name = module && module->file_name ? get_basename (module->file_name) : NULL;
      if (!check_Comm (comComs))
	// .loops, and .loopview are now in .compcom
	check_Loop (comComs);

      // should not read it after .info goes into .compcom
      check_Info (comComs);
      comComs->sort (ComCmp);
    }

  // get stabs info
  Stab_status statusStabs = DBGD_ERR_NO_STABS;
#define SRC_LINE_STABS(sec, secStr, comdat) \
    if ((elfDbg->sec)  && (elfDbg->secStr) && \
	srcline_Stabs(module, elfDbg->sec, elfDbg->secStr, comdat) == DBGD_ERR_NONE) \
	statusStabs = DBGD_ERR_NONE

  SRC_LINE_STABS (stabExcl, stabExclStr, false);
  SRC_LINE_STABS (stab, stabStr, false);
  SRC_LINE_STABS (stabIndex, stabIndexStr, true);

  // read Dwarf, if any sections found
  if (elfDbg->dwarf && readDwarf)
    {
      openDwarf ()->srcline_Dwarf (module);
      if (dwarf && dwarf->status == DBGD_ERR_NONE)
	return DBGD_ERR_NONE;
    }
  return statusStabs;
}

static int
ComCmp (const void *a, const void *b)
{
  ComC *item1 = *((ComC **) a);
  ComC *item2 = *((ComC **) b);
  return (item1->line > item2->line) ? 1 :
	  (item1->line < item2->line) ? -1 :
	  (item1->sec > item2->sec) ? 1 :
	  (item1->sec < item2->sec) ? -1 : 0;
}

static int
check_src_name (char *srcName)
{
  if (_src_name && srcName && streq (_src_name, get_basename (srcName)))
    return 1;
  if (_src_inode == (ino64_t) - 1)
    return 0;
  DbeFile *dbeFile = dbeSession->getDbeFile (srcName, DbeFile::F_SOURCE);
  char *path = dbeFile->get_location ();
  return (path == NULL || dbeFile->sbuf.st_ino != _src_inode) ? 0 : 1;
}

bool
Stabs::check_Comm (Vector<ComC*> *comComs)
{
  int sz = comComs->size ();
  Elf *elf = openElf (true);
  if (elf == NULL)
    return false;

  for (unsigned int sec = 1; sec < elf->elf_getehdr ()->e_shnum; sec++)
    {
      char *name = elf->get_sec_name (sec);
      if (name == NULL)
	continue;
      Section_type sec_type;
      if (streq (name, NTXT (".compcom")))
	sec_type = COMM_SEC;
      else if (streq (name, NTXT (".compcom1")))
	sec_type = COMM1_SEC;
      else
	continue;

      // find header, set messages id & visibility if succeed
      CompComment *cc = new CompComment (elf, sec);
      int cnt = cc->compcom_open ((CheckSrcName) check_src_name);
      // process messages
      for (int index = 0; index < cnt; index++)
	{
	  int visible;
	  compmsg msg;
	  char *str = cc->compcom_format (index, &msg, visible);
	  if (str)
	    {
	      ComC *citem = new ComC;
	      citem->sec = sec_type + index;
	      citem->type = msg.msg_type;
	      citem->visible = visible;
	      citem->line = (msg.lineno < 1) ? 1 : msg.lineno;
	      citem->com_str = str;
	      comComs->append (citem);
	    }
	}
      delete cc;
    }
  return (sz != comComs->size ());
}

static int
targetOffsetCmp (const void *a, const void *b)
{
  uint32_t o1 = ((target_info_t *) a)->offset;
  uint32_t o2 = ((target_info_t *) b)->offset;
  return (o1 >= o2);
}

void
Stabs::check_AnalyzerInfo ()
{
  Elf *elf = openElf (true);
  if ((elf == NULL) || (elf->analyzerInfo == 0))
    {
      Dprintf (DEBUG_STABS, NTXT ("Stabs::check_AnalyzerInfo: Null AnalyzerInfo section\n"));
      return; // inappropriate, but ignored anyway
    }
  Elf_Data *data = elf->elf_getdata (elf->analyzerInfo);
  int InfoSize = (int) data->d_size;
  char *InfoData = (char *) data->d_buf;
  int InfoAlign = (int) data->d_align;
  AnalyzerInfoHdr h;
  unsigned infoHdr_sz = sizeof (AnalyzerInfoHdr);
  int table, entry;
  int read = 0;
  Module *mitem;
  int index = 0;
  if (InfoSize <= 0)
    return;
  uint64_t baseAddr = elf->get_baseAddr ();
  Dprintf (DEBUG_STABS, NTXT ("Stabs::check_AnalyzerInfo size=%d @0x%lx (align=%d) base=0x%llx\n"),
	   InfoSize, (ul_t) InfoData, InfoAlign, (long long) baseAddr);
  Dprintf (DEBUG_STABS, NTXT ("analyzerInfoMap has %lld entries\n"), (long long) analyzerInfoMap.size ());
  if (analyzerInfoMap.size () == 0)
    {
      Dprintf (DEBUG_STABS, NTXT ("No analyzerInfoMap available!\n"));
      return;
    }

  // verify integrity of analyzerInfoMap before reading analyzerInfo
  unsigned count = 0;
  Module *lastmod = NULL;
  for (index = 0; index < analyzerInfoMap.size (); index++)
    {
      cpf_stabs_t map = analyzerInfoMap.fetch (index);
      if (map.type > 3)
	{
	  Dprintf (DEBUG_STABS, NTXT ("analyzerInfo contains table of unknown type %d for %s\n"),
		   map.type, map.module->get_name ());
	  return;
	}
      if (map.module != lastmod)
	{
	  if (lastmod != NULL)
	    Dprintf (DEBUG_STABS, "analyzerInfo contains %d 0x0 offset tables for %s\n",
		     count, lastmod->get_name ());
	  count = 0;
	}
      count += (map.offset == 0x0); // only check for 0x0 tables for now
      if (count > 4)
	{
	  Dprintf (DEBUG_STABS, NTXT ("analyzerInfo contains too many 0x0 offset tables for %s\n"),
		   map.module->get_name ());
	  return;
	}
      lastmod = map.module;
    }

  index = 0;
  while ((index < analyzerInfoMap.size ()) && (read < InfoSize))
    {
      for (table = 0; table < 3; table++)
	{ // memory operations (ld, st, prefetch)
	  // read the table header
	  memcpy ((void *) &h, (const void *) InfoData, infoHdr_sz);
	  InfoData += infoHdr_sz;
	  read += infoHdr_sz;

	  // use map for appropriate module
	  cpf_stabs_t map = analyzerInfoMap.fetch (index);
	  index++;
	  mitem = map.module;
	  Dprintf (DEBUG_STABS, "Table %d offset=0x%04x "
		   "text_labelref=0x%08llx entries=%d version=%d\n"
		   "itype %d offset=0x%04x module=%s\n", table, read,
		   (long long) (h.text_labelref - baseAddr), h.entries,
		   h.version, map.type, map.offset, map.module->get_name ());
	  // read the table entries
	  for (entry = 0; entry < h.entries; entry++)
	    {
	      memop_info_t *m = new memop_info_t;
	      unsigned memop_info_sz = sizeof (memop_info_t);
	      memcpy ((void *) m, (const void *) InfoData, memop_info_sz);
	      InfoData += memop_info_sz;
	      read += memop_info_sz;
	      m->offset += (uint32_t) (h.text_labelref - baseAddr);
	      Dprintf (DEBUG_STABS, NTXT ("%4d(%d): offset=0x%04x id=0x%08x sig=0x%08x dtid=0x%08x\n"),
		       entry, table, m->offset, m->id, m->signature, m->datatype_id);
	      switch (table)
		{
		case CPF_INSTR_TYPE_LD:
		  mitem->ldMemops.append (m);
		  break;
		case CPF_INSTR_TYPE_ST:
		  mitem->stMemops.append (m);
		  break;
		case CPF_INSTR_TYPE_PREFETCH:
		  mitem->pfMemops.append (m);
		  break;
		}
	    }
	  // following re-alignment should be redundant
	  //InfoData+=(read%InfoAlign); read+=(read%InfoAlign); // re-align
	}
      for (table = 3; table < 4; table++)
	{ // branch targets
	  memcpy ((void *) &h, (const void *) InfoData, infoHdr_sz);
	  InfoData += infoHdr_sz;
	  read += infoHdr_sz;

	  // use map for appropriate module
	  cpf_stabs_t map = analyzerInfoMap.fetch (index);
	  index++;
	  mitem = map.module;
	  Dprintf (DEBUG_STABS, "Table %d offset=0x%04x "
		   "text_labelref=0x%08llx entries=%d version=%d\n"
		   "itype %d offset=0x%04x module=%s\n", table, read,
		   (long long) (h.text_labelref - baseAddr), h.entries,
		   h.version, map.type, map.offset, map.module->get_name ());
	  for (entry = 0; entry < h.entries; entry++)
	    {
	      target_info_t *t = new target_info_t;
	      unsigned target_info_sz = sizeof (target_info_t);
	      memcpy ((void *) t, (const void *) InfoData, target_info_sz);
	      InfoData += target_info_sz;
	      read += target_info_sz;
	      t->offset += (uint32_t) (h.text_labelref - baseAddr);
	      Dprintf (DEBUG_STABS, NTXT ("%4d(%d): offset=0x%04x\n"), entry,
		       table, t->offset);
	      // the list of branch targets needs to be in offset sorted order
	      // and doing it here before archiving avoids the need to do it
	      // each time the archive is read.
	      mitem->bTargets.incorporate (t, targetOffsetCmp);
	    }
	  Dprintf (DEBUG_STABS, NTXT ("bTargets for %s has %lld items (last=0x%04x)\n"),
		   mitem->get_name (), (long long) mitem->bTargets.size (),
		   (mitem->bTargets.fetch (mitem->bTargets.size () - 1))->offset);
	  Dprintf (DEBUG_STABS, "read=%d at end of bTargets (InfoData=0x%lx)\n",
		   read, (ul_t) InfoData);
	  InfoData += (read % InfoAlign);
	  read += (read % InfoAlign); // re-align
	  Dprintf (DEBUG_STABS, "read=%d at end of bTargets (InfoData=0x%lx)\n",
		   read, (ul_t) InfoData);
	}
      Dprintf (DEBUG_STABS, "Stabs::check_AnalyzerInfo bytes read=%lld (index=%lld/%lld)\n",
	       (long long) read, (long long) index,
	       (long long) analyzerInfoMap.size ());
    }
}

void
Stabs::check_Info (Vector<ComC*> *comComs)
{
  Elf *elf = openElf (true);
  if (elf == NULL || elf->info == 0)
    return;
  Elf_Data *data = elf->elf_getdata (elf->info);
  uint64_t InfoSize = data->d_size;
  char *InfoData = (char *) data->d_buf;
  bool get_src = false;
  for (int h_num = 0; InfoSize; h_num++)
    {
      if (InfoSize < sizeof (struct info_header))
	return;
      struct info_header *h = (struct info_header*) InfoData;
      if (h->endian != '\0' || h->magic[0] != 'S' || h->magic[1] != 'U'
	  || h->magic[2] != 'N')
	return;
      if (h->len < InfoSize || h->len < sizeof (struct info_header) || (h->len & 3))
	return;

      char *fname = InfoData + sizeof (struct info_header);
      InfoData += h->len;
      InfoSize -= h->len;
      get_src = check_src_name (fname);
      for (uint32_t e_num = 0; e_num < h->cnt; ++e_num)
	{
	  if (InfoSize < sizeof (struct entry_header))
	    return;
	  struct entry_header *e = (struct entry_header*) InfoData;
	  if (InfoSize < e->len)
	    return;
	  int32_t copy_inout = 0;
	  if (e->len > sizeof (struct entry_header))
	    if (e->type == F95_COPYINOUT)
	      copy_inout = *(int32_t*) (InfoData + sizeof (struct entry_header));
	  InfoData += e->len;
	  InfoSize -= e->len;
	  if (get_src)
	    {
	      ComC *citem = new ComC;
	      citem->sec = INFO_SEC + h_num;
	      citem->type = e->msgnum & 0xFFFFFF;
	      citem->visible = CCMV_ALL;
	      citem->line = e->line;
	      citem->com_str = get_info_com (citem->type, copy_inout);
	      comComs->append (citem);
	    }
	}
      if (get_src)
	break;
    }
}

static char *
get_info_com (int type, int32_t copy_inout)
{
  switch (type)
    {
    case 1:
      return dbe_sprintf (GTXT ("In the call below, parameter number %d caused a copy-in -- loop(s) inserted"),
			  copy_inout);
    case 2:
      return dbe_sprintf (GTXT ("In the call below, parameter number %d caused a copy-out -- loop(s) inserted"),
			  copy_inout);
    case 3:
      return dbe_sprintf (GTXT ("In the call below, parameter number %d caused a copy-in and a copy-out -- loops inserted"),
			  copy_inout);
    case 4:
      return dbe_strdup (GTXT ("Alignment of variables in common block may cause performance degradation"));
    case 5:
      return dbe_strdup (GTXT ("DO statement bounds lead to no executions of the loop"));
    default:
      return dbe_strdup (NTXT (""));
    }
}

void
Stabs::check_Loop (Vector<ComC*> *comComs)
{
  Elf *elf = openElf (true);
  if (elf == NULL)
    return;

  StringBuilder sb;
  for (unsigned int sec = 1; sec < elf->elf_getehdr ()->e_shnum; sec++)
    {
      char *name = elf->get_sec_name (sec);
      if (name == NULL)
	continue;
      if (!streq (name, NTXT (".loops")) && !streq (name, NTXT (".loopview")))
	continue;

      Elf_Data *data = elf->elf_getdata (sec);
      size_t LoopSize = (size_t) data->d_size, len;
      char *LoopData = (char *) data->d_buf;
      int remainder, i;
      char src[2 * MAXPATHLEN], buf1[MAXPATHLEN], buf2[MAXPATHLEN];
      char **dep_str = NULL;
      bool get_src = false;
      while ((LoopSize > 0) && !get_src &&
	     (strncmp (LoopData, NTXT ("Source:"), 7) == 0))
	{
	  // The first three items in a .loops subsection are three strings.
	  //	Source: ...
	  //	Version: ...
	  //	Number of loops: ...
	  sscanf (LoopData, NTXT ("%*s%s"), src);
	  len = strlen (LoopData) + 1;
	  LoopData += len;
	  LoopSize -= len;
	  sscanf (LoopData, NTXT ("%*s%*s%s"), buf1);
	  //	double version   = atof(buf1);
	  len = strlen (LoopData) + 1;
	  LoopData += len;
	  LoopSize -= len;
	  get_src = check_src_name (src);
	  sscanf (LoopData, NTXT ("%*s%*s%*s%s%s"), buf1, buf2);
	  int n_loop = atoi (buf1);
	  int n_depend = atoi (buf2);
	  len = strlen (LoopData) + 1;
	  LoopData += len;
	  LoopSize -= len;
	  if (get_src && (n_loop > 0))
	    {
	      dep_str = new char*[n_loop];
	      for (i = 0; i < n_loop; i++)
		dep_str[i] = NULL;
	    }

	  // printf("Source: %s\nVersion: %f\nLoop#: %d\nDepend#: %d\n",
	  //	src, version, n_loop, n_depend);

	  // Read in the strings that contain the list of variables that cause
	  // data dependencies inside of loops. Not every loop has such a list
	  // of variables.
	  //
	  //	Example: if loop #54 has data dependencies caused by the
	  //	variables named i, j and foo, then the string that represents
	  //	this in the .loops section looks like this:
	  //
	  //	.asciz "54:i.j.foo"
	  //
	  //	The variable names are delimited with .
	  //
	  //	For now, store these strings in an array, and add them into
	  //	the loop structure when we read in the numeric loop info
	  //	(that's what we read in next.)
	  //
	  // printf("\tDependenncies:\n");
	  for (i = 0; i < n_depend; i++)
	    {
	      len = strlen (LoopData) + 1;
	      LoopData += len;
	      LoopSize -= len;
	      if (dep_str != NULL)
		{
		  char *dep_buf1 = dbe_strdup (LoopData);
		  char *ptr = strtok (dep_buf1, NTXT (":"));
		  if (ptr != NULL)
		    {
		      int index = atoi (ptr);
		      bool dep_first = true;
		      sb.setLength (0);
		      while ((ptr = strtok (NULL, NTXT (", "))) != NULL)
			{
			  if (dep_first)
			    dep_first = false;
			  else
			    sb.append (NTXT (", "));
			  sb.append (ptr);
			}
		      if (sb.length () > 0 && index < n_loop)
			dep_str[index] = sb.toString ();
		    }
		  free (dep_buf1);
		}
	    }

	  // Adjust Data pointer so that it is word aligned.
	  remainder = (int) (((unsigned long) LoopData) % 4);
	  if (remainder != 0)
	    {
	      len = 4 - remainder;
	      LoopData += len;
	      LoopSize -= len;
	    }

	  // Read in the loop info, one loop at a time.
	  for (i = 0; i < n_loop; i++)
	    {
	      int loopid = *((int *) LoopData);
	      LoopData += 4;
	      int line_no = *((int *) LoopData);
	      if (line_no < 1) // compiler has trouble on this
		line_no = 1;
	      LoopData += 4;
	      //	    int nest = *((int *) LoopData);
	      LoopData += 4;
	      int parallel = *((int *) LoopData);
	      LoopData += 4;
	      unsigned hints = *((unsigned *) LoopData);
	      LoopData += 4;
	      //	    int count = *((int *) LoopData);
	      LoopData += 4;
	      LoopSize -= 24;
	      if (!get_src || (loopid >= n_loop))
		continue;
	      ComC *citem = new ComC;
	      citem->sec = LOOP_SEC + i;
	      citem->type = hints;
	      citem->visible = CCMV_ALL;
	      citem->line = line_no;
	      citem->com_str = get_lp_com (hints, parallel, dep_str[loopid]);
	      comComs->append (citem);
	    }
	  if (dep_str)
	    {
	      for (i = 0; i < n_loop; i++)
		free (dep_str[i]);
	      delete[] dep_str;
	      dep_str = NULL;
	    }
	}
    }
}

static char *
get_lp_com (unsigned hints, int parallel, char *dep)
{
  StringBuilder sb;
  if (parallel == -1)
    sb.append (GTXT ("Loop below is serial, but parallelizable: "));
  else if (parallel == 0)
    sb.append (GTXT ("Loop below is not parallelized: "));
  else
    sb.append (GTXT ("Loop below is parallelized: "));
  switch (hints)
    {
    case 0:
      // No loop mesg will print
      // strcat(com, GTXT("no hint available"));
      break;
    case 1:
      sb.append (GTXT ("loop contains procedure call"));
      break;
    case 2:
      sb.append (GTXT ("compiler generated two versions of this loop"));
      break;
    case 3:
      {
	StringBuilder sb_tmp;
	sb_tmp.sprintf (GTXT ("the variable(s) \"%s\" cause a data dependency in this loop"),
			dep ? dep : GTXT ("<Unknown>"));
	sb.append (&sb_tmp);
      }
      break;
    case 4:
      sb.append (GTXT ("loop was significantly transformed during optimization"));
      break;
    case 5:
      sb.append (GTXT ("loop may or may not hold enough work to be profitably parallelized"));
      break;
    case 6:
      sb.append (GTXT ("loop was marked by user-inserted pragma"));
      break;
    case 7:
      sb.append (GTXT ("loop contains multiple exits"));
      break;
    case 8:
      sb.append (GTXT ("loop contains I/O, or other function calls, that are not MT safe"));
      break;
    case 9:
      sb.append (GTXT ("loop contains backward flow of control"));
      break;
    case 10:
      sb.append (GTXT ("loop may have been distributed"));
      break;
    case 11:
      sb.append (GTXT ("two loops or more may have been fused"));
      break;
    case 12:
      sb.append (GTXT ("two or more loops may have been interchanged"));
      break;
    default:
      break;
    }
  return sb.toString ();
}

StabReader::StabReader (Elf *_elf, Platform_t platform, int StabSec, int StabStrSec)
{
  stabCnt = -1;
  stabNum = 0;
  if (_elf == NULL)
    return;
  elf = _elf;

  // Get ELF data
  Elf_Data *data = elf->elf_getdata (StabSec);
  if (data == NULL)
    return;
  uint64_t stabSize = data->d_size;
  StabData = (char *) data->d_buf;
  Elf_Internal_Shdr *shdr = elf->get_shdr (StabSec);
  if (shdr == NULL)
    return;

  // GCC bug: sh_entsize is 20 for 64 apps on Linux
  StabEntSize = (platform == Amd64 || platform == Sparcv9) ? 12 : (unsigned) shdr->sh_entsize;
  if (stabSize == 0 || StabEntSize == 0)
    return;
  data = elf->elf_getdata (StabStrSec);
  if (data == NULL)
    return;
  shdr = elf->get_shdr (StabStrSec);
  if (shdr == NULL)
    return;
  StabStrtab = (char *) data->d_buf;
  StabStrtabEnd = StabStrtab + shdr->sh_size;
  StrTabSize = 0;
  stabCnt = (int) (stabSize / StabEntSize);
}

char *
StabReader::get_stab (struct stab *np, bool comdat)
{
  struct stab *stbp = (struct stab *) (StabData + stabNum * StabEntSize);
  stabNum++;
  *np = *stbp;
  np->n_desc = elf->decode (stbp->n_desc);
  np->n_strx = elf->decode (stbp->n_strx);
  np->n_value = elf->decode (stbp->n_value);
  switch (np->n_type)
    {
    case N_UNDF:
    case N_ILDPAD:
      // Start of new stab section (or padding)
      StabStrtab += StrTabSize;
      StrTabSize = np->n_value;
    }

  char *str = NULL;
  if (np->n_strx)
    {
      if (comdat && np->n_type == N_FUN && np->n_other == 1)
	{
	  if (np->n_strx == 1)
	    StrTabSize++;
	  str = StabStrtab + StrTabSize;
	  // Each COMDAT string must be sized to find the next string:
	  StrTabSize += strlen (str) + 1;
	}
      else
	str = StabStrtab + np->n_strx;
      if (str >= StabStrtabEnd)
	str = NULL;
    }
  if (DEBUG_STABS)
    {
      char buf[128];
      char *s = get_type_name (np->n_type);
      if (s == NULL)
	{
	  snprintf (buf, sizeof (buf), NTXT ("n_type=%d"), np->n_type);
	  s = buf;
	}
      if (str)
	{
	  Dprintf (DEBUG_STABS, NTXT ("%4d:  .stabs \"%s\",%s,0x%x,0x%x,0x%x\n"),
		   stabNum - 1, str, s, (int) np->n_other, (int) np->n_desc,
		   (int) np->n_value);
	}
      else
	Dprintf (DEBUG_STABS, NTXT ("%4d:  .stabn %s,0x%x,0x%x,0x%x\n"),
		 stabNum - 1, s, (int) np->n_other, (int) np->n_desc,
		 (int) np->n_value);
    }
  return str;
}

void
StabReader::parse_N_OPT (Module *mod, char *str)
{
  if (mod == NULL || str == NULL)
      return;
  for (char *s = str; 1; s++)
    {
      switch (*s)
	{
	case 'd':
	  if (s[1] == 'i' && s[2] == ';')
	    {
	      delete mod->dot_o_file;
	      mod->dot_o_file = NULL;
	    }
	  break;
	case 's':
	  if ((s[1] == 'i' || s[1] == 'n') && s[2] == ';')
	    {
	      delete mod->dot_o_file;
	      mod->dot_o_file = NULL;
	    }
	  break;
	}
      s = strchr (s, ';');
      if (s == NULL)
	break;
    }
}

Stabs::Stab_status
Stabs::srcline_Stabs (Module *module, unsigned int StabSec,
		      unsigned int StabStrSec, bool comdat)
{
  StabReader *stabReader = new StabReader (openElf (true), platform, StabSec, StabStrSec);
  int tot = stabReader->stabCnt;
  if (tot < 0)
    {
      delete stabReader;
      return DBGD_ERR_NO_STABS;
    }
  int n, lineno;
  char *sbase, *n_so = NTXT (""), curr_src[2 * MAXPATHLEN];
  Function *newFunc;
  Sp_lang_code _lang_code = module->lang_code;
  Vector<Function*> *functions = module->functions;
  bool no_stabs = true;
  *curr_src = '\0';
  Function *func = NULL;
  int phase = 0;
  int stabs_level = 0;
  int xline = 0;

  // Find module
  for (n = 0; n < tot; n++)
    {
      struct stab stb;
      char *str = stabReader->get_stab (&stb, comdat);
      if (stb.n_type == N_UNDF)
	phase = 0;
      else if (stb.n_type == N_SO)
	{
	  if (str == NULL || *str == '\0')
	    continue;
	  if (phase == 0)
	    {
	      phase = 1;
	      n_so = str;
	      continue;
	    }
	  phase = 0;
	  sbase = str;
	  if (*str == '/')
	    {
	      if (streq (sbase, module->file_name))
		break;
	    }
	  else
	    {
	      size_t last = strlen (n_so);
	      if (n_so[last - 1] == '/')
		last--;
	      if (strncmp (n_so, module->file_name, last) == 0 &&
		  module->file_name[last] == '/' &&
		  streq (sbase, module->file_name + last + 1))
		break;
	    }
	}
    }
  if (n >= tot)
    {
      delete stabReader;
      return DBGD_ERR_NO_STABS;
    }

  Include *includes = new Include;
  includes->new_src_file (module->getMainSrc (), 0, NULL);
  module->hasStabs = true;
  *curr_src = '\0';
  phase = 0;
  for (n++; n < tot; n++)
    {
      struct stab stb;
      char *str = stabReader->get_stab (&stb, comdat);
      int n_desc = (int) ((unsigned short) stb.n_desc);
      switch (stb.n_type)
	{
	case N_UNDF:
	case N_SO:
	case N_ENDM:
	  n = tot;
	  break;
	case N_ALIAS:
	  if (str == NULL)
	    break;
	  if (is_fortran (_lang_code))
	    {
	      char *p = strchr (str, ':');
	      if (p && streq (p + 1, NTXT ("FMAIN")))
		{
		  Function *afunc = find_func (NTXT ("MAIN"), functions, true);
		  if (afunc)
		    afunc->set_match_name (dbe_strndup (str, p - str));
		  break;
		}
	    }
	case N_FUN:
	case N_OUTL:
	  if (str == NULL)
	    break;
	  if (*str == '@')
	    {
	      str++;
	      if (*str == '>' || *str == '<')
		str++;
	    }
	  if (stabs_level != 0)
	    break;

	  // find address of the enclosed function
	  newFunc = find_func (str, functions, is_fortran (_lang_code));
	  if (newFunc == NULL)
	    break;
	  if (func)
	    while (func->popSrcFile ())
	      ;
	  func = newFunc;

	  // First line info to cover function from the beginning
	  lineno = xline + n_desc;
	  if (lineno > 0)
	    {
	      // Set the chain of includes for the new function
	      includes->push_src_files (func);
	      func->add_PC_info (0, lineno);
	      no_stabs = false;
	    }
	  break;
	case N_ENTRY:
	  break;
	case N_CMDLINE:
	  if (str && !module->comp_flags)
	    {
	      char *comp_flags = strchr (str, ';');
	      if (comp_flags)
		{
		  module->comp_flags = dbe_strdup (comp_flags + 1);
		  module->comp_dir = dbe_strndup (str, comp_flags - str);
		}
	    }
	  break;
	case N_LBRAC:
	  stabs_level++;
	  break;
	case N_RBRAC:
	  stabs_level--;
	  break;
	case N_XLINE:
	  xline = n_desc << 16;
	  break;
	case N_SLINE:
	  if (func == NULL)
	    break;
	  no_stabs = false;
	  lineno = xline + n_desc;
	  if (func->line_first <= 0)
	    {
	      // Set the chain of includes for the new function
	      includes->push_src_files (func);
	      func->add_PC_info (0, lineno);
	      break;
	    }
	  if (func->curr_srcfile == NULL)
	    includes->push_src_files (func);
	  if (func->line_first != lineno ||
	      !streq (curr_src, func->getDefSrc ()->get_name ()))
	    func->add_PC_info (stb.n_value, lineno);
	  break;
	case N_OPT:
	  if ((str != NULL) && streq (str, NTXT ("gcc2_compiled.")))
	    _lang_code = Sp_lang_gcc;
	  switch (elfDbg->elf_getehdr ()->e_type)
	    {
	    case ET_EXEC:
	    case ET_DYN:
	      // set the real object timestamp from the executable's N_OPT stab
	      // due to bug #4796329
	      module->real_timestamp = stb.n_value;
	      break;
	    default:
	      module->curr_timestamp = stb.n_value;
	      break;
	    }
	  break;
	case N_GSYM:
	  if ((str == NULL) || strncmp (str, NTXT ("__KAI_K"), 7))
	    break;
	  str += 7;
	  if (!strncmp (str, NTXT ("CC_"), 3))
	    _lang_code = Sp_lang_KAI_KCC;
	  else if (!strncmp (str, NTXT ("cc_"), 3))
	    _lang_code = Sp_lang_KAI_Kcc;
	  else if (!strncmp (str, NTXT ("PTS_"), 4) &&
		   (_lang_code != Sp_lang_KAI_KCC) &&
		   (_lang_code != Sp_lang_KAI_Kcc))
	    _lang_code = Sp_lang_KAI_KPTS;
	  break;
	case N_BINCL:
	  includes->new_include_file (module->setIncludeFile (str), func);
	  break;
	case N_EINCL:
	  includes->end_include_file (func);
	  break;
	case N_SOL:
	  if (str == NULL)
	    break;
	  lineno = xline + n_desc;
	  if (lineno > 0 && func && func->line_first <= 0)
	    {
	      includes->push_src_files (func);
	      func->add_PC_info (0, lineno);
	      no_stabs = false;
	    }
	  if (streq (sbase, str))
	    {
	      module->setIncludeFile (NULL);
	      snprintf (curr_src, sizeof (curr_src), NTXT ("%s"), module->file_name);
	      includes->new_src_file (module->getMainSrc (), lineno, func);
	    }
	  else
	    {
	      if (streq (sbase, get_basename (str)))
		{
		  module->setIncludeFile (NULL);
		  snprintf (curr_src, sizeof (curr_src), NTXT ("%s"), module->file_name);
		  includes->new_src_file (module->setIncludeFile (curr_src), lineno, func);
		}
	      else
		{
		  if (*str == '/')
		    snprintf (curr_src, sizeof (curr_src), NTXT ("%s"), str);
		  else
		    {
		      size_t last = strlen (n_so);
		      if (last == 0 || n_so[last - 1] != '/')
			snprintf (curr_src, sizeof (curr_src), NTXT ("%s/%s"), n_so, str);
		      else
			snprintf (curr_src, sizeof (curr_src), NTXT ("%s%s"), n_so, str);
		    }
		  includes->new_src_file (module->setIncludeFile (curr_src), lineno, func);
		}
	    }
	  break;
	}
    }
  delete includes;
  delete stabReader;
  return no_stabs ? DBGD_ERR_NO_STABS : DBGD_ERR_NONE;
}//srcline_Stabs

static bool
cmp_func_name (char *fname, size_t len, char *name, bool fortran)
{
  return (strncmp (name, fname, len) == 0
	  && (name[len] == 0
	      || (fortran && name[len] == '_' && name[len + 1] == 0)));
}

Function *
Stabs::find_func (char *fname, Vector<Function*> *functions, bool fortran, bool inner_names)
{
  char *arg, *name;
  Function *item;
  int index;
  size_t len;

  len = strlen (fname);
  arg = strchr (fname, ':');
  if (arg != NULL)
    {
      if (arg[1] == 'P') // Prototype for function
	return NULL;
      len -= strlen (arg);
    }

  Vec_loop (Function*, functions, index, item)
  {
    name = item->get_mangled_name ();
    if (cmp_func_name (fname, len, name, fortran))
      return item->cardinal ();
  }

  if (inner_names)
    {
      // Dwarf subprograms may only have plain (non-linker) names
      // Retry with inner names only

      Vec_loop (Function*, functions, index, item)
      {
	name = strrchr (item->get_mangled_name (), '.');
	if (!name) continue;
	name++;
	if (cmp_func_name (fname, len, name, fortran))
	  return item->cardinal ();
      }
    }
  return NULL;
}

Map<const char*, Symbol*> *
Stabs::get_elf_symbols ()
{
  Elf *elf = openElf (false);
  if (elf->elfSymbols == NULL)
    {
      Map<const char*, Symbol*> *elfSymbols = new StringMap<Symbol*>(128, 128);
      elf->elfSymbols = elfSymbols;
      for (int i = 0, sz = SymLst ? SymLst->size () : 0; i < sz; i++)
	{
	  Symbol *sym = SymLst->fetch (i);
	  elfSymbols->put (sym->name, sym);
	}
    }
  return elf->elfSymbols;
}

void
Stabs::read_dwarf_from_dot_o (Module *mod)
{
  Dprintf (DEBUG_STABS, NTXT ("stabsModules: %s\n"), STR (mod->get_name ()));
  Vector<Module*> *mods = mod->dot_o_file->seg_modules;
  char *bname = get_basename (mod->get_name ());
  for (int i1 = 0, sz1 = mods ? mods->size () : 0; i1 < sz1; i1++)
    {
      Module *m = mods->fetch (i1);
      Dprintf (DEBUG_STABS, NTXT ("  MOD: %s\n"), STR (m->get_name ()));
      if (dbe_strcmp (bname, get_basename (m->get_name ())) == 0)
	{
	  mod->indexStabsLink = m;
	  m->indexStabsLink = mod;
	  break;
	}
    }
  if (mod->indexStabsLink)
    {
      mod->dot_o_file->objStabs->openDwarf ()->srcline_Dwarf (mod->indexStabsLink);
      Map<const char*, Symbol*> *elfSymbols = get_elf_symbols ();
      Vector<Function*> *funcs = mod->indexStabsLink->functions;
      for (int i1 = 0, sz1 = funcs ? funcs->size () : 0; i1 < sz1; i1++)
	{
	  Function *f1 = funcs->fetch (i1);
	  Symbol *sym = elfSymbols->get (f1->get_mangled_name ());
	  if (sym == NULL)
	    continue;
	  Dprintf (DEBUG_STABS, NTXT ("  Symbol: %s func=%p\n"), STR (sym->name), sym->func);
	  Function *f = sym->func;
	  if (f->indexStabsLink)
	    continue;
	  f->indexStabsLink = f1;
	  f1->indexStabsLink = f;
	  f->copy_PCInfo (f1);
	}
    }
}

Stabs::Stab_status
Stabs::read_archive (LoadObject *lo)
{
  if (openElf (true) == NULL)
    return status;
  check_Symtab ();
  if (elfDbg->dwarf)
    openDwarf ()->archive_Dwarf (lo);

  // get Module/Function lists from stabs info
  Stab_status statusStabs = DBGD_ERR_NO_STABS;
#define ARCHIVE_STABS(sec, secStr, comdat) \
    if ((elfDbg->sec) != 0  && (elfDbg->secStr) != 0 && \
	archive_Stabs(lo, elfDbg->sec, elfDbg->secStr, comdat) == DBGD_ERR_NONE) \
	statusStabs = DBGD_ERR_NONE

  // prefer index stabs (where they exist) since they're most appropriate
  // for loadobjects and might have N_CPROF stabs for ABS/CPF
  ARCHIVE_STABS (stabIndex, stabIndexStr, true);
  ARCHIVE_STABS (stabExcl, stabExclStr, false);
  ARCHIVE_STABS (stab, stabStr, false);

  // Add all unassigned functions to the <unknown> module
  Symbol *sitem, *alias;
  int index;
  Vec_loop (Symbol*, SymLst, index, sitem)
  {
    if (sitem->func || (sitem->size == 0) || (sitem->flags & SYM_UNDEF))
      continue;
    alias = sitem->alias;
    if (alias)
      {
	if (alias->func == NULL)
	  {
	    alias->func = createFunction (lo, lo->noname, alias);
	    alias->func->alias = alias->func;
	  }
	if (alias != sitem)
	  {
	    sitem->func = createFunction (lo, alias->func->module, sitem);
	    sitem->func->alias = alias->func;
	  }
      }
    else
      sitem->func = createFunction (lo, lo->noname, sitem);
  }
  if (pltSym)
    {
      pltSym->func = createFunction (lo, lo->noname, pltSym);
      pltSym->func->flags |= FUNC_FLAG_PLT;
    }

  // need Module association, so this must be done after handling Modules
  check_AnalyzerInfo ();

  if (dwarf && dwarf->status == DBGD_ERR_NONE)
    return DBGD_ERR_NONE;
  return statusStabs;
}//read_archive

Function *
Stabs::createFunction (LoadObject *lo, Module *module, Symbol *sym)
{
  Function *func = dbeSession->createFunction ();
  func->module = module;
  func->img_fname = path;
  func->img_offset = sym->img_offset;
  func->save_addr = sym->save;
  func->size = sym->size;
  func->set_name (sym->name);
  func->elfSym = sym;
  module->functions->append (func);
  lo->functions->append (func);
  return func;
}

void
Stabs::fixSymtabAlias ()
{
  int ind, i, k;
  Symbol *sym, *bestAlias;
  SymLst->sort (SymImgOffsetCmp);
  ind = SymLst->size () - 1;
  for (i = 0; i < ind; i++)
    {
      bestAlias = SymLst->fetch (i);
      if (bestAlias->img_offset == 0) // Ignore this bad symbol
	continue;
      sym = SymLst->fetch (i + 1);
      if (bestAlias->img_offset != sym->img_offset)
	{
	  if ((bestAlias->size == 0) ||
	      (sym->img_offset < bestAlias->img_offset + bestAlias->size))
	    bestAlias->size = sym->img_offset - bestAlias->img_offset;
	  continue;
	}

      // Find a "best" alias
      size_t bestLen = strlen (bestAlias->name);
      int64_t maxSize = bestAlias->size;
      for (k = i + 1; k <= ind; k++)
	{
	  sym = SymLst->fetch (k);
	  if (bestAlias->img_offset != sym->img_offset)
	    { // no more aliases
	      if ((maxSize == 0) ||
		  (sym->img_offset < bestAlias->img_offset + maxSize))
		maxSize = sym->img_offset - bestAlias->img_offset;
	      break;
	    }
	  if (maxSize < sym->size)
	    maxSize = sym->size;
	  size_t len = strlen (sym->name);
	  if (len < bestLen)
	    {
	      bestAlias = sym;
	      bestLen = len;
	    }
	}
      for (; i < k; i++)
	{
	  sym = SymLst->fetch (i);
	  sym->alias = bestAlias;
	  sym->size = maxSize;
	}
      i--;
    }
}

void
Stabs::check_Symtab ()
{
  if (st_check_symtab)
    return;
  st_check_symtab = true;

  Elf *elf = openElf (true);
  if (elf == NULL)
    return;
  if (elf->plt != 0)
    {
      Elf_Internal_Shdr *shdr = elf->get_shdr (elf->plt);
      if (shdr)
	{
	  pltSym = new Symbol (SymLst);
	  pltSym->value = shdr->sh_addr;
	  pltSym->size = shdr->sh_size;
	  pltSym->img_offset = shdr->sh_offset;
	  pltSym->name = dbe_strdup (NTXT ("@plt"));
	  pltSym->flags |= SYM_PLT;
	}
    }
  if (elf->symtab)
    readSymSec (elf->symtab, elf);
  else
    {
      readSymSec (elf->SUNW_ldynsym, elf);
      readSymSec (elf->dynsym, elf);
    }
}

void
Stabs::readSymSec (unsigned int sec, Elf *elf)
{
  Symbol *sitem;
  Sp_lang_code local_lcode;
  if (sec == 0)
    return;
  // Get ELF data
  Elf_Data *data = elf->elf_getdata (sec);
  if (data == NULL)
    return;
  uint64_t SymtabSize = data->d_size;
  Elf_Internal_Shdr *shdr = elf->get_shdr (sec);

  if ((SymtabSize == 0) || (shdr->sh_entsize == 0))
    return;
  Elf_Data *data_str = elf->elf_getdata (shdr->sh_link);
  if (data_str == NULL)
    return;
  char *Strtab = (char *) data_str->d_buf;

  // read func symbolic table
  for (unsigned int n = 0, tot = SymtabSize / shdr->sh_entsize; n < tot; n++)
    {
      Elf_Internal_Sym Sym;
      elf->elf_getsym (data, n, &Sym);
      const char *st_name = Sym.st_name < data_str->d_size ?
	  (Strtab + Sym.st_name) : NTXT ("no_name");
      switch (GELF_ST_TYPE (Sym.st_info))
	{
	case STT_FUNC:
	  if (Sym.st_size == 0)
	    break;
	  if (Sym.st_shndx == 0)
	    {
	      if (Sym.st_value == 0)
		break;
	      sitem = new Symbol (SymLst);
	      sitem->flags |= SYM_UNDEF;
	      if (pltSym)
		sitem->img_offset = pltSym->img_offset +
		      Sym.st_value - pltSym->value;
	    }
	  else
	    {
	      Elf_Internal_Shdr *shdrp = elfDis->get_shdr (Sym.st_shndx);
	      if (shdrp == NULL)
		break;
	      sitem = new Symbol (SymLst);
	      sitem->img_offset = shdrp->sh_offset +
		      Sym.st_value - shdrp->sh_addr;
	    }
	  sitem->size = Sym.st_size;
	  sitem->name = dbe_strdup (st_name);
	  sitem->value = is_relocatable () ? sitem->img_offset : Sym.st_value;
	  if (GELF_ST_BIND (Sym.st_info) == STB_LOCAL)
	    {
	      sitem->local_ind = LocalFile->size () - 1;
	      LocalLst->append (sitem);
	    }
	  break;
	case STT_NOTYPE:
	  if (streq (st_name, NTXT ("gcc2_compiled.")))
	    {
	      sitem = new Symbol (SymLst);
	      sitem->lang_code = Sp_lang_gcc;
	      sitem->name = dbe_strdup (st_name);
	      sitem->local_ind = LocalFile->size () - 1;
	      LocalLst->append (sitem);
	    }
	  break;
	case STT_OBJECT:
	  if (!strncmp (st_name, NTXT ("__KAI_KPTS_"), 11))
	    local_lcode = Sp_lang_KAI_KPTS;
	  else if (!strncmp (st_name, NTXT ("__KAI_KCC_"), 10))
	    local_lcode = Sp_lang_KAI_KCC;
	  else if (!strncmp (st_name, NTXT ("__KAI_Kcc_"), 10))
	    local_lcode = Sp_lang_KAI_Kcc;
	  else
	    break;
	  sitem = new Symbol (LocalLst);
	  sitem->lang_code = local_lcode;
	  sitem->name = dbe_strdup (st_name);
	  break;
	case STT_FILE:
	  {
	    int last = LocalFile->size () - 1;
	    if (last >= 0 && LocalFileIdx->fetch (last) == LocalLst->size ())
	      {
		// There were no local functions in the latest file.
		free (LocalFile->get (last));
		LocalFile->store (last, dbe_strdup (st_name));
	      }
	    else
	      {
		LocalFile->append (dbe_strdup (st_name));
		LocalFileIdx->append (LocalLst->size ());
	      }
	    break;
	  }
	}
    }
  fixSymtabAlias ();
  SymLst->sort (SymValueCmp);
  get_save_addr (elf->need_swap_endian);
  dump ();
}//check_Symtab

void
Stabs::check_Relocs ()
{
  // We may have many relocation tables to process: .rela.text%foo,
  // rela.text%bar, etc. On Intel, compilers generate .rel.text sections
  // which have to be processed as well. A lot of rework is needed here.
  Symbol *sptr = NULL;
  if (st_check_relocs)
    return;
  st_check_relocs = true;

  Elf *elf = openElf (false);
  if (elf == NULL)
    return;
  for (unsigned int sec = 1; sec < elf->elf_getehdr ()->e_shnum; sec++)
    {
      bool use_rela, use_PLT;
      char *name = elf->get_sec_name (sec);
      if (name == NULL)
	continue;
      if (strncmp (name, NTXT (".rela.text"), 10) == 0)
	{
	  use_rela = true;
	  use_PLT = false;
	}
      else if (streq (name, NTXT (".rela.plt")))
	{
	  use_rela = true;
	  use_PLT = true;
	}
      else if (strncmp (name, NTXT (".rel.text"), 9) == 0)
	{
	  use_rela = false;
	  use_PLT = false;
	}
      else if (streq (name, NTXT (".rel.plt")))
	{
	  use_rela = false;
	  use_PLT = true;
	}
      else
	continue;

      Elf_Internal_Shdr *shdr = elf->get_shdr (sec);
      if (shdr == NULL)
	continue;

      // Get ELF data
      Elf_Data *data = elf->elf_getdata (sec);
      if (data == NULL)
	continue;
      uint64_t ScnSize = data->d_size;
      uint64_t EntSize = shdr->sh_entsize;
      if ((ScnSize == 0) || (EntSize == 0))
	continue;
      int tot = (int) (ScnSize / EntSize);

      // Get corresponding text section
      Elf_Internal_Shdr *shdr_txt = elf->get_shdr (shdr->sh_info);
      if (shdr_txt == NULL)
	continue;
      if (!(shdr_txt->sh_flags & SHF_EXECINSTR))
	    continue;

      // Get corresponding symbol table section
      Elf_Internal_Shdr *shdr_sym = elf->get_shdr (shdr->sh_link);
      if (shdr_sym == NULL)
	continue;
      Elf_Data *data_sym = elf->elf_getdata (shdr->sh_link);

      // Get corresponding string table section
      Elf_Data *data_str = elf->elf_getdata (shdr_sym->sh_link);
      if (data_str == NULL)
	continue;
      char *Strtab = (char*) data_str->d_buf;
      for (int n = 0; n < tot; n++)
	{
	  Elf_Internal_Sym sym;
	  Elf_Internal_Rela rela;
	  char *symName;
	  if (use_rela)
	    elf->elf_getrela (data, n, &rela);
	  else
	    {
	      // GElf_Rela is extended GElf_Rel
	      elf->elf_getrel (data, n, &rela);
	      rela.r_addend = 0;
	    }

	  int ndx = (int) GELF_R_SYM (rela.r_info);
	  elf->elf_getsym (data_sym, ndx, &sym);
	  switch (GELF_ST_TYPE (sym.st_info))
	    {
	    case STT_FUNC:
	    case STT_OBJECT:
	    case STT_NOTYPE:
	      if (sym.st_name == 0 || sym.st_name >= data_str->d_size)
		continue;
	      symName = Strtab + sym.st_name;
	      break;
	    case STT_SECTION:
	      {
		Elf_Internal_Shdr *secHdr = elf->get_shdr (sym.st_shndx);
		if (secHdr == NULL)
		  continue;
		if (sptr == NULL)
		  sptr = new Symbol;
		sptr->value = secHdr->sh_offset + rela.r_addend;
		long index = SymLst->bisearch (0, -1, &sptr, SymFindCmp);
		if (index == -1)
		  continue;
		Symbol *sp = SymLst->fetch (index);
		if (sptr->value != sp->value)
		  continue;
		symName = sp->name;
		break;
	      }
	    default:
	      continue;
	    }
	  Reloc *reloc = new Reloc;
	  reloc->name = dbe_strdup (symName);
	  reloc->type = GELF_R_TYPE (rela.r_info);
	  reloc->value = use_PLT ? rela.r_offset
		  : rela.r_offset + shdr_txt->sh_offset;
	  reloc->addend = rela.r_addend;
	  if (use_PLT)
	    RelPLTLst->append (reloc);
	  else
	    RelLst->append (reloc);
	}
    }
  delete sptr;
  RelLst->sort (RelValueCmp);
} //check_Relocs

void
Stabs::get_save_addr (bool need_swap_endian)
{
  if (elfDis->is_Intel ())
    {
      for (int j = 0, sz = SymLst ? SymLst->size () : 0; j < sz; j++)
	{
	  Symbol *sitem = SymLst->fetch (j);
	  sitem->save = 0;
	}
      return;
    }
  for (int j = 0, sz = SymLst ? SymLst->size () : 0; j < sz; j++)
    {
      Symbol *sitem = SymLst->fetch (j);
      sitem->save = FUNC_NO_SAVE;

      // If an image offset is not known skip it.
      // Works for artificial symbols like '@plt' as well.
      if (sitem->img_offset == 0)
	continue;

      bool is_o7_moved = false;
      int64_t off = sitem->img_offset;
      for (int i = 0; i < sitem->size; i += 4)
	{
	  unsigned int cmd;
	  if (elfDis->get_data (off, sizeof (cmd), &cmd) == NULL)
	    break;
	  if (need_swap_endian)
	    SWAP_ENDIAN (cmd);
	  off += sizeof (cmd);
	  if ((cmd & 0xffffc000) == 0x9de38000)
	    { // save %sp, ??, %sp
	      sitem->save = i;
	      break;
	    }
	  else if ((cmd & 0xc0000000) == 0x40000000 || // call ??
	 (cmd & 0xfff80000) == 0xbfc00000)
	    { // jmpl ??, %o7
	      if (!is_o7_moved)
		{
		  sitem->save = FUNC_ROOT;
		  break;
		}
	    }
	  else if ((cmd & 0xc1ffe01f) == 0x8010000f)    // or %g0,%o7,??
	    is_o7_moved = true;
	}
    }
}

uint64_t
Stabs::mapOffsetToAddress (uint64_t img_offset)
{
  Elf *elf = openElf (false);
  if (elf == NULL)
    return 0;
  if (is_relocatable ())
    return img_offset;
  for (unsigned int sec = 1; sec < elf->elf_getehdr ()->e_shnum; sec++)
    {
      Elf_Internal_Shdr *shdr = elf->get_shdr (sec);
      if (shdr == NULL)
	continue;
      if (img_offset >= (uint64_t) shdr->sh_offset
	  && img_offset < (uint64_t) (shdr->sh_offset + shdr->sh_size))
	return shdr->sh_addr + (img_offset - shdr->sh_offset);
    }
  return 0;
}

Stabs::Stab_status
Stabs::archive_Stabs (LoadObject *lo, unsigned int StabSec,
		      unsigned int StabStrSec, bool comdat)
{
  StabReader *stabReader = new StabReader (openElf (true), platform, StabSec, StabStrSec);
  int tot = stabReader->stabCnt;
  if (tot < 0)
    {
      delete stabReader;
      return DBGD_ERR_NO_STABS;
    }

  char *sbase = NTXT (""), *arg, *fname, sname[2 * MAXPATHLEN];
  int lastMod, phase, stabs_level, modCnt = 0;
  Function *func = NULL;
  Module *mod;
#define INIT_MOD    phase = 0; stabs_level = 0; *sname = '\0'; mod = NULL

  bool updateStabsMod = false;
  if (comdat && ((elfDbg->elf_getehdr ()->e_type == ET_EXEC) || (elfDbg->elf_getehdr ()->e_type == ET_DYN)))
    {
      if (stabsModules == NULL)
	stabsModules = new Vector<Module*>();
      updateStabsMod = true;
    }
  INIT_MOD;
  lastMod = lo->seg_modules->size ();

  for (int n = 0; n < tot; n++)
    {
      struct stab stb;
      char *str = stabReader->get_stab (&stb, comdat);
      switch (stb.n_type)
	{
	case N_FUN:
	  // Ignore a COMDAT function, if there are two or more modules in 'lo'
	  if (comdat && stb.n_other == 1 && modCnt > 1)
	    break;
	case N_OUTL:
	case N_ALIAS:
	case N_ENTRY:
	  if (mod == NULL || str == NULL
	      || (stb.n_type != N_ENTRY && stabs_level != 0))
	    break;
	  if (*str == '@')
	    {
	      str++;
	      if (*str == '>' || *str == '<')
		str++;
	    }

	  fname = dbe_strdup (str);
	  arg = strchr (fname, ':');
	  if (arg != NULL)
	    {
	      if (!strncmp (arg, NTXT (":P"), 2))
		{ // just prototype
		  free (fname);
		  break;
		}
	      *arg = '\0';
	    }

	  func = append_Function (mod, fname);
	  free (fname);
	  break;
	case N_CMDLINE:
	  if (str && mod)
	    {
	      char *comp_flags = strchr (str, ';');
	      if (comp_flags)
		{
		  mod->comp_flags = dbe_strdup (comp_flags + 1);
		  mod->comp_dir = dbe_strndup (str, comp_flags - str);
		}
	    }
	  break;
	case N_LBRAC:
	  stabs_level++;
	  break;
	case N_RBRAC:
	  stabs_level--;
	  break;
	case N_UNDF:
	  INIT_MOD;
	  break;
	case N_ENDM:
	  INIT_MOD;
	  break;
	case N_OPT:
	  stabReader->parse_N_OPT (mod, str);
	  if (mod && (str != NULL) && streq (str, NTXT ("gcc2_compiled.")))
	    // Is it anachronism ?
	    mod->lang_code = Sp_lang_gcc;
	  break;
	case N_GSYM:
	  if (mod && (str != NULL))
	    {
	      if (strncmp (str, NTXT ("__KAI_K"), 7))
		break;
	      str += 7;
	      if (!strncmp (str, NTXT ("CC_"), 3))
		mod->lang_code = Sp_lang_KAI_KCC;
	      else if (!strncmp (str, NTXT ("cc_"), 3))
		mod->lang_code = Sp_lang_KAI_Kcc;
	      else if (!strncmp (str, NTXT ("PTS_"), 4) &&
		       (mod->lang_code != Sp_lang_KAI_KCC) &&
		       (mod->lang_code != Sp_lang_KAI_Kcc))
		mod->lang_code = Sp_lang_KAI_KPTS;
	    }
	  break;
	case N_SO:
	  if (str == NULL || *str == '\0')
	    {
	      INIT_MOD;
	      break;
	    }
	  if (phase == 0)
	    {
	      phase = 1;
	      sbase = str;
	    }
	  else
	    {
	      if (*str == '/')
		sbase = str;
	      else
		{
		  size_t last = strlen (sbase);
		  if (last == 0 || sbase[last - 1] != '/')
		    snprintf (sname, sizeof (sname), NTXT ("%s/%s"), sbase, str);
		  else
		    snprintf (sname, sizeof (sname), NTXT ("%s%s"), sbase, str);
		  sbase = sname;
		}
	      mod = append_Module (lo, sbase, lastMod);
	      if (updateStabsMod)
		stabsModules->append (mod);
	      mod->hasStabs = true;
	      modCnt++;
	      if ((mod->lang_code != Sp_lang_gcc) &&
		  (mod->lang_code != Sp_lang_KAI_KPTS) &&
		  (mod->lang_code != Sp_lang_KAI_KCC) &&
		  (mod->lang_code != Sp_lang_KAI_Kcc))
		mod->lang_code = (Sp_lang_code) stb.n_desc;
	      *sname = '\0';
	      phase = 0;
	    }
	  break;
	case N_OBJ:
	  if (str == NULL)
	    break;
	  if (phase == 0)
	    {
	      phase = 1;
	      sbase = str;
	    }
	  else
	    {
	      if (*str == '/')
		sbase = str;
	      else
		{
		  size_t last = strlen (sbase);
		  if (last == 0 || sbase[last - 1] != '/')
		    snprintf (sname, sizeof (sname), NTXT ("%s/%s"), sbase, str);
		  else
		    snprintf (sname, sizeof (sname), NTXT ("%s%s"), sbase, str);
		  sbase = sname;
		}
	      if (mod && (mod->dot_o_file == NULL))
		{
		  if (strcmp (sbase, NTXT ("/")) == 0)
		    mod->set_name (dbe_strdup (path));
		  else
		    {
		      mod->set_name (dbe_strdup (sbase));
		      mod->dot_o_file = mod->createLoadObject (sbase);
		    }
		}
	      *sname = '\0';
	      phase = 0;
	    }
	  break;
	case N_CPROF:
	  cpf_stabs_t map;
	  Dprintf (DEBUG_STABS, NTXT ("N_CPROF n_desc=%x n_value=0x%04x mod=%s\n"),
		   stb.n_desc, stb.n_value, (mod == NULL) ? NTXT ("???") : mod->get_name ());
	  map.type = stb.n_desc;
	  map.offset = stb.n_value;
	  map.module = mod;
	  analyzerInfoMap.append (map);
	  break;
	}
    }
  delete stabReader;
  return func ? DBGD_ERR_NONE : DBGD_ERR_NO_STABS;
}

Module *
Stabs::append_Module (LoadObject *lo, char *name, int lastMod)
{
  Module *module;
  int size;
  Symbol *sitem;

  if (lo->seg_modules != NULL)
    {
      size = lo->seg_modules->size ();
      if (size < lastMod)
	lastMod = size;
      for (int i = 0; i < lastMod; i++)
	{
	  module = lo->seg_modules->fetch (i);
	  if (module->linkerStabName && streq (module->linkerStabName, name))
	    return module;
	}
    }
  module = dbeSession->createModule (lo, NULL);
  module->set_file_name (dbe_strdup (name));
  module->linkerStabName = dbe_strdup (module->file_name);

  // Append all functions with 'local_ind == -1' to the module.
  if (LocalLst->size () > 0)
    {
      sitem = LocalLst->fetch (0);
      if (!sitem->defined && sitem->local_ind == -1)
	// Append all functions with 'local_ind == -1' to the module.
	append_local_funcs (module, 0);
    }

  // Append local func
  char *basename = get_basename (name);
  size = LocalFile->size ();
  for (int i = 0; i < size; i++)
    {
      if (streq (basename, LocalFile->fetch (i)))
	{
	  int local_ind = LocalFileIdx->fetch (i);
	  if (local_ind >= LocalLst->size ())
	    break;
	  sitem = LocalLst->fetch (local_ind);
	  if (!sitem->defined)
	    {
	      append_local_funcs (module, local_ind);
	      break;
	    }
	}
    }
  return module;
}

void
Stabs::append_local_funcs (Module *module, int first_ind)
{
  Symbol *sitem = LocalLst->fetch (first_ind);
  int local_ind = sitem->local_ind;
  int size = LocalLst->size ();
  for (int i = first_ind; i < size; i++)
    {
      sitem = LocalLst->fetch (i);
      if (sitem->local_ind != local_ind)
	break;
      sitem->defined = true;

      // 3rd party compiled. e.g., Gcc or KAI compiled
      if (sitem->lang_code != Sp_lang_unknown)
	{
	  if (module->lang_code == Sp_lang_unknown)
	    module->lang_code = sitem->lang_code;
	  continue;
	}
      if (sitem->func)
	continue;
      Function *func = dbeSession->createFunction ();
      sitem->func = func;
      func->img_fname = path;
      func->img_offset = sitem->img_offset;
      func->save_addr = sitem->save;
      func->size = sitem->size;
      func->module = module;
      func->set_name (sitem->name);
      module->functions->append (func);
      module->loadobject->functions->append (func);
    }
}

Function *
Stabs::append_Function (Module *module, char *fname)
{
  Symbol *sitem, *sptr;
  Function *func;
  long sid, index;
  char *name;
  if (SymLstByName == NULL)
    {
      SymLstByName = SymLst->copy ();
      SymLstByName->sort (SymNameCmp);
    }
  sptr = new Symbol;
  if (module->lang_code == N_SO_FORTRAN || module->lang_code == N_SO_FORTRAN90)
    {
      char *fortran = dbe_sprintf (NTXT ("%s_"), fname); // FORTRAN name
      sptr->name = fortran;
      sid = SymLstByName->bisearch (0, -1, &sptr, SymNameCmp);
      if (sid == -1)
	{
	  free (fortran);
	  sptr->name = fname;
	  sid = SymLstByName->bisearch (0, -1, &sptr, SymNameCmp);
	}
      else
	fname = fortran;
    }
  else
    {
      sptr->name = fname;
      sid = SymLstByName->bisearch (0, -1, &sptr, SymNameCmp);
    }
  sptr->name = NULL;
  delete sptr;

  if (sid == -1)
    {
      Vec_loop (Symbol*, SymLstByName, index, sitem)
      {
	if (strncmp (sitem->name, NTXT ("$X"), 2) == 0
	    || strncmp (sitem->name, NTXT (".X"), 2) == 0)
	  {
	    char *n = strchr (((sitem->name) + 2), (int) '.');
	    if (n != NULL)
	      name = n + 1;
	    else
	      name = sitem->name;
	  }
	else
	  name = sitem->name;
	if (name != NULL && fname != NULL && (strcmp (name, fname) == 0))
	  {
	    sid = index;
	    break;
	  }
      }
    }
  if (sid != -1)
    {
      sitem = SymLstByName->fetch (sid);
      if (sitem->alias)
	sitem = sitem->alias;
      if (sitem->func)
	return sitem->func;
      sitem->func = func = dbeSession->createFunction ();
      func->img_fname = path;
      func->img_offset = sitem->img_offset;
      func->save_addr = sitem->save;
      func->size = sitem->size;
    }
  else
    func = dbeSession->createFunction ();

  func->module = module;
  func->set_name (fname);
  module->functions->append (func);
  module->loadobject->functions->append (func);
  return func;
}

Function *
Stabs::append_Function (Module *module, char *linkerName, uint64_t pc)
{
  Dprintf (DEBUG_STABS, NTXT ("Stabs::append_Function: module=%s linkerName=%s pc=0x%llx\n"),
	   STR (module->get_name ()), STR (linkerName), (unsigned long long) pc);
  long i;
  Symbol *sitem = NULL, *sp;
  Function *func;
  sp = new Symbol;
  if (pc)
    {
      sp->value = pc;
      i = SymLst->bisearch (0, -1, &sp, SymFindCmp);
      if (i != -1)
	sitem = SymLst->fetch (i);
    }

  if (!sitem && linkerName)
    {
      if (SymLstByName == NULL)
	{
	  SymLstByName = SymLst->copy ();
	  SymLstByName->sort (SymNameCmp);
	}
      sp->name = linkerName;
      i = SymLstByName->bisearch (0, -1, &sp, SymNameCmp);
      sp->name = NULL;
      if (i != -1)
	sitem = SymLstByName->fetch (i);
    }
  delete sp;

  if (!sitem)
    return NULL;
  if (sitem->alias)
    sitem = sitem->alias;
  if (sitem->func)
    return sitem->func;

  sitem->func = func = dbeSession->createFunction ();
  func->img_fname = path;
  func->img_offset = sitem->img_offset;
  func->save_addr = sitem->save;
  func->size = sitem->size;
  func->module = module;
  func->set_name (sitem->name); //XXXX ?? Now call it to set obj->name
  module->functions->append (func);
  module->loadobject->functions->append (func);
  return func;
}// Stabs::append_Function

Dwarf *
Stabs::openDwarf ()
{
  if (dwarf == NULL)
    {
      dwarf = new Dwarf (this);
      check_Symtab ();
    }
  return dwarf;
}

void
Stabs::read_hwcprof_info (Module *module)
{
  openDwarf ()->read_hwcprof_info (module);
}

void
Stabs::dump ()
{
  if (!DUMP_ELF_SYM)
    return;
  printf (NTXT ("\n======= Stabs::dump: %s =========\n"), path ? path : NTXT ("NULL"));
  int i, sz;
  if (LocalFile)
    {
      sz = LocalFile->size ();
      for (i = 0; i < sz; i++)
	printf ("  %3d: %5d '%s'\n", i, LocalFileIdx->fetch (i),
		LocalFile->fetch (i));
    }
  Symbol::dump (SymLst, NTXT ("SymLst"));
  Symbol::dump (LocalLst, NTXT ("LocalLst"));
  printf (NTXT ("\n===== END of Stabs::dump: %s =========\n\n"),
  path ? path : NTXT ("NULL"));
}

///////////////////////////////////////////////////////////////////////////////
//  Class Include
Include::Include ()
{
  stack = new Vector<SrcFileInfo*>;
}

Include::~Include ()
{
  Destroy (stack);
}

void
Include::new_src_file (SourceFile *source, int lineno, Function *func)
{
  for (int index = stack->size () - 1; index >= 0; index--)
    {
      if (source == stack->fetch (index)->srcfile)
	{
	  for (int i = stack->size () - 1; i > index; i--)
	    {
	      delete stack->remove (i);
	      if (func && func->line_first > 0)
		func->popSrcFile ();
	    }
	  return;
	}
    }
  if (func && func->line_first > 0)
    func->pushSrcFile (source, lineno);

  SrcFileInfo *sfinfo = new SrcFileInfo;
  sfinfo->srcfile = source;
  sfinfo->lineno = lineno;
  stack->append (sfinfo);
}

void
Include::push_src_files (Function *func)
{
  int index;
  SrcFileInfo *sfinfo;

  if (func->line_first <= 0 && stack->size () > 0)
    {
      sfinfo = stack->fetch (stack->size () - 1);
      func->setDefSrc (sfinfo->srcfile);
    }
  Vec_loop (SrcFileInfo*, stack, index, sfinfo)
  {
    func->pushSrcFile (sfinfo->srcfile, sfinfo->lineno);
  }
}

void
Include::new_include_file (SourceFile *source, Function *func)
{
  if (stack->size () == 1 && stack->fetch (0)->srcfile == source)
    // workaroud for gcc; gcc creates 'N_BINCL' stab for main source
    return;
  if (func && func->line_first > 0)
    func->pushSrcFile (source, 0);

  SrcFileInfo *sfinfo = new SrcFileInfo;
  sfinfo->srcfile = source;
  sfinfo->lineno = 0;
  stack->append (sfinfo);
}

void
Include::end_include_file (Function *func)
{
  int index = stack->size () - 1;
  if (index > 0)
    {
      delete stack->remove (index);
      if (func && func->line_first > 0)
	func->popSrcFile ();
    }
}

#define RET_S(x)   if (t == x) return (char *) #x
char *
StabReader::get_type_name (int t)
{
  RET_S (N_UNDF);
  RET_S (N_ABS);
  RET_S (N_TEXT);
  RET_S (N_DATA);
  RET_S (N_BSS);
  RET_S (N_COMM);
  RET_S (N_FN);
  RET_S (N_EXT);
  RET_S (N_TYPE);
  RET_S (N_GSYM);
  RET_S (N_FNAME);
  RET_S (N_FUN);
  RET_S (N_OUTL);
  RET_S (N_STSYM);
  RET_S (N_TSTSYM);
  RET_S (N_LCSYM);
  RET_S (N_TLCSYM);
  RET_S (N_MAIN);
  RET_S (N_ROSYM);
  RET_S (N_FLSYM);
  RET_S (N_TFLSYM);
  RET_S (N_PC);
  RET_S (N_CMDLINE);
  RET_S (N_OBJ);
  RET_S (N_OPT);
  RET_S (N_RSYM);
  RET_S (N_SLINE);
  RET_S (N_XLINE);
  RET_S (N_ILDPAD);
  RET_S (N_SSYM);
  RET_S (N_ENDM);
  RET_S (N_SO);
  RET_S (N_MOD);
  RET_S (N_EMOD);
  RET_S (N_READ_MOD);
  RET_S (N_ALIAS);
  RET_S (N_LSYM);
  RET_S (N_BINCL);
  RET_S (N_SOL);
  RET_S (N_PSYM);
  RET_S (N_EINCL);
  RET_S (N_ENTRY);
  RET_S (N_SINCL);
  RET_S (N_LBRAC);
  RET_S (N_EXCL);
  RET_S (N_USING);
  RET_S (N_ISYM);
  RET_S (N_ESYM);
  RET_S (N_PATCH);
  RET_S (N_CONSTRUCT);
  RET_S (N_DESTRUCT);
  RET_S (N_CODETAG);
  RET_S (N_FUN_CHILD);
  RET_S (N_RBRAC);
  RET_S (N_BCOMM);
  RET_S (N_TCOMM);
  RET_S (N_ECOMM);
  RET_S (N_XCOMM);
  RET_S (N_ECOML);
  RET_S (N_WITH);
  RET_S (N_LENG);
  RET_S (N_CPROF);
  RET_S (N_BROWS);
  RET_S (N_FUN_PURE);
  RET_S (N_FUN_ELEMENTAL);
  RET_S (N_FUN_RECURSIVE);
  RET_S (N_FUN_AMD64_PARMDUMP);
  RET_S (N_SYM_OMP_TLS);
  RET_S (N_SO_AS);
  RET_S (N_SO_C);
  RET_S (N_SO_ANSI_C);
  RET_S (N_SO_CC);
  RET_S (N_SO_FORTRAN);
  RET_S (N_SO_FORTRAN77);
  RET_S (N_SO_PASCAL);
  RET_S (N_SO_FORTRAN90);
  RET_S (N_SO_JAVA);
  RET_S (N_SO_C99);
  return NULL;
}