summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/as/config/obj-vms.c
blob: 2a51ba92bcebde45dd1fd1c8bd0f8318d00f360c (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
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
/* vms.c -- Write out a VAX/VMS object file
   Copyright (C) 1987, 1988, 1992 Free Software Foundation, Inc.

This file is part of GAS, the GNU Assembler.

GAS 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 2, or (at your option)
any later version.

GAS 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 GAS; see the file COPYING.  If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */

/* Written by David L. Kashtan */
/* Modified by Eric Youngdale to write VMS debug records for program
   variables */
#include "as.h"
#include "subsegs.h"
#include "obstack.h"

/* What we do if there is a goof. */
#define error as_fatal

#ifdef HO_VMS			/* These are of no use if we are cross assembling. */
#include <fab.h>		/* Define File Access Block	  */
#include <nam.h>		/* Define NAM Block		  */
#include <xab.h>		/* Define XAB - all different types*/
#endif
/*
 *	Version string of the compiler that produced the code we are
 *	assembling.  (And this assembler, if we do not have compiler info.)
 */
extern const char version_string[];
char *compiler_version_string;

/* Flag that determines how we map names.  This takes several values, and
 * is set with the -h switch.  A value of zero implies names should be
 * upper case, and the presence of the -h switch inhibits the case hack.
 * No -h switch at all sets vms_name_mapping to 0, and allows case hacking.
 * A value of 2 (set with -h2) implies names should be
 * all lower case, with no case hack.  A value of 3 (set with -h3) implies
 * that case should be preserved.  */

/* If the -+ switch is given, then the hash is appended to any name that is
 * longer than 31 characters, irregardless of the setting of the -h switch.
 */

char vms_name_mapping = 0;


extern char *strchr ();
extern char *myname;
static symbolS *Entry_Point_Symbol = 0;	/* Pointer to "_main" */

/*
 *	We augment the "gas" symbol structure with this
 */
struct VMS_Symbol
{
  struct VMS_Symbol *Next;
  struct symbol *Symbol;
  int Size;
  int Psect_Index;
  int Psect_Offset;
};
struct VMS_Symbol *VMS_Symbols = 0;

/* We need this to keep track of the various input files, so that we can
 * give the debugger the correct source line.
 */

struct input_file
{
  struct input_file *next;
  struct input_file *same_file_fpnt;
  int file_number;
  int max_line;
  int min_line;
  int offset;
  char flag;
  char *name;
  symbolS *spnt;
};

static struct input_file *file_root = (struct input_file *) NULL;


static struct input_file *find_file (symbolS *);

/*
 * This enum is used to keep track of the various types of variables that
 * may be present.
 */

enum advanced_type
{
  BASIC, POINTER, ARRAY, ENUM, STRUCT, UNION, FUNCTION, VOID, UNKNOWN
};

/*
 * This structure contains the information from the stabs directives, and the
 * information is filled in by VMS_typedef_parse.  Everything that is needed
 * to generate the debugging record for a given symbol is present here.
 * This could be done more efficiently, using nested struct/unions, but for now
 * I am happy that it works.
 */
struct VMS_DBG_Symbol
{
  struct VMS_DBG_Symbol *next;
  enum advanced_type advanced;	/* description of what this is */
  int dbx_type;			/* this record is for this type */
  int type2;			/* For advanced types this is the type referred to.
					i.e. the type a pointer points to, or the type
					of object that makes up an array */
  int VMS_type;			/* Use this type when generating a variable def */
  int index_min;		/* used for arrays - this will be present for all */
  int index_max;		/* entries, but will be meaningless for non-arrays */
  int data_size;		/* size in bytes of the data type.  For an array, this
				   is the size of one element in the array */
  int struc_numb;		/* Number of the structure/union/enum - used for ref */
};

struct VMS_DBG_Symbol *VMS_Symbol_type_list =
{(struct VMS_DBG_Symbol *) NULL};

/*
 * We need this structure to keep track of forward references to
 * struct/union/enum that have not been defined yet.  When they are ultimately
 * defined, then we can go back and generate the TIR commands to make a back
 * reference.
 */

struct forward_ref
{
  struct forward_ref *next;
  int dbx_type;
  int struc_numb;
  char resolved;
};

struct forward_ref *f_ref_root =
{(struct forward_ref *) NULL};

/*
 * This routine is used to compare the names of certain types to various
 * fixed types that are known by the debugger.
 */
#define type_check(x)  !strcmp( symbol_name , x )

/*
 * This variable is used to keep track of the name of the symbol we are
 * working on while we are parsing the stabs directives.
 */
static char *symbol_name;

/* We use this counter to assign numbers to all of the structures, unions
 * and enums that we define.  When we actually declare a variable to the
 * debugger, we can simply do it by number, rather than describing the
 * whole thing each time.
 */

static structure_count = 0;

/* This variable is used to keep track of the current structure number
 * for a given variable.  If this is < 0, that means that the structure
 * has not yet been defined to the debugger.  This is still cool, since
 * the VMS object language has ways of fixing things up after the fact,
 * so we just make a note of this, and generate fixups at the end.
 */
static int struct_number;


/*
 * Variable descriptors are used tell the debugger the data types of certain
 * more complicated variables (basically anything involving a structure,
 * union, enum, array or pointer).  Some non-pointer variables of the
 * basic types that the debugger knows about do not require a variable
 * descriptor.
 *
 * Since it is impossible to have a variable descriptor longer than 128
 * bytes by virtue of the way that the VMS object language is set up,
 * it makes not sense to make the arrays any longer than this, or worrying
 * about dynamic sizing of the array.
 *
 * These are the arrays and counters that we use to build a variable
 * descriptor.
 */

#define MAX_DEBUG_RECORD 128
static char Local[MAX_DEBUG_RECORD];	/* buffer for variable descriptor */
static char Asuffix[MAX_DEBUG_RECORD];	/* buffer for array descriptor */
static int Lpnt;		/* index into Local */
static int Apoint;		/* index into Asuffix */
static char overflow;		/* flag to indicate we have written too much*/
static int total_len;		/* used to calculate the total length of variable
				descriptor plus array descriptor - used for len byte*/

/* Flag if we have told user about finding global constants in the text
   section. */
static gave_compiler_message = 0;

/* A pointer to the current routine that we are working on.  */

static symbolS *Current_Routine;

/* The psect number for $code a.k.a. the text section. */

static int Text_Psect;


/*
 *	Global data (Object records limited to 512 bytes by VAX-11 "C" runtime)
 */
static int VMS_Object_File_FD;	/* File Descriptor for object file */
static char Object_Record_Buffer[512];	/* Buffer for object file records  */
static int Object_Record_Offset;/* Offset to end of data	   */
static int Current_Object_Record_Type;	/* Type of record in above	   */

/*
 *	Macros for placing data into the object record buffer
 */

#define	PUT_LONG(val) \
{ md_number_to_chars(Object_Record_Buffer + \
		     Object_Record_Offset, val, 4); \
			 Object_Record_Offset += 4; }

#define	PUT_SHORT(val) \
{ md_number_to_chars(Object_Record_Buffer + \
		     Object_Record_Offset, val, 2); \
			 Object_Record_Offset += 2; }

#define	PUT_CHAR(val)	Object_Record_Buffer[Object_Record_Offset++] = val

#define	PUT_COUNTED_STRING(cp) {\
			register char *p = cp; \
			PUT_CHAR(strlen(p)); \
			while (*p) PUT_CHAR(*p++);}

/*
 *	Macro for determining if a Name has psect attributes attached
 *	to it.
 */
#define	PSECT_ATTRIBUTES_STRING		"$$PsectAttributes_"
#define	PSECT_ATTRIBUTES_STRING_LENGTH	18

#define	HAS_PSECT_ATTRIBUTES(Name) \
		(strncmp((Name[0] == '_' ? Name + 1 : Name), \
		 PSECT_ATTRIBUTES_STRING, \
		 PSECT_ATTRIBUTES_STRING_LENGTH) == 0)


 /* in: segT   out: N_TYPE bits */
const short seg_N_TYPE[] =
{
  N_ABS,
  N_TEXT,
  N_DATA,
  N_BSS,
  N_UNDF,			/* unknown */
  N_UNDF,			/* absent */
  N_UNDF,			/* pass1 */
  N_UNDF,			/* error */
  N_UNDF,			/* bignum/flonum */
  N_UNDF,			/* difference */
  N_UNDF,			/* debug */
  N_UNDF,			/* ntv */
  N_UNDF,			/* ptv */
  N_REGISTER,			/* register */
};

const segT N_TYPE_seg[N_TYPE + 2] =
{				/* N_TYPE == 0x1E = 32-2 */
  SEG_UNKNOWN,			/* N_UNDF == 0 */
  SEG_GOOF,
  SEG_ABSOLUTE,			/* N_ABS == 2 */
  SEG_GOOF,
  SEG_TEXT,			/* N_TEXT == 4 */
  SEG_GOOF,
  SEG_DATA,			/* N_DATA == 6 */
  SEG_GOOF,
  SEG_BSS,			/* N_BSS == 8 */
  SEG_GOOF,
  SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF,
  SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF,
  SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF,
  SEG_REGISTER,			/* dummy N_REGISTER for regs = 30 */
  SEG_GOOF,
};


/* The following code defines the special types of pseudo-ops that we
 *  use with VMS.
 */

char const_flag = 0;

void
s_const ()
{
  register int temp;

  temp = get_absolute_expression ();
  subseg_new (SEG_DATA, (subsegT) temp);
  const_flag = 1;
  demand_empty_rest_of_line ();
}

/*
 *			stab()
 *
 * Handle .stabX directives, which used to be open-coded.
 * So much creeping featurism overloaded the semantics that we decided
 * to put all .stabX thinking in one place. Here.
 *
 * We try to make any .stabX directive legal. Other people's AS will often
 * do assembly-time consistency checks: eg assigning meaning to n_type bits
 * and "protecting" you from setting them to certain values. (They also zero
 * certain bits before emitting symbols. Tut tut.)
 *
 * If an expression is not absolute we either gripe or use the relocation
 * information. Other people's assemblers silently forget information they
 * don't need and invent information they need that you didn't supply.
 *
 * .stabX directives always make a symbol table entry. It may be junk if
 * the rest of your .stabX directive is malformed.
 */
static void
obj_aout_stab (what)
     int what;
{
  register symbolS *symbolP = 0;
  register char *string;
  int saved_type = 0;
  int length;
  int goof;			/* TRUE if we have aborted. */
  long longint;

/*
 * Enter with input_line_pointer pointing past .stabX and any following
 * whitespace.
 */
  goof = 0;			/* JF who forgot this?? */
  if (what == 's')
    {
      string = demand_copy_C_string (&length);
      SKIP_WHITESPACE ();
      if (*input_line_pointer == ',')
	input_line_pointer++;
      else
	{
	  as_bad ("I need a comma after symbol's name");
	  goof = 1;
	}
    }
  else
    string = "";

/*
 * Input_line_pointer->after ','.  String->symbol name.
 */
  if (!goof)
    {
      symbolP = symbol_new (string,
			    SEG_UNKNOWN,
			    0,
			    (struct frag *) 0);
      switch (what)
	{
	case 'd':
	  S_SET_NAME (symbolP, NULL);	/* .stabd feature. */
	  S_SET_VALUE (symbolP, obstack_next_free (&frags) - frag_now->fr_literal);
	  symbolP->sy_frag = frag_now;
	  break;

	case 'n':
	  symbolP->sy_frag = &zero_address_frag;
	  break;

	case 's':
	  symbolP->sy_frag = &zero_address_frag;
	  break;

	default:
	  BAD_CASE (what);
	  break;
	}

      if (get_absolute_expression_and_terminator (&longint) == ',')
	symbolP->sy_symbol.n_type = saved_type = longint;
      else
	{
	  as_bad ("I want a comma after the n_type expression");
	  goof = 1;
	  input_line_pointer--;	/* Backup over a non-',' char. */
	}
    }

  if (!goof)
    {
      if (get_absolute_expression_and_terminator (&longint) == ',')
	S_SET_OTHER (symbolP, longint);
      else
	{
	  as_bad ("I want a comma after the n_other expression");
	  goof = 1;
	  input_line_pointer--;	/* Backup over a non-',' char. */
	}
    }

  if (!goof)
    {
      S_SET_DESC (symbolP, get_absolute_expression ());
      if (what == 's' || what == 'n')
	{
	  if (*input_line_pointer != ',')
	    {
	      as_bad ("I want a comma after the n_desc expression");
	      goof = 1;
	    }
	  else
	    {
	      input_line_pointer++;
	    }
	}
    }

  if ((!goof) && (what == 's' || what == 'n'))
    {
      pseudo_set (symbolP);
      symbolP->sy_symbol.n_type = saved_type;
    }

  if (goof)
    ignore_rest_of_line ();
  else
    demand_empty_rest_of_line ();
}				/* obj_aout_stab() */

const pseudo_typeS obj_pseudo_table[] =
{
  {"stabd", obj_aout_stab, 'd'},/* stabs */
  {"stabn", obj_aout_stab, 'n'},/* stabs */
  {"stabs", obj_aout_stab, 's'},/* stabs */
  {"const", s_const, 0},
  {0, 0, 0},

};				/* obj_pseudo_table */

void
obj_read_begin_hook ()
{
  return;
}				/* obj_read_begin_hook() */

void
obj_crawl_symbol_chain (headers)
     object_headers *headers;
{
  symbolS *symbolP;
  symbolS **symbolPP;
  int symbol_number = 0;

  /* JF deal with forward references first... */
  for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next (symbolP))
    {
      if (symbolP->sy_forward)
	{
	  S_SET_VALUE (symbolP, S_GET_VALUE (symbolP)
		       + S_GET_VALUE (symbolP->sy_forward)
		       + symbolP->sy_forward->sy_frag->fr_address);
	  symbolP->sy_forward = 0;
	}			/* if it has a forward reference */
    }				/* walk the symbol chain */

  {				/* crawl symbol table */
    register int symbol_number = 0;

    {
      symbolPP = &symbol_rootP;	/* -> last symbol chain link. */
      while ((symbolP = *symbolPP) != NULL)
	{
	  S_GET_VALUE (symbolP) += symbolP->sy_frag->fr_address;

	  /* OK, here is how we decide which symbols go out into the
	     brave new symtab.  Symbols that do are:

	     * symbols with no name (stabd's?)
	     * symbols with debug info in their N_TYPE

	     Symbols that don't are:
	     * symbols that are registers
	     * symbols with \1 as their 3rd character (numeric labels)
	     * "local labels" as defined by S_LOCAL_NAME(name)
	     if the -L switch was passed to gas.

	     All other symbols are output.  We complain if a deleted
	     symbol was marked external.  */


	  if (!S_IS_REGISTER (symbolP))
	    {
	      symbolP->sy_name_offset = 0;
	      symbolPP = &(symbol_next (symbolP));
	    }
	  else
	    {
	      if (S_IS_EXTERNAL (symbolP) || !S_IS_DEFINED (symbolP))
		{
		  as_bad ("Local symbol %s never defined", S_GET_NAME (symbolP));
		}		/* oops. */

	    }			/* if this symbol should be in the output */
	}			/* for each symbol */
    }
    H_SET_STRING_SIZE (headers, string_byte_count);
    H_SET_SYMBOL_TABLE_SIZE (headers, symbol_number);
  }				/* crawl symbol table */

}				/* obj_crawl_symbol_chain() */


 /****** VMS OBJECT FILE HACKING ROUTINES *******/


/*
 *	Create the VMS object file
 */
static
Create_VMS_Object_File ()
{
#if	defined(eunice) || !defined(HO_VMS)
  VMS_Object_File_FD = creat (out_file_name, 0777, "var");
#else	/* eunice */
  VMS_Object_File_FD = creat (out_file_name, 0, "rfm=var",
			     "mbc=16", "deq=64", "fop=tef", "shr=nil");
#endif	/* eunice */
  /*
   *	Deal with errors
   */
  if (VMS_Object_File_FD < 0)
    {
      char Error_Line[256];

      sprintf (Error_Line, "Couldn't create VMS object file \"%s\"",
	       out_file_name);
      error (Error_Line);
    }
  /*
   *	Initialize object file hacking variables
   */
  Object_Record_Offset = 0;
  Current_Object_Record_Type = -1;
}


/*
 *	Flush the object record buffer to the object file
 */
static
Flush_VMS_Object_Record_Buffer ()
{
  int i;
  short int zero;
  /*
   *	If the buffer is empty, we are done
   */
  if (Object_Record_Offset == 0)
    return;
  /*
   *	Write the data to the file
   */
#ifndef HO_VMS			/* For cross-assembly purposes. */
  i = write (VMS_Object_File_FD, &Object_Record_Offset, 2);
#endif /* not HO_VMS */
  i = write (VMS_Object_File_FD,
	     Object_Record_Buffer,
	     Object_Record_Offset);
  if (i != Object_Record_Offset)
    error ("I/O error writing VMS object file");
#ifndef HO_VMS			/* When cross-assembling, we need to pad the record to an even
						number of bytes. */
  /* pad it if needed */
  zero = 0;
  if (Object_Record_Offset & 1 != 0)
    write (VMS_Object_File_FD, &zero, 1);
#endif /* not HO_VMS */
  /*
   *	The buffer is now empty
   */
  Object_Record_Offset = 0;
}


/*
 *	Declare a particular type of object file record
 */
static
Set_VMS_Object_File_Record (Type)
     int Type;
{
  /*
   *	If the type matches, we are done
   */
  if (Type == Current_Object_Record_Type)
    return;
  /*
   *	Otherwise: flush the buffer
   */
  Flush_VMS_Object_Record_Buffer ();
  /*
   *	Set the new type
   */
  Current_Object_Record_Type = Type;
}



/*
 *	Close the VMS Object file
 */
static
Close_VMS_Object_File ()
{
  short int m_one = -1;
#ifndef HO_VMS			/* For cross-assembly purposes. */
/* Write a 0xffff into the file, which means "End of File" */
  write (VMS_Object_File_FD, &m_one, 2);
#endif /* not HO_VMS */
  close (VMS_Object_File_FD);
}


/*
 *	Store immediate data in current Psect
 */
static
VMS_Store_Immediate_Data (Pointer, Size, Record_Type)
     register char *Pointer;
     int Size;
     int Record_Type;
{
  register int i;

  /*
   *	We are writing a "Record_Type" record
   */
  Set_VMS_Object_File_Record (Record_Type);
  /*
   *	We can only store 128 bytes at a time
   */
  while (Size > 0)
    {
      /*
       *	Store a maximum of 128 bytes
       */
      i = (Size > 128) ? 128 : Size;
      Size -= i;
      /*
       *	If we cannot accommodate this record, flush the
       *	buffer.
       */
      if ((Object_Record_Offset + i + 1) >=
	  sizeof (Object_Record_Buffer))
	Flush_VMS_Object_Record_Buffer ();
      /*
       *	If the buffer is empty we must insert record type
       */
      if (Object_Record_Offset == 0)
	PUT_CHAR (Record_Type);
      /*
       *	Store the count
       */
      PUT_CHAR (-i & 0xff);
      /*
       *	Store the data
       */
      while (--i >= 0)
	PUT_CHAR (*Pointer++);
      /*
       *	Flush the buffer if it is more than 75% full
       */
      if (Object_Record_Offset >
	  (sizeof (Object_Record_Buffer) * 3 / 4))
	Flush_VMS_Object_Record_Buffer ();
    }
}

/*
 *	Make a data reference
 */
static
VMS_Set_Data (Psect_Index, Offset, Record_Type, Force)
     int Psect_Index;
     int Offset;
     int Record_Type;
     int Force;
{
  /*
   *	We are writing a "Record_Type" record
   */
  Set_VMS_Object_File_Record (Record_Type);
  /*
   *	If the buffer is empty we must insert the record type
   */
  if (Object_Record_Offset == 0)
    PUT_CHAR (Record_Type);
  /*
   *	Stack the Psect base + Longword Offset
   */
  if (Force == 1)
    {
      if (Psect_Index > 127)
	{
	  PUT_CHAR (TIR_S_C_STA_WPL);
	  PUT_SHORT (Psect_Index);
	  PUT_LONG (Offset);
	}
      else
	{
	  PUT_CHAR (TIR_S_C_STA_PL);
	  PUT_CHAR (Psect_Index);
	  PUT_LONG (Offset);
	}
    }
  else
    {
      if (Offset > 32767)
	{
	  PUT_CHAR (TIR_S_C_STA_WPL);
	  PUT_SHORT (Psect_Index);
	  PUT_LONG (Offset);
	}
      else if (Offset > 127)
	{
	  PUT_CHAR (TIR_S_C_STA_WPW);
	  PUT_SHORT (Psect_Index);
	  PUT_SHORT (Offset);
	}
      else
	{
	  PUT_CHAR (TIR_S_C_STA_WPB);
	  PUT_SHORT (Psect_Index);
	  PUT_CHAR (Offset);
	};
    };
  /*
   *	Set relocation base
   */
  PUT_CHAR (TIR_S_C_STO_PIDR);
  /*
   *	Flush the buffer if it is more than 75% full
   */
  if (Object_Record_Offset >
      (sizeof (Object_Record_Buffer) * 3 / 4))
    Flush_VMS_Object_Record_Buffer ();
}

/*
 *	Make a debugger reference to a struct, union or enum.
 */
static
VMS_Store_Struct (int Struct_Index)
{
  /*
   *	We are writing a "OBJ_S_C_DBG" record
   */
  Set_VMS_Object_File_Record (OBJ_S_C_DBG);
  /*
   *	If the buffer is empty we must insert the record type
   */
  if (Object_Record_Offset == 0)
    PUT_CHAR (OBJ_S_C_DBG);
  PUT_CHAR (TIR_S_C_STA_UW);
  PUT_SHORT (Struct_Index);
  PUT_CHAR (TIR_S_C_CTL_STKDL);
  PUT_CHAR (TIR_S_C_STO_L);
  /*
   *	Flush the buffer if it is more than 75% full
   */
  if (Object_Record_Offset >
      (sizeof (Object_Record_Buffer) * 3 / 4))
    Flush_VMS_Object_Record_Buffer ();
}

/*
 *	Make a debugger reference to partially define a struct, union or enum.
 */
static
VMS_Def_Struct (int Struct_Index)
{
  /*
   *	We are writing a "OBJ_S_C_DBG" record
   */
  Set_VMS_Object_File_Record (OBJ_S_C_DBG);
  /*
   *	If the buffer is empty we must insert the record type
   */
  if (Object_Record_Offset == 0)
    PUT_CHAR (OBJ_S_C_DBG);
  PUT_CHAR (TIR_S_C_STA_UW);
  PUT_SHORT (Struct_Index);
  PUT_CHAR (TIR_S_C_CTL_DFLOC);
  /*
   *	Flush the buffer if it is more than 75% full
   */
  if (Object_Record_Offset >
      (sizeof (Object_Record_Buffer) * 3 / 4))
    Flush_VMS_Object_Record_Buffer ();
}

static
VMS_Set_Struct (int Struct_Index)
{				/* see previous functions for comments */
  Set_VMS_Object_File_Record (OBJ_S_C_DBG);
  if (Object_Record_Offset == 0)
    PUT_CHAR (OBJ_S_C_DBG);
  PUT_CHAR (TIR_S_C_STA_UW);
  PUT_SHORT (Struct_Index);
  PUT_CHAR (TIR_S_C_CTL_STLOC);
  if (Object_Record_Offset >
      (sizeof (Object_Record_Buffer) * 3 / 4))
    Flush_VMS_Object_Record_Buffer ();
}

/*
 *	Write the Traceback Module Begin record
 */
static
VMS_TBT_Module_Begin ()
{
  register char *cp, *cp1;
  int Size;
  char Module_Name[256];
  char Local[256];

  /*
   *	Get module name (the FILENAME part of the object file)
   */
  cp = out_file_name;
  cp1 = Module_Name;
  while (*cp)
    {
      if ((*cp == ']') || (*cp == '>') ||
	  (*cp == ':') || (*cp == '/'))
	{
	  cp1 = Module_Name;
	  cp++;
	  continue;
	}
      *cp1++ = islower (*cp) ? toupper (*cp++) : *cp++;
    }
  *cp1 = 0;
  /*
   *	Limit it to 31 characters
   */
  while (--cp1 >= Module_Name)
    if (*cp1 == '.')
      *cp1 = 0;
  if (strlen (Module_Name) > 31)
    {
      if (flagseen['+'])
	printf ("%s: Module name truncated: %s\n", myname, Module_Name);
      Module_Name[31] = 0;
    }
  /*
   *	Arrange to store the data locally (leave room for size byte)
   */
  cp = Local + 1;
  /*
   *	Begin module
   */
  *cp++ = DST_S_C_MODBEG;
  /*
   *	Unused
   */
  *cp++ = 0;
  /*
   *	Language type == "C"
   */
  *(long *) cp = DST_S_C_C;
  cp += sizeof (long);
  /*
   *	Store the module name
   */
  *cp++ = strlen (Module_Name);
  cp1 = Module_Name;
  while (*cp1)
    *cp++ = *cp1++;
  /*
   *	Now we can store the record size
   */
  Size = (cp - Local);
  Local[0] = Size - 1;
  /*
   *	Put it into the object record
   */
  VMS_Store_Immediate_Data (Local, Size, OBJ_S_C_TBT);
}


/*
 *	Write the Traceback Module End record
*/
static
VMS_TBT_Module_End ()
{
  char Local[2];

  /*
   *	End module
   */
  Local[0] = 1;
  Local[1] = DST_S_C_MODEND;
  /*
   *	Put it into the object record
   */
  VMS_Store_Immediate_Data (Local, 2, OBJ_S_C_TBT);
}


/*
 *	Write the Traceback Routine Begin record
 */
static
VMS_TBT_Routine_Begin (symbolP, Psect)
     struct symbol *symbolP;
     int Psect;
{
  register char *cp, *cp1;
  char *Name;
  int Offset;
  int Size;
  char Local[512];

  /*
   *	Strip the leading "_" from the name
   */
  Name = S_GET_NAME (symbolP);
  if (*Name == '_')
    Name++;
  /*
   *	Get the text psect offset
   */
  Offset = S_GET_VALUE (symbolP);
  /*
   *	Calculate the record size
   */
  Size = 1 + 1 + 4 + 1 + strlen (Name);
  /*
   *	Record Size
   */
  Local[0] = Size;
  /*
   *	Begin Routine
   */
  Local[1] = DST_S_C_RTNBEG;
  /*
   *	Uses CallS/CallG
   */
  Local[2] = 0;
  /*
   *	Store the data so far
   */
  VMS_Store_Immediate_Data (Local, 3, OBJ_S_C_TBT);
  /*
   *	Make sure we are still generating a OBJ_S_C_TBT record
   */
  if (Object_Record_Offset == 0)
    PUT_CHAR (OBJ_S_C_TBT);
  /*
   *	Now get the symbol address
   */
  PUT_CHAR (TIR_S_C_STA_WPL);
  PUT_SHORT (Psect);
  PUT_LONG (Offset);
  /*
   *	Store the data reference
   */
  PUT_CHAR (TIR_S_C_STO_PIDR);
  /*
   *	Store the counted string as data
   */
  cp = Local;
  cp1 = Name;
  Size = strlen (cp1) + 1;
  *cp++ = Size - 1;
  while (*cp1)
    *cp++ = *cp1++;
  VMS_Store_Immediate_Data (Local, Size, OBJ_S_C_TBT);
}


/*
 *	Write the Traceback Routine End record
 * 	We *must* search the symbol table to find the next routine, since
 * 	the assember has a way of reassembling the symbol table OUT OF ORDER
 * 	Thus the next routine in the symbol list is not necessarily the
 *	next one in memory.  For debugging to work correctly we must know the
 *	size of the routine.
 */
static
VMS_TBT_Routine_End (Max_Size, sp)
     int Max_Size;
     symbolS *sp;
{
  symbolS *symbolP;
  int Size = 0x7fffffff;
  char Local[16];


  for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next (symbolP))
    {
      if (!S_IS_DEBUG (symbolP) && S_GET_TYPE (symbolP) == N_TEXT)
	{
	  if (*S_GET_NAME (symbolP) == 'L')
	    continue;
	  if ((S_GET_VALUE (symbolP) > S_GET_VALUE (sp)) &&
	      (S_GET_VALUE (symbolP) < Size))
	    Size = S_GET_VALUE (symbolP);
	  /* check if gcc_compiled. has size of zero */
	  if ((S_GET_VALUE (symbolP) == S_GET_VALUE (sp)) &&
	      sp != symbolP &&
	      (!strcmp (S_GET_NAME (sp), "gcc_compiled.") ||
	       !strcmp (S_GET_NAME (sp), "gcc2_compiled.")))
	    Size = S_GET_VALUE (symbolP);

	};
    };
  if (Size == 0x7fffffff)
    Size = Max_Size;
  Size -= S_GET_VALUE (sp);	/* and get the size of the routine */
  /*
   *	Record Size
   */
  Local[0] = 6;
  /*
   *	End of Routine
   */
  Local[1] = DST_S_C_RTNEND;
  /*
   *	Unused
   */
  Local[2] = 0;
  /*
   *	Size of routine
   */
  *((long *) (Local + 3)) = Size;
  /*
   *	Store the record
   */
  VMS_Store_Immediate_Data (Local, 7, OBJ_S_C_TBT);
}

/*
 *	Write the Traceback Block End record
 */
static
VMS_TBT_Block_Begin (symbolP, Psect, Name)
     struct symbol *symbolP;
     int Psect;
     char *Name;
{
  register char *cp, *cp1;
  int Offset;
  int Size;
  char Local[512];
  /*
   *	Begin block
   */
  Size = 1 + 1 + 4 + 1 + strlen (Name);
  /*
   *	Record Size
   */
  Local[0] = Size;
  /*
   *	Begin Block - We simulate with a phony routine
   */
  Local[1] = DST_S_C_BLKBEG;
  /*
   *	Uses CallS/CallG
   */
  Local[2] = 0;
  /*
   *	Store the data so far
   */
  VMS_Store_Immediate_Data (Local, 3, OBJ_S_C_DBG);
  /*
   *	Make sure we are still generating a OBJ_S_C_DBG record
   */
  if (Object_Record_Offset == 0)
    PUT_CHAR (OBJ_S_C_DBG);
  /*
   *	Now get the symbol address
   */
  PUT_CHAR (TIR_S_C_STA_WPL);
  PUT_SHORT (Psect);
  /*
   *	Get the text psect offset
   */
  Offset = S_GET_VALUE (symbolP);
  PUT_LONG (Offset);
  /*
   *	Store the data reference
   */
  PUT_CHAR (TIR_S_C_STO_PIDR);
  /*
   *	Store the counted string as data
   */
  cp = Local;
  cp1 = Name;
  Size = strlen (cp1) + 1;
  *cp++ = Size - 1;
  while (*cp1)
    *cp++ = *cp1++;
  VMS_Store_Immediate_Data (Local, Size, OBJ_S_C_DBG);
}


/*
 *	Write the Traceback Block End record
 */
static
VMS_TBT_Block_End (int Size)
{
  char Local[16];

  /*
   *	End block - simulate with a phony end routine
   */
  Local[0] = 6;
  Local[1] = DST_S_C_BLKEND;
  *((long *) (Local + 3)) = Size;
  /*
   *	Unused
   */
  Local[2] = 0;
  VMS_Store_Immediate_Data (Local, 7, OBJ_S_C_DBG);
}



/*
 *	Write a Line number / PC correlation record
 */
static
VMS_TBT_Line_PC_Correlation (Line_Number, Offset, Psect, Do_Delta)
     int Line_Number;
     int Offset;
     int Psect;
     int Do_Delta;
{
  register char *cp;
  char Local[64];

  /*
*	If not delta, set our PC/Line number correlation
*/
  if (Do_Delta == 0)
    {
      /*
       *	Size
       */
      Local[0] = 1 + 1 + 2 + 1 + 4;
      /*
       *	Line Number/PC correlation
       */
      Local[1] = DST_S_C_LINE_NUM;
      /*
       *	Set Line number
       */
      Local[2] = DST_S_C_SET_LINE_NUM;
      *((unsigned short *) (Local + 3)) = Line_Number - 1;
      /*
       *	Set PC
       */
      Local[5] = DST_S_C_SET_ABS_PC;
      VMS_Store_Immediate_Data (Local, 6, OBJ_S_C_TBT);
      /*
       *	Make sure we are still generating a OBJ_S_C_TBT record
       */
      if (Object_Record_Offset == 0)
	PUT_CHAR (OBJ_S_C_TBT);
      if (Psect < 255)
	{
	  PUT_CHAR (TIR_S_C_STA_PL);
	  PUT_CHAR (Psect);
	}
      else
	{
	  PUT_CHAR (TIR_S_C_STA_WPL);
	  PUT_SHORT (Psect);
	}
      PUT_LONG (Offset);
      PUT_CHAR (TIR_S_C_STO_PIDR);
      /*
       *	Do a PC offset of 0 to register the line number
       */
      Local[0] = 2;
      Local[1] = DST_S_C_LINE_NUM;
      Local[2] = 0;		/* Increment PC by 0 and register line # */
      VMS_Store_Immediate_Data (Local, 3, OBJ_S_C_TBT);
    }
  else
    {
      /*
       *	If Delta is negative, terminate the line numbers
       */
      if (Do_Delta < 0)
	{
	  Local[0] = 1 + 1 + 4;
	  Local[1] = DST_S_C_LINE_NUM;
	  Local[2] = DST_S_C_TERM_L;
	  *((long *) (Local + 3)) = Offset;
	  VMS_Store_Immediate_Data (Local, 7, OBJ_S_C_TBT);
	  /*
	   *	Done
	   */
	  return;
	}
      /*
       *	Do a PC/Line delta
       */
      cp = Local + 1;
      *cp++ = DST_S_C_LINE_NUM;
      if (Line_Number > 1)
	{
	  /*
	   *	We need to increment the line number
	   */
	  if (Line_Number - 1 <= 255)
	    {
	      *cp++ = DST_S_C_INCR_LINUM;
	      *cp++ = Line_Number - 1;
	    }
	  else
	    {
	      *cp++ = DST_S_C_INCR_LINUM_W;
	      *(short *) cp = Line_Number - 1;
	      cp += sizeof (short);
	    }
	}
      /*
       *	Increment the PC
       */
      if (Offset <= 128)
	{
	  *cp++ = -Offset;
	}
      else
	{
	  if (Offset < 0x10000)
	    {
	      *cp++ = DST_S_C_DELTA_PC_W;
	      *(short *) cp = Offset;
	      cp += sizeof (short);
	    }
	  else
	    {
	      *cp++ = DST_S_C_DELTA_PC_L;
	      *(long *) cp = Offset;
	      cp += sizeof (long);
	    }
	}
      Local[0] = cp - (Local + 1);
      VMS_Store_Immediate_Data (Local, cp - Local, OBJ_S_C_TBT);
    }
}


/*
 *	Describe a source file to the debugger
 */
static
VMS_TBT_Source_File (Filename, ID_Number)
     char *Filename;
     int ID_Number;
{
  register char *cp, *cp1;
  int Status, i;
  char Local[512];
#ifndef HO_VMS			/* Used for cross-assembly */
  i = strlen (Filename);
#else /* HO_VMS */
  static struct FAB Fab;
  static struct NAM Nam;
  static struct XABDAT Date_Xab;
  static struct XABFHC File_Header_Xab;
  char Es_String[255], Rs_String[255];

  /*
   *	Setup the Fab
   */
  Fab.fab$b_bid = FAB$C_BID;
  Fab.fab$b_bln = sizeof (Fab);
  Fab.fab$l_nam = (&Nam);
  Fab.fab$l_xab = (char *) &Date_Xab;
  /*
   *	Setup the Nam block so we can find out the FULL name
   *	of the source file.
   */
  Nam.nam$b_bid = NAM$C_BID;
  Nam.nam$b_bln = sizeof (Nam);
  Nam.nam$l_rsa = Rs_String;
  Nam.nam$b_rss = sizeof (Rs_String);
  Nam.nam$l_esa = Es_String;
  Nam.nam$b_ess = sizeof (Es_String);
  /*
   *	Setup the Date and File Header Xabs
   */
  Date_Xab.xab$b_cod = XAB$C_DAT;
  Date_Xab.xab$b_bln = sizeof (Date_Xab);
  Date_Xab.xab$l_nxt = (char *) &File_Header_Xab;
  File_Header_Xab.xab$b_cod = XAB$C_FHC;
  File_Header_Xab.xab$b_bln = sizeof (File_Header_Xab);
  /*
   *	Get the file information
   */
  Fab.fab$l_fna = Filename;
  Fab.fab$b_fns = strlen (Filename);
  Status = sys$open (&Fab);
  if (!(Status & 1))
    {
      printf ("gas: Couldn't find source file \"%s\", Error = %%X%x\n",
	      Filename, Status);
      return (0);
    }
  sys$close (&Fab);
  /*
   *	Calculate the size of the resultant string
   */
  i = Nam.nam$b_rsl;
#endif /* HO_VMS */
  /*
   *	Size of record
   */
  Local[0] = 1 + 1 + 1 + 1 + 1 + 2 + 8 + 4 + 2 + 1 + 1 + i + 1;
  /*
   *	Source declaration
   */
  Local[1] = DST_S_C_SOURCE;
  /*
   *	Make formfeeds count as source records
   */
  Local[2] = DST_S_C_SRC_FORMFEED;
  /*
   *	Declare source file
   */
  Local[3] = DST_S_C_SRC_DECLFILE;
  Local[4] = 1 + 2 + 8 + 4 + 2 + 1 + 1 + i + 1;
  cp = Local + 5;
  /*
   *	Flags
   */
  *cp++ = 0;
  /*
   *	File ID
   */
  *(short *) cp = ID_Number;
  cp += sizeof (short);
#ifndef HO_VMS
  /*
   *	Creation Date.  Unknown, so we fill with zeroes.
   */
  *(long *) cp = 0;
  cp += sizeof (long);
  *(long *) cp = 0;
  cp += sizeof (long);
  /*
   *	End of file block
   */
  *(long *) cp = 0;
  cp += sizeof (long);
  /*
   *	First free byte
   */
  *(short *) cp = 0;
  cp += sizeof (short);
  /*
   *	Record format
   */
  *cp++ = 0;
  /*
   *	Filename
   */
  *cp++ = i;
  cp1 = Filename;
#else /* Use this code when assembling for VMS on a VMS system */
  /*
   *	Creation Date
   */
  *(long *) cp = ((long *) &Date_Xab.xab$q_cdt)[0];
  cp += sizeof (long);
  *(long *) cp = ((long *) &Date_Xab.xab$q_cdt)[1];
  cp += sizeof (long);
  /*
   *	End of file block
   */
  *(long *) cp = File_Header_Xab.xab$l_ebk;
  cp += sizeof (long);
  /*
   *	First free byte
   */
  *(short *) cp = File_Header_Xab.xab$w_ffb;
  cp += sizeof (short);
  /*
   *	Record format
   */
  *cp++ = File_Header_Xab.xab$b_rfo;
  /*
   *	Filename
   */
  *cp++ = i;
  cp1 = Rs_String;
#endif /* HO_VMS */
  while (--i >= 0)
    *cp++ = *cp1++;
  /*
   *	Library module name (none)
   */
  *cp++ = 0;
  /*
   *	Done
   */
  VMS_Store_Immediate_Data (Local, cp - Local, OBJ_S_C_TBT);
  return 1;
}


/*
 *	Give the number of source lines to the debugger
 */
static
VMS_TBT_Source_Lines (ID_Number, Starting_Line_Number, Number_Of_Lines)
     int ID_Number;
     int Starting_Line_Number;
     int Number_Of_Lines;
{
  char *cp, *cp1;
  char Local[16];

  /*
   *	Size of record
   */
  Local[0] = 1 + 1 + 2 + 1 + 4 + 1 + 2;
  /*
   *	Source declaration
   */
  Local[1] = DST_S_C_SOURCE;
  /*
   *	Set Source File
   */
  cp = Local + 2;
  *cp++ = DST_S_C_SRC_SETFILE;
  /*
   *	File ID Number
   */
  *(short *) cp = ID_Number;
  cp += sizeof (short);
  /*
   *	Set record number
   */
  *cp++ = DST_S_C_SRC_SETREC_L;
  *(long *) cp = Starting_Line_Number;
  cp += sizeof (long);
  /*
   *	Define lines
   */
  *cp++ = DST_S_C_SRC_DEFLINES_W;
  *(short *) cp = Number_Of_Lines;
  cp += sizeof (short);
  /*
   *	Done
   */
  VMS_Store_Immediate_Data (Local, cp - Local, OBJ_S_C_TBT);
}




/* This routine locates a file in the list of files.  If an entry does not
 * exist, one is created.  For include files, a new entry is always created
 * such that inline functions can be properly debugged. */
static struct input_file *
find_file (sp)
     symbolS *sp;
{
  struct input_file *same_file;
  struct input_file *fpnt;
  same_file = (struct input_file *) NULL;
  for (fpnt = file_root; fpnt; fpnt = fpnt->next)
    {
      if (fpnt == (struct input_file *) NULL)
	break;
      if (fpnt->spnt == sp)
	return fpnt;
    };
  for (fpnt = file_root; fpnt; fpnt = fpnt->next)
    {
      if (fpnt == (struct input_file *) NULL)
	break;
      if (strcmp (S_GET_NAME (sp), fpnt->name) == 0)
	{
	  if (fpnt->flag == 1)
	    return fpnt;
	  same_file = fpnt;
	  break;
	};
    };
  fpnt = (struct input_file *) malloc (sizeof (struct input_file));
  if (file_root == (struct input_file *) NULL)
    file_root = fpnt;
  else
    {
      struct input_file *fpnt1;
      for (fpnt1 = file_root; fpnt1->next; fpnt1 = fpnt1->next) ;
      fpnt1->next = fpnt;
    };
  fpnt->next = (struct input_file *) NULL;
  fpnt->name = S_GET_NAME (sp);
  fpnt->min_line = 0x7fffffff;
  fpnt->max_line = 0;
  fpnt->offset = 0;
  fpnt->flag = 0;
  fpnt->file_number = 0;
  fpnt->spnt = sp;
  fpnt->same_file_fpnt = same_file;
  return fpnt;
}

/*
 * The following functions and definitions are used to generate object records
 * that will describe program variables to the VMS debugger.
 *
 * This file contains many of the routines needed to output debugging info into
 * the object file that the VMS debugger needs to understand symbols.  These
 * routines are called very late in the assembly process, and thus we can be
 * fairly lax about changing things, since the GSD and the TIR sections have
 * already been output.
 */


/* This routine converts a number string into an integer, and stops when it
 * sees an invalid character the return value is the address of the character
 * just past the last character read.  No error is generated.
 */
static char *
cvt_integer (str, rtn)
     char *str;
     int *rtn;
{
  int ival, neg;
  neg = *str == '-' ? ++str, -1 : 1;
  ival = 0;			/* first get the number of the type for dbx */
  while ((*str <= '9') && (*str >= '0'))
    ival = 10 * ival + *str++ - '0';
  *rtn = neg * ival;
  return str;
}

/* this routine fixes the names that are generated by C++, ".this" is a good
 * example.  The period does not work for the debugger, since it looks like
 * the syntax for a structure element, and thus it gets mightily confused
 *
 * We also use this to strip the PsectAttribute hack from the name before we
 * write a debugger record */

static char *
fix_name (pnt)
     char *pnt;
{
  char *pnt1;
  /*
   *	Kill any leading "_"
   */
  if (*pnt == '_')
    pnt++;
  /*
   *	Is there a Psect Attribute to skip??
   */
  if (HAS_PSECT_ATTRIBUTES (pnt))
    {
      /*
       *	Yes: Skip it
       */
      pnt += PSECT_ATTRIBUTES_STRING_LENGTH;
      while (*pnt)
	{
	  if ((pnt[0] == '$') && (pnt[1] == '$'))
	    {
	      pnt += 2;
	      break;
	    }
	  pnt++;
	}
    }
/* Here we fix the .this -> $this conversion */
  for (pnt1 = pnt; *pnt1 != 0; pnt1++)
    {
      if (*pnt1 == '.')
	*pnt1 = '$';
    };
  return pnt;
}

/* When defining a structure, this routine is called to find the name of
 * the actual structure.  It is assumed that str points to the equal sign
 * in the definition, and it moves backward until it finds the start of the
 * name.  If it finds a 0, then it knows that this structure def is in the
 * outermost level, and thus symbol_name points to the symbol name.
 */
static char *
get_struct_name (str)
     char *str;
{
  char *pnt;
  pnt = str;
  while ((*pnt != ':') && (*pnt != '\0'))
    pnt--;
  if (*pnt == '\0')
    return symbol_name;
  *pnt-- = '\0';
  while ((*pnt != ';') && (*pnt != '='))
    pnt--;
  if (*pnt == ';')
    return pnt + 1;
  while ((*pnt < '0') || (*pnt > '9'))
    pnt++;
  while ((*pnt >= '0') && (*pnt <= '9'))
    pnt++;
  return pnt;
}

/* search symbol list for type number dbx_type.  Return a pointer to struct */
static struct VMS_DBG_Symbol *
find_symbol (dbx_type)
     int dbx_type;
{
  struct VMS_DBG_Symbol *spnt;
  spnt = VMS_Symbol_type_list;
  while (spnt != (struct VMS_DBG_Symbol *) NULL)
    {
      if (spnt->dbx_type == dbx_type)
	break;
      spnt = spnt->next;
    };
  if (spnt == (struct VMS_DBG_Symbol *) NULL)
    return 0;			/*Dunno what this is*/
  return spnt;
}


/* this routine puts info into either Local or Asuffix, depending on the sign
 * of size.  The reason is that it is easier to build the variable descriptor
 * backwards, while the array descriptor is best built forwards.  In the end
 * they get put together, if there is not a struct/union/enum along the way
 */
static
push (value, size)
     int value, size;
{
  char *pnt;
  int i;
  int size1;
  long int val;
  val = value;
  pnt = (char *) &val;
  size1 = size;
  if (size < 0)
    {
      size1 = -size;
      pnt += size1 - 1;
    };
  if (size < 0)
    for (i = 0; i < size1; i++)
      {
	Local[Lpnt--] = *pnt--;
	if (Lpnt < 0)
	  {
	    overflow = 1;
	    Lpnt = 1;
	  };
      }
  else
    for (i = 0; i < size1; i++)
      {
	Asuffix[Apoint++] = *pnt++;
	if (Apoint >= MAX_DEBUG_RECORD)
	  {
	    overflow = 1;
	    Apoint = MAX_DEBUG_RECORD - 1;
	  };
      }
}

/* this routine generates the array descriptor for a given array */
static
array_suffix (spnt2)
     struct VMS_DBG_Symbol *spnt2;
{
  struct VMS_DBG_Symbol *spnt;
  struct VMS_DBG_Symbol *spnt1;
  int rank;
  int total_size;
  int i;
  rank = 0;
  spnt = spnt2;
  while (spnt->advanced != ARRAY)
    {
      spnt = find_symbol (spnt->type2);
      if (spnt == (struct VMS_DBG_Symbol *) NULL)
	return;
    };
  spnt1 = spnt;
  spnt1 = spnt;
  total_size = 1;
  while (spnt1->advanced == ARRAY)
    {
      rank++;
      total_size *= (spnt1->index_max - spnt1->index_min + 1);
      spnt1 = find_symbol (spnt1->type2);
    };
  total_size = total_size * spnt1->data_size;
  push (spnt1->data_size, 2);
  if (spnt1->VMS_type == 0xa3)
    push (0, 1);
  else
    push (spnt1->VMS_type, 1);
  push (4, 1);
  for (i = 0; i < 6; i++)
    push (0, 1);
  push (0xc0, 1);
  push (rank, 1);
  push (total_size, 4);
  push (0, 4);
  spnt1 = spnt;
  while (spnt1->advanced == ARRAY)
    {
      push (spnt1->index_max - spnt1->index_min + 1, 4);
      spnt1 = find_symbol (spnt1->type2);
    };
  spnt1 = spnt;
  while (spnt1->advanced == ARRAY)
    {
      push (spnt1->index_min, 4);
      push (spnt1->index_max, 4);
      spnt1 = find_symbol (spnt1->type2);
    };
}

/* this routine generates the start of a variable descriptor based upon
 * a struct/union/enum that has yet to be defined.  We define this spot as
 * a new location, and save four bytes for the address.  When the struct is
 * finally defined, then we can go back and plug in the correct address
*/
static
new_forward_ref (dbx_type)
     int dbx_type;
{
  struct forward_ref *fpnt;
  fpnt = (struct forward_ref *) malloc (sizeof (struct forward_ref));
  fpnt->next = f_ref_root;
  f_ref_root = fpnt;
  fpnt->dbx_type = dbx_type;
  fpnt->struc_numb = ++structure_count;
  fpnt->resolved = 'N';
  push (3, -1);
  total_len = 5;
  push (total_len, -2);
  struct_number = -fpnt->struc_numb;
}

/* this routine generates the variable descriptor used to describe non-basic
 * variables.  It calls itself recursively until it gets to the bottom of it
 * all, and then builds the descriptor backwards.  It is easiest to do it this
 *way since we must periodically write length bytes, and it is easiest if we know
 *the value when it is time to write it.
 */
static int
gen1 (spnt, array_suffix_len)
     struct VMS_DBG_Symbol *spnt;
     int array_suffix_len;
{
  struct VMS_DBG_Symbol *spnt1;
  int i;
  switch (spnt->advanced)
    {
    case VOID:
      push (DBG_S_C_VOID, -1);
      total_len += 1;
      push (total_len, -2);
      return 0;
    case BASIC:
    case FUNCTION:
      if (array_suffix_len == 0)
	{
	  push (spnt->VMS_type, -1);
	  push (DBG_S_C_BASIC, -1);
	  total_len = 2;
	  push (total_len, -2);
	  return 1;
	};
      push (0, -4);
      push (0xfa02, -2);
      total_len = -2;
      return 1;
    case STRUCT:
    case UNION:
    case ENUM:
      struct_number = spnt->struc_numb;
      if (struct_number < 0)
	{
	  new_forward_ref (spnt->dbx_type);
	  return 1;
	}
      push (DBG_S_C_STRUCT, -1);
      total_len = 5;
      push (total_len, -2);
      return 1;
    case POINTER:
      spnt1 = find_symbol (spnt->type2);
      i = 1;
      if (spnt1 == (struct VMS_DBG_Symbol *) NULL)
	new_forward_ref (spnt->type2);
      else
	i = gen1 (spnt1, 0);
      if (i)
	{			/* (*void) is a special case, do not put pointer suffix*/
	  push (DBG_S_C_POINTER, -1);
	  total_len += 3;
	  push (total_len, -2);
	};
      return 1;
    case ARRAY:
      spnt1 = spnt;
      while (spnt1->advanced == ARRAY)
	{
	  spnt1 = find_symbol (spnt1->type2);
	  if (spnt1 == (struct VMS_DBG_Symbol *) NULL)
	    {
	      printf ("gcc-as warning(debugger output):");
	      printf ("Forward reference error, dbx type %d\n",
		      spnt->type2);
	      return;
	    }
	};
/* It is too late to generate forward references, so the user gets a message.
 * This should only happen on a compiler error */
      i = gen1 (spnt1, 1);
      i = Apoint;
      array_suffix (spnt);
      array_suffix_len = Apoint - i;
      switch (spnt1->advanced)
	{
	case BASIC:
	case FUNCTION:
	  break;
	default:
	  push (0, -2);
	  total_len += 2;
	  push (total_len, -2);
	  push (0xfa, -1);
	  push (0x0101, -2);
	  push (DBG_S_C_COMPLEX_ARRAY, -1);
	};
      total_len += array_suffix_len + 8;
      push (total_len, -2);
    };
}

/* This generates a suffix for a variable.  If it is not a defined type yet,
 * then dbx_type contains the type we are expecting so we can generate a
 * forward reference.  This calls gen1 to build most of the descriptor, and
 * then it puts the icing on at the end.  It then dumps whatever is needed
 * to get a complete descriptor (i.e. struct reference, array suffix ).
 */
static
generate_suffix (spnt, dbx_type)
     struct VMS_DBG_Symbol *spnt;
     int dbx_type;
{
  int ilen;
  int i;
  char pvoid[6] =
  {5, 0xaf, 0, 1, 0, 5};
  struct VMS_DBG_Symbol *spnt1;
  Apoint = 0;
  Lpnt = MAX_DEBUG_RECORD - 1;
  total_len = 0;
  struct_number = 0;
  overflow = 0;
  if (spnt == (struct VMS_DBG_Symbol *) NULL)
    new_forward_ref (dbx_type);
  else
    {
      if (spnt->VMS_type != 0xa3)
	return 0;		/* no suffix needed */
      gen1 (spnt, 0);
    };
  push (0x00af, -2);
  total_len += 4;
  push (total_len, -1);
/* if the variable descriptor overflows the record, output a descriptor for
 * a pointer to void.
 */
  if ((total_len >= MAX_DEBUG_RECORD) || overflow)
    {
      printf (" Variable descriptor %d too complicated. Defined as *void ", spnt->dbx_type);
      VMS_Store_Immediate_Data (pvoid, 6, OBJ_S_C_DBG);
      return;
    };
  i = 0;
  while (Lpnt < MAX_DEBUG_RECORD - 1)
    Local[i++] = Local[++Lpnt];
  Lpnt = i;
/* we use this for a reference to a structure that has already been defined */
  if (struct_number > 0)
    {
      VMS_Store_Immediate_Data (Local, Lpnt, OBJ_S_C_DBG);
      Lpnt = 0;
      VMS_Store_Struct (struct_number);
    };
/* we use this for a forward reference to a structure that has yet to be
*defined.  We store four bytes of zero to make room for the actual address once
* it is known
*/
  if (struct_number < 0)
    {
      struct_number = -struct_number;
      VMS_Store_Immediate_Data (Local, Lpnt, OBJ_S_C_DBG);
      Lpnt = 0;
      VMS_Def_Struct (struct_number);
      for (i = 0; i < 4; i++)
	Local[Lpnt++] = 0;
      VMS_Store_Immediate_Data (Local, Lpnt, OBJ_S_C_DBG);
      Lpnt = 0;
    };
  i = 0;
  while (i < Apoint)
    Local[Lpnt++] = Asuffix[i++];
  if (Lpnt != 0)
    VMS_Store_Immediate_Data (Local, Lpnt, OBJ_S_C_DBG);
  Lpnt = 0;
}

/* This routine generates a symbol definition for a C sybmol for the debugger.
 * It takes a psect and offset for global symbols - if psect < 0, then this is
 * a local variable and the offset is relative to FP.  In this case it can
 * be either a variable (Offset < 0) or a parameter (Offset > 0).
 */
static
VMS_DBG_record (spnt, Psect, Offset, Name)
     struct VMS_DBG_Symbol *spnt;
     int Psect;
     int Offset;
     char *Name;
{
  char *pnt;
  char *Name_pnt;
  int j;
  int maxlen;
  int i = 0;
  Name_pnt = fix_name (Name);	/* if there are bad characters in name, convert them */
  if (Psect < 0)
    {				/* this is a local variable, referenced to SP */
      maxlen = 7 + strlen (Name_pnt);
      Local[i++] = maxlen;
      Local[i++] = spnt->VMS_type;
      if (Offset > 0)
	Local[i++] = DBG_S_C_FUNCTION_PARAMETER;
      else
	Local[i++] = DBG_S_C_LOCAL_SYM;
      pnt = (char *) &Offset;
      for (j = 0; j < 4; j++)
	Local[i++] = *pnt++;	/* copy the offset */
    }
  else
    {
      maxlen = 7 + strlen (Name_pnt);	/* symbols fixed in memory */
      Local[i++] = 7 + strlen (Name_pnt);
      Local[i++] = spnt->VMS_type;
      Local[i++] = 1;
      VMS_Store_Immediate_Data (Local, i, OBJ_S_C_DBG);
      i = 0;
      VMS_Set_Data (Psect, Offset, OBJ_S_C_DBG, 0);
    }
  Local[i++] = strlen (Name_pnt);
  while (*Name_pnt != '\0')
    Local[i++] = *Name_pnt++;
  VMS_Store_Immediate_Data (Local, i, OBJ_S_C_DBG);
  if (spnt->VMS_type == DBG_S_C_ADVANCED_TYPE)
    generate_suffix (spnt, 0);
}


/* This routine parses the stabs entries in order to make the definition
 * for the debugger of local symbols and function parameters
 */
static int
VMS_local_stab_Parse (sp)
     symbolS *sp;
{
  char *pnt;
  char *pnt1;
  char *str;
  struct VMS_DBG_Symbol *spnt;
  struct VMS_Symbol *vsp;
  int dbx_type;
  int VMS_type;
  dbx_type = 0;
  str = S_GET_NAME (sp);
  pnt = (char *) strchr (str, ':');
  if (pnt == (char *) NULL)
    return;			/* no colon present */
  pnt1 = pnt++;			/* save this for later, and skip colon */
  if (*pnt == 'c')
    return 0;			/* ignore static constants */
/* there is one little catch that we must be aware of.  Sometimes function
 * parameters are optimized into registers, and the compiler, in its infiite
 * wisdom outputs stabs records for *both*.  In general we want to use the
 * register if it is present, so we must search the rest of the symbols for
 * this function to see if this parameter is assigned to a register.
 */
  {
    char *str1;
    char *pnt2;
    symbolS *sp1;
    if (*pnt == 'p')
      {
	for (sp1 = symbol_next (sp); sp1; sp1 = symbol_next (sp1))
	  {
	    if (!S_IS_DEBUG (sp1))
	      continue;
	    if (S_GET_RAW_TYPE (sp1) == N_FUN)
	      {
		char * pnt3=(char*) strchr (S_GET_NAME (sp1), ':') + 1;
		if (*pnt3 == 'F' || *pnt3 == 'f') break;
	      };
	    if (S_GET_RAW_TYPE (sp1) != N_RSYM)
	      continue;
	    str1 = S_GET_NAME (sp1);	/* and get the name */
	    pnt2 = str;
	    while (*pnt2 != ':')
	      {
		if (*pnt2 != *str1)
		  break;
		pnt2++;
		str1++;
	      };
	    if ((*str1 != ':') || (*pnt2 != ':'))
	      continue;
	    return;		/* they are the same!  lets skip this one */
	  };			/* for */
/* first find the dbx symbol type from list, and then find VMS type */
	pnt++;			/* skip p in case no register */
      };			/* if */
  };				/* p block */
  pnt = cvt_integer (pnt, &dbx_type);
  spnt = find_symbol (dbx_type);
  if (spnt == (struct VMS_DBG_Symbol *) NULL)
    return 0;			/*Dunno what this is*/
  *pnt1 = '\0';
  VMS_DBG_record (spnt, -1, S_GET_VALUE (sp), str);
  *pnt1 = ':';			/* and restore the string */
  return 1;
}

/* This routine parses a stabs entry to find the information required to define
 * a variable.  It is used for global and static variables.
 * Basically we need to know the address of the symbol.  With older versions
 * of the compiler, const symbols are
 * treated differently, in that if they are global they are written into the
 * text psect.  The global symbol entry for such a const is actually written
 * as a program entry point (Yuk!!), so if we cannot find a symbol in the list
 * of psects, we must search the entry points as well.  static consts are even
 * harder, since they are never assigned a memory address.  The compiler passes
 * a stab to tell us the value, but I am not sure what to do with it.
 */

static
VMS_stab_parse (sp, expected_type, type1, type2, Text_Psect)
     symbolS *sp;
     char expected_type;
     int type1, type2, Text_Psect;
{
  char *pnt;
  char *pnt1;
  char *str;
  symbolS *sp1;
  struct VMS_DBG_Symbol *spnt;
  struct VMS_Symbol *vsp;
  int dbx_type;
  int VMS_type;
  dbx_type = 0;
  str = S_GET_NAME (sp);
  pnt = (char *) strchr (str, ':');
  if (pnt == (char *) NULL)
    return;			/* no colon present */
  pnt1 = pnt;			/* save this for later*/
  pnt++;
  if (*pnt == expected_type)
    {
      pnt = cvt_integer (pnt + 1, &dbx_type);
      spnt = find_symbol (dbx_type);
      if (spnt == (struct VMS_DBG_Symbol *) NULL)
	return 0;		/*Dunno what this is*/
/* now we need to search the symbol table to find the psect and offset for
 * this variable.
 */
      *pnt1 = '\0';
      vsp = VMS_Symbols;
      while (vsp != (struct VMS_Symbol *) NULL)
	{
	  pnt = S_GET_NAME (vsp->Symbol);
	  if (pnt != (char *) NULL)
	    if (*pnt++ == '_')
/* make sure name is the same, and make sure correct symbol type */
	      if ((strlen (pnt) == strlen (str)) && (strcmp (pnt, str) == 0)
		  && ((S_GET_RAW_TYPE (vsp->Symbol) == type1) ||
		      (S_GET_RAW_TYPE (vsp->Symbol) == type2)))
		break;
	  vsp = vsp->Next;
	};
      if (vsp != (struct VMS_Symbol *) NULL)
	{
	  VMS_DBG_record (spnt, vsp->Psect_Index, vsp->Psect_Offset, str);
	  *pnt1 = ':';		/* and restore the string */
	  return 1;
	};
/* the symbol was not in the symbol list, but it may be an "entry point"
   if it was a constant */
      for (sp1 = symbol_rootP; sp1; sp1 = symbol_next (sp1))
	{
	  /*
	   *	Dispatch on STAB type
	   */
	  if (S_IS_DEBUG (sp1) || (S_GET_TYPE (sp1) != N_TEXT))
	    continue;
	  pnt = S_GET_NAME (sp1);
	  if (*pnt == '_')
	    pnt++;
	  if (strcmp (pnt, str) == 0)
	    {
	      if (!gave_compiler_message && expected_type == 'G')
		{
		  printf ("***Warning - the assembly code generated by the compiler has placed\n");
		  printf ("global constant(s) in the text psect.  These will not be available to\n");
		  printf ("other modules, since this is not the correct way to handle this. You\n");
		  printf ("have two options: 1) get a patched compiler that does not put global\n");
		  printf ("constants in the text psect, or 2) remove the 'const' keyword from\n");
		  printf ("definitions of global variables in your source module(s).  Don't say\n");
		  printf ("I didn't warn you!");
		  gave_compiler_message = 1;
		};
	      VMS_DBG_record (spnt,
			      Text_Psect,
			      S_GET_VALUE (sp1),
			      str);
	      *pnt1 = ':';
	      *S_GET_NAME (sp1) = 'L';
	      /* fool assembler to not output this
	       * as a routine in the TBT */
	      return 1;
	    };
	};
    };
  *pnt1 = ':';			/* and restore the string */
  return 0;
}

static
VMS_GSYM_Parse (sp, Text_Psect)
     symbolS *sp;
     int Text_Psect;
{				/* Global variables */
  VMS_stab_parse (sp, 'G', (N_UNDF | N_EXT), (N_DATA | N_EXT), Text_Psect);
}


static
VMS_LCSYM_Parse (sp, Text_Psect)
     symbolS *sp;
     int Text_Psect;
{				/* Static symbols - uninitialized */
  VMS_stab_parse (sp, 'S', N_BSS, -1, Text_Psect);
}

static
VMS_STSYM_Parse (sp, Text_Psect)
     symbolS *sp;
     int Text_Psect;
{				/* Static symbols - initialized */
  VMS_stab_parse (sp, 'S', N_DATA, -1, Text_Psect);
}


/* for register symbols, we must figure out what range of addresses within the
 * psect are valid. We will use the brackets in the stab directives to give us
 * guidance as to the PC range that this variable is in scope.  I am still not
 * completely comfortable with this but as I learn more, I seem to get a better
 * handle on what is going on.
 * Caveat Emptor.
 */
static
VMS_RSYM_Parse (sp, Current_Routine, Text_Psect)
     symbolS *sp, *Current_Routine;
     int Text_Psect;
{
  char *pnt;
  char *pnt1;
  char *str;
  int dbx_type;
  struct VMS_DBG_Symbol *spnt;
  int j;
  int maxlen;
  int i = 0;
  int bcnt = 0;
  int Min_Offset = -1;		/* min PC of validity */
  int Max_Offset = 0;		/* max PC of validity */
  symbolS *symbolP;
  for (symbolP = sp; symbolP; symbolP = symbol_next (symbolP))
    {
      /*
       *	Dispatch on STAB type
       */
      switch (S_GET_RAW_TYPE (symbolP))
	{
	case N_LBRAC:
	  if (bcnt++ == 0)
	    Min_Offset = S_GET_VALUE (symbolP);
	  break;
	case N_RBRAC:
	  if (--bcnt == 0)
	    Max_Offset =
	      S_GET_VALUE (symbolP) - 1;
	  break;
	}
      if ((Min_Offset != -1) && (bcnt == 0))
	break;
      if (S_GET_RAW_TYPE (symbolP) == N_FUN)
	{
	  pnt=(char*) strchr (S_GET_NAME (symbolP), ':') + 1;
	  if (*pnt == 'F' || *pnt == 'f') break;
	};
    }
/* check to see that the addresses were defined.  If not, then there were no
 * brackets in the function, and we must try to search for the next function
 * Since functions can be in any order, we should search all of the symbol list
 * to find the correct ending address. */
  if (Min_Offset == -1)
    {
      int Max_Source_Offset;
      int This_Offset;
      Min_Offset = S_GET_VALUE (sp);
      for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next (symbolP))
	{
	  /*
	   *	Dispatch on STAB type
	   */
	  This_Offset = S_GET_VALUE (symbolP);
	  switch (S_GET_RAW_TYPE (symbolP))
	    {
	    case N_TEXT | N_EXT:
	      if ((This_Offset > Min_Offset) && (This_Offset < Max_Offset))
		Max_Offset = This_Offset;
	      break;
	    case N_SLINE:
	      if (This_Offset > Max_Source_Offset)
		Max_Source_Offset = This_Offset;
	    }
	}
/* if this is the last routine, then we use the PC of the last source line
 * as a marker of the max PC for which this reg is valid */
      if (Max_Offset == 0x7fffffff)
	Max_Offset = Max_Source_Offset;
    };
  dbx_type = 0;
  str = S_GET_NAME (sp);
  pnt = (char *) strchr (str, ':');
  if (pnt == (char *) NULL)
    return;			/* no colon present */
  pnt1 = pnt;			/* save this for later*/
  pnt++;
  if (*pnt != 'r')
    return 0;
  pnt = cvt_integer (pnt + 1, &dbx_type);
  spnt = find_symbol (dbx_type);
  if (spnt == (struct VMS_DBG_Symbol *) NULL)
    return 0;			/*Dunno what this is yet*/
  *pnt1 = '\0';
  pnt = fix_name (S_GET_NAME (sp));	/* if there are bad characters in name, convert them */
  maxlen = 25 + strlen (pnt);
  Local[i++] = maxlen;
  Local[i++] = spnt->VMS_type;
  Local[i++] = 0xfb;
  Local[i++] = strlen (pnt) + 1;
  Local[i++] = 0x00;
  Local[i++] = 0x00;
  Local[i++] = 0x00;
  Local[i++] = strlen (pnt);
  while (*pnt != '\0')
    Local[i++] = *pnt++;
  Local[i++] = 0xfd;
  Local[i++] = 0x0f;
  Local[i++] = 0x00;
  Local[i++] = 0x03;
  Local[i++] = 0x01;
  VMS_Store_Immediate_Data (Local, i, OBJ_S_C_DBG);
  i = 0;
  VMS_Set_Data (Text_Psect, Min_Offset, OBJ_S_C_DBG, 1);
  VMS_Set_Data (Text_Psect, Max_Offset, OBJ_S_C_DBG, 1);
  Local[i++] = 0x03;
  Local[i++] = S_GET_VALUE (sp);
  Local[i++] = 0x00;
  Local[i++] = 0x00;
  Local[i++] = 0x00;
  VMS_Store_Immediate_Data (Local, i, OBJ_S_C_DBG);
  *pnt1 = ':';
  if (spnt->VMS_type == DBG_S_C_ADVANCED_TYPE)
    generate_suffix (spnt, 0);
}

/* this function examines a structure definition, checking all of the elements
 * to make sure that all of them are fully defined.  The only thing that we
 * kick out are arrays of undefined structs, since we do not know how big
 * they are.  All others we can handle with a normal forward reference.
 */
static int
forward_reference (pnt)
     char *pnt;
{
  int i;
  struct VMS_DBG_Symbol *spnt;
  struct VMS_DBG_Symbol *spnt1;
  pnt = cvt_integer (pnt + 1, &i);
  if (*pnt == ';')
    return 0;			/* no forward references */
  do
    {
      pnt = (char *) strchr (pnt, ':');
      pnt = cvt_integer (pnt + 1, &i);
      spnt = find_symbol (i);
      if (spnt == (struct VMS_DBG_Symbol *) NULL)
	return 0;
      while ((spnt->advanced == POINTER) || (spnt->advanced == ARRAY))
	{
	  i = spnt->type2;
	  spnt1 = find_symbol (spnt->type2);
	  if ((spnt->advanced == ARRAY) &&
	      (spnt1 == (struct VMS_DBG_Symbol *) NULL))
	    return 1;
	  if (spnt1 == (struct VMS_DBG_Symbol *) NULL)
	    break;
	  spnt = spnt1;
	};
      pnt = cvt_integer (pnt + 1, &i);
      pnt = cvt_integer (pnt + 1, &i);
  } while (*++pnt != ';');
  return 0;			/* no forward refences found */
}

/* This routine parses the stabs directives to find any definitions of dbx type
 * numbers.  It makes a note of all of them, creating a structure element
 * of VMS_DBG_Symbol that describes it.  This also generates the info for the
 * debugger that describes the struct/union/enum, so that further references
 * to these data types will be by number
 * 	We have to process pointers right away, since there can be references
 * to them later in the same stabs directive.  We cannot have forward
 * references to pointers, (but we can have a forward reference to a pointer to
 * a structure/enum/union) and this is why we process them immediately.
 * After we process the pointer, then we search for defs that are nested even
 * deeper.
 */
static int
VMS_typedef_parse (str)
     char *str;
{
  char *pnt;
  char *pnt1;
  char *pnt2;
  int i;
  int dtype;
  struct forward_ref *fpnt;
  int i1, i2, i3;
  int convert_integer;
  struct VMS_DBG_Symbol *spnt;
  struct VMS_DBG_Symbol *spnt1;
/* check for any nested def's */
  pnt = (char *) strchr (str + 1, '=');
  if ((pnt != (char *) NULL) && (*(str + 1) != '*'))
    if (VMS_typedef_parse (pnt) == 1)
      return 1;
/* now find dbx_type of entry */
  pnt = str - 1;
  if (*pnt == 'c')
    {				/* check for static constants */
      *str = '\0';		/* for now we ignore them */
      return 0;
    };
  while ((*pnt <= '9') && (*pnt >= '0'))
    pnt--;
  pnt++;			/* and get back to the number */
  cvt_integer (pnt, &i1);
  spnt = find_symbol (i1);
/* first we see if this has been defined already, due to a forward reference*/
  if (spnt == (struct VMS_DBG_Symbol *) NULL)
    {
      if (VMS_Symbol_type_list == (struct VMS_DBG_Symbol *) NULL)
	{
	  spnt = (struct VMS_DBG_Symbol *) malloc (sizeof (struct VMS_DBG_Symbol));
	  spnt->next = (struct VMS_DBG_Symbol *) NULL;
	  VMS_Symbol_type_list = spnt;
	}
      else
	{
	  spnt = (struct VMS_DBG_Symbol *) malloc (sizeof (struct VMS_DBG_Symbol));
	  spnt->next = VMS_Symbol_type_list;
	  VMS_Symbol_type_list = spnt;
	};
      spnt->dbx_type = i1;	/* and save the type */
    };
/* for structs and unions, do a partial parse, otherwise we sometimes get
 * circular definitions that are impossible to resolve. We read enough info
 * so that any reference to this type has enough info to be resolved
 */
  pnt = str + 1;		/* point to character past equal sign */
  if ((*pnt == 'u') || (*pnt == 's'))
    {
    };
  if ((*pnt <= '9') && (*pnt >= '0'))
    {
      if (type_check ("void"))
	{			/* this is the void symbol */
	  *str = '\0';
	  spnt->advanced = VOID;
	  return 0;
	};
      if (type_check ("unknown type"))
	{			/* this is the void symbol */
	  *str = '\0';
	  spnt->advanced = UNKNOWN;
	  return 0;
	};
      printf ("gcc-as warning(debugger output):");
      printf (" %d is an unknown untyped variable.\n", spnt->dbx_type);
      return 1;			/* do not know what this is */
    };
/* now define this module*/
  pnt = str + 1;		/* point to character past equal sign */
  switch (*pnt)
    {
    case 'r':
      spnt->advanced = BASIC;
      if (type_check ("int"))
	{
	  spnt->VMS_type = DBG_S_C_SLINT;
	  spnt->data_size = 4;
	}
      else if (type_check ("long int"))
	{
	  spnt->VMS_type = DBG_S_C_SLINT;
	  spnt->data_size = 4;
	}
      else if (type_check ("unsigned int"))
	{
	  spnt->VMS_type = DBG_S_C_ULINT;
	  spnt->data_size = 4;
	}
      else if (type_check ("long unsigned int"))
	{
	  spnt->VMS_type = DBG_S_C_ULINT;
	  spnt->data_size = 4;
	}
      else if (type_check ("short int"))
	{
	  spnt->VMS_type = DBG_S_C_SSINT;
	  spnt->data_size = 2;
	}
      else if (type_check ("short unsigned int"))
	{
	  spnt->VMS_type = DBG_S_C_USINT;
	  spnt->data_size = 2;
	}
      else if (type_check ("char"))
	{
	  spnt->VMS_type = DBG_S_C_SCHAR;
	  spnt->data_size = 1;
	}
      else if (type_check ("signed char"))
	{
	  spnt->VMS_type = DBG_S_C_SCHAR;
	  spnt->data_size = 1;
	}
      else if (type_check ("unsigned char"))
	{
	  spnt->VMS_type = DBG_S_C_UCHAR;
	  spnt->data_size = 1;
	}
      else if (type_check ("float"))
	{
	  spnt->VMS_type = DBG_S_C_REAL4;
	  spnt->data_size = 4;
	}
      else if (type_check ("double"))
	{
	  spnt->VMS_type = DBG_S_C_REAL8;
	  spnt->data_size = 8;
	}
      pnt1 = (char *) strchr (str, ';') + 1;
      break;
    case 's':
    case 'u':
      if (*pnt == 's')
	spnt->advanced = STRUCT;
      else
	spnt->advanced = UNION;
      spnt->VMS_type = DBG_S_C_ADVANCED_TYPE;
      pnt1 = cvt_integer (pnt + 1, &spnt->data_size);
      if (forward_reference (pnt))
	{
	  spnt->struc_numb = -1;
	  return 1;
	}
      spnt->struc_numb = ++structure_count;
      pnt1--;
      pnt = get_struct_name (str);
      VMS_Def_Struct (spnt->struc_numb);
      fpnt = f_ref_root;
      while (fpnt != (struct forward_ref *) NULL)
	{
	  if (fpnt->dbx_type == spnt->dbx_type)
	    {
	      fpnt->resolved = 'Y';
	      VMS_Set_Struct (fpnt->struc_numb);
	      VMS_Store_Struct (spnt->struc_numb);
	    };
	  fpnt = fpnt->next;
	};
      VMS_Set_Struct (spnt->struc_numb);
      i = 0;
      Local[i++] = 11 + strlen (pnt);
      Local[i++] = DBG_S_C_STRUCT_START;
      Local[i++] = 0x80;
      for (i1 = 0; i1 < 4; i1++)
	Local[i++] = 0x00;
      Local[i++] = strlen (pnt);
      pnt2 = pnt;
      while (*pnt2 != '\0')
	Local[i++] = *pnt2++;
      i2 = spnt->data_size * 8;	/* number of bits */
      pnt2 = (char *) &i2;
      for (i1 = 0; i1 < 4; i1++)
	Local[i++] = *pnt2++;
      VMS_Store_Immediate_Data (Local, i, OBJ_S_C_DBG);
      i = 0;
      if (pnt != symbol_name)
	{
	  pnt += strlen (pnt);
	  *pnt = ':';
	};			/* replace colon for later */
      while (*++pnt1 != ';')
	{
	  pnt = (char *) strchr (pnt1, ':');
	  *pnt = '\0';
	  pnt2 = pnt1;
	  pnt1 = cvt_integer (pnt + 1, &dtype);
	  pnt1 = cvt_integer (pnt1 + 1, &i2);
	  pnt1 = cvt_integer (pnt1 + 1, &i3);
	  if ((dtype == 1) && (i3 != 32))
	    {			/* bitfield */
	      Apoint = 0;
	      push (19 + strlen (pnt2), 1);
	      push (0xfa22, 2);
	      push (1 + strlen (pnt2), 4);
	      push (strlen (pnt2), 1);
	      while (*pnt2 != '\0')
		push (*pnt2++, 1);
	      push (i3, 2);	/* size of bitfield */
	      push (0x0d22, 2);
	      push (0x00, 4);
	      push (i2, 4);	/* start position */
	      VMS_Store_Immediate_Data (Asuffix, Apoint, OBJ_S_C_DBG);
	      Apoint = 0;
	    }
	  else
	    {
	      Local[i++] = 7 + strlen (pnt2);
	      spnt1 = find_symbol (dtype);
	      /* check if this is a forward reference */
	      if (spnt1 != (struct VMS_DBG_Symbol *) NULL)
		Local[i++] = spnt1->VMS_type;
	      else
		Local[i++] = DBG_S_C_ADVANCED_TYPE;
	      Local[i++] = DBG_S_C_STRUCT_ITEM;
	      pnt = (char *) &i2;
	      for (i1 = 0; i1 < 4; i1++)
		Local[i++] = *pnt++;
	      Local[i++] = strlen (pnt2);
	      while (*pnt2 != '\0')
		Local[i++] = *pnt2++;
	      VMS_Store_Immediate_Data (Local, i, OBJ_S_C_DBG);
	      i = 0;
	      if (spnt1 == (struct VMS_DBG_Symbol *) NULL)
		generate_suffix (spnt1, dtype);
	      else if (spnt1->VMS_type == DBG_S_C_ADVANCED_TYPE)
		generate_suffix (spnt1, 0);
	    };
	};
      pnt1++;
      Local[i++] = 0x01;	/* length byte */
      Local[i++] = DBG_S_C_STRUCT_END;
      VMS_Store_Immediate_Data (Local, i, OBJ_S_C_DBG);
      i = 0;
      break;
    case 'e':
      spnt->advanced = ENUM;
      spnt->VMS_type = DBG_S_C_ADVANCED_TYPE;
      spnt->struc_numb = ++structure_count;
      spnt->data_size = 4;
      VMS_Def_Struct (spnt->struc_numb);
      fpnt = f_ref_root;
      while (fpnt != (struct forward_ref *) NULL)
	{
	  if (fpnt->dbx_type == spnt->dbx_type)
	    {
	      fpnt->resolved = 'Y';
	      VMS_Set_Struct (fpnt->struc_numb);
	      VMS_Store_Struct (spnt->struc_numb);
	    };
	  fpnt = fpnt->next;
	};
      VMS_Set_Struct (spnt->struc_numb);
      i = 0;
      Local[i++] = 3 + strlen (symbol_name);
      Local[i++] = DBG_S_C_ENUM_START;
      Local[i++] = 0x20;
      Local[i++] = strlen (symbol_name);
      pnt2 = symbol_name;
      while (*pnt2 != '\0')
	Local[i++] = *pnt2++;
      VMS_Store_Immediate_Data (Local, i, OBJ_S_C_DBG);
      i = 0;
      while (*++pnt != ';')
	{
	  pnt1 = (char *) strchr (pnt, ':');
	  *pnt1++ = '\0';
	  pnt1 = cvt_integer (pnt1, &i1);
	  Local[i++] = 7 + strlen (pnt);
	  Local[i++] = DBG_S_C_ENUM_ITEM;
	  Local[i++] = 0x00;
	  pnt2 = (char *) &i1;
	  for (i2 = 0; i2 < 4; i2++)
	    Local[i++] = *pnt2++;
	  Local[i++] = strlen (pnt);
	  pnt2 = pnt;
	  while (*pnt != '\0')
	    Local[i++] = *pnt++;
	  VMS_Store_Immediate_Data (Local, i, OBJ_S_C_DBG);
	  i = 0;
	  pnt = pnt1;		/* Skip final semicolon */
	};
      Local[i++] = 0x01;	/* len byte */
      Local[i++] = DBG_S_C_ENUM_END;
      VMS_Store_Immediate_Data (Local, i, OBJ_S_C_DBG);
      i = 0;
      pnt1 = pnt + 1;
      break;
    case 'a':
      spnt->advanced = ARRAY;
      spnt->VMS_type = DBG_S_C_ADVANCED_TYPE;
      pnt = (char *) strchr (pnt, ';');
      if (pnt == (char *) NULL)
	return 1;
      pnt1 = cvt_integer (pnt + 1, &spnt->index_min);
      pnt1 = cvt_integer (pnt1 + 1, &spnt->index_max);
      pnt1 = cvt_integer (pnt1 + 1, &spnt->type2);
      break;
    case 'f':
      spnt->advanced = FUNCTION;
      spnt->VMS_type = DBG_S_C_FUNCTION_ADDR;
      /* this masquerades as a basic type*/
      spnt->data_size = 4;
      pnt1 = cvt_integer (pnt + 1, &spnt->type2);
      break;
    case '*':
      spnt->advanced = POINTER;
      spnt->VMS_type = DBG_S_C_ADVANCED_TYPE;
      spnt->data_size = 4;
      pnt1 = cvt_integer (pnt + 1, &spnt->type2);
      pnt = (char *) strchr (str + 1, '=');
      if ((pnt != (char *) NULL))
	if (VMS_typedef_parse (pnt) == 1)
	  return 1;
      break;
    default:
      spnt->advanced = UNKNOWN;
      spnt->VMS_type = 0;
      printf ("gcc-as warning(debugger output):");
      printf (" %d is an unknown type of variable.\n", spnt->dbx_type);
      return 1;			/* unable to decipher */
    };
/* this removes the evidence of the definition so that the outer levels of
parsing do not have to worry about it */
  pnt = str;
  while (*pnt1 != '\0')
    *pnt++ = *pnt1++;
  *pnt = '\0';
  return 0;
}


/*
 * This is the root routine that parses the stabs entries for definitions.
 * it calls VMS_typedef_parse, which can in turn call itself.
 * We need to be careful, since sometimes there are forward references to
 * other symbol types, and these cannot be resolved until we have completed
 * the parse.
 */
static int
VMS_LSYM_Parse ()
{
  char *pnt;
  char *pnt1;
  char *pnt2;
  char *str;
  char fixit[10];
  int incomplete, i, pass, incom1;
  struct VMS_DBG_Symbol *spnt;
  struct VMS_Symbol *vsp;
  struct forward_ref *fpnt;
  symbolS *sp;
  pass = 0;
  incomplete = 0;
  do
    {
      incom1 = incomplete;
      incomplete = 0;
      for (sp = symbol_rootP; sp; sp = symbol_next (sp))
	{
	  /*
	   *	Deal with STAB symbols
	   */
	  if (S_IS_DEBUG (sp))
	    {
	      /*
	       *	Dispatch on STAB type
	       */
	      switch (S_GET_RAW_TYPE (sp))
		{
		case N_GSYM:
		case N_LCSYM:
		case N_STSYM:
		case N_PSYM:
		case N_RSYM:
		case N_LSYM:
		case N_FUN:	/*sometimes these contain typedefs*/
		  str = S_GET_NAME (sp);
		  symbol_name = str;
		  pnt = (char *) strchr (str, ':');
		  if (pnt == (char *) NULL)
		    break;
		  *pnt = '\0';
		  pnt1 = pnt + 1;
		  pnt2 = (char *) strchr (pnt1, '=');
		  if (pnt2 == (char *) NULL)
		    {
		      *pnt = ':';	/* replace colon */
		      break;
		    };		/* no symbol here */
		  incomplete += VMS_typedef_parse (pnt2);
		  *pnt = ':';	/* put back colon so variable def code finds dbx_type*/
		  break;
		}		/*switch*/
	    }			/* if */
	}			/*for*/
      pass++;
  } while ((incomplete != 0) && (incomplete != incom1));
  /* repeat until all refs resolved if possible */
/*	if (pass > 1) printf(" Required %d passes\n",pass);*/
  if (incomplete != 0)
    {
      printf ("gcc-as warning(debugger output):");
      printf ("Unable to resolve %d circular references.\n", incomplete);
    };
  fpnt = f_ref_root;
  symbol_name = "\0";
  while (fpnt != (struct forward_ref *) NULL)
    {
      if (fpnt->resolved != 'Y')
	{
	  if (find_symbol (fpnt->dbx_type) !=
	      (struct VMS_DBG_Symbol *) NULL)
	    {
	      printf ("gcc-as warning(debugger output):");
	      printf ("Forward reference error, dbx type %d\n",
		      fpnt->dbx_type);
	      break;
	    };
	  fixit[0] = 0;
	  sprintf (&fixit[1], "%d=s4;", fpnt->dbx_type);
	  pnt2 = (char *) strchr (&fixit[1], '=');
	  VMS_typedef_parse (pnt2);
	};
      fpnt = fpnt->next;
    };
}

static
Define_Local_Symbols (s1, s2)
     symbolS *s1, *s2;
{
  symbolS *symbolP1;
  for (symbolP1 = symbol_next (s1); symbolP1 != s2; symbolP1 = symbol_next (symbolP1))
    {
      if (symbolP1 == (symbolS *) NULL)
	return;
      if (S_GET_RAW_TYPE (symbolP1) == N_FUN)
	{
	  char * pnt=(char*) strchr (S_GET_NAME (symbolP1), ':') + 1;
	  if (*pnt == 'F' || *pnt == 'f') break;
	};
      /*
       *	Deal with STAB symbols
       */
      if (S_IS_DEBUG (symbolP1))
	{
	  /*
	   *	Dispatch on STAB type
	   */
	  switch (S_GET_RAW_TYPE (symbolP1))
	    {
	    case N_LSYM:
	    case N_PSYM:
	      VMS_local_stab_Parse (symbolP1);
	      break;
	    case N_RSYM:
	      VMS_RSYM_Parse (symbolP1, Current_Routine, Text_Psect);
	      break;
	    }			/*switch*/
	}			/* if */
    }				/* for */
}


/* This function crawls the symbol chain searching for local symbols that need
 * to be described to the debugger.  When we enter a new scope with a "{", it
 * creates a new "block", which helps the debugger keep track of which scope
 * we are currently in.
 */

static symbolS *
Define_Routine (symbolP, Level)
     symbolS *symbolP;
     int Level;
{
  symbolS *sstart;
  symbolS *symbolP1;
  char str[10];
  int rcount = 0;
  int Offset;
  sstart = symbolP;
  for (symbolP1 = symbol_next (symbolP); symbolP1; symbolP1 = symbol_next (symbolP1))
    {
      if (S_GET_RAW_TYPE (symbolP1) == N_FUN)
	{
	  char * pnt=(char*) strchr (S_GET_NAME (symbolP1), ':') + 1;
	  if (*pnt == 'F' || *pnt == 'f') break;
	};
      /*
       *	Deal with STAB symbols
       */
      if (S_IS_DEBUG (symbolP1))
	{
	  /*
	   *	Dispatch on STAB type
	   */
	  switch (S_GET_RAW_TYPE (symbolP1))
	    {
	    case N_LBRAC:
	      if (Level != 0)
		{
		  sprintf (str, "$%d", rcount++);
		  VMS_TBT_Block_Begin (symbolP1, Text_Psect, str);
		};
	      Offset = S_GET_VALUE (symbolP1);
	      Define_Local_Symbols (sstart, symbolP1);
	      symbolP1 =
		Define_Routine (symbolP1, Level + 1);
	      if (Level != 0)
		VMS_TBT_Block_End (S_GET_VALUE (symbolP1) -
				   Offset);
	      sstart = symbolP1;
	      break;
	    case N_RBRAC:
	      return symbolP1;
	    }			/*switch*/
	}			/* if */
    }				/* for */
  /* we end up here if there were no brackets in this function. Define
everything */
  Define_Local_Symbols (sstart, (symbolS *) 0);
  return symbolP1;
}


static
VMS_DBG_Define_Routine (symbolP, Curr_Routine, Txt_Psect)
     symbolS *symbolP;
     symbolS *Curr_Routine;
     int Txt_Psect;
{
  Current_Routine = Curr_Routine;
  Text_Psect = Txt_Psect;
  Define_Routine (symbolP, 0);
}




#ifndef HO_VMS
#include <sys/types.h>
#include <time.h>

/* Manufacure a VMS like time on a unix based system. */
get_VMS_time_on_unix (char *Now)
{
  char *pnt;
  time_t timeb;
  time (&timeb);
  pnt = ctime (&timeb);
  pnt[3] = 0;
  pnt[7] = 0;
  pnt[10] = 0;
  pnt[16] = 0;
  pnt[24] = 0;
  sprintf (Now, "%2s-%3s-%s %s", pnt + 8, pnt + 4, pnt + 20, pnt + 11);
}

#endif /* not HO_VMS */
/*
 *	Write the MHD (Module Header) records
 */
static
Write_VMS_MHD_Records ()
{
  register char *cp, *cp1;
  register int i;
  struct
  {
    int Size;
    char *Ptr;
  } Descriptor;
  char Module_Name[256];
  char Now[18];

  /*
   *	We are writing a module header record
   */
  Set_VMS_Object_File_Record (OBJ_S_C_HDR);
  /*
   *	***************************
   *	*MAIN MODULE HEADER RECORD*
   *	***************************
   *
   *	Store record type and header type
   */
  PUT_CHAR (OBJ_S_C_HDR);
  PUT_CHAR (MHD_S_C_MHD);
  /*
   *	Structure level is 0
   */
  PUT_CHAR (OBJ_S_C_STRLVL);
  /*
   *	Maximum record size is size of the object record buffer
   */
  PUT_SHORT (sizeof (Object_Record_Buffer));
  /*
   *	Get module name (the FILENAME part of the object file)
   */
  cp = out_file_name;
  cp1 = Module_Name;
  while (*cp)
    {
      if ((*cp == ']') || (*cp == '>') ||
	  (*cp == ':') || (*cp == '/'))
	{
	  cp1 = Module_Name;
	  cp++;
	  continue;
	}
      *cp1++ = islower (*cp) ? toupper (*cp++) : *cp++;
    }
  *cp1 = 0;
  /*
   *	Limit it to 31 characters and store in the object record
   */
  while (--cp1 >= Module_Name)
    if (*cp1 == '.')
      *cp1 = 0;
  if (strlen (Module_Name) > 31)
    {
      if (flagseen['+'])
	printf ("%s: Module name truncated: %s\n", myname, Module_Name);
      Module_Name[31] = 0;
    }
  PUT_COUNTED_STRING (Module_Name);
  /*
   *	Module Version is "V1.0"
   */
  PUT_COUNTED_STRING ("V1.0");
  /*
   *	Creation time is "now" (17 chars of time string)
   */
#ifndef HO_VMS
  get_VMS_time_on_unix (&Now[0]);
#else /* HO_VMS */
  Descriptor.Size = 17;
  Descriptor.Ptr = Now;
  sys$asctim (0, &Descriptor, 0, 0);
#endif /* HO_VMS */
  for (i = 0; i < 17; i++)
    PUT_CHAR (Now[i]);
  /*
   *	Patch time is "never" (17 zeros)
   */
  for (i = 0; i < 17; i++)
    PUT_CHAR (0);
  /*
   *	Flush the record
   */
  Flush_VMS_Object_Record_Buffer ();
  /*
   *	*************************
   *	*LANGUAGE PROCESSOR NAME*
   *	*************************
   *
   *	Store record type and header type
   */
  PUT_CHAR (OBJ_S_C_HDR);
  PUT_CHAR (MHD_S_C_LNM);
  /*
   *	Store language processor name and version
   *	(not a counted string!)
   */
  cp = compiler_version_string;
  if (cp == 0)
    {
      cp = "GNU AS  V";
      while (*cp)
	PUT_CHAR (*cp++);
      cp = strchr (&version_string, '.');
      while (*cp != ' ')
	cp--;
      cp++;
    };
  while (*cp >= 32)
    PUT_CHAR (*cp++);
  /*
   *	Flush the record
   */
  Flush_VMS_Object_Record_Buffer ();
}


/*
 *	Write the EOM (End Of Module) record
 */
static
Write_VMS_EOM_Record (Psect, Offset)
     int Psect;
     int Offset;
{
  /*
   *	We are writing an end-of-module record
   */
  Set_VMS_Object_File_Record (OBJ_S_C_EOM);
  /*
   *	Store record Type
   */
  PUT_CHAR (OBJ_S_C_EOM);
  /*
   *	Store the error severity (0)
   */
  PUT_CHAR (0);
  /*
   *	Store the entry point, if it exists
   */
  if (Psect >= 0)
    {
      /*
       *	Store the entry point Psect
       */
      PUT_CHAR (Psect);
      /*
       *	Store the entry point Psect offset
       */
      PUT_LONG (Offset);
    }
  /*
   *	Flush the record
   */
  Flush_VMS_Object_Record_Buffer ();
}


/* this hash routine borrowed from GNU-EMACS, and strengthened slightly  ERY*/

static int
hash_string (ptr)
     unsigned char *ptr;
{
  register unsigned char *p = ptr;
  register unsigned char *end = p + strlen (ptr);
  register unsigned char c;
  register int hash = 0;

  while (p != end)
    {
      c = *p++;
      hash = ((hash << 3) + (hash << 15) + (hash >> 28) + c);
    }
  return hash;
}

/*
 *	Generate a Case-Hacked VMS symbol name (limited to 31 chars)
 */
static
VMS_Case_Hack_Symbol (In, Out)
     register char *In;
     register char *Out;
{
  long int init = 0;
  long int result;
  char *pnt;
  char *new_name;
  char *old_name;
  register int i;
  int destructor = 0;		/*hack to allow for case sens in a destructor*/
  int truncate = 0;
  int Case_Hack_Bits = 0;
  int Saw_Dollar = 0;
  static char Hex_Table[16] =
  {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};

  /*
   *	Kill any leading "_"
   */
  if ((In[0] == '_') && ((In[1] > '9') || (In[1] < '0')))
    In++;

  new_name = Out;		/* save this for later*/

#if barfoo			/* Dead code */
  if ((In[0] == '_') && (In[1] == '$') && (In[2] == '_'))
    destructor = 1;
#endif

  /* We may need to truncate the symbol, save the hash for later*/
  if (strlen (In) > 23)
    result = hash_string (In);
  /*
   *	Is there a Psect Attribute to skip??
   */
  if (HAS_PSECT_ATTRIBUTES (In))
    {
      /*
       *	Yes: Skip it
       */
      In += PSECT_ATTRIBUTES_STRING_LENGTH;
      while (*In)
	{
	  if ((In[0] == '$') && (In[1] == '$'))
	    {
	      In += 2;
	      break;
	    }
	  In++;
	}
    }

  old_name = In;
/*	if (strlen(In) > 31 && flagseen['+'])
		printf("%s: Symbol name truncated: %s\n",myname,In);*/
  /*
   *	Do the case conversion
   */
  i = 23;			/* Maximum of 23 chars */
  while (*In && (--i >= 0))
    {
      Case_Hack_Bits <<= 1;
      if (*In == '$')
	Saw_Dollar = 1;
      if ((destructor == 1) && (i == 21))
	Saw_Dollar = 0;
      switch (vms_name_mapping)
	{
	case 0:
	  if (isupper(*In)) {
	    *Out++ = *In++;
	    Case_Hack_Bits |= 1;
	  } else {
	    *Out++ = islower(*In) ? toupper(*In++) : *In++;
	  }
	  break;
	case 3: *Out++ = *In++;
	  break;
	case 2:
	  if (islower(*In)) {
	    *Out++ = *In++;
	  } else {
	    *Out++ = isupper(*In) ? tolower(*In++) : *In++;
	  }
	  break;
	};
    }
  /*
   *	If we saw a dollar sign, we don't do case hacking
   */
  if (flagseen['h'] || Saw_Dollar)
    Case_Hack_Bits = 0;

  /*
   *	If we have more than 23 characters and everything is lowercase
   *	we can insert the full 31 characters
   */
  if (*In)
    {
      /*
       *	We  have more than 23 characters
       * If we must add the case hack, then we have truncated the str
       */
      pnt = Out;
      truncate = 1;
      if (Case_Hack_Bits == 0)
	{
	  /*
	   *	And so far they are all lower case:
	   *		Check up to 8 more characters
	   *		and ensure that they are lowercase
	   */
	  for (i = 0; (In[i] != 0) && (i < 8); i++)
	    if (isupper(In[i]) && !Saw_Dollar && !flagseen['h'])
	      break;

	  if (In[i] == 0)
	    truncate = 0;

	  if ((i == 8) || (In[i] == 0))
	    {
	      /*
	       *	They are:  Copy up to 31 characters
	       *			to the output string
	       */
	      i = 8;
	      while ((--i >= 0) && (*In))
		switch (vms_name_mapping){
		case 0: *Out++ = islower(*In) ?
		  toupper (*In++) :
		    *In++;
		  break;
		case 3: *Out++ = *In++;
		  break;
		case 2: *Out++ = isupper(*In) ?
		  tolower(*In++) :
		    *In++;
		  break;
		};
	    }
	}
    }
  /*
   *	If there were any uppercase characters in the name we
   *	take on the case hacking string
   */

  /* Old behavior for regular GNU-C compiler */
  if (!flagseen['+'])
    truncate = 0;
  if ((Case_Hack_Bits != 0) || (truncate == 1))
    {
      if (truncate == 0)
	{
	  *Out++ = '_';
	  for (i = 0; i < 6; i++)
	    {
	      *Out++ = Hex_Table[Case_Hack_Bits & 0xf];
	      Case_Hack_Bits >>= 4;
	    }
	  *Out++ = 'X';
	}
      else
	{
	  Out = pnt;		/*Cut back to 23 characters maximum */
	  *Out++ = '_';
	  for (i = 0; i < 7; i++)
	    {
	      init = result & 0x01f;
	      if (init < 10)
		*Out++ = '0' + init;
	      else
		*Out++ = 'A' + init - 10;
	      result = result >> 5;
	    }
	}
    }				/*Case Hack */
  /*
   *	Done
   */
  *Out = 0;
  if (truncate == 1 && flagseen['+'] && flagseen['H'])
    printf ("%s: Symbol %s replaced by %s\n", myname, old_name, new_name);
}


/*
 *	Scan a symbol name for a psect attribute specification
 */
#define GLOBALSYMBOL_BIT	0x10000
#define GLOBALVALUE_BIT		0x20000


static
VMS_Modify_Psect_Attributes (Name, Attribute_Pointer)
     char *Name;
     int *Attribute_Pointer;
{
  register int i;
  register char *cp;
  int Negate;
  static struct
  {
    char *Name;
    int Value;
  } Attributes[] =
  {
    {"PIC", GPS_S_M_PIC},
    {"LIB", GPS_S_M_LIB},
    {"OVR", GPS_S_M_OVR},
    {"REL", GPS_S_M_REL},
    {"GBL", GPS_S_M_GBL},
    {"SHR", GPS_S_M_SHR},
    {"EXE", GPS_S_M_EXE},
    {"RD", GPS_S_M_RD},
    {"WRT", GPS_S_M_WRT},
    {"VEC", GPS_S_M_VEC},
    {"GLOBALSYMBOL", GLOBALSYMBOL_BIT},
    {"GLOBALVALUE", GLOBALVALUE_BIT},
    {0, 0}
  };

  /*
   *	Kill leading "_"
   */
  if (*Name == '_')
    Name++;
  /*
   *	Check for a PSECT attribute list
   */
  if (!HAS_PSECT_ATTRIBUTES (Name))
    return;			/* If not, return */
  /*
   *	Skip the attribute list indicator
   */
  Name += PSECT_ATTRIBUTES_STRING_LENGTH;
  /*
   *	Process the attributes ("_" separated, "$" terminated)
   */
  while (*Name != '$')
    {
      /*
       *	Assume not negating
       */
      Negate = 0;
      /*
       *	Check for "NO"
       */
      if ((Name[0] == 'N') && (Name[1] == 'O'))
	{
	  /*
	   *	We are negating (and skip the NO)
	   */
	  Negate = 1;
	  Name += 2;
	}
      /*
       *	Find the token delimiter
       */
      cp = Name;
      while (*cp && (*cp != '_') && (*cp != '$'))
	cp++;
      /*
       *	Look for the token in the attribute list
       */
      for (i = 0; Attributes[i].Name; i++)
	{
	  /*
	   *	If the strings match, set/clear the attr.
	   */
	  if (strncmp (Name, Attributes[i].Name, cp - Name) == 0)
	    {
	      /*
	       *	Set or clear
	       */
	      if (Negate)
		*Attribute_Pointer &=
		  ~Attributes[i].Value;
	      else
		*Attribute_Pointer |=
		  Attributes[i].Value;
	      /*
	       *	Done
	       */
	      break;
	    }
	}
      /*
       *	Now skip the attribute
       */
      Name = cp;
      if (*Name == '_')
	Name++;
    }
  /*
   *	Done
   */
  return;
}


/*
 *	Define a global symbol
 */
static
VMS_Global_Symbol_Spec (Name, Psect_Number, Psect_Offset, Defined)
     char *Name;
     int Psect_Number;
     int Psect_Offset;
{
  char Local[32];

  /*
   *	We are writing a GSD record
   */
  Set_VMS_Object_File_Record (OBJ_S_C_GSD);
  /*
   *	If the buffer is empty we must insert the GSD record type
   */
  if (Object_Record_Offset == 0)
    PUT_CHAR (OBJ_S_C_GSD);
  /*
   *	We are writing a Global symbol definition subrecord
   */
  if (Psect_Number <= 255)
    {
      PUT_CHAR (GSD_S_C_SYM);
    }
  else
    {
      PUT_CHAR (GSD_S_C_SYMW);
    }
  /*
   *	Data type is undefined
   */
  PUT_CHAR (0);
  /*
   *	Switch on Definition/Reference
   */
  if ((Defined & 1) != 0)
    {
      /*
       *	Definition:
       *	Flags = "RELOCATABLE" and "DEFINED" for regular symbol
       *	      = "DEFINED" for globalvalue (Defined & 2 == 1)
       */
      if ((Defined & 2) == 0)
	{
	  PUT_SHORT (GSY_S_M_DEF | GSY_S_M_REL);
	}
      else
	{
	  PUT_SHORT (GSY_S_M_DEF);
	};
      /*
       *	Psect Number
       */
      if (Psect_Number <= 255)
	{
	  PUT_CHAR (Psect_Number);
	}
      else
	{
	  PUT_SHORT (Psect_Number);
	}
      /*
       *	Offset
       */
      PUT_LONG (Psect_Offset);
    }
  else
    {
      /*
       *	Reference:
       *	Flags = "RELOCATABLE" for regular symbol,
       *	      = "" for globalvalue (Defined & 2 == 1)
       */
      if ((Defined & 2) == 0)
	{
	  PUT_SHORT (GSY_S_M_REL);
	}
      else
	{
	  PUT_SHORT (0);
	};
    }
  /*
   *	Finally, the global symbol name
   */
  VMS_Case_Hack_Symbol (Name, Local);
  PUT_COUNTED_STRING (Local);
  /*
   *	Flush the buffer if it is more than 75% full
   */
  if (Object_Record_Offset >
      (sizeof (Object_Record_Buffer) * 3 / 4))
    Flush_VMS_Object_Record_Buffer ();
}


/*
 *	Define a psect
 */
static int
VMS_Psect_Spec (Name, Size, Type, vsp)
     char *Name;
     int Size;
     char *Type;
     struct VMS_Symbol *vsp;
{
  char Local[32];
  int Psect_Attributes;

  /*
   *	Generate the appropriate PSECT flags given the PSECT type
   */
  if (strcmp (Type, "COMMON") == 0)
    {
      /*
       *	Common block psects are:  PIC,OVR,REL,GBL,SHR,RD,WRT
       */
      Psect_Attributes = (GPS_S_M_PIC | GPS_S_M_OVR | GPS_S_M_REL | GPS_S_M_GBL |
			  GPS_S_M_SHR | GPS_S_M_RD | GPS_S_M_WRT);
    }
  else if (strcmp (Type, "CONST") == 0)
    {
      /*
       *	Common block psects are:  PIC,OVR,REL,GBL,SHR,RD
       */
      Psect_Attributes = (GPS_S_M_PIC | GPS_S_M_OVR | GPS_S_M_REL | GPS_S_M_GBL |
			  GPS_S_M_SHR | GPS_S_M_RD);
    }
  else if (strcmp (Type, "DATA") == 0)
    {
      /*
       *	The Data psects are PIC,REL,RD,WRT
       */
      Psect_Attributes =
	(GPS_S_M_PIC | GPS_S_M_REL | GPS_S_M_RD | GPS_S_M_WRT);
    }
  else if (strcmp (Type, "TEXT") == 0)
    {
      /*
       *	The Text psects are PIC,REL,SHR,EXE,RD
       */
      Psect_Attributes =
	(GPS_S_M_PIC | GPS_S_M_REL | GPS_S_M_SHR |
	 GPS_S_M_EXE | GPS_S_M_RD);
    }
  else
    {
      /*
       *	Error: Unknown psect type
       */
      error ("Unknown VMS psect type");
    }
  /*
   *	Modify the psect attributes according to any attribute string
   */
  if (HAS_PSECT_ATTRIBUTES (Name))
    VMS_Modify_Psect_Attributes (Name, &Psect_Attributes);
  /*
   *	Check for globalref/def/val.
   */
  if ((Psect_Attributes & GLOBALVALUE_BIT) != 0)
    {
      /*
       * globalvalue symbols were generated before. This code
       * prevents unsightly psect buildup, and makes sure that
       * fixup references are emitted correctly.
       */
      vsp->Psect_Index = -1;	/* to catch errors */
      S_GET_RAW_TYPE (vsp->Symbol) = N_UNDF;	/* make refs work */
      return 1;			/* decrement psect counter */
    };

  if ((Psect_Attributes & GLOBALSYMBOL_BIT) != 0)
    {
      switch (S_GET_RAW_TYPE (vsp->Symbol))
	{
	case N_UNDF | N_EXT:
	  VMS_Global_Symbol_Spec (Name, vsp->Psect_Index,
				  vsp->Psect_Offset, 0);
	  vsp->Psect_Index = -1;
	  S_GET_RAW_TYPE (vsp->Symbol) = N_UNDF;
	  return 1;		/* return and indicate no psect */
	case N_DATA | N_EXT:
	  VMS_Global_Symbol_Spec (Name, vsp->Psect_Index,
				  vsp->Psect_Offset, 1);
	  /* In this case we still generate the psect */
	  break;
	default:
	  {
	    char Error_Line[256];
	    sprintf (Error_Line, "Globalsymbol attribute for"
		     " symbol %s was unexpected.\n", Name);
	    error (Error_Line);
	    break;
	  };
	};			/* switch */
    };

  Psect_Attributes &= 0xffff;	/* clear out the globalref/def stuff */
  /*
   *	We are writing a GSD record
   */
  Set_VMS_Object_File_Record (OBJ_S_C_GSD);
  /*
   *	If the buffer is empty we must insert the GSD record type
   */
  if (Object_Record_Offset == 0)
    PUT_CHAR (OBJ_S_C_GSD);
  /*
   *	We are writing a PSECT definition subrecord
   */
  PUT_CHAR (GSD_S_C_PSC);
  /*
   *	Psects are always LONGWORD aligned
   */
  PUT_CHAR (2);
  /*
   *	Specify the psect attributes
   */
  PUT_SHORT (Psect_Attributes);
  /*
   *	Specify the allocation
   */
  PUT_LONG (Size);
  /*
   *	Finally, the psect name
   */
  VMS_Case_Hack_Symbol (Name, Local);
  PUT_COUNTED_STRING (Local);
  /*
   *	Flush the buffer if it is more than 75% full
   */
  if (Object_Record_Offset >
      (sizeof (Object_Record_Buffer) * 3 / 4))
    Flush_VMS_Object_Record_Buffer ();
  return 0;
}


/*
 *	Given the pointer to a symbol we calculate how big the data at the
 *	symbol is.  We do this by looking for the next symbol (local or
 *	global) which will indicate the start of another datum.
 */
static int
VMS_Initialized_Data_Size (sp, End_Of_Data)
     register struct symbol *sp;
     int End_Of_Data;
{
  register struct symbol *sp1, *Next_Symbol;

  /*
   *	Find the next symbol
   *	it delimits this datum
   */
  Next_Symbol = 0;
  for (sp1 = symbol_rootP; sp1; sp1 = symbol_next (sp1))
    {
      /*
       *	The data type must match
       */
      if (S_GET_TYPE (sp1) != N_DATA)
	continue;
      /*
       *	The symbol must be AFTER this symbol
       */
      if (S_GET_VALUE (sp1) <= S_GET_VALUE (sp))
	continue;
      /*
       *	We ignore THIS symbol
       */
      if (sp1 == sp)
	continue;
      /*
       *	If there is already a candidate selected for the
       *	next symbol, see if we are a better candidate
       */
      if (Next_Symbol)
	{
	  /*
	   *	We are a better candidate if we are "closer"
	   *	to the symbol
	   */
	  if (S_GET_VALUE (sp1) >
	      S_GET_VALUE (Next_Symbol))
	    continue;
	  /*
	   *	Win:  Make this the candidate
	   */
	  Next_Symbol = sp1;
	}
      else
	{
	  /*
	   *	This is the 1st candidate
	   */
	  Next_Symbol = sp1;
	}
    }
  /*
   *	Calculate its size
   */
  return (Next_Symbol ?
	  (S_GET_VALUE (Next_Symbol) -
	   S_GET_VALUE (sp)) :
	  (End_Of_Data - S_GET_VALUE (sp)));
}

/*
 *	Check symbol names for the Psect hack with a globalvalue, and then
 *	generate globalvalues for those that have it.
 */
static
VMS_Emit_Globalvalues (text_siz, data_siz, Data_Segment)
     unsigned text_siz;
     unsigned data_siz;
     char *Data_Segment;
{
  register symbolS *sp;
  char *stripped_name, *Name;
  int Size;
  int Psect_Attributes;
  int globalvalue;

  /*
   * Scan the symbol table for globalvalues, and emit def/ref when
   * required.  These will be caught again later and converted to
   * N_UNDF
   */
  for (sp = symbol_rootP; sp; sp = sp->sy_next)
    {
      /*
       *	See if this is something we want to look at.
       */
      if ((S_GET_RAW_TYPE (sp) != (N_DATA | N_EXT)) &&
	  (S_GET_RAW_TYPE (sp) != (N_UNDF | N_EXT)))
	continue;
      /*
       *	See if this has globalvalue specification.
       */
      Name = S_GET_NAME (sp);

      if (!HAS_PSECT_ATTRIBUTES (Name))
	continue;

      stripped_name = (char *) malloc (strlen (Name) + 1);
      strcpy (stripped_name, Name);
      Psect_Attributes = 0;
      VMS_Modify_Psect_Attributes (stripped_name, &Psect_Attributes);

      if ((Psect_Attributes & GLOBALVALUE_BIT) != 0)
	{
	  switch (S_GET_RAW_TYPE (sp))
	    {
	    case N_UNDF | N_EXT:
	      VMS_Global_Symbol_Spec (stripped_name, 0, 0, 2);
	      break;
	    case N_DATA | N_EXT:
	      Size = VMS_Initialized_Data_Size (sp, text_siz + data_siz);
	      if (Size > 4)
		error ("Invalid data type for globalvalue");
	      globalvalue = 0;

	      memcpy (&globalvalue, Data_Segment + S_GET_VALUE (sp) -
		     text_siz, Size);
	      /* Three times for good luck.  The linker seems to get confused
	         if there are fewer than three */
	      VMS_Global_Symbol_Spec (stripped_name, 0, 0, 2);
	      VMS_Global_Symbol_Spec (stripped_name, 0, globalvalue, 3);
	      VMS_Global_Symbol_Spec (stripped_name, 0, globalvalue, 3);
	      break;
	    default:
	      printf (" Invalid globalvalue of %s\n", stripped_name);
	      break;
	    };			/* switch */
	};			/* if */
      free (stripped_name);	/* clean up */
    };				/* for */

}


/*
 *	Define a procedure entry pt/mask
 */
static
VMS_Procedure_Entry_Pt (Name, Psect_Number, Psect_Offset, Entry_Mask)
     char *Name;
     int Psect_Number;
     int Psect_Offset;
     int Entry_Mask;
{
  char Local[32];

  /*
   *	We are writing a GSD record
   */
  Set_VMS_Object_File_Record (OBJ_S_C_GSD);
  /*
   *	If the buffer is empty we must insert the GSD record type
   */
  if (Object_Record_Offset == 0)
    PUT_CHAR (OBJ_S_C_GSD);
  /*
   *	We are writing a Procedure Entry Pt/Mask subrecord
   */
  if (Psect_Number <= 255)
    {
      PUT_CHAR (GSD_S_C_EPM);
    }
  else
    {
      PUT_CHAR (GSD_S_C_EPMW);
    }
  /*
   *	Data type is undefined
   */
  PUT_CHAR (0);
  /*
   *	Flags = "RELOCATABLE" and "DEFINED"
   */
  PUT_SHORT (GSY_S_M_DEF | GSY_S_M_REL);
  /*
   *	Psect Number
   */
  if (Psect_Number <= 255)
    {
      PUT_CHAR (Psect_Number);
    }
  else
    {
      PUT_SHORT (Psect_Number);
    }
  /*
   *	Offset
   */
  PUT_LONG (Psect_Offset);
  /*
   *	Entry mask
   */
  PUT_SHORT (Entry_Mask);
  /*
   *	Finally, the global symbol name
   */
  VMS_Case_Hack_Symbol (Name, Local);
  PUT_COUNTED_STRING (Local);
  /*
   *	Flush the buffer if it is more than 75% full
   */
  if (Object_Record_Offset >
      (sizeof (Object_Record_Buffer) * 3 / 4))
    Flush_VMS_Object_Record_Buffer ();
}


/*
 *	Set the current location counter to a particular Psect and Offset
 */
static
VMS_Set_Psect (Psect_Index, Offset, Record_Type)
     int Psect_Index;
     int Offset;
     int Record_Type;
{
  /*
   *	We are writing a "Record_Type" record
   */
  Set_VMS_Object_File_Record (Record_Type);
  /*
   *	If the buffer is empty we must insert the record type
   */
  if (Object_Record_Offset == 0)
    PUT_CHAR (Record_Type);
  /*
   *	Stack the Psect base + Longword Offset
   */
  if (Psect_Index < 255)
    {
      PUT_CHAR (TIR_S_C_STA_PL);
      PUT_CHAR (Psect_Index);
    }
  else
    {
      PUT_CHAR (TIR_S_C_STA_WPL);
      PUT_SHORT (Psect_Index);
    }
  PUT_LONG (Offset);
  /*
   *	Set relocation base
   */
  PUT_CHAR (TIR_S_C_CTL_SETRB);
  /*
   *	Flush the buffer if it is more than 75% full
   */
  if (Object_Record_Offset >
      (sizeof (Object_Record_Buffer) * 3 / 4))
    Flush_VMS_Object_Record_Buffer ();
}


/*
 *	Store repeated immediate data in current Psect
 */
static
VMS_Store_Repeated_Data (Repeat_Count, Pointer, Size, Record_Type)
     int Repeat_Count;
     register char *Pointer;
     int Size;
     int Record_Type;
{

  /*
   *	Ignore zero bytes/words/longwords
   */
  if ((Size == sizeof (char)) && (*Pointer == 0))
    return;
  if ((Size == sizeof (short)) && (*(short *) Pointer == 0))
    return;
  if ((Size == sizeof (long)) && (*(long *) Pointer == 0))
    return;
  /*
   *	If the data is too big for a TIR_S_C_STO_RIVB sub-record
   *	then we do it manually
   */
  if (Size > 255)
    {
      while (--Repeat_Count >= 0)
	VMS_Store_Immediate_Data (Pointer, Size, Record_Type);
      return;
    }
  /*
   *	We are writing a "Record_Type" record
   */
  Set_VMS_Object_File_Record (Record_Type);
  /*
   *	If the buffer is empty we must insert record type
   */
  if (Object_Record_Offset == 0)
    PUT_CHAR (Record_Type);
  /*
   *	Stack the repeat count
   */
  PUT_CHAR (TIR_S_C_STA_LW);
  PUT_LONG (Repeat_Count);
  /*
   *	And now the command and its data
   */
  PUT_CHAR (TIR_S_C_STO_RIVB);
  PUT_CHAR (Size);
  while (--Size >= 0)
    PUT_CHAR (*Pointer++);
  /*
   *	Flush the buffer if it is more than 75% full
   */
  if (Object_Record_Offset >
      (sizeof (Object_Record_Buffer) * 3 / 4))
    Flush_VMS_Object_Record_Buffer ();
}


/*
 *	Store a Position Independent Reference
 */
static
VMS_Store_PIC_Symbol_Reference (Symbol, Offset, PC_Relative,
				Psect, Psect_Offset, Record_Type)
     struct symbol *Symbol;
     int Offset;
     int PC_Relative;
     int Psect;
     int Psect_Offset;
     int Record_Type;
{
  register struct VMS_Symbol *vsp =
  (struct VMS_Symbol *) (Symbol->sy_number);
  char Local[32];

  /*
   *	We are writing a "Record_Type" record
   */
  Set_VMS_Object_File_Record (Record_Type);
  /*
   *	If the buffer is empty we must insert record type
   */
  if (Object_Record_Offset == 0)
    PUT_CHAR (Record_Type);
  /*
   *	Set to the appropriate offset in the Psect
   */
  if (PC_Relative)
    {
      /*
       *	For a Code reference we need to fix the operand
       *	specifier as well (so back up 1 byte)
       */
      VMS_Set_Psect (Psect, Psect_Offset - 1, Record_Type);
    }
  else
    {
      /*
       *	For a Data reference we just store HERE
       */
      VMS_Set_Psect (Psect, Psect_Offset, Record_Type);
    }
  /*
   *	Make sure we are still generating a "Record Type" record
   */
  if (Object_Record_Offset == 0)
    PUT_CHAR (Record_Type);
  /*
   *	Dispatch on symbol type (so we can stack its value)
   */
  switch (S_GET_RAW_TYPE (Symbol))
    {
      /*
       *	Global symbol
       */
#ifdef	NOT_VAX_11_C_COMPATIBLE
    case N_UNDF | N_EXT:
    case N_DATA | N_EXT:
#endif	/* NOT_VAX_11_C_COMPATIBLE */
    case N_UNDF:
    case N_TEXT | N_EXT:
      /*
       *	Get the symbol name (case hacked)
       */
      VMS_Case_Hack_Symbol (S_GET_NAME (Symbol), Local);
      /*
       *	Stack the global symbol value
       */
      PUT_CHAR (TIR_S_C_STA_GBL);
      PUT_COUNTED_STRING (Local);
      if (Offset)
	{
	  /*
	   *	Stack the longword offset
	   */
	  PUT_CHAR (TIR_S_C_STA_LW);
	  PUT_LONG (Offset);
	  /*
	   *	Add the two, leaving the result on the stack
	   */
	  PUT_CHAR (TIR_S_C_OPR_ADD);
	}
      break;
      /*
       *	Uninitialized local data
       */
    case N_BSS:
      /*
       *	Stack the Psect (+offset)
       */
      if (vsp->Psect_Index < 255)
	{
	  PUT_CHAR (TIR_S_C_STA_PL);
	  PUT_CHAR (vsp->Psect_Index);
	}
      else
	{
	  PUT_CHAR (TIR_S_C_STA_WPL);
	  PUT_SHORT (vsp->Psect_Index);
	}
      PUT_LONG (vsp->Psect_Offset + Offset);
      break;
      /*
       *	Local text
       */
    case N_TEXT:
      /*
       *	Stack the Psect (+offset)
       */
      if (vsp->Psect_Index < 255)
	{
	  PUT_CHAR (TIR_S_C_STA_PL);
	  PUT_CHAR (vsp->Psect_Index);
	}
      else
	{
	  PUT_CHAR (TIR_S_C_STA_WPL);
	  PUT_SHORT (vsp->Psect_Index);
	}
      PUT_LONG (S_GET_VALUE (Symbol) + Offset);
      break;
      /*
       *	Initialized local or global data
       */
    case N_DATA:
#ifndef	NOT_VAX_11_C_COMPATIBLE
    case N_UNDF | N_EXT:
    case N_DATA | N_EXT:
#endif	/* NOT_VAX_11_C_COMPATIBLE */
      /*
       *	Stack the Psect (+offset)
       */
      if (vsp->Psect_Index < 255)
	{
	  PUT_CHAR (TIR_S_C_STA_PL);
	  PUT_CHAR (vsp->Psect_Index);
	}
      else
	{
	  PUT_CHAR (TIR_S_C_STA_WPL);
	  PUT_SHORT (vsp->Psect_Index);
	}
      PUT_LONG (vsp->Psect_Offset + Offset);
      break;
    }
  /*
   *	Store either a code or data reference
   */
  PUT_CHAR (PC_Relative ? TIR_S_C_STO_PICR : TIR_S_C_STO_PIDR);
  /*
   *	Flush the buffer if it is more than 75% full
   */
  if (Object_Record_Offset >
      (sizeof (Object_Record_Buffer) * 3 / 4))
    Flush_VMS_Object_Record_Buffer ();
}


/*
 *	Check in the text area for an indirect pc-relative reference
 *	and fix it up with addressing mode 0xff [PC indirect]
 *
 *	THIS SHOULD BE REPLACED BY THE USE OF TIR_S_C_STO_PIRR IN THE
 *	PIC CODE GENERATING FIXUP ROUTINE.
 */
static
VMS_Fix_Indirect_Reference (Text_Psect, Offset, fragP, text_frag_root)
     int Text_Psect;
     int Offset;
     register fragS *fragP;
     struct frag *text_frag_root;
{
  /*
   *	The addressing mode byte is 1 byte before the address
   */
  Offset--;
  /*
   *	Is it in THIS frag??
   */
  if ((Offset < fragP->fr_address) ||
      (Offset >= (fragP->fr_address + fragP->fr_fix)))
    {
      /*
       *	We need to search for the fragment containing this
       *	Offset
       */
      for (fragP = text_frag_root; fragP; fragP = fragP->fr_next)
	{
	  if ((Offset >= fragP->fr_address) &&
	      (Offset < (fragP->fr_address + fragP->fr_fix)))
	    break;
	}
      /*
       *	If we couldn't find the frag, things are BAD!!
       */
      if (fragP == 0)
	error ("Couldn't find fixup fragment when checking for indirect reference");
    }
  /*
   *	Check for indirect PC relative addressing mode
   */
  if (fragP->fr_literal[Offset - fragP->fr_address] == (char) 0xff)
    {
      static char Address_Mode = 0xff;

      /*
       *	Yes: Store the indirect mode back into the image
       *	     to fix up the damage done by STO_PICR
       */
      VMS_Set_Psect (Text_Psect, Offset, OBJ_S_C_TIR);
      VMS_Store_Immediate_Data (&Address_Mode, 1, OBJ_S_C_TIR);
    }
}



/*
 *	This is a hacked _doprnt() for VAX-11 "C".  It understands that
 *	it is ONLY called by as_fatal(Format, Args) with a pointer to the
 *	"Args" argument.  From this we can make it all work right!
 */
#if	!defined(eunice) && defined(HO_VMS)
_doprnt (Format, a, f)
     char *Format;
     FILE *f;
     char **a;
{
  int Nargs = ((int *) a)[-2];	/* This understands as_fatal() */

  switch (Nargs)
    {
    default:
      fprintf (f, "_doprnt error on \"%s\"!!", Format);
      break;
    case 1:
      fprintf (f, Format);
      break;
    case 2:
      fprintf (f, Format, a[0]);
      break;
    case 3:
      fprintf (f, Format, a[0], a[1]);
      break;
    case 4:
      fprintf (f, Format, a[0], a[1], a[2]);
      break;
    case 5:
      fprintf (f, Format, a[0], a[1], a[2], a[3]);
      break;
    case 6:
      fprintf (f, Format, a[0], a[1], a[2], a[3], a[4]);
      break;
    case 7:
      fprintf (f, Format, a[0], a[1], a[2], a[3], a[4], a[5]);
      break;
    case 8:
      fprintf (f, Format, a[0], a[1], a[2], a[3], a[4], a[5], a[6]);
      break;
    case 9:
      fprintf (f, Format, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7]);
      break;
    case 10:
      fprintf (f, Format, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]);
      break;
    }
}

#endif /* eunice */


/*
 *	If the procedure "main()" exists we have to add the instruction
 *	"jsb c$main_args" at the beginning to be compatible with VAX-11 "C".
 */
VMS_Check_For_Main ()
{
  register symbolS *symbolP;
#ifdef	HACK_DEC_C_STARTUP	/* JF */
  register struct frchain *frchainP;
  register fragS *fragP;
  register fragS **prev_fragPP;
  register struct fix *fixP;
  register fragS *New_Frag;
  int i;
#endif	/* HACK_DEC_C_STARTUP */

  symbolP = (struct symbol *) symbol_find ("_main");
  if (symbolP && !S_IS_DEBUG (symbolP) &&
      S_IS_EXTERNAL (symbolP) && (S_GET_TYPE (symbolP) == N_TEXT))
    {
#ifdef	HACK_DEC_C_STARTUP
      if (!flagseen['+'])
	{
#endif
	  /*
	   *	Remember the entry point symbol
	   */
	  Entry_Point_Symbol = symbolP;
#ifdef HACK_DEC_C_STARTUP
	}
      else
	{
	  /*
	   *	Scan all the fragment chains for the one with "_main"
	   *	(Actually we know the fragment from the symbol, but we need
	   *	 the previous fragment so we can change its pointer)
	   */
	  frchainP = frchain_root;
	  while (frchainP)
	    {
	      /*
	       *	Scan all the fragments in this chain, remembering
	       *	the "previous fragment"
	       */
	      prev_fragPP = &frchainP->frch_root;
	      fragP = frchainP->frch_root;
	      while (fragP && (fragP != frchainP->frch_last))
		{
		  /*
		   *	Is this the fragment?
		   */
		  if (fragP == symbolP->sy_frag)
		    {
		      /*
		       *	Yes: Modify the fragment by replacing
		       *	     it with a new fragment.
		       */
		      New_Frag = (fragS *)
			xmalloc (sizeof (*New_Frag) +
				 fragP->fr_fix +
				 fragP->fr_var +
				 5);
		      /*
		       *	The fragments are the same except
		       *	that the "fixed" area is larger
		       */
		      *New_Frag = *fragP;
		      New_Frag->fr_fix += 6;
		      /*
		       *	Copy the literal data opening a hole
		       *	2 bytes after "_main" (i.e. just after
		       *	the entry mask).  Into which we place
		       *	the JSB instruction.
		       */
		      New_Frag->fr_literal[0] = fragP->fr_literal[0];
		      New_Frag->fr_literal[1] = fragP->fr_literal[1];
		      New_Frag->fr_literal[2] = 0x16;	/* Jsb */
		      New_Frag->fr_literal[3] = 0xef;
		      New_Frag->fr_literal[4] = 0;
		      New_Frag->fr_literal[5] = 0;
		      New_Frag->fr_literal[6] = 0;
		      New_Frag->fr_literal[7] = 0;
		      for (i = 2; i < fragP->fr_fix + fragP->fr_var; i++)
			New_Frag->fr_literal[i + 6] =
			  fragP->fr_literal[i];
		      /*
		       *	Now replace the old fragment with the
		       *	newly generated one.
		       */
		      *prev_fragPP = New_Frag;
		      /*
		       *	Remember the entry point symbol
		       */
		      Entry_Point_Symbol = symbolP;
		      /*
		       *	Scan the text area fixup structures
		       *	as offsets in the fragment may have
		       *	changed
		       */
		      for (fixP = text_fix_root; fixP; fixP = fixP->fx_next)
			{
			  /*
			   *	Look for references to this
			   *	fragment.
			   */
			  if (fixP->fx_frag == fragP)
			    {
			      /*
			       *	Change the fragment
			       *	pointer
			       */
			      fixP->fx_frag = New_Frag;
			      /*
			       *	If the offset is after
			       *	the entry mask we need
			       *	to account for the JSB
			       *	instruction we just
			       *	inserted.
			       */
			      if (fixP->fx_where >= 2)
				fixP->fx_where += 6;
			    }
			}
		      /*
		       *	Scan the symbols as offsets in the
		       *	fragment may have changed
		       */
		      for (symbolP = symbol_rootP;
			   symbolP;
			   symbolP = symbol_next (symbolP))
			{
			  /*
			   *	Look for references to this
			   *	fragment.
			   */
			  if (symbolP->sy_frag == fragP)
			    {
			      /*
			       *	Change the fragment
			       *	pointer
			       */
			      symbolP->sy_frag = New_Frag;
			      /*
			       *	If the offset is after
			       *	the entry mask we need
			       *	to account for the JSB
			       *	instruction we just
			       *	inserted.
			       */
			      if (S_GET_VALUE (symbolP) >= 2)
				S_GET_VALUE (symbolP) += 6;
			    }
			}
		      /*
		       *	Make a symbol reference to
		       *	"_c$main_args" so we can get
		       *	its address inserted into the
		       *	JSB instruction.
		       */
		      symbolP = (symbolS *) xmalloc (sizeof (*symbolP));
		      S_GET_NAME (symbolP) = "_c$main_args";
		      S_SET_TYPE (symbolP, N_UNDF);
		      S_GET_OTHER (symbolP) = 0;
		      S_GET_DESC (symbolP) = 0;
		      S_GET_VALUE (symbolP) = 0;
		      symbolP->sy_name_offset = 0;
		      symbolP->sy_number = 0;
		      symbolP->sy_frag = New_Frag;
		      symbolP->sy_forward = 0;
		      /* this actually inserts at the beginning of the list */
		      symbol_append (symbol_rootP, symbolP, &symbol_rootP, &symbol_lastP);

		      symbol_rootP = symbolP;
		      /*
		       *	Generate a text fixup structure
		       *	to get "_c$main_args" stored into the
		       *	JSB instruction.
		       */
		      fixP = (struct fix *) xmalloc (sizeof (*fixP));
		      fixP->fx_frag = New_Frag;
		      fixP->fx_where = 4;
		      fixP->fx_addsy = symbolP;
		      fixP->fx_subsy = 0;
		      fixP->fx_offset = 0;
		      fixP->fx_size = sizeof (long);
		      fixP->fx_pcrel = 1;
		      fixP->fx_next = text_fix_root;
		      text_fix_root = fixP;
		      /*
		       *	Now make sure we exit from the loop
		       */
		      frchainP = 0;
		      break;
		    }
		  /*
		   *	Try the next fragment
		   */
		  prev_fragPP = &fragP->fr_next;
		  fragP = fragP->fr_next;
		}
	      /*
	       *	Try the next fragment chain
	       */
	      if (frchainP)
		frchainP = frchainP->frch_next;
	    }
	}
#endif /* HACK_DEC_C_STARTUP */
    }
}

/*
 *	Write a VAX/VMS object file (everything else has been done!)
 */
VMS_write_object_file (text_siz, data_siz, text_frag_root, data_frag_root)
     unsigned text_siz;
     unsigned data_siz;
     struct frag *text_frag_root;
     struct frag *data_frag_root;
{
  register fragS *fragP;
  register symbolS *symbolP;
  register symbolS *sp;
  register struct fix *fixP;
  register struct VMS_Symbol *vsp;
  char *Data_Segment;
  int Local_Initialized_Data_Size = 0;
  int Globalref;
  int Psect_Number = 0;		/* Psect Index Number */
  int Text_Psect = -1;		/* Text Psect Index   */
  int Data_Psect = -2;		/* Data Psect Index   JF: Was -1 */
  int Bss_Psect = -3;		/* Bss Psect Index    JF: Was -1 */

  /*
   *	Create the VMS object file
   */
  Create_VMS_Object_File ();
  /*
   *	Write the module header records
   */
  Write_VMS_MHD_Records ();

  /*
   *	Store the Data segment:
   *
   *	Since this is REALLY hard to do any other way,
   *	we actually manufacture the data segment and
   *	the store the appropriate values out of it.
   *	We need to generate this early, so that globalvalues
   *	can be properly emitted.
   */
  if (data_siz > 0)
    {
      /*
       *	Allocate the data segment
       */
      Data_Segment = (char *) xmalloc (data_siz);
      /*
       *	Run through the data fragments, filling in the segment
       */
      for (fragP = data_frag_root; fragP; fragP = fragP->fr_next)
	{
	  register long int count;
	  register char *fill_literal;
	  register long int fill_size;
	  int i;

	  i = fragP->fr_address - text_siz;
	  if (fragP->fr_fix)
	    memcpy (Data_Segment + i,
		    fragP->fr_literal,
		    fragP->fr_fix);
	  i += fragP->fr_fix;

	  fill_literal = fragP->fr_literal + fragP->fr_fix;
	  fill_size = fragP->fr_var;
	  for (count = fragP->fr_offset; count; count--)
	    {
	      if (fill_size)
		memcpy (Data_Segment + i, fill_literal, fill_size);
	      i += fill_size;
	    }
	}
    }


  /*
   *	Generate the VMS object file records
   *	1st GSD then TIR records
   */

  /*******       Global Symbol Dictionary       *******/
  /*
   * Emit globalvalues now.  We must do this before the text psect
   * is defined, or we will get linker warnings about multiply defined
   * symbols.  All of the globalvalues "reference" psect 0, although
   * it really does not have anything to do with it.
   */
  VMS_Emit_Globalvalues (text_siz, data_siz, Data_Segment);
  /*
   *	Define the Text Psect
   */
  Text_Psect = Psect_Number++;
  VMS_Psect_Spec ("$code", text_siz, "TEXT", 0);
  /*
   *	Define the BSS Psect
   */
  if (local_bss_counter > 0)
    {
      Bss_Psect = Psect_Number++;
      VMS_Psect_Spec ("$uninitialized_data", local_bss_counter, "DATA",
		      0);
    }
#ifndef gxx_bug_fixed
  /*
   * The g++ compiler does not write out external references to vtables
   * correctly.  Check for this and holler if we see it happening.
   * If that compiler bug is ever fixed we can remove this.
   */
  for (sp = symbol_rootP; sp; sp = symbol_next (sp))
    {
      /*
       *	Dispatch on symbol type
       */
      switch (S_GET_RAW_TYPE (sp)) {
	/*
	 *	Global Reference
	 */
      case N_UNDF:
	/*
	 *	Make a GSD global symbol reference
	 *	record.
	 */
	if (strncmp (S_GET_NAME (sp),"__vt.",5) == 0)
	  {
	    S_GET_RAW_TYPE (sp) = N_UNDF | N_EXT;
	    as_warn("g++ wrote an extern reference to %s as a routine.",
		    S_GET_NAME (sp));
	    as_warn("I will fix it, but I hope that it was not really a routine");
	  };
	break;
      default:
	break;
      }
    }
#endif /* gxx_bug_fixed */
  /*
   *	Now scan the symbols and emit the appropriate GSD records
   */
  for (sp = symbol_rootP; sp; sp = symbol_next (sp))
    {
      /*
       *	Dispatch on symbol type
       */
      switch (S_GET_RAW_TYPE (sp))
	{
	  /*
	   *	Global uninitialized data
	   */
	case N_UNDF | N_EXT:
	  /*
	   *	Make a VMS data symbol entry
	   */
	  vsp = (struct VMS_Symbol *)
	    xmalloc (sizeof (*vsp));
	  vsp->Symbol = sp;
	  vsp->Size = S_GET_VALUE (sp);
	  vsp->Psect_Index = Psect_Number++;
	  vsp->Psect_Offset = 0;
	  vsp->Next = VMS_Symbols;
	  VMS_Symbols = vsp;
	  sp->sy_number = (int) vsp;
	  /*
	   *	Make the psect for this data
	   */
	  if (S_GET_OTHER (sp))
	    Globalref = VMS_Psect_Spec (
					 S_GET_NAME (sp),
					 vsp->Size,
					 "CONST",
					 vsp);
	  else
	    Globalref = VMS_Psect_Spec (
					 S_GET_NAME (sp),
					 vsp->Size,
					 "COMMON",
					 vsp);
	  if (Globalref)
	    Psect_Number--;
#ifdef	NOT_VAX_11_C_COMPATIBLE
	  /*
	   *	Place a global symbol at the
	   *	beginning of the Psect
	   */
	  VMS_Global_Symbol_Spec (S_GET_NAME (sp),
				  vsp->Psect_Index,
				  0,
				  1);
#endif	/* NOT_VAX_11_C_COMPATIBLE */
	  break;
	  /*
	   *	Local uninitialized data
	   */
	case N_BSS:
	  /*
	   *	Make a VMS data symbol entry
	   */
	  vsp = (struct VMS_Symbol *)
	    xmalloc (sizeof (*vsp));
	  vsp->Symbol = sp;
	  vsp->Size = 0;
	  vsp->Psect_Index = Bss_Psect;
	  vsp->Psect_Offset =
	    S_GET_VALUE (sp) -
	    bss_address_frag.fr_address;
	  vsp->Next = VMS_Symbols;
	  VMS_Symbols = vsp;
	  sp->sy_number = (int) vsp;
	  break;
	  /*
	   *	Global initialized data
	   */
	case N_DATA | N_EXT:
	  /*
	   *	Make a VMS data symbol entry
	   */
	  vsp = (struct VMS_Symbol *)
	    xmalloc (sizeof (*vsp));
	  vsp->Symbol = sp;
	  vsp->Size = VMS_Initialized_Data_Size (sp,
						 text_siz + data_siz);
	  vsp->Psect_Index = Psect_Number++;
	  vsp->Psect_Offset = 0;
	  vsp->Next = VMS_Symbols;
	  VMS_Symbols = vsp;
	  sp->sy_number = (int) vsp;
	  /*
	   *	Make its psect
	   */
	  if (S_GET_OTHER (sp))
	    Globalref = VMS_Psect_Spec (
					 S_GET_NAME (sp),
					 vsp->Size,
					 "CONST",
					 vsp);
	  else
	    Globalref = VMS_Psect_Spec (
					 S_GET_NAME (sp),
					 vsp->Size,
					 "COMMON",
					 vsp);
	  if (Globalref)
	    Psect_Number--;
#ifdef	NOT_VAX_11_C_COMPATIBLE
	  /*
	   *	Place a global symbol at the
	   *	beginning of the Psect
	   */
	  VMS_Global_Symbol_Spec (S_GET_NAME (sp),
				  vsp->Psect_Index,
				  0,
				  1);
#endif	/* NOT_VAX_11_C_COMPATIBLE */
	  break;
	  /*
	   *	Local initialized data
	   */
	case N_DATA:
	  /*
	   *	Make a VMS data symbol entry
	   */
	  vsp = (struct VMS_Symbol *)
	    xmalloc (sizeof (*vsp));
	  vsp->Symbol = sp;
	  vsp->Size =
	    VMS_Initialized_Data_Size (sp,
				       text_siz + data_siz);
	  vsp->Psect_Index = Data_Psect;
	  vsp->Psect_Offset =
	    Local_Initialized_Data_Size;
	  Local_Initialized_Data_Size += vsp->Size;
	  vsp->Next = VMS_Symbols;
	  VMS_Symbols = vsp;
	  sp->sy_number = (int) vsp;
	  break;
	  /*
	   *	Global Text definition
	   */
	case N_TEXT | N_EXT:
	  {
	    unsigned short Entry_Mask;

	    /*
	     *	Get the entry mask
	     */
	    fragP = sp->sy_frag;
	    Entry_Mask = (fragP->fr_literal[0] & 0xff) +
	      ((fragP->fr_literal[1] & 0xff)
	       << 8);
	    /*
	     *	Define the Procedure entry pt.
	     */
	    VMS_Procedure_Entry_Pt (S_GET_NAME (sp),
				    Text_Psect,
				    S_GET_VALUE (sp),
				    Entry_Mask);
	    break;
	  }
	  /*
	   *	Local Text definition
	   */
	case N_TEXT:
	  /*
	   *	Make a VMS data symbol entry
	   */
	  if (Text_Psect != -1)
	    {
	      vsp = (struct VMS_Symbol *)
		xmalloc (sizeof (*vsp));
	      vsp->Symbol = sp;
	      vsp->Size = 0;
	      vsp->Psect_Index = Text_Psect;
	      vsp->Psect_Offset = S_GET_VALUE (sp);
	      vsp->Next = VMS_Symbols;
	      VMS_Symbols = vsp;
	      sp->sy_number = (int) vsp;
	    }
	  break;
	  /*
	   *	Global Reference
	   */
	case N_UNDF:
	  /*
	   *	Make a GSD global symbol reference
	   *	record.
	   */
	  VMS_Global_Symbol_Spec (S_GET_NAME (sp),
				  0,
				  0,
				  0);
	  break;
	  /*
	   *	Anything else
	   */
	default:
	  /*
	   *	Ignore STAB symbols
	   *	Including .stabs emitted by g++
	   */
	  if (S_IS_DEBUG (sp) || (S_GET_TYPE (sp) == 22))
	    break;
	  /*
	   *	Error
	   */
	  if (S_GET_TYPE (sp) != 22)
	    printf (" ERROR, unknown type (%d)\n",
		    S_GET_TYPE (sp));
	  break;
	}
    }
  /*
   *	Define the Data Psect
   */
  if ((data_siz > 0) && (Local_Initialized_Data_Size > 0))
    {
      /*
       *	Do it
       */
      Data_Psect = Psect_Number++;
      VMS_Psect_Spec ("$data",
		      Local_Initialized_Data_Size,
		      "DATA", 0);
      /*
       *	Scan the VMS symbols and fill in the data psect
       */
      for (vsp = VMS_Symbols; vsp; vsp = vsp->Next)
	{
	  /*
	   *	Only look for undefined psects
	   */
	  if (vsp->Psect_Index < 0)
	    {
	      /*
	       *	And only initialized data
	       */
	      if ((S_GET_TYPE (vsp->Symbol) == N_DATA) && !S_IS_EXTERNAL (vsp->Symbol))
		vsp->Psect_Index = Data_Psect;
	    }
	}
    }

  /*******  Text Information and Relocation Records  *******/
  /*
   *	Write the text segment data
   */
  if (text_siz > 0)
    {
      /*
       *	Scan the text fragments
       */
      for (fragP = text_frag_root; fragP; fragP = fragP->fr_next)
	{
	  /*
	   *	Stop if we get to the data fragments
	   */
	  if (fragP == data_frag_root)
	    break;
	  /*
	   *	Ignore fragments with no data
	   */
	  if ((fragP->fr_fix == 0) && (fragP->fr_var == 0))
	    continue;
	  /*
	   *	Go the the appropriate offset in the
	   *	Text Psect.
	   */
	  VMS_Set_Psect (Text_Psect, fragP->fr_address, OBJ_S_C_TIR);
	  /*
	   *	Store the "fixed" part
	   */
	  if (fragP->fr_fix)
	    VMS_Store_Immediate_Data (fragP->fr_literal,
				      fragP->fr_fix,
				      OBJ_S_C_TIR);
	  /*
	   *	Store the "variable" part
	   */
	  if (fragP->fr_var && fragP->fr_offset)
	    VMS_Store_Repeated_Data (fragP->fr_offset,
				     fragP->fr_literal +
				     fragP->fr_fix,
				     fragP->fr_var,
				     OBJ_S_C_TIR);
	}
      /*
       *	Now we go through the text segment fixups and
       *	generate TIR records to fix up addresses within
       *	the Text Psect
       */
      for (fixP = text_fix_root; fixP; fixP = fixP->fx_next)
	{
	  /*
	   *	We DO handle the case of "Symbol - Symbol" as
	   *	long as it is in the same segment.
	   */
	  if (fixP->fx_subsy && fixP->fx_addsy)
	    {
	      int i;

	      /*
	       *	They need to be in the same segment
	       */
	      if (S_GET_RAW_TYPE (fixP->fx_subsy) !=
		  S_GET_RAW_TYPE (fixP->fx_addsy))
		error ("Fixup data addsy and subsy didn't have the same type");
	      /*
	       *	And they need to be in one that we
	       *	can check the psect on
	       */
	      if ((S_GET_TYPE (fixP->fx_addsy) != N_DATA) &&
		  (S_GET_TYPE (fixP->fx_addsy) != N_TEXT))
		error ("Fixup data addsy and subsy didn't have an appropriate type");
	      /*
	       *	This had better not be PC relative!
	       */
	      if (fixP->fx_pcrel)
		error ("Fixup data was erroneously \"pcrel\"");
	      /*
	       *	Subtract their values to get the
	       *	difference.
	       */
	      i = S_GET_VALUE (fixP->fx_addsy) -
		S_GET_VALUE (fixP->fx_subsy);
	      /*
	       *	Now generate the fixup object records
	       *	Set the psect and store the data
	       */
	      VMS_Set_Psect (Text_Psect,
			     fixP->fx_where +
			     fixP->fx_frag->fr_address,
			     OBJ_S_C_TIR);
	      VMS_Store_Immediate_Data (&i,
					fixP->fx_size,
					OBJ_S_C_TIR);
	      /*
	       *	Done
	       */
	      continue;
	    }
	  /*
	   *	Size will HAVE to be "long"
	   */
	  if (fixP->fx_size != sizeof (long))
	    error ("Fixup datum was not a longword");
	  /*
	   *	Symbol must be "added" (if it is ever
	   *				subtracted we can
	   *				fix this assumption)
	   */
	  if (fixP->fx_addsy == 0)
	    error ("Fixup datum was not \"fixP->fx_addsy\"");
	  /*
	   *	Store the symbol value in a PIC fashion
	   */
	  VMS_Store_PIC_Symbol_Reference (fixP->fx_addsy,
					  fixP->fx_offset,
					  fixP->fx_pcrel,
					  Text_Psect,
					  fixP->fx_where +
					  fixP->fx_frag->fr_address,
					  OBJ_S_C_TIR);
	  /*
	   *	Check for indirect address reference,
	   *	which has to be fixed up (as the linker
	   *	will screw it up with TIR_S_C_STO_PICR).
	   */
	  if (fixP->fx_pcrel)
	    VMS_Fix_Indirect_Reference (Text_Psect,
					fixP->fx_where +
					fixP->fx_frag->fr_address,
					fixP->fx_frag,
					text_frag_root);
	}
    }
  /*
   *	Store the Data segment:
   *
   *	Since this is REALLY hard to do any other way,
   *	we actually manufacture the data segment and
   *	the store the appropriate values out of it.
   *	The segment was manufactured before, now we just
   *	dump it into the appropriate psects.
   */
  if (data_siz > 0)
    {

      /*
       *	Now we can run through all the data symbols
       *	and store the data
       */
      for (vsp = VMS_Symbols; vsp; vsp = vsp->Next)
	{
	  /*
	   *	Ignore anything other than data symbols
	   */
	  if (S_GET_TYPE (vsp->Symbol) != N_DATA)
	    continue;
	  /*
	   *	Set the Psect + Offset
	   */
	  VMS_Set_Psect (vsp->Psect_Index,
			 vsp->Psect_Offset,
			 OBJ_S_C_TIR);
	  /*
	   *	Store the data
	   */
	  VMS_Store_Immediate_Data (Data_Segment +
				    S_GET_VALUE (vsp->Symbol) -
				    text_siz,
				    vsp->Size,
				    OBJ_S_C_TIR);
	}
      /*
       *	Now we go through the data segment fixups and
       *	generate TIR records to fix up addresses within
       *	the Data Psects
       */
      for (fixP = data_fix_root; fixP; fixP = fixP->fx_next)
	{
	  /*
	   *	Find the symbol for the containing datum
	   */
	  for (vsp = VMS_Symbols; vsp; vsp = vsp->Next)
	    {
	      /*
	       *	Only bother with Data symbols
	       */
	      sp = vsp->Symbol;
	      if (S_GET_TYPE (sp) != N_DATA)
		continue;
	      /*
	       *	Ignore symbol if After fixup
	       */
	      if (S_GET_VALUE (sp) >
		  (fixP->fx_where +
		   fixP->fx_frag->fr_address))
		continue;
	      /*
	       *	See if the datum is here
	       */
	      if ((S_GET_VALUE (sp) + vsp->Size) <=
		  (fixP->fx_where +
		   fixP->fx_frag->fr_address))
		continue;
	      /*
	       *	We DO handle the case of "Symbol - Symbol" as
	       *	long as it is in the same segment.
	       */
	      if (fixP->fx_subsy && fixP->fx_addsy)
		{
		  int i;

		  /*
		   *	They need to be in the same segment
		   */
		  if (S_GET_RAW_TYPE (fixP->fx_subsy) !=
		      S_GET_RAW_TYPE (fixP->fx_addsy))
		    error ("Fixup data addsy and subsy didn't have the same type");
		  /*
		   *	And they need to be in one that we
		   *	can check the psect on
		   */
		  if ((S_GET_TYPE (fixP->fx_addsy) != N_DATA) &&
		      (S_GET_TYPE (fixP->fx_addsy) != N_TEXT))
		    error ("Fixup data addsy and subsy didn't have an appropriate type");
		  /*
		   *	This had better not be PC relative!
		   */
		  if (fixP->fx_pcrel)
		    error ("Fixup data was erroneously \"pcrel\"");
		  /*
		   *	Subtract their values to get the
		   *	difference.
		   */
		  i = S_GET_VALUE (fixP->fx_addsy) -
		    S_GET_VALUE (fixP->fx_subsy);
		  /*
		   *	Now generate the fixup object records
		   *	Set the psect and store the data
		   */
		  VMS_Set_Psect (vsp->Psect_Index,
				 fixP->fx_frag->fr_address +
				 fixP->fx_where -
				 S_GET_VALUE (vsp->Symbol) +
				 vsp->Psect_Offset,
				 OBJ_S_C_TIR);
		  VMS_Store_Immediate_Data (&i,
					    fixP->fx_size,
					    OBJ_S_C_TIR);
		  /*
		   *	Done
		   */
		  break;
		}
	      /*
	       *	Size will HAVE to be "long"
	       */
	      if (fixP->fx_size != sizeof (long))
		error ("Fixup datum was not a longword");
	      /*
	       *	Symbol must be "added" (if it is ever
	       *				subtracted we can
	       *				fix this assumption)
	       */
	      if (fixP->fx_addsy == 0)
		error ("Fixup datum was not \"fixP->fx_addsy\"");
	      /*
	       *	Store the symbol value in a PIC fashion
	       */
	      VMS_Store_PIC_Symbol_Reference (
					       fixP->fx_addsy,
					       fixP->fx_offset,
					       fixP->fx_pcrel,
					       vsp->Psect_Index,
					       fixP->fx_frag->fr_address +
					       fixP->fx_where -
					       S_GET_VALUE (vsp->Symbol) +
					       vsp->Psect_Offset,
					       OBJ_S_C_TIR);
	      /*
	       *	Done
	       */
	      break;
	    }

	}
    }

  /*
   *	Write the Traceback Begin Module record
   */
  VMS_TBT_Module_Begin ();
  /*
   *	Scan the symbols and write out the routines
   *	(this makes the assumption that symbols are in
   *	 order of ascending text segment offset)
   */
  {
    struct symbol *Current_Routine = 0;
    int Current_Line_Number = 0;
    int Current_Offset = -1;
    struct input_file *Current_File;

/* Output debugging info for global variables and static variables that are not
 * specific to one routine. We also need to examine all stabs directives, to
 * find the definitions to all of the advanced data types, and this is done by
 * VMS_LSYM_Parse.  This needs to be done before any definitions are output to
 * the object file, since there can be forward references in the stabs
 * directives. When through with parsing, the text of the stabs directive
 * is altered, with the definitions removed, so that later passes will see
 * directives as they would be written if the type were already defined.
 *
 * We also look for files and include files, and make a list of them.  We
 * examine the source file numbers to establish the actual lines that code was
 * generated from, and then generate offsets.
 */
    VMS_LSYM_Parse ();
    for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next (symbolP))
      {
	/*
	 *	Deal with STAB symbols
	 */
	if (S_IS_DEBUG (symbolP))
	  {
	    /*
	     *	Dispatch on STAB type
	     */
	    switch ((unsigned char) S_GET_RAW_TYPE (symbolP))
	      {
	      case N_SLINE:
		if (S_GET_DESC (symbolP) > Current_File->max_line)
		  Current_File->max_line = S_GET_DESC (symbolP);
		if (S_GET_DESC (symbolP) < Current_File->min_line)
		  Current_File->min_line = S_GET_DESC (symbolP);
		break;
	      case N_SO:
		Current_File = find_file (symbolP);
		Current_File->flag = 1;
		Current_File->min_line = 1;
		break;
	      case N_SOL:
		Current_File = find_file (symbolP);
		break;
	      case N_GSYM:
		VMS_GSYM_Parse (symbolP, Text_Psect);
		break;
	      case N_LCSYM:
		VMS_LCSYM_Parse (symbolP, Text_Psect);
		break;
	      case N_FUN:	/* For static constant symbols */
	      case N_STSYM:
		VMS_STSYM_Parse (symbolP, Text_Psect);
		break;
	      }
	  }
      }

    /* now we take a quick sweep through the files and assign offsets
    to each one.  This will essentially be the starting line number to the
   debugger for each file.  Output the info for the debugger to specify the
   files, and then tell it how many lines to use */
    {
      int File_Number = 0;
      int Debugger_Offset = 0;
      int file_available;
      Current_File = file_root;
      for (Current_File = file_root; Current_File; Current_File = Current_File->next)
	{
	  if (Current_File == (struct input_file *) NULL)
	    break;
	  if (Current_File->max_line == 0)
	    continue;
	  if ((strncmp (Current_File->name, "GNU_GXX_INCLUDE:", 16) == 0) &&
	      !flagseen['D'])
	    continue;
	  if ((strncmp (Current_File->name, "GNU_CC_INCLUDE:", 15) == 0) &&
	      !flagseen['D'])
	    continue;
/* show a few extra lines at the start of the region selected */
	  if (Current_File->min_line > 2)
	    Current_File->min_line -= 2;
	  Current_File->offset = Debugger_Offset - Current_File->min_line + 1;
	  Debugger_Offset += Current_File->max_line - Current_File->min_line + 1;
	  if (Current_File->same_file_fpnt != (struct input_file *) NULL)
	    Current_File->file_number = Current_File->same_file_fpnt->file_number;
	  else
	    {
	      Current_File->file_number = ++File_Number;
	      file_available = VMS_TBT_Source_File (Current_File->name,
						 Current_File->file_number);
	      if (!file_available)
		{
		  Current_File->file_number = 0;
		  File_Number--;
		  continue;
		};
	    };
	  VMS_TBT_Source_Lines (Current_File->file_number,
				Current_File->min_line,
		       Current_File->max_line - Current_File->min_line + 1);
	};			/* for */
    };				/* scope */
    Current_File = (struct input_file *) NULL;

    for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next (symbolP))
      {
	/*
	 *	Deal with text symbols
	 */
	if (!S_IS_DEBUG (symbolP) && (S_GET_TYPE (symbolP) == N_TEXT))
	  {
	    /*
	     *	Ignore symbols starting with "L",
	     *	as they are local symbols
	     */
	    if (*S_GET_NAME (symbolP) == 'L')
	      continue;
	    /*
	     *	If there is a routine start defined,
	     *	terminate it.
	     */
	    if (Current_Routine)
	      {
		/*
		 *	End the routine
		 */
		VMS_TBT_Routine_End (text_siz, Current_Routine);
	      }
	    /*
	     *	Store the routine begin traceback info
	     */
	    if (Text_Psect != -1)
	      {
		VMS_TBT_Routine_Begin (symbolP, Text_Psect);
		Current_Routine = symbolP;
	      }
/* Output local symbols, i.e. all symbols that are associated with a specific
 * routine.  We output them now so the debugger recognizes them as local to
 * this routine.
 */
	    {
	      symbolS *symbolP1;
	      char *pnt;
	      char *pnt1;
	      for (symbolP1 = Current_Routine; symbolP1; symbolP1 = symbol_next (symbolP1))
		{
		  if (!S_IS_DEBUG (symbolP1))
		    continue;
		  if (S_GET_RAW_TYPE (symbolP1) != N_FUN)
		    continue;
		  pnt = S_GET_NAME (symbolP);
		  pnt1 = S_GET_NAME (symbolP1);
		  if (*pnt++ != '_')
		    continue;
		  while (*pnt++ == *pnt1++)
		    {
		    };
		  if (*pnt1 != 'F' && *pnt1 != 'f') continue;
		  if ((*(--pnt) == '\0') && (*(--pnt1) == ':'))
		    break;
		};
	      if (symbolP1 != (symbolS *) NULL)
		VMS_DBG_Define_Routine (symbolP1, Current_Routine, Text_Psect);
	    }			/* local symbol block */
	    /*
	     *	Done
	     */
	    continue;
	  }
	/*
	 *	Deal with STAB symbols
	 */
	if (S_IS_DEBUG (symbolP))
	  {
	    /*
	     *	Dispatch on STAB type
	     */
	    switch ((unsigned char) S_GET_RAW_TYPE (symbolP))
	      {
		/*
		 *	Line number
		 */
	      case N_SLINE:
		/* Offset the line into the correct portion
		 * of the file */
		if (Current_File->file_number == 0)
		  break;
		/* Sometimes the same offset gets several source
		 * lines assigned to it.
		 * We should be selective about which lines
		 * we allow, we should prefer lines that are
		 * in the main source file when debugging
		 * inline functions. */
		if ((Current_File->file_number != 1) &&
		    S_GET_VALUE (symbolP) ==
		    Current_Offset)
		  break;
		/* calculate actual debugger source line */
		S_GET_DESC (symbolP)
		  += Current_File->offset;
		/*
		 *	If this is the 1st N_SLINE, setup
		 *	PC/Line correlation.  Otherwise
		 *	do the delta PC/Line.  If the offset
		 *	for the line number is not +ve we need
		 *	to do another PC/Line correlation
		 *	setup
		 */
		if (Current_Offset == -1)
		  {
		    VMS_TBT_Line_PC_Correlation (
						  S_GET_DESC (symbolP),
						  S_GET_VALUE (symbolP),
						  Text_Psect,
						  0);
		  }
		else
		  {
		    if ((S_GET_DESC (symbolP) -
			 Current_Line_Number) <= 0)
		      {
			/*
			 *	Line delta is not +ve, we
			 *	need to close the line and
			 *	start a new PC/Line
			 *	correlation.
			 */
			VMS_TBT_Line_PC_Correlation (0,
						     S_GET_VALUE (symbolP) -
						     Current_Offset,
						     0,
						     -1);
			VMS_TBT_Line_PC_Correlation (
						      S_GET_DESC (symbolP),
						      S_GET_VALUE (symbolP),
						      Text_Psect,
						      0);
		      }
		    else
		      {
			/*
			 *	Line delta is +ve, all is well
			 */
			VMS_TBT_Line_PC_Correlation (
						      S_GET_DESC (symbolP) -
						      Current_Line_Number,
						      S_GET_VALUE (symbolP) -
						      Current_Offset,
						      0,
						      1);
		      }
		  }
		/*
		 *	Update the current line/PC
		 */
		Current_Line_Number = S_GET_DESC (symbolP);
		Current_Offset = S_GET_VALUE (symbolP);
		/*
		 *	Done
		 */
		break;
		/*
		 *	Source file
		 */
	      case N_SO:
		/*
		 *	Remember that we had a source file
		 *	and emit the source file debugger
		 *	record
		 */
		Current_File =
		  find_file (symbolP);
		break;
/* We need to make sure that we are really in the actual source file when
 * we compute the maximum line number.  Otherwise the debugger gets really
 * confused */
	      case N_SOL:
		Current_File =
		  find_file (symbolP);
		break;
	      }
	  }
      }
    /*
     *	If there is a routine start defined,
     *	terminate it (and the line numbers)
     */
    if (Current_Routine)
      {
	/*
	 *	Terminate the line numbers
	 */
	VMS_TBT_Line_PC_Correlation (0,
				   text_siz - S_GET_VALUE (Current_Routine),
				     0,
				     -1);
	/*
	 *	Terminate the routine
	 */
	VMS_TBT_Routine_End (text_siz, Current_Routine);
      }
  }
  /*
   *	Write the Traceback End Module TBT record
   */
  VMS_TBT_Module_End ();

  /*
   *	Write the End Of Module record
   */
  if (Entry_Point_Symbol == 0)
    Write_VMS_EOM_Record (-1, 0);
  else
    Write_VMS_EOM_Record (Text_Psect,
			  S_GET_VALUE (Entry_Point_Symbol));

  /*
   *	All done, close the object file
   */
  Close_VMS_Object_File ();
}

/* end of obj-vms.c */
OpenPOWER on IntegriCloud