File: libdwarf2p.1.mm

package info (click to toggle)
dwarfutils 20201201-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 11,868 kB
  • sloc: ansic: 104,667; sh: 5,947; cpp: 4,675; python: 878; makefile: 646; awk: 11
file content (5369 lines) | stat: -rw-r--r-- 153,588 bytes parent folder | download
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
\." $Revision: 1.12 $
\." $Date: 2002/01/14 23:40:11 $
\."
\."
\." the following line may be removed if the ff ligature works on your machine
.lg 0
\." set up heading formats
.ds HF 3 3 3 3 3 2 2
.ds HP +2 +2 +1 +0 +0
.nr Hs 5
.nr Hb 5
\." Increment body point size
.S +2
\." ==============================================
\." Put current date in the following at each rev
.ds vE Rev 1.51, 14 July 2020
\." ==============================================
\." ==============================================
.ds | |
.ds ~ ~
.ds ' '
.if t .ds Cw \&\f(CW
.if n .ds Cw \fB
.de Cf          \" Place every other arg in Cw font, beginning with first
.if \\n(.$=1 \&\*(Cw\\$1\fP
.if \\n(.$=2 \&\*(Cw\\$1\fP\\$2
.if \\n(.$=3 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP
.if \\n(.$=4 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP\\$4
.if \\n(.$=5 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP\\$4\*(Cw\\$5\fP
.if \\n(.$=6 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP\\$4\*(Cw\\$5\fP\\$6
.if \\n(.$=7 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP\\$4\*(Cw\\$5\fP\\$6\*(Cw\\$7\fP
.if \\n(.$=8 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP\\$4\*(Cw\\$5\fP\\$6\*(Cw\\$7\fP\\$8
.if \\n(.$=9 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP\\$4\*(Cw\\$5\fP\\$6\*(Cw\\$7\fP\\$8\
*(Cw
..
.nr Cl 3
.SA 1
.TL
A Producer Library Interface to DWARF
.AF ""
.AU "David Anderson"
.PF "'\*(vE '- \\\\nP -''"
.AS 1
This document describes an interface to a library of functions
to create DWARF debugging information entries and DWARF line number
information. It does not make recommendations as to how the functions
described in this document should be implemented nor does it
suggest possible optimizations. 
.P
The document is oriented to creating DWARF version 2.
Support for creating DWARF3 and DWARF4
and DWARF5 is only partial: various features
since DWARF2 cannot be created.
.P
\*(vE 
.AE
.MT 4
.H 1 "INTRODUCTION"
This document describes an interface to \f(CWlibdwarf\fP, a
library of functions to provide creation of DWARF debugging information
records, DWARF line number information, DWARF address range and
pubnames information, weak names information, and DWARF frame description 
information.


.H 2 "Copyright"
Copyright 1993-2006 Silicon Graphics, Inc.

Copyright 2007-2020 David Anderson.

Permission is hereby granted to copy or republish or use any
or all of this document without restriction except that when
publishing more than a small amount of the document please
acknowledge Silicon Graphics, Inc and David Anderson.

This document is distributed in the hope that it would be
useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

.H 2 "Purpose and Scope"
The purpose of this document is to propose a library of
functions to create DWARF debugging information.  Reading
(consuming) of such records is discussed in a separate
document.

The functions in this document have mostly been implemented
at Silicon Graphics and used by the SGI code generator to
provide debugging information.  Some functions (and support
for some extensions) were provided by Sun Microsystems.

Example code showing one use of the functionality
may be found in the dwarfgen 
\f(CWdwarfgen\fP
and
\f(CWsimpleexample\fP
application
(provided in the source distribution along with libdwarf).

.P
The focus of this document is the functional interface,
and as such, implementation and optimization issues are
intentionally ignored.

.P
Error handling, error codes, and certain 
\f(CWLibdwarf\fP codes are discussed
in the "\fIA Consumer Library Interface to DWARF\fP",
which should 
be read before reading this document.
.P
Before December 2018 
very few functions in the Producer Library follow the error-returns
as defined in "\fIA Consumer Library Interface to DWARF\fP".
.P
As of December 2018 every Producer Library call has
a version that supports that Consumer Library Interface
and returns DW_DLV_OK or DW_DLV_ERROR (the Producer Library
has no use of DW_DLV_NO_ENTRY).
The table of contents of this document lists the latest
version of each function. However, all the earlier
documentation is present here immediately following
the documentation of the latest, and preferred, interface. 
All the earlier interfaces are supported in the library.
.P
Early interfaces (before December 2018)
The general style of functions here 
in the producer library is rather C-traditional
with various types as return values (quite different
from the consumer library interfaces).
The style
generally follows the style of the original DWARF1 reader
proposed as an interface to DWARF.
When the style of the reader interfaces was changed (1994) in the
dwarf reader ( See the "Document History"
section of "A Consumer Library Interface to DWARF")
the interfaces here were not changed as it seemed like
too much of a change for the two applications then using
the interface!  So this interface remains in the traditional C style
of returning various data types with various (somewhat inconsistent)
means of indicating failure.
.P
December 2018 and later function interfaces
all return either DW_DLV_OK or DW_DLV_ERROR
in a simple int.
.P
The error handling code in the library may either
return a value or abort. 
The library user can provide a function that the producer code
will call on errors (which would allow callers avoid testing
for error returns if the user function exits or aborts).
See the  \f(CWdwarf_producer_init()\fP
description below for more details.

.H 2 "Document History"
This document originally prominently referenced
"UNIX International Programming Languages Special Interest Group " 
(PLSIG).
Both  UNIX International and the
affiliated  Programming Languages Special Interest Group
are defunct
(UNIX is a registered trademark of UNIX System Laboratories, Inc.
in the United States and other countries).
Nothing except the general interface style is actually
related to anything shown to the PLSIG
(this document was open sourced with libdwarf in the mid 1990's).
.P
See "http://www.dwarfstd.org" for information on current
DWARF standards and committee activities.

.H 2 "Definitions"
DWARF debugging information entries (DIEs) are the segments of information 
placed in the \f(CW.debug_info\fP  and related
sections by compilers, assemblers, and linkage 
editors that, in conjunction with line number entries, are necessary for 
symbolic source-level debugging.  
Refer to the document 
"\fIDWARF Debugging Information Format\fP" from UI PLSIG for a more complete 
description of these entries.

.P
This document adopts all the terms and definitions in
"\fIDWARF Debugging Information Format\fP" version 2.
and the "\fIA Consumer Library Interface to DWARF\fP".

.P
In addition, this document refers to Elf, the ATT/USL System V
Release 4 object format.
This is because the library was first developed for that object
format.
Hopefully the functions defined here can easily be
applied to other object formats.

.H 2 "Overview"
The remaining sections of this document describe a proposed producer 
(compiler or assembler) interface to \fILibdwarf\fP, first by describing 
the purpose of additional types defined by the interface, followed by 
descriptions of the available operations.  
This document assumes you 
are thoroughly familiar with the information contained in the 
\fIDWARF 
Debugging Information Format\fP document, and 
"\fIA Consumer Library Interface to DWARF\fP".

.P
The interface necessarily knows a little bit about the object format
(which is assumed to be Elf).  We make an attempt to make this knowledge 
as limited as possible.  For example, \fILibdwarf\fP does not do the 
writing of object data to the disk.  The producer program does that.

.H 2 "Revision History"
.VL 15
.LI "March 1993"
Work on dwarf2 sgi producer draft begins
.LI "March 1999"
Adding a function to allow any number of trips
through the dwarf_get_section_bytes() call.
.LI "April 10 1999"
Added support for assembler text output of dwarf
(as when the output must pass through an assembler).
Revamped internals for better performance and
simpler provision for differences in ABI.
.LI "Sep 1, 1999"
Added support for little- and cross- endian
debug info creation.
.LI "May 7  2007"
This library interface now cleans up, deallocating
all memory it uses (the application simply calls
dwarf_producer_finish(dbg)).
.LI "September 20  2010"
Now documents the marker feature of DIE creation.
.LI "May 01  2014"
The dwarf_producer_init() code has a new interface
and DWARF is configured at run time by its arguments.
The producer code used to be configured at configure
time, but the configure time producer configure options
are no longer used. 
The configuration was unnecessarily complicated:
the run-time configuration is simpler to understand.
.LI "September 10, 2016"
Beginning the process of creating new interfaces
so that checking for error is consistent across all
calls (as is done in the consumer library).
The old interfaces are kept and supported so
we have binary and source compatibility with
old code.
.LI "December 01, 2018"
All function interfaces now have a version
that returns only DW_DLV_OK or DW_DLV_ERROR
and pointer and other values are returned
through pointer arguments.
For example, dwarf_add_frame_info_c()
is the December 2018 version, while
dwarf_add_frame_info(), 
dwarf_add_frame_info_b()
are earlier versions (which are still supported).
.LI "July 14, 2020"
To enable testing of reading the DWARF5 section .debug_sup
the new function dwarf_add_debug_sup() is added.
dwarfgen can call this function, though dwarfgen
presently only fills out a bogus .debug_sup
section to enable simple testing.
.LE

.H 1 "Type Definitions"

.H 2 "General Description"
The \fIlibdwarf.h\fP 
header file contains typedefs and preprocessor 
definitions of types and symbolic names 
used to reference objects of \fI Libdwarf \fP .  
The types defined by typedefs contained in \fI libdwarf.h\fP 
all use the convention of adding \fI Dwarf_ \fP 
as a prefix to
indicate that they refer to objects used by Libdwarf.  
The prefix \fI Dwarf_P_\fP is used for objects 
referenced by the \fI Libdwarf\fP 
Producer when there are similar but distinct 
objects used by the Consumer.

.H 2 "Namespace issues"
Application programs should avoid creating names
beginning with 
\f(CWDwarf_\fP
\f(CWdwarf_\fP
or 
\f(CWDW_\fP
as these are reserved to dwarf and libdwarf.

.H 1 "libdwarf and Elf and relocations"
Much of the description below presumes that 
Elf is the object
format in use.
The library is probably usable with other object formats
that allow arbitrary sections to be created.
The library does not write anything to disk.
Instead it provides access so that callers
can do that.


.H 2 "binary or assembler output"
With 
\f(CWDW_DLC_STREAM_RELOCATIONS\fP 
(see below)
it is assumed that the calling app will simply
write the streams and relocations directly into
an Elf file, without going through an assembler.

With 
\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP 
the calling app must either 
A) generate binary relocation streams and write
the generated debug information streams and
the relocation streams direct to an elf file
or
B) generate assembler output text for an assembler
to read and produce an object file. 

With case B) the libdwarf-calling application must
use the relocation information to change
points of each binary stream into references to 
symbolic names.  
It is necessary for the assembler to be
willing to accept and generate relocations
for references from arbitrary byte boundaries.
For example:
.sp
.nf
.in +4
 .data 0a0bcc    #producing 3 bytes of data.
 .word mylabel   #producing a reference
 .word endlabel - startlabel #producing absolute length
.in -4
.fi
.sp




.H 2 "libdwarf relationship to Elf"
When the documentation below refers to 'an elf section number'
it is really only dependent on getting (via the callback
function passed by the caller of
\f(CWdwarf_producer_init()\fP.
a sequence of integers back (with 1 as the lowest).

When the documentation below refers to 'an Elf symbol index'
it is really dependent on 
Elf symbol numbers
only if
\f(CWDW_DLC_STREAM_RELOCATIONS\fP 
are being generated (see below).
With 
\f(CWDW_DLC_STREAM_RELOCATIONS\fP 
the library is generating Elf relocations
and the section numbers in binary form so
the section numbers and symbol indices must really 
be Elf (or elf-like) numbers.


With
\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP 
the values passed as symbol indexes can be any
integer set or even pointer set.
All that libdwarf assumes is that where values
are unique they get unique values.
Libdwarf does not generate any kind of symbol table
from the numbers and does not check their
uniqueness or lack thereof.

.H 2 "libdwarf and relocations"
With
\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP 
libdwarf creates binary streams of debug information
and arrays of relocation information describing
the necessary relocation.
The Elf section numbers and symbol numbers appear
nowhere in the binary streams. Such appear
only in the relocation information and the passed-back
information from calls requesting the relocation information.
As a consequence, the 'symbol indices' can be
any pointer or integer value as the caller must
arrange that the output deal with relocations.

With 
\f(CWDW_DLC_STREAM_RELOCATIONS\fP 
all the relocations are directly created by libdwarf
as binary streams (libdwarf only creates the streams
in memory,
it does not write them to disk).

.H 2 "symbols, addresses, and offsets"
The following applies to calls that
pass in symbol indices, addresses, and offsets, such
as
\f(CWdwarf_add_AT_targ_address_c() \fP 
\f(CWdwarf_add_arange_b()\fP 
and
\f(CWdwarf_add_frame_fde_c()\fP.

With 
\f(CWDW_DLC_STREAM_RELOCATIONS\fP 
a passed in address is one of:
a) a section offset and the (non-global) symbol index of
a section symbol.
b) A symbol index (global symbol) and a zero offset.

With \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP
the same approach can be used, or, instead,
a passed in address may be
c) a symbol handle and an offset.
In this case, since it is up to the calling app to
generate binary relocations (if appropriate)
or to turn the binary stream into 
a text stream (for input to an assembler, if appropriate)
the application has complete control of the interpretation
of the symbol handles.

.H 1 "Memory Management"

Several of the functions that comprise the \fILibdwarf\fP 
producer interface dynamically allocate values and some
return pointers to those spaces.
The dynamically allocated spaces 
can not be reclaimed  (and must
not be freed) except that
all such libdwarf-allocated memory
is freed by 
\f(CWdwarf_producer_finish_a(dbg)\fP  
or
\f(CWdwarf_producer_finish(dbg)\fP.  

All data for a particular \f(CWDwarf_P_Debug\fP descriptor
is separate from the data for any other 
\f(CWDwarf_P_Debug\fP descriptor in use in the library-calling
application.

.H 2 "Read Only Properties"
The read-only properties
specified in the
consumer interface document do not
generally apply to the functions
described here.

.H 2 "Storage Deallocation"
Calling \f(CWdwarf_producer_finish_a(dbg)\fP frees all the space, and 
invalidates all pointers returned from \f(CWLibdwarf\fP functions on 
or descended from \f(CWdbg\fP).

.H 2 "Error Handling"
In general any error detected by the producer
should be considered fatal. 
That is, it is impossible to produce correct
output so producing anything seems questionable.
.P
The original producer interfaces tended to return
a pointer or a large integer as a result and
required the caller to cast that value to determine
if it was actually a -1 meaning there was an error.
.P
Beginning in September 2016 additional interfaces
are being added to eliminate the necessity for callers
to do this ugly casting of results.
In December 2018 that process has reached completion.
The revised functions return
\f(CWDW_DLV_OK\fP,
or
\f(CWDW_DLV_ERROR\fP.
(which are small signed integers) and will
have an additional pointer argument that will provide
the value that used to be the return value.
This will make the interfaces type-safe.
.P
The function
\f(CWdwarf_get_section_bytes_a()\fP
can also return
\f(CWDW_DLV_NO_ENTRY\fP.
.P
The original interfaces will remain.
Binary and source compatibility for old
code using the older interfaces is retained.

.H 1 "Functional Interface"
This section describes the functions available in the \fILibdwarf\fP
library.  Each function description includes its definition, followed 
by a paragraph describing the function's operation.
.P
The following sections describe these functions.
.P
The functions may be categorized into groups: 
\fIinitialization and termination operations\fP,
\fIdebugging information entry creation\fP,
\fIElf section callback function\fP,
\fIattribute creation\fP,
\fIexpression creation\fP, 
\fIline number creation\fP, 
\fIfast-access (aranges) creation\fP, 
\fIfast-access (pubnames) creation\fP, 
\fIfast-access (weak names) creation\fP,
\fImacro information creation\fP, 
\fIlow level (.debug_frame) creation\fP, 
and
\fIlocation list (.debug_loc) creation\fP. 
.P
.H 2 "Initialization and Termination Operations"
These functions setup \f(CWLibdwarf\fP to accumulate debugging information
for an object, usually a compilation-unit, provided by the producer.
The actual addition of information is done by functions in the other
sections of this document.  Once all the information has been added,
functions from this section are used to transform the information to
appropriate byte streams, and help to write out the byte streams to
disk.

Typically then, a producer application 
would create a \f(CWDwarf_P_Debug\fP 
descriptor to gather debugging information for a particular
compilation-unit using \f(CWdwarf_producer_init()\fP.  

The producer application would 
use this \f(CWDwarf_P_Debug\fP descriptor to accumulate debugging 
information for this object using functions from other sections of 
this document.  
Once all the information had been added, it would 
call \f(CWdwarf_transform_to_disk_form()\fP to convert the accumulated 
information into byte streams in accordance with the \f(CWDWARF\fP 
standard.  
The application would then repeatedly call 
\f(CWdwarf_get_section_bytes_a()\fP 
for each of the \f(CW.debug_*\fP created.  
This gives the producer 
information about the data bytes to be written to disk.  
At this point, 
the producer would release all resource used by \f(CWLibdwarf\fP for 
this object by calling \f(CWdwarf_producer_finish_a()\fP.

It is also possible to create assembler-input character streams
from the byte streams created by this library.
This feature requires slightly different interfaces than
direct binary output.
The details are mentioned in the text.

.H 3 "dwarf_producer_init()"

.DS
\f(CWint dwarf_producer_init(
        Dwarf_Unsigned flags,
        Dwarf_Callback_Func func,
        Dwarf_Handler errhand,
        Dwarf_Ptr errarg,
        void *    user_data      
        const char *isa_name,
        const char *dwarf_version,
        const char *extra, 
        Dwarf_P_Debug *dbg_returned,
        Dwarf_Error *error) \fP
.DE
.P
The function \f(CWdwarf_producer_init() \fP returns a new 
\f(CWDwarf_P_Debug\fP descriptor that can be used to add
\f(CWDwarf\fP 
information to the object.  
On success it returns \f(CWDW_DLV_OK\fP.  
On error it returns \f(CWDW_DLV_ERROR\fP.  
\f(CWflags\fP determine whether the target object is 64-bit or 32-bit.  
\f(CWfunc\fP
is a pointer to a function called-back from \f(CWLibdwarf\fP 
whenever \f(CWLibdwarf\fP needs to create a new object section (as it will 
for each .debug_* section and related relocation section).  

.P
The \f(CWflags\fP
values (to be OR'd together in the flags field
in the calling code) are as follows:
.in +4
\f(CWDW_DLC_WRITE\fP 
is required.
The values
\f(CWDW_DLC_READ\fP  
\f(CWDW_DLC_RDWR\fP
are not supported by the producer and must not be passed.

The flag bit
\f(CWDW_DLC_POINTER64\fP
(or
\f(CWDW_DLC_SIZE_64\fP)
Indicates the target has a 64 bit (8 byte) address size.
The flag bit
\f(CWDW_DLC_POINTER32\fP
(or
\f(CWDW_DLC_SIZE_32\fP)
Indicates the target has a 32 bit (4 byte) address size.
If none of these pointer sizes is passed in 
\f(CWDW_DLC_POINTER32\fP 
is assumed.

The flag bit
\f(CWDW_DLC_OFFSET32\fP
indicates that 32bit offsets should be used in the generated DWARF.
The flag bit
\f(CWDW_DLC_OFFSET64\fP
\f(CWDW_DLC_OFFSET_SIZE_64\fP
indicates that 64bit offsets should be used in the generated DWARF.

The flag bit
\f(CWDW_DLC_IRIX_OFFSET64\fP
indicates that the generated DWARF should use the
early (pre DWARF3) IRIX method of generating 64 bit offsets.
In this case \f(CWDW_DLC_POINTER64\fP should also be passed in,
and the \f(CWisa_name\fP
passed in (see below) should be "irix".



If
\f(CWDW_DLC_TARGET_BIGENDIAN\fP
or
\f(CWDW_DLC_TARGET_LITTLEENDIAN\fP
is not ORed into \f(CWflags\fP
then 
endianness the same as the host is assumed.
If both 
\f(CWDW_DLC_TARGET_LITTLEENDIAN\fP
and
\f(CWDW_DLC_TARGET_BIGENDIAN\fP
are OR-d in it is an error.



Either one of two output forms is specifiable:
\f(CWDW_DLC_STREAM_RELOCATIONS\fP 
or
\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP .

The default is
\f(CWDW_DLC_STREAM_RELOCATIONS\fP . 
The
\f(CWDW_DLC_STREAM_RELOCATIONS\fP
are relocations in a binary stream (as used
in a MIPS/IRIX Elf object).

The
\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP
are the same relocations but expressed in an
array of structures defined by libdwarf,
which the caller of the relevant function
(see below) must deal with appropriately.
This method of expressing relocations allows 
the producer-application to easily produce
assembler text output of debugging information.

When
\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP
is ORed into \f(CWflags\fP
then relocations are returned not as streams
but through an array of structures.

.in -4

.P
The function 
\f(CWfunc\fP 
must be provided by the user of this library.
Its prototype is:
.DS
\f(CWtypedef int (*Dwarf_Callback_Func)(
    char* name,
    int                 size,
    Dwarf_Unsigned      type,
    Dwarf_Unsigned      flags,
    Dwarf_Unsigned      link,
    Dwarf_Unsigned      info,
    Dwarf_Unsigned*     sect_name_index,
    void *              user_data,
    int*                error) \fP
.DE
For each section in the object file that \f(CWlibdwarf\fP
needs to create, it calls this function once (calling it
from \f(CWdwarf_transform_to_disk_form()\fP), passing in
the section \f(CWname\fP, the section \f(CWtype\fP,
the section \f(CWflags\fP, the \f(CWlink\fP field, and
the \f(CWinfo\fP field.  
For an Elf object file these values
should be appropriate Elf section header values.
For example, for relocation callbacks, the \f(CWlink\fP
field is supposed to be set (by the app) to the index
of the symtab section (the link field passed through the
callback must be ignored by the app).
And, for relocation callbacks, the \f(CWinfo\fP field
is passed as the elf section number of the section
the relocations apply to.
.P
The  \f(CWsect_name_index\fP field is a field you use
to pass a symbol index back to libdwarf.
In Elf, each section gets an elf symbol table entry
so that relocations have an address to refer to
(relocations rely on addresses in the Elf symbol table).
You will create the Elf symbol table, so you have to tell
libdwarf the index to put into relocation records for the
section newly defined here.
.P
On success
the user function should return the Elf section number of the
newly created Elf section.
.P
On success, the function should also set the integer
pointed to by \f(CWsect_name_index\fP to the
Elf symbol number assigned in the Elf symbol table of the
new Elf section.
This symbol number is needed with relocations
dependent on the relocation of this new section.
.P
Use the 
\f(CWdwarf_producer_init_c()\fP
interface instead of this interface.
.P
For example, the \f(CW.debug_line\fP section's third
data element (in a compilation unit) is the offset from the
beginning of the \f(CW.debug_info\fP section of the compilation
unit entry for this \f(CW.debug_line\fP set.
The relocation entry in \f(CW.rel.debug_line\fP
for this offset
must have the relocation symbol index of the 
symbol \f(CW.debug_info\fP  returned
by the callback of that section-creation through 
the pointer \f(CWsect_name_index\fP.
.P
On failure, the function should return -1 and set the \f(CWerror\fP
integer to an error code.
.P
Nothing in libdwarf actually depends on the section index
returned being a real Elf section.
The Elf section is simply useful for generating relocation
records.
Similarly, the Elf symbol table index returned through 
the \f(CWsect_name_index\fP must be an index
that can be used in relocations against this section.
The application will probably want to note the
values passed to this function in some form, even if
no Elf file is being produced.

.P
\f(CWerrhand\fP 
is a pointer to a function that will be used as
a default fall-back function for handling errors detected 
by \f(CWLibdwarf\fP.  

.P
\f(CWerrarg\fP is the default error argument used 
by the function pointed to by \f(CWerrhand\fP.
.P
For historical reasons the error handling is complicated
and the following three paragraphs describe the three
possible scenarios when a producer function detects an error.
In all cases a short error message is printed on
stdout if the error number
is negative (as all such should be, see libdwarf.h).
Then further action is taken as follows.
.P
First,
if the  Dwarf_Error argument to any specific producer function
(see the functions documented below)  is non-null
the \f(CWerrhand\fP argument here is ignored in that call and
the specific producer function sets the Dwarf_Error and returns
some specific value (for dwarf_producer_init it is DW_DLV_OK
as mentioned just above) indicating there is an error.
.P
Second,
if the  Dwarf_Error argument to any specific producer function 
(see the functions documented below)  is NULL and the
\f(CWerrarg\fP
to \f(CWdwarf_producer_init()\fP is non-NULL
then on an error in the producer code the Dwarf_Handler function is called
and if that called function returns the producer code returns
a specific value (for dwarf_producer_init it is DW_DLV_OK
as mentioned just above) indicating there is an error.
.P
Third,
if the  Dwarf_Error argument to any specific producer function
(see the functions documented below)  is NULL and the
\f(CWerrarg\fP
to \f(CWdwarf_producer_init()\fP is NULL
then on an error \f(CWabort()\fP is called.

.P
The \f(CWuser_data\fP argument is not examined by libdwarf.
It is passed to user code in all 
calls by libdwarf to  the \f(CWDwarf_Callback_Func()\fP
function and 
may be used by consumer code for the consumer's own purposes.
Typical uses might be to pass in a pointer to some user
data structure or to pass an integer that somehow
is useful to the libdwarf-using code.

.P
The \f(CWisa_name\fP argument 
must be non-null and contain one of the
strings defined in the isa_relocs array
in pro_init.c: "irix","mips","x86",
"x86_64","arm","arm64","ppc","ppc64",
"sparc". 
The names are not strictly ISA
names (nor ABI names) but a hopefully-meaningful
mixing of the concepts of ISA and ABI.
The intent is mainly to 
define relocation codes applicable to DW_DLC_STREAM_RELOCATIONS.
New \f(CWisa_name\fP values will be provided as users
request. In the "irix" case a special relocation is defined
so a special CIE reference field can be created (if and
only if the augmentation
string is "z").
.P
The \f(CWdwarf_version\fP argument 
should be one of 
"V2",
"V3",
"V4",
"V5"
to indicate which DWARF version is the overall format
to be emitted.  Individual section version numbers will obey
the standard for that overall DWARF version.
.P
The \f(CWextra\fP argument 
is supports a comma-separated
list of options.
Passing in a null pointer or an empty string
is acceptable if no such options are needed 
or used.  
All-lowercase option names are reserved to
the libdwarf implementation itself (specific implementations
may want to use a leading upper-case letter for
additional options).
.P
The available options are
.DS
"default_is_stmt",
"address_size",
"minimum_instruction_length",
"maximum_operations_per_instruction",
"opcode_base",
"line_base",
"line_range",
"linetable_version",
"segment_selector_size",
and
"segment_size".
.DE
.P
For example, to set the line-table generation
default value of is_stmt to 0
pass in 
.DS
"default_is_stmt=0".
.DE
To also set the minimum_instruction_length
used in calculating line table address-advance
values to one one would pass 
in 
.DS
"default_is_stmt=0,minimum_instruction_length=1".
.DE
It's appropriate to add 
.DS
"opcode_base=13"
.DE
for
DWARF3 through DWARF5.
All these default to something, but the something
depends on environment what macro names 
are set by the envirnment or a just constants
which makes it difficult to alter these values.
See pro_line.h for the use of line-table related
constants (which will vary depending on the target ISA
and ABI and compilers).

.P
The \f(CWerror\fP argument 
is set through the pointer to return specific error  
if \f(CWerror\fP is non-null and
and there is an error.  The error details
will be passed back through this pointer argument.

.H 3 "dwarf_pro_set_default_string_form()"

.DS
\f(CWint dwarf_pro_set_default_string_form(
    Dwarf_P_Debug *dbg,
    int            desired_form,
    Dwarf_Error *error) \fP
.DE
.P
The function 
\f(CWdwarf_pro_set_default_string_form()\fP 
sets the 
\f(CWDwarf_P_Debug\fP descriptor to favor one of
the two allowed values:
\f(CWDW_FORM_string\fP
(the default)
or
\f(CWDW_FORM_strp\fP.
.P
When
\f(CWDW_FORM_strp\fP
is selected very short names will still
use form
\f(CWDW_FORM_string\fP .
.P
The function should be called immediately after a successful call
to 
\f(CWdwarf_producer_init()\fP.
.P
Strings for 
\f(CWDW_FORM_strp\fP
are not duplicated in the 
\f(CW.debug_str\fP
section: each unique string
appears exactly once.
.P
On success it returns \f(CWDW_DLV_OK\fP.
On error it returns \f(CWDW_DLV_ERROR\fP.

.H 3 "dwarf_transform_to_disk_form_a()"
.DS
\f(CWint dwarf_transform_to_disk_form_a(
        Dwarf_P_Debug dbg,
        Dwarf_Signed *chunk_count_out,
        Dwarf_Error* error)\fP
.DE
New September 2016.
The function
\f(CWdwarf_transform_to_disk_form_a()\fP 
is new in September 2016. 
It produces the same result as
\f(CWdwarf_transform_to_disk_form()\fP 
but returns the count through the new
pointer argument
\f(CWchunk_count_out\fP . 
.P
On success it returns
\f(CWDW_DLV_OK\fP
and sets
\f(CWchunk_count_out\fP 
to
the number of chunks of section data to be
accessed by
\f(CWdwarf_get_section_bytes_a()\fP .
.P
It
turns the DIE and other information specified
for this \f(CWDwarf_P_Debug\fP into a stream of
bytes for each section being produced.
These byte streams can be retrieved from
the \f(CWDwarf_P_Debug\fP by calls to
\f(CWdwarf_get_section_bytes_a()\fP (see below).
.P
In case of error
\f(CWdwarf_transform_to_disk_form_a()\fP 
returns
\f(CWDW_DLV_ERROR\fP.
.P
The number of chunks
is used to access data 
by
\f(CWdwarf_get_section_bytes_a()\fP
(see below) and the section data
provided your code will insert
into an object file or the like.
Each section of the resulting object is typically
many small chunks. 
Each chunk has a section index
and a length as well as a pointer to a block of data
(see
\f(CWdwarf_get_section_bytes_a()\fP
).
.P
For each unique section being produced 
\f(CWdwarf_transform_to_disk_form_a()\fP 
calls the
\f(CWDwarf_Callback_Func\fP exactly once. 
The callback provides the connection
between Elf sections (which we presume
is the object format to be emitted) and
the 
\f(CWlibdwarf()\fP 
internal section numbering.
.P
For \f(CWDW_DLC_STREAM_RELOCATIONS\fP
a call to 
\f(CWDwarf_Callback_Func\fP is made
by libdwarf for each relocation section.
Calls to \f(CWdwarf_get_section_bytes_a()\fP (see below).
allow the 
\f(CWdwarf_transform_to_disk_form_a()\fP  caller
to get byte streams and write them to
an object file as desired, just as with
the other sections of the object being created.
.P
For \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP
the user code should use
\f(CWdwarf_get_relocation_info_count()\fP
and
\f(CWdwarf_get_relocation_info()\fP
to retrieve the relocation info
generated by 
\f(CWdwarf_transform_to_disk_form()\fP
and do something with it.

.P
On failure it returns 
\f(CWDW_DLV_ERROR\fP
and returns an error pointer through
\f(CW*error\fP .


.H 4 "dwarf_transform_to_disk_form()"
.DS
\f(CWDwarf_Signed dwarf_transform_to_disk_form(
        Dwarf_P_Debug dbg,
        Dwarf_Error* error)\fP
.DE
The function
\f(CWdwarf_transform_to_disk_form()\fP 
is the original call to generate output
and a better interface is used by
\f(CWdwarf_transform_to_disk_form_a()\fP 
though both do the same work and have the
same meaning.


.H 3 "dwarf_get_section_bytes_a()"

.DS
\f(CWint dwarf_get_section_bytes_a(
        Dwarf_P_Debug dbg,
        Dwarf_Signed dwarf_section,
        Dwarf_Signed *elf_section_index, 
        Dwarf_Unsigned *length,
        Dwarf_Ptr      *section_bytes,
        Dwarf_Error* error)\fP
.DE
The function \f(CWdwarf_get_section_bytes_a() \fP 
must be called repetitively, 
with the index 
\f(CWdwarf_section\fP starting at 0 and continuing for the 
number of sections 
returned by 
\f(CWdwarf_transform_to_disk_form_a() \fP.
.P
It returns 
\f(CWDW_DLV_NO_ENTRY\fP
to indicate that there are no more sections of 
\f(CWDwarf\fP information.  
Normally one would index through using the sectioncount
from dwarf_transform_to_disk_form_a() so
\f(CWDW_DLV_NO_ENTRY\fP
would never be seen.

For each successful return (return value
\f(CWDW_DLV_OK\fP),
\f(CW*section_bytes\fP
points to \f(CW*length\fP bytes of data that are normally
added to the output 
object in \f(CWElf\fP section \f(CW*elf_section\fP by the producer application.
It is illegal to call these in any order other than 0 through N-1 where
N is the number of dwarf sections
returned by \f(CWdwarf_transform_to_disk_form() \fP.
The elf section number is returned through the pointer
\f(CWelf_section_index\fP.

The \f(CWdwarf_section\fP
number is ignored: the data is returned as if the
caller passed in the correct dwarf_section numbers in the
required sequence.
.P
In case of an error, 
\f(CWDW_DLV_ERROR\fP
is returned and 
the \f(CWerror\fP argument is set to indicate the error.
.P
There is no requirement that the section bytes actually 
be written to an elf file.
For example, consider the .debug_info section and its
relocation section (the call back function would resulted in
assigning 'section' numbers and the link field to tie these
together (.rel.debug_info would have a link to .debug_info).
One could examine the relocations, split the .debug_info
data at relocation boundaries, emit byte streams (in hex)
as assembler output, and at each relocation point,
emit an assembler directive with a symbol name for the assembler.
Examining the relocations is awkward though. 
It is much better to use \f(CWdwarf_get_section_relocation_info() \fP
.P

The memory space of the section byte stream is freed
by the \f(CWdwarf_producer_finish_a() \fP call
(or would be if the \f(CWdwarf_producer_finish_a() \fP
was actually correct), along
with all the other space in use with that Dwarf_P_Debug.

Function created 01 December 2018.

.H 4 "dwarf_get_section_bytes()"
.DS
\f(CWDwarf_Ptr dwarf_get_section_bytes(
        Dwarf_P_Debug dbg,
        Dwarf_Signed dwarf_section,
        Dwarf_Signed *elf_section_index, 
        Dwarf_Unsigned *length,
        Dwarf_Error* error)\fP
.DE
Beginning in September 2016 one should call
\f(CWdwarf_get_section_bytes_a()\fP
 in preference to
\f(CWdwarf_get_section_bytes()\fP as
the former makes checking for errors easier.
.P
The function 
\f(CWdwarf_get_section_bytes()\fP
must be called repetitively,
with the index 
\f(CWdwarf_section\fP
starting at 0 and continuing for the
number of sections
returned by \f(CWdwarf_transform_to_disk_form() \fP.
.P
It returns 
\f(CWNULL\fP to indicate that there are no more sections of
\f(CWDwarf\fP information.
Normally one would index through using the sectioncount
from dwarf_transform_to_disk_form_a() so
\f(CWNULL\fP
would never be seen.
.P
For each non-NULL return, the return value
points to \f(CW*length\fP bytes of data that are normally
added to the output
object in \f(CWElf\fP section \f(CW*elf_section\fP by the producer application.
The elf section number is returned through the pointer
\f(CWelf_section_index\fP.
.P
In case of an error, 
\f(CWDW_DLV_BADADDR\fP
is returned and 
the \f(CWerror\fP argument is set to indicate the error.
.P
It is illegal to call these in any order other than 0 through N-1 where
N is the number of dwarf sections
returned by \f(CWdwarf_transform_to_disk_form() \fP.
The \f(CWdwarf_section\fP
number is actually ignored: the data is returned as if the
caller passed in the correct dwarf_section numbers in the
required sequence.
The \f(CWerror\fP argument is not used.
.P
There is no requirement that the section bytes actually
be written to an elf file.
For example, consider the .debug_info section and its
relocation section (the call back function would resulted in
assigning 'section' numbers and the link field to tie these
together (.rel.debug_info would have a link to .debug_info).
One could examine the relocations, split the .debug_info
data at relocation boundaries, emit byte streams (in hex)
as assembler output, and at each relocation point,
emit an assembler directive with a symbol name for the assembler.
Examining the relocations is awkward though.
It is much better to use \f(CWdwarf_get_section_relocation_info() \fP
.P

The memory space of the section byte stream is freed
by the \f(CWdwarf_producer_finish_a() \fP call
(or would be if the \f(CWdwarf_producer_finish_a() \fP
was actually correct), along
with all the other space in use with that Dwarf_P_Debug.



.H 3 "dwarf_get_relocation_info_count()"
.DS
\f(CWint dwarf_get_relocation_info_count(
        Dwarf_P_Debug dbg,
        Dwarf_Unsigned *count_of_relocation_sections ,
	int            *drd_buffer_version,
        Dwarf_Error* error)\fP
.DE
The function \f(CWdwarf_get_relocation_info() \fP
returns, through  the pointer \f(CWcount_of_relocation_sections\fP, the
number of times that \f(CWdwarf_get_relocation_info() \fP
should be called.

The function \f(CWdwarf_get_relocation_info() \fP
returns DW_DLV_OK if the call was successful (the 
\f(CWcount_of_relocation_sections\fP is therefore meaningful,
though \f(CWcount_of_relocation_sections\fP
could be zero).

\f(CW*drd_buffer_version\fP
is the value 2.
If the structure pointed to by
the \f(CW*reldata_buffer\fP
changes this number will change.
The application should verify that the number is
the version it understands (that it matches
the value of DWARF_DRD_BUFFER_VERSION (from libdwarf.h)).
The value 1 version was never used in production 
MIPS libdwarf (version 1 did exist in source).

It returns DW_DLV_NO_ENTRY if 
\f(CWcount_of_relocation_sections\fP is not meaningful
because \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP was not
passed to the
\f(CWdwarf_producer_init_c()\fP
\f(CWdwarf_producer_init_b()\fP or 
\f(CWdwarf_producer_init()\fP  call
(whichever one was used).

It returns DW_DLV_ERROR if there was an error,
in which case
\f(CWcount_of_relocation_sections\fP is not meaningful.

.H 3 "dwarf_get_relocation_info()"
.DS
\f(CWint dwarf_get_relocation_info(
        Dwarf_P_Debug dbg,
        Dwarf_Signed *elf_section_index, 
	Dwarf_Signed *elf_section_index_link, 
        Dwarf_Unsigned *relocation_buffer_count,
	Dwarf_Relocation_Data *reldata_buffer,
        Dwarf_Error* error)\fP
.DE

The function \f(CWdwarf_get_relocation_info() \fP 
should normally be called repetitively, 
for the number of relocation sections that 
\f(CWdwarf_get_relocation_info_count() \fP
indicated exist.

It returns \f(CWDW_DLV_OK\fP to indicate that 
valid values are returned through the pointer arguments.
The \f(CWerror\fP argument is not set.

It returns DW_DLV_NO_ENTRY if there are no entries
(the count of relocation arrays is zero.).
The \f(CWerror\fP argument is not set.

It returns \f(CWDW_DLV_ERROR\fP if there is an error.
Calling \f(CWdwarf_get_relocation_info() \fP
more than the number of times indicated by
\f(CWdwarf_get_relocation_info_count() \fP
(without an intervening call to
\f(CWdwarf_reset_section_bytes() \fP )
results in a return of \f(CWDW_DLV_ERROR\fP once past
the valid count.
The \f(CWerror\fP argument is set to indicate the error.

Now consider the returned-through-pointer values for
\f(CWDW_DLV_OK\fP .

\f(CW*elf_section_index\fP
is the 'elf section index' of the section implied by
this group of relocations.


\f(CW*elf_section_index_link\fP
is the section index of the section that these
relocations apply to.

\f(CW*relocation_buffer_count\fP
is the number of array entries of relocation information
in the array pointed to by
\f(CW*reldata_buffer\fP .


\f(CW*reldata_buffer\fP
points to an array of 'struct Dwarf_Relocation_Data_s'
structures.

The version 2 array information is as follows:

.nf
enum Dwarf_Rel_Type {dwarf_drt_none,
                dwarf_drt_data_reloc,
                dwarf_drt_segment_rel,
                dwarf_drt_first_of_length_pair,
                dwarf_drt_second_of_length_pair
};
typedef struct Dwarf_Relocation_Data_s  * Dwarf_Relocation_Data;
struct Dwarf_Relocation_Data_s {
        unsigned char        drd_type;   /* contains Dwarf_Rel_Type */
	unsigned char        drd_length; /* typically 4 or 8 */
        Dwarf_Unsigned       drd_offset; /* where the data to reloc is */
        Dwarf_Unsigned       drd_symbol_index;
};

.fi

The \f(CWDwarf_Rel_Type\fP enum is encoded (via casts if necessary)
into the single unsigned char \f(CWdrd_type\fP field to control
the space used for this information (keep the space to 1 byte).

The unsigned char \f(CWdrd_length\fP field
holds the size in bytes of the field to be relocated.
So for elf32 object formats with 32 bit apps, \f(CWdrd_length\fP
will be 4.  For objects with MIPS -64 contents,
\f(CWdrd_length\fP will be 8.  
For some dwarf 64 bit environments, such as ia64, \f(CWdrd_length\fP
is 4 for some relocations (file offsets, for example) 
and 8 for others (run time
addresses, for example).

If \f(CWdrd_type\fP is \f(CWdwarf_drt_none\fP, this is an unused slot
and it should be ignored.

If \f(CWdrd_type\fP is \f(CWdwarf_drt_data_reloc\fP 
this is an ordinary relocation.
The relocation type means either
(R_MIPS_64) or (R_MIPS_32) (or the like for
the particular ABI.
\f(CWdrd_length\fP gives the length of the field to be relocated.
\f(CWdrd_offset\fP
is an offset (of the
value to be relocated) in
the section this relocation stuff is linked to.
\f(CWdrd_symbol_index\fP
is the symbol index (if elf symbol
indices were provided) or the handle to arbitrary
information (if that is what the caller passed in 
to the relocation-creating dwarf calls) of the symbol
that the relocation is relative to.


When \f(CWdrd_type\fP is \f(CWdwarf_drt_first_of_length_pair\fP
the next data record will be \f(CWdrt_second_of_length_pair\fP
and the \f(CWdrd_offset\fP of the two data records will match.
The relevant 'offset' in the section this reloc applies to
should contain a symbolic pair like
.nf
.in +4
 .word    second_symbol - first_symbol
.in -4
.fi
to generate a length.
\f(CWdrd_length\fP gives the length of the field to be relocated.

\f(CWdrt_segment_rel\fP
means (R_MIPS_SCN_DISP)
is the real relocation (R_MIPS_SCN_DISP applies to
exception tables and this part may need further work).
\f(CWdrd_length\fP gives the length of the field to be relocated.

.P
The memory space of the section byte stream is freed
by the \f(CWdwarf_producer_finish_a() \fP call
(or would be if the \f(CWdwarf_producer_finish_a() \fP
was actually correct), along
with all the other space in use with that Dwarf_P_Debug.

.H 3 "dwarf_reset_section_bytes()"

.DS
\f(CWvoid dwarf_reset_section_bytes(
        Dwarf_P_Debug dbg
        )\fP
.DE
The function \f(CWdwarf_reset_section_bytes() \fP 
is used to reset the internal information so that
\f(CWdwarf_get_section_bytes() \fP will begin (on the next
call) at the initial dwarf section again.
It also resets so that calls to 
\f(CWdwarf_get_relocation_info() \fP
will begin again at the initial array of relocation information.

Some dwarf producers need to be able to run through
the \f(CWdwarf_get_section_bytes()\fP
and/or
the \f(CWdwarf_get_relocation_info()\fP
calls more than once and this call makes additional 
passes possible.
The set of Dwarf_Ptr values returned is identical to the
set returned by the first pass.
It is acceptable to call this before finishing a pass
of \f(CWdwarf_get_section_bytes()\fP
or
\f(CWdwarf_get_relocation_info()\fP
calls.
No errors are possible as this just resets some
internal pointers.
It is unwise to call this before
\f(CWdwarf_transform_to_disk_form() \fP has been called.
.P

.H 3 "dwarf_pro_get_string_stats()"
.DS
\f(CWint dwarf_pro_get_string_stats(
    Dwarf_P_Debug dbg,
    Dwarf_Unsigned * str_count,
    Dwarf_Unsigned * str_total_length,
    Dwarf_Unsigned * strp_count_debug_str,
    Dwarf_Unsigned * strp_len_debug_str,
    Dwarf_Unsigned * strp_reused_count,
    Dwarf_Unsigned * strp_reused_len,
    Dwarf_Error* error) \fP
.DE
If it returns 
\f(CWDW_DLV_OK\fP 
the function 
\f(CWdwarf_pro_get_string_stats()\fP 
returns information about how 
\f(CWDW_AT_name\fP 
etc strings were stored in the output object.
The values suggest how much string duplication
was detected in the DWARF being created.
.P
Call it after calling
\f(CWdwarf_transform_to_disk_form()\fP
and before calling
\f(CWdwarf_producer_finish_a()\fP .
It has no effect on the object being output.
.P
On error it returns
\f(CWDW_DLV_ERROR\fP 
and sets
\f(CWerror\fP 
through the pointer.


.H 3 "dwarf_producer_finish_a()"
.DS
\f(CWint dwarf_producer_finish_a(
        Dwarf_P_Debug dbg,
        Dwarf_Error* error) \fP
.DE
This is new in September 2016 and has the newer interface style,
but is otherwise identical to
\f(CWdwarf_producer_finish() \fP.
.P
The function 
\f(CWdwarf_producer_finish_a() \fP
should be called after all 
the bytes of data have been copied somewhere
(normally the bytes are written to disk).  
It frees all dynamic space 
allocated for \f(CWdbg\fP, include space for the structure pointed to by
\f(CWdbg\fP.  
This should not be called till the data have been 
copied or written 
to disk or are no longer of interest.  
It returns 
\f(CWDW_DLV_OK\fP 
if successful.
.P
On error it returns
\f(CWDW_DLV_ERROR\fP 
and sets
\f(CWerror\fP 
through the pointer.

.H 4 "dwarf_producer_finish()"
.DS
\f(CWDwarf_Unsigned dwarf_producer_finish(
        Dwarf_P_Debug dbg,
        Dwarf_Error* error) \fP
.DE
This is the original interface. 
It works but calling 
\f(CWdwarf_producer_finish_a() \fP
is preferred as it matches the latest libdwarf
interface standard.
.P
The function 
\f(CWdwarf_producer_finish() \fP
should be called after all 
the bytes of data have been copied somewhere
(normally the bytes are written to disk).  
It frees all dynamic space 
allocated for \f(CWdbg\fP, include space for the structure pointed to by
\f(CWdbg\fP.  
This should not be called till the data have been 
copied or written 
to disk or are no longer of interest.  
It returns zero if successful.
.P
On error it returns
\f(CWDW_DLV_NOCOUNT\fP 
and sets
\f(CWerror\fP 
through the pointer.

.H 2 "Debugging Information Entry Creation"
The functions in this section add new \f(CWDIE\fPs to the object,
and also the relationships among the \f(CWDIE\fP to be specified
by linking them up as parents, children, left or right siblings
of each other.  
In addition, there is a function that marks the
root of the graph thus created.

.H 3 "dwarf_add_die_to_debug_a()"
.DS
\f(CWint dwarf_add_die_to_debug_a(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die first_die,
        Dwarf_Error *error) \fP
.DE
The function 
\f(CWdwarf_add_die_to_debug_a() \fP indicates to 
\f(CWLibdwarf\fP
the root 
\f(CWDIE\fP of the 
\f(CWDIE\fP graph that has been built so far.  
It is intended to mark the compilation-unit \f(CWDIE\fP for the 
object represented by \f(CWdbg\fP.  
The root \f(CWDIE\fP
is specified 
by \f(CWfirst_die\fP.
.P
It returns 
\f(CWDW_DLV_OK\fP on success, and 
\f(CWDW_DLV_error\fP on error.

Function created 2016.

.H 4 "dwarf_add_die_to_debug()"
.DS
\f(CWDwarf_Unsigned dwarf_add_die_to_debug(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die first_die,
        Dwarf_Error *error) \fP
.DE
This is the original form of the call.
Use \f(CWdwarf_add_die_to_debug_a() instead.
.P
It returns \f(CW0\fP on success, and 
\f(CWDW_DLV_NOCOUNT\fP on error.

.H 3 "dwarf_new_die_a()"
.DS
\f(CWint dwarf_new_die_a(
        Dwarf_P_Debug dbg, 
        Dwarf_Tag new_tag,
        Dwarf_P_Die parent,
        Dwarf_P_Die child,
        Dwarf_P_Die left_sibling, 
        Dwarf_P_Die right_sibling,
        Dwarf_P_Die *die_out,
        Dwarf_Error *error) \fP
.DE
New September 2016.
On success 
\f(CWdwarf_new_die_a() \fP 
returns DW_DLV_OK
and
creates a new \f(CWDIE\fP with
its parent, child, left sibling, and right sibling \f(CWDIE\fPs
specified by 
\f(CWparent\fP, 
\f(CWchild\fP, 
\f(CWleft_sibling\fP,
and \f(CWright_sibling\fP, respectively.  
The new die is passed to the caller via the
argument
\f(CWdie_out() \fP .
There is no requirement
that all of these \f(CWDIE\fPs
be specified, i.e. any of these
descriptors may be \f(CWNULL\fP.  
If none is specified, this will
be an isolated \f(CWDIE\fP.  
A \f(CWDIE\fP is 
transformed to disk form by \f(CWdwarf_transform_to_disk_form() \fP 
only if there is a path from
the 
\f(CWDIE\fP
specified by 
\f(CWdwarf_add_die_to_debug\fP to it.
.P
The value of
\f(CWnew_tag\fP
is the tag which is given to the new
\f(CWDIE\fP.
\f(CWparent\fP,
\f(CWchild\fP, 
\f(CWleft_sibling\fP, and
\f(CWright_sibling\fP are pointers to establish links to existing 
\f(CWDIE\fPs.
Only one of 
\f(CWparent\fP, 
\f(CWchild\fP, 
\f(CWleft_sibling\fP, and 
\f(CWright_sibling\fP may be non-NULL.
If \f(CWparent\fP
(\f(CWchild\fP) is given, the \f(CWDIE\fP is 
linked into the list after (before) the \f(CWDIE\fP pointed to.  
If \f(CWleft_sibling\fP
(\f(CWright_sibling\fP) is given, the 
\f(CWDIE\fP
is linked into the list after (before) the \f(CWDIE\fP 
pointed to.
.P
To add attributes to the new \f(CWDIE\fP, 
use the \f(CWAttribute Creation\fP 
functions defined in the next section.
.P
On failure
\f(CWdwarf_new_die_a() \fP 
returns DW_DLV_ERROR and sets 
\f(CW*error\fP. 

Function created 01 December 2018.

.H 4 "dwarf_new_die()"
.DS
\f(CWDwarf_P_Die dwarf_new_die(
        Dwarf_P_Debug dbg, 
        Dwarf_Tag new_tag,
        Dwarf_P_Die parent,
        Dwarf_P_Die child,
        Dwarf_P_Die left_sibling, 
        Dwarf_P_Die right_sibling,
        Dwarf_Error *error) \fP
.DE
This is the original form of the function and
users should switch to calling
\f(CWdwarf_new_die_a()\fP 
instead to use the newer interface.
See
\f(CWdwarf_new_die_a()\fP 
for details (both functions do the same thing).

.H 3 "dwarf_die_link_a()"
.DS
\f(CWint dwarf_die_link_a(
        Dwarf_P_Die die, 
        Dwarf_P_Die parent,
        Dwarf_P_Die child,
        Dwarf_P_Die left-sibling, 
        Dwarf_P_Die right_sibling,
        Dwarf_Error *error) \fP
.DE
New September 2016.
On success
the function 
\f(CWdwarf_die_link_a() \fP 
returns 
\f(CWDW_DLV_OK\fP
and
links an existing 
\f(CWDIE\fP
described by the given
\f(CWdie\fP to other existing 
\f(CWDIE\fPs.
The given
\f(CWdie\fP can be linked to a parent
\f(CWDIE\fP, a child
\f(CWDIE\fP, a left sibling
\f(CWDIE\fP, or a right sibling
\f(CWDIE\fP
by specifying non-NULL 
\f(CWparent\fP, 
\f(CWchild\fP, 
\f(CWleft_sibling\fP,
and \f(CWright_sibling\fP 
\f(CWDwarf_P_Die\fP
descriptors.  

Only one of \f(CWparent\fP,
\f(CWchild\fP,
\f(CWleft_sibling\fP,
and \f(CWright_sibling\fP may be non-NULL.  
If \f(CWparent\fP
(\f(CWchild\fP) is given, the \f(CWDIE\fP is linked into the list 
after (before) the \f(CWDIE\fP pointed to.  
If \f(CWleft_sibling\fP
(\f(CWright_sibling\fP) is given, the 
\f(CWDIE\fP
is linked into 
the list after (before) the \f(CWDIE\fP pointed to.  
Non-NULL links
overwrite the corresponding links the given \f(CWdie\fP may have
had before the call to 
\f(CWdwarf_die_link_a() \fP.

If there is an error
\f(CWdwarf_die_link_a() \fP 
returns 
\f(CWDW_DLV_ERROR\fP 
and sets
\f(CWerror\fP 
with the specific applicable error code.


.H 4 "dwarf_die_link()"
.DS
\f(CWDwarf_P_Die dwarf_die_link(
        Dwarf_P_Die die, 
        Dwarf_P_Die parent,
        Dwarf_P_Die child,
        Dwarf_P_Die left-sibling, 
        Dwarf_P_Die right_sibling,
        Dwarf_Error *error) \fP
.DE
This is the original function to link
\f(CWDIEs\fP together.
The function 
does the same thing as 
\f(CWdwarf_die_link_a()\fP but.
the newer function is simpler to
work with.


.H 2 "DIE Markers"
DIE markers provide a way for a producer to extract DIE offsets
from DIE generation.  The markers do not influence the
generation of DWARF, they simply allow a producer to
extract .debug_info offsets for whatever purpose the
producer finds useful (for example, a producer might
want some unique other section unknown
to libdwarf to know a particular DIE offset).

One marks one or more DIEs as desired any time before
calling \f(CWdwarf_transform_to_disk_form()\fP.

After calling \f(CWdwarf_transform_to_disk_form()\fP
call 
\f(CWdwarf_get_die_markers()\fP 
which has the offsets where the marked DIEs were written
in the generated .debug_info data.

.H 3 "dwarf_add_die_marker_a()"
.DS
\f(CWint dwarf_add_die_marker_a(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die die,
        Dwarf_Unsigned marker,
        Dwarf_Error *error) \fP
.DE
This is preferred over
\f(CWdwarf_add_die_marker()\fP.
The function 
\f(CWdwarf_add_die_marker_a()\fP 
writes the
value 
\f(CWmarker\fP
to the \f(CWDIE\fP descriptor given by
\f(CWdie\fP.  
Passing in a marker of 0 means 'there is no marker'
(zero is the default in DIEs).

It returns \f(CWDW_DLV_OK\fP, on success.  
On error it returns \f(CWDW_DLV_ERROR\fP.
.H 4 "dwarf_add_die_marker()"
.DS
\f(CWDwarf_Unsigned dwarf_add_die_marker(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die die,
        Dwarf_Unsigned marker,
        Dwarf_Error *error) \fP
.DE
This is preferred over
\f(CWdwarf_add_die_marker()\fP.
The function
\f(CWdwarf_add_die_marker_a()\fP
writes the
value
\f(CWmarker\fP
to the \f(CWDIE\fP descriptor given by
\f(CWdie\fP.
Passing in a marker of 0 means 'there is no marker'
(zero is the default in DIEs).

It returns \f(CW0\fP, on success.
On error it returns \f(CWDW_DLV_NOCOUNT\fP.

.H 4 "dwarf_get_die_marker_a()"
.DS
\f(CWint dwarf_get_die_marker_a(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die die,
        Dwarf_Unsigned *marker,
        Dwarf_Error *error) \fP
.DE
The function \f(CWdwarf_get_die_marker() \fP returns the
current marker value for this DIE
through the pointer \f(CWmarker\fP.
A marker value of 0 means 'no marker was set'.

It returns \f(CWDW_DLV_OK\fP, on success.  
On error it returns \f(CWDW_DLV_ERROR\fP.

.H 4 "dwarf_get_die_marker()"
.DS
\f(CWDwarf_Unsigned dwarf_get_die_marker(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die die,
        Dwarf_Unsigned *marker,
        Dwarf_Error *error) \fP
.DE
The function \f(CWdwarf_get_die_marker() \fP returns the
current marker value for this DIE
through the pointer \f(CWmarker\fP.
A marker value of 0 means 'no marker was set'.

It returns \f(CW0\fP, on success.  
On error it returns \f(CWDW_DLV_NOCOUNT\fP.

.H 3 "dwarf_get_die_markers_a()"
.DS
\f(CWint dwarf_get_die_markers_a(
        Dwarf_P_Debug dbg,
        Dwarf_P_Marker * marker_list,
        Dwarf_Unsigned *marker_count,
        Dwarf_Error *error) \fP
.DE 
The function \f(CWdwarf_get_die_markers_a()\fP returns
a pointer to an array of \f(CWDwarf_P_Marker\fP pointers to
\f(CWstruct Dwarf_P_Marker_s\fP structures through
the pointer \f(CWmarker_list\fP.
The array length is returned through the
pointer \f(CWmarker_count\fP.
    
The call is only meaningful after 
a call to \f(CWdwarf_transform_to_disk_form()\fP as the
transform call creates the \f(CWstruct Dwarf_P_Marker_s\fP
structures, one for each DIE generated for .debug_info
(but only for DIEs that had a non-zero marker value).
The field \f(CWma_offset\fP in the structure is set
during generation of the .debug_info byte stream.
The field \f(CWma_marker\fP in the structure is a copy
of the DIE marker of the DIE given that offset.

It returns \f(CWDW_DLV_OK\fP, on success.
On error it returns \f(CWDW_DLV_ERROR\fP (if there are no
markers it returns \f(CWDW_DLV_ERROR\fP).


.H 4 "dwarf_get_die_markers()"
.DS
\f(CWDwarf_Signed dwarf_get_die_markers(
        Dwarf_P_Debug dbg,
        Dwarf_P_Marker * marker_list,
        Dwarf_Unsigned *marker_count,
        Dwarf_Error *error) \fP
.DE
The function \f(CWdwarf_get_die_marker()\fP returns
a pointer to an array of \f(CWDwarf_P_Marker\fP pointers to
\f(CWstruct Dwarf_P_Marker_s\fP structures through
the pointer \f(CWmarker_list\fP.
The array length is returned through the
pointer \f(CWmarker_count\fP.

The call is only meaningful after 
a call to \f(CWdwarf_transform_to_disk_form()\fP as the
transform call creates the \f(CWstruct Dwarf_P_Marker_s\fP
structures, one for each DIE generated for .debug_info
(but only for DIEs that had a non-zero marker value).
The field \f(CWma_offset\fP in the structure is set
during generation of the .debug_info byte stream.
The field \f(CWma_marker\fP in the structure is a copy
of the DIE marker of the DIE given that offset.

It returns \f(CW0\fP, on success.
On error it returns \f(CWDW_DLV_BADADDR\fP (if there are no
markers it returns \f(CWDW_DLV_BADADDR\fP).

.H 2 "Attribute Creation"
The functions in this section add attributes to a \f(CWDIE\fP.
These functions return a \f(CWDwarf_P_Attribute\fP descriptor 
that represents the attribute added to the given \f(CWDIE\fP.  
In most cases the return value is only useful to determine if 
an error occurred.

Some of the attributes have values that are relocatable.  
They
need a symbol with respect to which the linker will perform
relocation.  
This symbol is specified by means of an index into
the Elf symbol table for the object
(of course, the symbol index can be more general than an index).

.H 3 "dwarf_add_AT_location_expr_a()"
.DS
\f(CWint dwarf_add_AT_location_expr_a(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die ownerdie,
        Dwarf_Half attr,
        Dwarf_P_Expr loc_expr,
        Dwarf_P_Attr *attr_out,
        Dwarf_Error *error) \fP
.DE
On success the function
\f(CWdwarf_add_AT_location_expr()\fP
returns
\f(CWDW_DLV_OK\fP
and adds the attribute
specified by
\f(CWattr\fP
to the
\f(CWDIE\fP descriptor given by
\f(CWownerdie\fP.
The new attribute is passed back
to the caller through the pointer
\f(CWattr_out\fP.

The attribute should be one that has a location
expression as its value.
The location expression that is the value
is represented by the
\f(CWDwarf_P_Expr\fP descriptor
\f(CWloc_expr\fP.

On error it returns 
\f(CWDW_DLV_ERROR\fP.


.H 4 "dwarf_add_AT_location_expr()"
.DS
\f(CWDwarf_P_Attribute dwarf_add_AT_location_expr(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die ownerdie,
        Dwarf_Half attr,
        Dwarf_P_Expr loc_expr,
        Dwarf_Error *error) \fP
.DE
The function 
\f(CWdwarf_add_AT_location_expr()\fP adds the attribute
specified by 
\f(CWattr\fP to the 
\f(CWDIE\fP descriptor given by
\f(CWownerdie\fP.
The attribute should be one that has a location
expression as its value.
The location expression that is the value
is represented by the 
\f(CWDwarf_P_Expr\fP descriptor 
\f(CWloc_expr\fP.

It returns the 
\f(CWDwarf_P_Attribute\fP descriptor for the attribute
given, on success.  

On error it returns 
\f(CWDW_DLV_BADADDR\fP.

.H 3 "dwarf_add_AT_name_a()"
.DS
\f(CWint dwarf_add_AT_name_a(
        Dwarf_P_Die ownerdie, 
        char *name,
        Dwarf_P_Attribute * attr_out,
        Dwarf_Error *error) \fP
.DE
New November 2018, a better alternative to
\f(CWdwarf_add_AT_name()\fP.

The function \f(CWdwarf_add_AT_name_a() \fP adds
the string specified by
\f(CWname\fP as the
value of the \f(CWDW_AT_name\fP attribute for the
given \f(CWDIE\fP, \f(CWownerdie\fP.  It returns
DW_DLV_OK on success and assignes the new
attribute descriptor to
\f(CW*attr_out\fP.

On error it returns
\f(CWDW_DLV_ERROR\fP
and does not set
\f(CW*attr_out\fP.

.H 4 "dwarf_add_AT_name()"
.DS
\f(CWDwarf_P_Attribute dwarf_add_AT_name(
        Dwarf_P_Die ownerdie, 
        char *name,
        Dwarf_Error *error) \fP
.DE
The function 
\f(CWdwarf_add_AT_name()\fP 
adds
the string specified by 
\f(CWname\fP as the
value of the
\f(CWDW_AT_name\fP attribute for the
given \f(CWDIE\fP, \f(CWownerdie\fP.  It returns
the \f(CWDwarf_P_attribute\fP descriptor for the
\f(CWDW_AT_name\fP attribute on success.  On error,
it returns \f(CWDW_DLV_BADADDR\fP.

.H 3 "dwarf_add_AT_comp_dir_a()"
.DS
\f(CWint dwarf_add_AT_comp_dir_a(
        Dwarf_P_Die ownerdie,
        char *current_working_directory,
        Dwarf_P_Attribute *attr_out,
        Dwarf_Error *error) \fP
.DE
The function 
\f(CWdwarf_add_AT_comp_dir_a\fP adds the string given by
\f(CWcurrent_working_directory\fP as the value of the
\f(CWDW_AT_comp_dir\fP
attribute for the
\f(CWDIE\fP described by the given 
\f(CWownerdie\fP.  
On success it returns 
\f(CWDW_DLV_OK\fP
and sets
\f(CW*attr_out\fP to the new attribute.
.P
On error, it returns 
\f(CWDW_DLV_ERROR\fP
and does not touch \f(CWattr_out\fP .

.H 4 "dwarf_add_AT_comp_dir()"
.DS
\f(CWDwarf_P_Attribute dwarf_add_AT_comp_dir(
        Dwarf_P_Die ownerdie,
        char *current_working_directory,
        Dwarf_Error *error) \fP
.DE
The function \f(CWint dwarf_add_AT_comp_dir\fP
adds the string given by
\f(CWcurrent_working_directory\fP
as the value of the 
\f(CWDW_AT_comp_dir\fP
attribute for the 
\f(CWDIE\fP described by the given
\f(CWownerdie\fP.  
It returns the \f(CWDwarf_P_Attribute\fP for this attribute on success.
On error, it returns
\f(CWDW_DLV_BADADDR\fP.

.H 3 "dwarf_add_AT_producer_a()"
.DS
\f(CWint dwarf_add_AT_producer_a(
        Dwarf_P_Die ownerdie,
        char *producer_string,
        Dwarf_P_Attribute *attr_out,
        Dwarf_Error *error) \fP
.DE
The function 
\f(CWdwarf_add_AT_producer()\fP
adds the string given by
\f(CWproducer_string\fP as the value of the 
\f(CWDW_AT_producer\fP
attribute for the 
\f(CWDIE\fP given by 
\f(CWownerdie\fP.

On success it returns
\f(CWDW_DLV_OK\fP
and returns the new attribute descriptor 
representing this attribute
through the pointer argument
\f(CWattr_out\fP.

On error, it returns 
\f(CWDW_DLV_ERROR\fP.


.H 4 "dwarf_add_AT_producer()"
.DS
\f(CWDwarf_P_Attribute dwarf_add_AT_producer(
        Dwarf_P_Die ownerdie,
        char *producer_string,
        Dwarf_Error *error) \fP
.DE
The function \f(CWdwarf_add_AT_producer() \fP adds the string given by
\f(CWproducer_string\fP
as the value of the 
\f(CWDW_AT_producer\fP
attribute for the \f(CWDIE\fP given by 
\f(CWownerdie\fP.  It returns
the \f(CWDwarf_P_Attribute\fP descriptor representing this attribute
on success.  On error, it returns 
\f(CWDW_DLV_BADADDR\fP.

.H 3 "dwarf_add_AT_any_value_sleb_a()"
.DS
\f(CWint dwarf_add_AT_any_value_sleb_a(
        Dwarf_P_Die ownerdie,
        Dwarf_Half  attrnum,
        Dwarf_Signed signed_value,
        Dwarf_P_Attribute *out_attr,
        Dwarf_Error *error) \fP
.DE
The function 
\f(CWdwarf_add_AT_any_value_sleb_a()\fP adds the
given 
\f(CWDwarf_Signed\fP value 
\f(CWsigned_value\fP as the value
of the 
\f(CWDW_AT_const_value\fP attribute for the 
\f(CWDIE\fP
described by the given \f(CWownerdie\fP.

The FORM of the output value is 
\f(CWDW_FORM_sdata\fP (signed leb number)
and the attribute will be \f(CWDW_AT_const_value\fP.

On success it returns
\f(CWDW_DLV_OK\fP
and sets
\f(CW*out_attr\fP to the created attribute.

On error, it returns \f(CWDW_DLV_ERROR\fP.

The function was created 01 December 2018.


.H 4 "dwarf_add_AT_any_value_sleb()"
.DS
\f(CWDwarf_P_Attribute dwarf_add_AT_any_value_sleb(
        Dwarf_P_Die ownerdie,
        Dwarf_Half  attrnum,
        Dwarf_Signed signed_value,
        Dwarf_Error *error) \fP
.DE
The function \f(CWdwarf_add_AT_any_value_sleb() \fP adds the
given \f(CWDwarf_Signed\fP value \f(CWsigned_value\fP as the value
of the \f(CWDW_AT_const_value\fP attribute for the \f(CWDIE\fP
described by the given \f(CWownerdie\fP.

The FORM of the output value is \f(CWDW_FORM_sdata\fP (signed leb number)
and the attribute will be \f(CWDW_AT_const_value\fP.

It returns the
\f(CWDwarf_P_Attribute\fP descriptor for this attribute on success.

On error, it returns \f(CWDW_DLV_BADADDR\fP.

The function was created 13 August 2013.

.H 3 "dwarf_add_AT_const_value_signedint_a()"
.DS
\f(CWint dwarf_add_AT_const_value_signedint_a(
        Dwarf_P_Die ownerdie,
        Dwarf_Signed signed_value,
        Dwarf_P_Attribute *attr_out,
        Dwarf_Error *error) \fP
.DE
The function 
\f(CWdwarf_add_AT_const_value_signedint_a\fP adds the
given 
\f(CWDwarf_Signed\fP value 
\f(CWsigned_value\fP as the value
of the \f(CWDW_AT_const_value\fP attribute for the \f(CWDIE\fP
described by the given \f(CWownerdie\fP.

The FORM of the output value is 
\f(CWDW_FORM_data<n>\fP (signed leb number)
and the attribute will be \f(CWDW_AT_const_value\fP.

With this interface and output, there is no way for consumers
to know from the FORM that the value is signed.


On success it returns \f(CWDW_DLV_OK\fP
and sets *attr_out to the created attribute.

On error, it returns \f(CWDW_DLV_ERROR\fP.


.H 4 "dwarf_add_AT_const_value_signedint()"
.DS
\f(CWDwarf_P_Attribute dwarf_add_AT_const_value_signedint(
        Dwarf_P_Die ownerdie,
        Dwarf_Signed signed_value,
        Dwarf_Error *error) \fP
.DE
The function \f(CWdwarf_add_AT_const_value_signedint\fP adds the
given \f(CWDwarf_Signed\fP value \f(CWsigned_value\fP as the value
of the \f(CWDW_AT_const_value\fP attribute for the \f(CWDIE\fP
described by the given \f(CWownerdie\fP.  

The FORM of the output value is \f(CWDW_FORM_data<n>\fP (signed leb number)
and the attribute will be \f(CWDW_AT_const_value\fP.

With this interface and output, there is no way for consumers
to know from the FORM that the value is signed.


It returns the 
\f(CWDwarf_P_Attribute\fP descriptor for this attribute on success.  

On error, it returns \f(CWDW_DLV_BADADDR\fP.


.H 3 "dwarf_add_AT_implicit_const()"
.DS
\f(CWint dwarf_add_AT_implicit_const(Dwarf_P_Die ownerdie,
    Dwarf_Half attrnum,
    Dwarf_Signed signed_value,
    Dwarf_P_Attribute *outattr,
    Dwarf_Error * error); \fP
.DE
The function
\f(CWdwarf_add_AT_implicit_const\fP
creates a new attribute and
adds the signed value to the abbreviation entry
for this new attribute and attaches the new attribute
to the DIE passed in.
.P
The new attribute has
 \f(CWattrnum\fP attribute for the \f(CWDIE\fP described
by the given \f(CWownerdie\fP.
The
\f(CWform\fP in the generated attribute is
\f(CWDW_FORM_implicit_const.\fP
The
\f(CWsigned_value\fP argument will be inserted
in the abbreviation table as a signed leb
value.
.P
For a successfull call the function returns
\f(CWDW_DLV_OK.\fP
and a pointer to the created argument is returned
through the pointer 
\f(CWoutaddr.\fP

.P
In case of error the function returns
\f(CWDW_DLV_ERROR\fP
and no attribute is created.

.H 3 "dwarf_add_AT_any_value_uleb_a()"
.DS
\f(CWint dwarf_add_AT_any_value_uleb_a(
        Dwarf_P_Die ownerdie,
        Dwarf_Half  attrnum,
        Dwarf_Unsigned unsigned_value,
        Dwarf_P_Attribute *attr_out,
        Dwarf_Error *error) \fP
.DE
The function 
\f(CWdwarf_add_AT_any_value_uleb_a\fP adds the
given 
\f(CWDwarf_Unsigned\fP value 
\f(CWunsigned_value\fP as the value
of the 
\f(CWattrnum\fP attribute for the 
\f(CWDIE\fP described
by the given \f(CWownerdie\fP.

The FORM of the output value is 
\f(CWDW_FORM_udata\fP (unsigned leb number)
and the attribute is \f(CWattrnum\fP.

On success it returns
\f(CWDW_DLV_OK\fP
and sets
\f(CW*attr_out\fP
to the newly created attribute.

On error, it returns \f(CWDW_DLV_ERROR\fP.

The function was created 01 December 2018.


.H 4 "dwarf_add_AT_any_value_uleb()"
.DS
\f(CWDwarf_P_Attribute dwarf_add_AT_any_value_uleb(
        Dwarf_P_Die ownerdie,
        Dwarf_Half  attrnum,
        Dwarf_Unsigned unsigned_value,
        Dwarf_Error *error) \fP
.DE
The function \f(CWdwarf_add_AT_any_value_uleb\fP adds the
given \f(CWDwarf_Unsigned\fP value \f(CWunsigned_value\fP as the value
of the \f(CWattrnum\fP attribute for the \f(CWDIE\fP described
by the given \f(CWownerdie\fP.

The FORM of the output value is \f(CWDW_FORM_udata\fP (unsigned leb number)
and the attribute is \f(CWattrnum\fP.

It returns the \f(CWDwarf_P_Attribute\fP
descriptor for this attribute on success.

On error, it returns \f(CWDW_DLV_BADADDR\fP.

The function was created 13 August 2013.

.H 3 "dwarf_add_AT_const_value_unsignedint_a()"
.DS
\f(CWint dwarf_add_AT_const_value_unsignedint_a(
        Dwarf_P_Die ownerdie,
        Dwarf_Unsigned unsigned_value,
        Dwarf_P_Attribute *attr_out,
        Dwarf_Error *error)\fP
.DE
The function 
\f(CWdwarf_add_AT_const_value_unsignedint_a\fP adds the
given 
\f(CWDwarf_Unsigned\fP value 
\f(CWunsigned_value\fP as the value
of the 
\f(CWDW_AT_const_value\fP attribute for the 
\f(CWDIE\fP described
by the given 
\f(CWownerdie\fP.

The FORM of the output value is 
\f(CWDW_FORM_data<n>\fP
and the attribute will be 
\f(CWDW_AT_const_value\fP.

With this interface and output, there is no way for consumers
to know from the FORM that the value is signed.

On success it returns
\f(CWDW_DLV_OK\fP.
and sets \f(CW*attr_out\fP
to the newly created attribute.

On error, it returns \f(CWDW_DLV_ERROR\fP.
Created 01 December 2018.

.H 4 "dwarf_add_AT_const_value_unsignedint()"
.DS
\f(CWDwarf_P_Attribute dwarf_add_AT_const_value_unsignedint(
        Dwarf_P_Die ownerdie,
        Dwarf_Unsigned unsigned_value,
        Dwarf_Error *error) \fP
.DE
The function \f(CWdwarf_add_AT_const_value_unsignedint\fP adds the
given \f(CWDwarf_Unsigned\fP value \f(CWunsigned_value\fP as the value
of the \f(CWDW_AT_const_value\fP attribute for the \f(CWDIE\fP described 
by the given \f(CWownerdie\fP.  

The FORM of the output value is \f(CWDW_FORM_data<n>\fP
and the attribute will be \f(CWDW_AT_const_value\fP.

With this interface and output, there is no way for consumers
to know from the FORM that the value is signed.

It returns the \f(CWDwarf_P_Attribute\fP
descriptor for this attribute on success.  

On error, it returns \f(CWDW_DLV_BADADDR\fP.

.H 3 "dwarf_add_AT_const_value_string_a()"
.DS
\f(CWint dwarf_add_AT_const_value_string_a(
    Dwarf_P_Die ownerdie,
    char *string_value,
    Dwarf_P_Attribute *attr_out,
    Dwarf_Error *error) \fP
.DE
The function 
\f(CWdwarf_add_AT_const_value_string_afP adds the
string value given by 
\f(CWstring_value\fP as the value of the
\f(CWDW_AT_const_value\fP attribute for the 
\f(CWDIE\fP described
by the given 
\f(CWownerdie\fP.  
.P
On success it returns 
\f(CWDW_DLV_OK\fP
\f(CW*attr_out\fP
to a newly created attribute.
.P
On error, it returns
\f(CWDW_DLV_ERROR\fP.

Function created 01 December 2018.

.H 4 "dwarf_add_AT_const_value_string()"
.DS
\f(CWDwarf_P_Attribute dwarf_add_AT_const_value_string(
        Dwarf_P_Die ownerdie,
        char *string_value,
        Dwarf_Error *error) \fP
.DE
The function 
\f(CWdwarf_add_AT_const_value_stringfP adds the 
string value given by 
\f(CWstring_value\fP as the value of the 
\f(CWDW_AT_const_value\fP attribute for the 
\f(CWDIE\fP described 
by the given 
\f(CWownerdie\fP.  
.P
It returns the 
\f(CWDwarf_P_Attribute\fP
descriptor for this attribute on success.  On error, it returns
\f(CWDW_DLV_BADADDR\fP.

.H 3 "dwarf_add_AT_targ_address_c()"
.DS
\f(CWint dwarf_add_AT_targ_address_c(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die ownerdie,
        Dwarf_Half attr,
        Dwarf_Unsigned pc_value,
        Dwarf_Unsigned sym_index,  
        Dwarf_P_Attribute *attr_out,
        Dwarf_Error *error) \fP
.DE
The function 
\f(CWdwarf_add_AT_targ_address_cfP 
is identical to 
\f(CWdwarf_add_AT_targ_address_bfP
except for the return value and an added argument.
Because this is type-safe use this instead of
\f(CWdwarf_add_AT_targ_address_bfP.

.P
\f(CWsym_index\fP is guaranteed to
be large enough that it can contain a pointer to
arbitrary data (so the caller can pass in a real elf
symbol index, an arbitrary number, or a pointer
to arbitrary data).
The ability to pass in a pointer through 
\f(CWsym_index\fP
is only usable with
\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP.

On success the function returns
\f(CWDW_DLV_OK\fP
\f(CWDwarf_P_Attribute\fP
and
\f(CWpc_value\fP
is put into the section stream output and
the 
\f(CWsym_index\fP is applied to the relocation
information.

On failure it returns
\f(CWDW_DLV_ERROR\fP.

Do not use this function for attr 
\f(CWDW_AT_high_pc\fP
if the value to be recorded is an offset (not a pc)
[ use 
\f(CWdwarf_add_AT_unsigned_const_afP
or  
\f(CWdwarf_add_AT_any_value_uleb_afP
instead].

On failure the function returns
\f(CWDW_DLV_ERROR\fP

Function created 01 December 2018.

.H 4 "dwarf_add_AT_targ_address()"
.DS
\f(CWDwarf_P_Attribute dwarf_add_AT_targ_address(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die ownerdie,
        Dwarf_Half attr,
        Dwarf_Unsigned pc_value,
        Dwarf_Signed sym_index,
        Dwarf_Error *error) \fP
.DE
The function 
\f(CWdwarf_add_AT_targ_address\fP
adds an attribute that
belongs to the "address" class to the die specified by 
\f(CWownerdie\fP.  
The attribute is specified by 
\f(CWattr\fP, and the object that the 
\f(CWDIE\fP belongs to is specified by 
\f(CWdbg\fP.  The relocatable 
address that is the value of the attribute is specified by 
\f(CWpc_value\fP. 
The symbol to be used for relocation is specified by the 
\f(CWsym_index\fP,
which is the index of the symbol in the Elf symbol table.

It returns the 
\f(CWDwarf_P_Attribute\fP descriptor for the attribute
on success, and 
\f(CWDW_DLV_BADADDR\fP on error.



.H 4 "dwarf_add_AT_targ_address_b()"
.DS
\f(CWDwarf_P_Attribute dwarf_add_AT_targ_address_b(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die ownerdie,
        Dwarf_Half attr,
        Dwarf_Unsigned pc_value,
        Dwarf_Unsigned sym_index,
        Dwarf_Error *error) \fP
.DE
Please use
\f(CWdwarf_add_AT_targ_address_c\fP 
instead of
\f(CWdwarf_add_AT_targ_address_b\fP 
or
\f(CWdwarf_add_AT_targ_address\fP 
when is is convient for you.
The function 
\f(CWdwarf_add_AT_targ_address_b\fP 
is identical to 
\f(CWdwarf_add_AT_targ_address\fP
except that 
\f(CWsym_index\fP is guaranteed to 
be large enough that it can contain a pointer to
arbitrary data (so the caller can pass in a real elf
symbol index, an arbitrary number, or a pointer
to arbitrary data).  
The ability to pass in a pointer through 
\f(CWsym_index\fP
is only usable with 
\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP.

The 
\f(CWpc_value\fP
is put into the section stream output and
the 
\f(CWsym_index\fP is applied to the relocation
information.

Do not use this function for attr 
\f(CWDW_AT_high_pc\fP
if the value to be recorded is an offset (not a pc)
[ use 
\f(CWdwarf_add_AT_unsigned_const_a\fP  
or  
\f(CWdwarf_add_AT_any_value_uleb_a\fP 
instead].

.H 3 "dwarf_add_AT_block_a()"
.DS
\f(CWint dwarf_add_AT_block_a(
    Dwarf_P_Debug       dbg,
    Dwarf_P_Die         ownerdie,
    Dwarf_Half          attr,
    Dwarf_Small         *block_data,
    Dwarf_Unsigned      block_size,
    Dwarf_P_Attribute*  attr_out,
    Dwarf_Error         *error)
.DE
On success this returns 
\f(CWDW_DLV_OK\fP
an attribute
with a
\f(CWDW_FORM_block\fP
instance
(does not create 
\f(CWDW_FORM_block1\fP,
\f(CWDW_FORM_block2\fP, or
\f(CWDW_FORM_block4\fP
at present)
and returns a pointer to the new attribute
through the pointer
\f(CWattr_out\fP.

On failure this returns
\f(CWDW_DLV_ERROR\fP

/*  New December 2018. Preferred version. */

.H 4 "dwarf_add_AT_block()"
.DS
\f(CWDwarf_P_Attribute dwarf_add_AT_block(
    Dwarf_P_Debug       dbg,
    Dwarf_P_Die         ownerdie,
    Dwarf_Half          attr,
    Dwarf_Small         *block_data,
    Dwarf_Unsigned      block_size,
    Dwarf_Error         *error)
.DE
On success this returns 
an attribute pointer
just as
\f(CWdwarf_add_AT_block_a\fP
 does
and returns the attribute.

On failure it returns
\f(CWDW_DLV_BADADDR\fP.

jjk


.H 3 "dwarf_add_AT_dataref_a()"
.DS
\f(CWint dwarf_add_AT_dataref_a(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die ownerdie,
        Dwarf_Half attr,
        Dwarf_Unsigned pc_value,
        Dwarf_Unsigned sym_index,
        Dwarf_P_Attribute *attr_out,
        Dwarf_Error *error) \fP
.DE
This is very similar to 
\f(CWdwarf_add_AT_targ_address_b\fP
but results in a different FORM (results in DW_FORM_data4
or DW_FORM_data8).

Useful for adding relocatable addresses in location lists.

\f(CWsym_index\fP is guaranteed to
be large enough that it can contain a pointer to
arbitrary data (so the caller can pass in a real elf
symbol index, an arbitrary number, or a pointer
to arbitrary data).
The ability to pass in a pointer through 
\f(CWsym_index\fP
is only usable with
\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP.

On success it returns 
\f(CWDW_DLV_OK\fP
and
the 
\f(CWpc_value\fP
is put into the section stream output and
the 
\f(CWsym_index\fP is applied to the relocation
information.

Do not use this function for 
\f(CWDW_AT_high_pc\fP, use
\f(CWdwarf_add_AT_unsigned_const\fP
or 
\f(CWdwarf_add_AT_any_value_uleb\fP
[ if the value to be recorded is
an offset of 
\f(CWDW_AT_low_pc\fP]
or 
\f(CWdwarf_add_AT_targ_address_b\fP [ if the value
to be recorded is an address].

Function created 01 December 2018.

.H 4 "dwarf_add_AT_dataref()"
.DS
\f(CWDwarf_P_Attribute dwarf_add_AT_dataref(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die ownerdie,
        Dwarf_Half attr,
        Dwarf_Unsigned pc_value,
        Dwarf_Unsigned sym_index,
        Dwarf_Error *error) \fP
.DE
This is very similar to 
\f(CWdwarf_add_AT_targ_address_b\fP
but results in a different FORM (results in DW_FORM_data4
or DW_FORM_data8).

Useful for adding relocatable addresses in location lists.

\f(CWsym_index\fP is guaranteed to
be large enough that it can contain a pointer to
arbitrary data (so the caller can pass in a real elf
symbol index, an arbitrary number, or a pointer
to arbitrary data).
The ability to pass in a pointer through 
\f(CWsym_index\fP
is only usable with
\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP.

The 
\f(CWpc_value\fP
is put into the section stream output and
the 
\f(CWsym_index\fP is applied to the relocation
information.

Do not use this function for 
\f(CWDW_AT_high_pc\fP, use
\f(CWdwarf_add_AT_unsigned_const\fP 
or 
\f(CWdwarf_add_AT_any_value_uleb\fP 
[ if the value to be recorded is
an offset of 
\f(CWDW_AT_low_pc\fP]
or 
\f(CWdwarf_add_AT_targ_address_b\fP [ if the value
to be recorded is an address].

.H 3 "dwarf_add_AT_ref_address_a"
.DS
\f(CWint dwarf_add_AT_ref_address_a(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die ownerdie,
        Dwarf_Half attr,
        Dwarf_Unsigned pc_value,
        Dwarf_Unsigned sym_index,
        Dwarf_P_Attribute *attr_out,
        Dwarf_Error *error) \fP
.DE

This is very similar to 
\f(CWdwarf_add_AT_targ_address_c\fP
but results in a different FORM (results in 
\f(CWDW_FORM_ref_addr\fP
being generated).

Useful for  
\f(CWDW_AT_type\fP and 
\f(CWDW_AT_import\fP attributes.

\f(CWsym_index() \fP is guaranteed to
be large enough that it can contain a pointer to
arbitrary data (so the caller can pass in a real elf
symbol index, an arbitrary number, or a pointer
to arbitrary data).
The ability to pass in a pointer through \f(CWsym_index() \fP
is only usable with
\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP.

On success the function returns
\f(CWDW_DLV_OK\fP and
\f(CWpc_value\fP
is put into the section stream output and
the 
\f(CWsym_index\fP is applied to the relocation
information.

On failure the function returns
\f(CWDW_DLV_ERROR\fP.

Do not use this function for 
\f(CWDW_AT_high_pc\fP.  

Function created 01 December 2018.

.H 4 "dwarf_add_AT_ref_address()"
.DS
\f(CWDwarf_P_Attribute dwarf_add_AT_ref_address(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die ownerdie,
        Dwarf_Half attr,
        Dwarf_Unsigned pc_value,
        Dwarf_Unsigned sym_index,
        Dwarf_Error *error) \fP
.DE

This is very similar to \f(CWdwarf_add_AT_targ_address_b() \fP
but results in a different FORM (results in \f(CWDW_FORM_ref_addr\fP
being generated).

Useful for  \f(CWDW_AT_type\fP and \f(CWDW_AT_import\fP attributes.

\f(CWsym_index() \fP is guaranteed to
be large enough that it can contain a pointer to
arbitrary data (so the caller can pass in a real elf
symbol index, an arbitrary number, or a pointer
to arbitrary data).
The ability to pass in a pointer through 
\f(CWsym_index()\fP
is only usable with
\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP.

The 
\f(CWpc_value\fP
is put into the section stream output and
the 
\f(CWsym_index\fP is applied to the relocation
information.

Do not use this function for \f(CWDW_AT_high_pc\fP.

.H 3 "dwarf_add_AT_unsigned_const_a()"
.DS
\f(CWint dwarf_add_AT_unsigned_const_a(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die ownerdie,
        Dwarf_Half attr,
        Dwarf_Unsigned value,
        Dwarf_P_Attribute *attr_out,
        Dwarf_Error *error) \fP
.DE
The function 
\f(CWdwarf_add_AT_unsigned_const_a()\fP adds an attribute
with a 
\f(CWDwarf_Unsigned\fP value belonging to the "constant" class,
to the 
\f(CWDIE\fP specified by 
\f(CWownerdie\fP.  The object that
the 
\f(CWDIE\fP belongs to is specified by 
\f(CWdbg\fP.  The attribute
is specified by 
\f(CWattr\fP, and its value is specified by 
\f(CWvalue\fP.

The FORM of the output will be one of the 
\f(CWDW_FORM_data<n>\fP forms.


On success it returns 
\f(CWDW_DLV_OK\fP
and sets
\f(CW*attr_out\fP to the newly created attribute.

It returns
\f(CWDW_DLV_ERROR\fP on error.

Function created 01 December 2018.

.H 4 "dwarf_add_AT_unsigned_const()"
.DS
\f(CWDwarf_P_Attribute dwarf_add_AT_unsigned_const(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die ownerdie,
        Dwarf_Half attr,
        Dwarf_Unsigned value,
        Dwarf_Error *error) \fP
.DE
The function 
\f(CWdwarf_add_AT_unsigned_const()\fP adds an attribute
with a 
\f(CWDwarf_Unsigned\fP value belonging to the "constant" class, 
to the 
\f(CWDIE\fP specified by 
\f(CWownerdie\fP.  The object that
the 
\f(CWDIE\fP belongs to is specified by 
\f(CWdbg\fP.  The attribute
is specified by 
\f(CWattr\fP, and its value is specified by 
\f(CWvalue\fP.

The FORM of the output will be one of the 
\f(CWDW_FORM_data<n>\fP forms.

It returns the 
\f(CWDwarf_P_Attribute\fP descriptor for the attribute
on success, and 
\f(CWDW_DLV_BADADDR\fP on error.

.H 3 "dwarf_add_AT_signed_const_a()"
.DS
\f(CWint dwarf_add_AT_signed_const_a(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die ownerdie,
        Dwarf_Half attr,
        Dwarf_Signed value,
        Dwarf_P_Attribute *out_addr,
        Dwarf_Error *error) \fP
.DE
The function 
\f(CWdwarf_add_AT_signed_const_a()\fP adds an attribute
with a 
\f(CWDwarf_Signed\fP value belonging to the "constant" class,
to the 
\f(CWDIE\fP specified by 
\f(CWownerdie\fP.  The object that
the 
\f(CWDIE\fP belongs to is specified by 
\f(CWdbg\fP.  The attribute
is specified by 
\f(CWattr\fP, and its value is specified by 
\f(CWvalue\fP.

On success it returns
\f(CWDW_DLV_OK\fP and sets
\f(CW*out_addr\fP
with a pointer to the new attribute.

On error it returns
\f(CWDW_DLV_ERROR\fP.

Function created 01 December 2018.

.H 4 "dwarf_add_AT_signed_const()"
.DS
\f(CWDwarf_P_Attribute dwarf_add_AT_signed_const(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die ownerdie,
        Dwarf_Half attr,
        Dwarf_Signed value,
        Dwarf_Error *error) \fP
.DE
The function 
\f(CWdwarf_add_AT_signed_const()\fP adds an attribute
with a 
\f(CWDwarf_Signed\fP value belonging to the "constant" class,
to the 
\f(CWDIE\fP specified by 
\f(CWownerdie\fP.  The object that
the 
\f(CWDIE\fP belongs to is specified by 

\f(CWdbg\fP.  The attribute
is specified by 
\f(CWattr\fP, and its value is specified by 
\f(CWvalue\fP.

It returns the 
\f(CWDwarf_P_Attribute\fP descriptor for the attribute
on success, and 
\f(CWDW_DLV_BADADDR\fP on error.

.H 3 "dwarf_add_AT_reference_c()"
.DS
\f(CWint dwarf_add_AT_reference_c(
        Dwarf_P_Debug dbg,
        Dwarf_Half attr,
        Dwarf_P_Die ownerdie,
        Dwarf_P_Die otherdie,
        Dwarf_P_Attribute *attr_out,
        Dwarf_Error *error)\fP
.DE
The function 
\f(CWdwarf_add_AT_reference_c()\fP
is the same as  
\f(CWdwarf_add_AT_reference_b()\fP
except that 
\f(CWdwarf_add_AT_reference_c()\fP
returns a simple error code.

\f(CWdwarf_add_AT_reference_c()\fP
accepts a NULL 
\f(CWotherdie\fP with the assumption
that 
\f(CWdwarf_fixup_AT_reference_die()\fP
will be called by user code
to fill in the missing 
\f(CWotherdie\fP
before the DIEs are transformed to disk form.

On success it returns
\f(CWDW_DLV_OK\fP
and returns a pointer to the new attribute
through \f(CW*attr_out\fP.

On failure it returns
\f(CWDW_DLV_ERROR\fP.

Function created 01 December 2018.

.H 4 "dwarf_add_AT_reference()"
.DS
\f(CWDwarf_P_Attribute dwarf_add_AT_reference(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die ownerdie,
        Dwarf_Half attr,
        Dwarf_P_Die otherdie,
        Dwarf_Error *error)\fP
.DE
The function \f(CWdwarf_add_AT_reference()\fP adds an attribute
with a value that is a reference to another \f(CWDIE\fP in the
same compilation-unit to the \f(CWDIE\fP specified by \f(CWownerdie\fP.  
The object that the \f(CWDIE\fP belongs to is specified by \f(CWdbg\fP.  
The attribute is specified by \f(CWattr\fP, and the other \f(CWDIE\fP
being referred to is specified by \f(CWotherdie\fP.

The FORM of the output will be one of the \f(CWDW_FORM_data<n>\fP forms.

This cannot generate DW_FORM_ref_addr references to
\f(CWDIE\fPs in other compilation units.

It returns the \f(CWDwarf_P_Attribute\fP descriptor for the attribute
on success, and \f(CWDW_DLV_BADADDR\fP on error.

.H 4 "dwarf_add_AT_reference_b()"
.DS
\f(CWDwarf_P_Attribute dwarf_add_AT_reference_b(
        Dwarf_P_Debug dbg,
        Dwarf_Half attr,
        Dwarf_P_Die ownerdie,
        Dwarf_P_Die otherdie,
        Dwarf_Error *error)\fP
.DE
The function \f(CWdwarf_add_AT_reference_b()\fP
is the same as  \f(CWdwarf_add_AT_reference()\fP
except that \f(CWdwarf_add_AT_reference_b()\fP
accepts a NULL \f(CWotherdie\fP with the assumption
that \f(CWdwarf_fixup_AT_reference_die()\fP
will be called by user code 
to fill in the missing \f(CWotherdie\fP 
before the DIEs are transformed to disk form.

.H 3 "dwarf_fixup_AT_reference_die()"
.DS
\f(CWint dwarf_fixup_AT_reference_die(
        Dwarf_Half attrnum,
        Dwarf_P_Die ownerdie,
        Dwarf_P_Die otherdie,
        Dwarf_Error *error)\fP
.DE
The function 
\f(CWdwarf_fixup_AT_reference_die()\fP
is provided to set the NULL \f(CWotherdie\fP
that  
\f(CWdwarf_add_AT_reference_c()\fP allows
to the reference target DIE.
This must be done before transforming to disk form.
\f(CWattrnum()\fP should be the 
attribute number of the attribute of \fCWownerdie\fP which is
to be updated.
For example, if a local forward reference
was in a \fCWDW_AT_sibling\fP attribute in ownerdie, pass
the value \fCWDW_AT_sibling\fP as attrnum.
.P
Since no attribute number can appear more than once on a
given DIE
the 
\f(CWattrnum()\fP suffices to uniquely identify which
attribute of \fCWownerdie\fP to update
.P
It returns either \f(CWDW_DLV_OK\fP (on success) 
or \f(CWDW_DLV_ERROR\fP (on error).
Calling this on an attribute where \f(CWotherdie\fP
was already set is an error.

New 22 October, 2013.

.H 3 "dwarf_add_AT_flag_a()"
.DS
\f(CWint dwarf_add_AT_flag_a(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die ownerdie,
        Dwarf_Half attr,
        Dwarf_Small flag,
        Dwarf_P_Attribute *attr_out, 
        Dwarf_Error *error)\fP
.DE
The function 
\f(CWdwarf_add_AT_flag_a()\fP adds an attribute with
a 
\f(CWDwarf_Small\fP value belonging to the "flag" class, to the
\f(CWDIE\fP specified by 
\f(CWownerdie\fP.
The object that the
\f(CWDIE\fP belongs to is specified by 
\f(CWdbg\fP.
The attribute
is specified by 
\f(CWattr\fP, and its value is specified by 
\f(CWflag\fP.

On success it returns
\f(CWDW_DLV_OK\fP
and passes back a pointer to the new attribute
through
\f(CW*attr_out\fP.

On error it returns
\f(CWDW_DLV_ERROR\fP.

Function created 01 December 2018.

.H 4 "dwarf_add_AT_flag()"
.DS
\f(CWDwarf_P_Attribute dwarf_add_AT_flag(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die ownerdie,
        Dwarf_Half attr,
        Dwarf_Small flag,
        Dwarf_Error *error)\fP
.DE
The function \f(CWdwarf_add_AT_flag()\fP adds an attribute with 
a \f(CWDwarf_Small\fP value belonging to the "flag" class, to the 
\f(CWDIE\fP specified by 
\f(CWownerdie\fP.  The object that the 
\f(CWDIE\fP belongs to is specified by 
\f(CWdbg\fP.  The attribute
is specified by \f(CWattr\fP, and its value is specified by \f(CWflag\fP.

It returns the \f(CWDwarf_P_Attribute\fP descriptor for the attribute
on success, and \f(CWDW_DLV_BADADDR\fP on error.

.H 3 "dwarf_add_AT_string_a()"
.DS
\f(CWint dwarf_add_AT_string_a(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die ownerdie,
        Dwarf_Half attr,
        char *string,
        Dwarf_P_Attribute *attr_out,
        Dwarf_Error *error)\fP
.DE
The function 
\f(CWdwarf_add_AT_string()\fP adds an attribute with a
value that is a character string to the 
\f(CWDIE\fP specified by
\f(CWownerdie\fP.  The object that the 
\f(CWDIE\fP belongs to is
specified by 
\f(CWdbg\fP.  The attribute is specified by 
\f(CWattr\fP,
and its value is pointed to by 
\f(CWstring\fP.

On success
it returns 
\f(CWDW_DLV_OK\fP
and set \f(CW*attr_out\fP
with a pointer to the new attribute.

On failure it returns 
\f(CWDW_DLV_ERROR\fP.

Function created 01 December 2018.

.H 4 "dwarf_add_AT_string()"
.DS
\f(CWDwarf_P_Attribute dwarf_add_AT_string(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die ownerdie,
        Dwarf_Half attr,
        char *string,
        Dwarf_Error *error)\fP
.DE
The function 
\f(CWdwarf_add_AT_string()\fP adds an attribute with a 
value that is a character string to the 
\f(CWDIE\fP specified by 
\f(CWownerdie\fP.  The object that the 
\f(CWDIE\fP belongs to is 
specified by 
\f(CWdbg\fP.  
The attribute is specified by 
\f(CWattr\fP, 
and its value is pointed to by 
\f(CWstring\fP.

It returns the 
\f(CWDwarf_P_Attribute\fP descriptor for the attribute
on success, and 
\f(CWDW_DLV_BADADDR\fP on error.

.H 3 "dwarf_add_AT_with_ref_sig8_a()"
.DS
\f(CWint dwarf_add_AT_with_ref_sig8_a(
        Dwarf_P_Die ownerdie,
        Dwarf_Half attrnum,
        const Dwarf_Sig8 *sig8_in,
        Dwarf_P_Attribute *attr_out,
        Dwarf_Error * error)\fP
.DE
The function
\f(CWdwarf_add_AT_with_sig8_a\fP
creates an attribute containing
the 8-byte signature block
pointed to by 
\f(CWsig8_in\fP
\f(CWDW_FORM_ref_sig8\fP
with form
\f(CWDW_FORM_ref_sig8\fP.


On success it returns 
\f(CWDW_DLV_OK\fP
and sets *attr_out
\f(CW*attr_out\fP 
to the newly created
attribute.

On failure it returns 
\f(CWDW_DLV_ERROR\fP.

Function created 01 December 2018.

.H 4 "dwarf_add_AT_with_ref_sig8()"
.DS
\f(CWDwarf_P_Attribute dwarf_add_AT_with_ref_sig8(
        Dwarf_P_Die ownerdie,
        Dwarf_Half attrnum,
        const Dwarf_Sig8 *sig8_in,
        Dwarf_Error * error)\fP
.DE
The function
\f(CWdwarf_add_AT_with_sig8\fP
creates an attribute containing
the 8-byte signature block
pointed to by 
\f(CWsig8_in\fP
\f(CWDW_FORM_ref_sig8\fP
with form
\f(CWDW_FORM_ref_sig8\fP.


It returns the
\f(CWDwarf_P_Attribute\fP descriptor for the 
new attribute
on success, and
\f(CWDW_DLV_BADADDR\fP on error.

.H 3 "dwarf_add_AT_data16()"
.DS
\f(CWint dwarf_add_AT_data16(
        Dwarf_P_Die ownerdie,
        Dwarf_Half attrnum,
        Dwarf_Form_Data16 *ptr_to_val,
        Dwarf_P_Attribute * attr_out,
        Dwarf_Error * error)\fP
.DE
The
DWARF5
standard refers to 16 byte as simply data.
It is up to the eventual reader of the 
DWARF
entry this call creates 
to understand what the sixteen
bytes mean.
.P
On success it returns
\f(CWDW_DLV_OK\fP
and returns the new attribute through
the pointer
\f(CWattr_out\fP.


On failure it returns 
\f(CWDW_DLV_ERROR\fP.


.H 3 "dwarf_compress_integer_block()"
.DS
\f(CWvoid* dwarf_compress_integer_block(
    Dwarf_P_Debug    dbg,
    Dwarf_Bool       unit_is_signed,
    Dwarf_Small      unit_length_in_bits,
    void*            input_block,
    Dwarf_Unsigned   input_length_in_units,
    Dwarf_Unsigned*  output_length_in_bytes_ptr,
    Dwarf_Error*     error)
.DE
This was created in 2016 in support of the attribute
DW_AT_SUN_func_offsets but the particular DWARF project
involving this seems to have died. 
We have not provided a way to create
the attribute.
So this is pretty useless at this time.

.H 2 "Expression Creation"
The following functions are used to convert location expressions into
blocks so that attributes with values that are location expressions
can store their values as a \f(CWDW_FORM_blockn\fP value.  This is for 
both .debug_info and .debug_loc expression blocks.

To create an expression, first call \f(CWdwarf_new_expr()\fP to get 
a \f(CWDwarf_P_Expr\fP descriptor that can be used to build up the
block containing the location expression.  Then insert the parts of 
the expression in prefix order (exactly the order they would be 
interpreted in in an expression interpreter).  The bytes of the 
expression are then built-up as specified by the user.

.H 3 "dwarf_new_expr_a()"
.DS
\f(CWint dwarf_new_expr_a(
        Dwarf_P_Debug dbg,
        Dwarf_P_Expr *expr_out,
        Dwarf_Error *error)\fP
.DE
The function 
\f(CWdwarf_new_expra()\fP creates a new expression area 
in which a location expression stream can be created.

On success
it returns
\f(CWDW_DLV_OK\fP
and returns a 
Dwarf_Expr
\f(CWDwarf_Expr\fP
through
the pointer 
which can be used to add operators
a to build up a location expression.

On failure it returns
\f(CWDW_DLV_OK\fP.

Function created 01 December 2018.

.H 4 "dwarf_new_expr()"
.DS
\f(CWDwarf_P_Expr dwarf_new_expr(
        Dwarf_P_Debug dbg,
        Dwarf_Error *error)\fP
.DE
The function 
\f(CWdwarf_new_expr()\fP creates a new expression area 
in which a location expression stream can be created.
It returns
a 
\f(CWDwarf_P_Expr\fP descriptor that can be used to add operators
to build up a location expression.
It returns 
\f(CWNULL\fP on error.

.H 3 "dwarf_add_expr_gen_a()"
.DS
\f(CWint dwarf_add_expr_gen_a(
        Dwarf_P_Expr expr,
        Dwarf_Small opcode,
        Dwarf_Unsigned val1,
        Dwarf_Unsigned val2,
        Dwarf_Unsigned *stream_length_out,
        Dwarf_Error *error)\fP
.DE
The function 
\f(CWdwarf_add_expr_gen()\fP takes an operator specified
by 
\f(CWopcode\fP, along with up to 2 operands specified by 
\f(CWval1\fP,
and 
\f(CWval2\fP, converts it into the 
\f(CWDwarf\fP representation and
appends the bytes to the byte stream being assembled for the location
expression represented by 
\f(CWexpr\fP.
The first operand, if present,
to 
\f(CWopcode\fP is in 
\f(CWval1\fP, and the second operand, if present,
is in 
\f(CWval2\fP.  Both the operands may actually be signed or unsigned
depending on 
\f(CWopcode\fP.

On success it returns 
\f(CWDW_DLV_OK\fP and sets
\f(CW*stream_length_out\fP
to
the number of bytes in the byte
stream for 
\f(CWexpr\fP currently generated, i.e. after the addition of
\f(CWopcode\fP.

It returns
\f(CWDW_DLV_ERROR\fP on error.

The function 
\f(CWdwarf_add_expr_gen_a()\fP works for all opcodes except
those that have a target address as an operand.  This is because 
the function cannot
not set up a relocation record that is needed when target addresses are
involved.

Function created 01 December 2018.

.H 4 "dwarf_add_expr_gen()"
.DS
\f(CWDwarf_Unsigned dwarf_add_expr_gen(
        Dwarf_P_Expr expr,
        Dwarf_Small opcode, 
        Dwarf_Unsigned val1,
        Dwarf_Unsigned val2,
        Dwarf_Error *error)\fP
.DE
The function 
\f(CWdwarf_add_expr_gen()\fP takes an operator specified
by 
\f(CWopcode\fP, along with up to 2 operands specified by 
\f(CWval1\fP,
and 
\f(CWval2\fP, converts it into the 
\f(CWDwarf\fP representation and 
appends the bytes to the byte stream being assembled for the location
expression represented by 
\f(CWexpr\fP.
The first operand, if present,
to 
\f(CWopcode\fP is in 
\f(CWval1\fP, and the second operand, if present,
is in 
\f(CWval2\fP.  Both the operands may actually be signed or unsigned
depending on 
\f(CWopcode\fP.  It returns the number of bytes in the byte
stream for 
\f(CWexpr\fP currently generated, i.e. after the addition of
\f(CWopcode\fP.

It returns 
\f(CWDW_DLV_NOCOUNT\fP on error.

The function 
\f(CWdwarf_add_expr_gen()\fP works for all opcodes except
those that have a target address as an operand.  This is because 
the function cannot
not set up a relocation record that is needed when target addresses are
involved.

.H 3 "dwarf_add_expr_addr_c()"
.DS
\f(CWint dwarf_add_expr_addr_c(
        Dwarf_P_Expr expr,
        Dwarf_Unsigned address,
        Dwarf_Unsigned sym_index,
        Dwarf_Unsigned *stream_length_out,
        Dwarf_Error *error)\fP
.DE
The function 
\f(CWdwarf_add_expr_addr_c()\fP is
identical to 
\f(CWdwarf_add_expr_addr_b()\fP
except that 
\f(CWdwarf_add_expr_addr_c()\fP 
returns a simple integer code.
.P
\f(CWsym_index() \fP is guaranteed to
be large enough that it can contain a pointer to
arbitrary data (so the caller can pass in a real elf
symbol index, an arbitrary number, or a pointer
to arbitrary data).
The ability to pass in a pointer through 
\f(CWsym_index() \fP
is only usable with
\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP.

On success the function returns
\f(CWDW_DLV_OK\fP and sets
\f(CW*stream_length_out\fP
to to the total length of the expression stream
in
\f(CWexpr\fP.

On failure the function returns
\f(CWDW_DLV_ERROR\fP.

Function created 01 December 2018.

.H 4 "dwarf_add_expr_addr()"
.DS
\f(CWDwarf_Unsigned dwarf_add_expr_addr(
        Dwarf_P_Expr expr,
        Dwarf_Unsigned address,
        Dwarf_Signed sym_index,
        Dwarf_Error *error)\fP 
.DE
The function \f(CWdwarf_add_expr_addr()\fP is used to add the
\f(CWDW_OP_addr\fP opcode to the location expression represented
by the given \f(CWDwarf_P_Expr\fP descriptor, \f(CWexpr\fP.  The
value of the relocatable address is given by \f(CWaddress\fP.  
The symbol to be used for relocation is given by \f(CWsym_index\fP,
which is the index of the symbol in the Elf symbol table.  It returns 
the number of bytes in the byte stream for \f(CWexpr\fP currently 
generated, i.e. after the addition of the \f(CWDW_OP_addr\fP operator.  
It returns \f(CWDW_DLV_NOCOUNT\fP on error.

.H 4 "dwarf_add_expr_addr_b()"
.DS
\f(CWDwarf_Unsigned dwarf_add_expr_addr_b(
        Dwarf_P_Expr expr,
        Dwarf_Unsigned address,
        Dwarf_Unsigned sym_index,
        Dwarf_Error *error)\fP 
.DE
The function 
\f(CWdwarf_add_expr_addr_b()\fP is
identical to 
\f(CWdwarf_add_expr_addr()\fP
except that 
\f(CWsym_index() \fP is guaranteed to
be large enough that it can contain a pointer to
arbitrary data (so the caller can pass in a real elf
symbol index, an arbitrary number, or a pointer
to arbitrary data).
The ability to pass in a pointer through 
\f(CWsym_index() \fP
is only usable with
\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP.



.H 3 "dwarf_expr_current_offset_a()"
.DS
\f(CWint dwarf_expr_current_offset_a(
        Dwarf_P_Expr expr, 
        Dwarf_Unsigned *stream_offset_out,
        Dwarf_Error *error)\fP
.DE
On success
the function 
\f(CWdwarf_expr_current_offset_a()\fP
returns
\f(CWDW_DLV_OK\fP
and sets 
\f(CW*stream_offset_out\fP
to the current length in bytes of the expression
stream.

On failure the function returns
\f(CWDW_DLV_ERROR\fP.

Function created 01 December 2018.

.H 4 "dwarf_expr_current_offset()"
.DS
\f(CWDwarf_Unsigned dwarf_expr_current_offset(
        Dwarf_P_Expr expr, 
        Dwarf_Error *error)\fP
.DE
The function 
\f(CWdwarf_expr_current_offset()\fP returns the number
of bytes currently in the byte stream for the location expression
represented by the given 
\fCW(Dwarf_P_Expr\fP descriptor, 
\f(CWexpr\fP.
It returns 
\f(CWDW_DLV_NOCOUNT\fP on error.

.H 3 "dwarf_expr_into_block_a()"
.DS
\f(CWint dwarf_expr_into_block_a(
        Dwarf_P_Expr expr,
        Dwarf_Unsigned *length,
        Dwarf_Small    **address,
        Dwarf_Error *error)\fP
.DE
On success
the function 
\f(CWdwarf_expr_into_block_a()\fP
returns
\f(CWDW_DLV_OK\fP
and sets the length of the
\f(CWexpr\fP expression
into 
\f(CW*length\fP
and sets the value of a pointer
into memory where the expression
is currently held in the executing libdwarf into
\f(CW*address\fP.
.P
On failure it returns
\f(CWDW_DLV_ERROR\fP.

Function created 01 December 2018.

.H 4 "dwarf_expr_into_block()"
.DS
\f(CWDwarf_Addr dwarf_expr_into_block(
        Dwarf_P_Expr expr,
        Dwarf_Unsigned *length,
        Dwarf_Error *error)\fP 
.DE
The function 
\f(CWdwarf_expr_into_block()\fP returns the address
of the start of the byte stream generated for the location expression
represented by the given 
\f(CWDwarf_P_Expr\fP descriptor, 
\f(CWexpr\fP.
The address is a pointer into the current application memory
known to libdwarf (stored in a Dwarf_Addr).

The length of the byte stream is returned 
in the location pointed to
by 
\f(CWlength\fP.  It returns 
f(CWDW_DLV_BADADDR\fP on error.

.H 3 "dwarf_expr_reset()"
.DS
\f(CWvoid dwarf_expr_reset(
        Dwarf_P_Expr expr,
        Dwarf_Error *error)\fP
.DE
This resets the expression content of
\f(CWexpr()\fP
to be empty.


.H 2 "Line Number Operations"
These are operations on the .debug_line section.  
They provide 
information about instructions in the program and the source 
lines the instruction come from.  
Typically, code is generated 
in contiguous blocks, which may then be relocated as contiguous 
blocks.  
To make the provision of relocation information more 
efficient, the information is recorded in such a manner that only
the address of the start of the block needs to be relocated.  
This is done by providing the address of the first instruction 
in a block using the function \f(CWdwarf_lne_set_address()\fP.  
Information about the instructions in the block are then added 
using the function \f(CWdwarf_add_line_entry()\fP, which specifies
offsets from the address of the first instruction.  
The end of 
a contiguous block is indicated by calling the function 
\f(CWdwarf_lne_end_sequence()\fP.
.P
Line number operations do not support
\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP.

.H 3 "dwarf_add_line_entry_c()"
.DS
\f(CWint dwarf_add_line_entry_c(
        Dwarf_P_Debug dbg,
        Dwarf_Unsigned file_index, 
        Dwarf_Addr code_offset,
        Dwarf_Unsigned lineno, 
        Dwarf_Signed column_number,
        Dwarf_Bool is_source_stmt_begin, 
        Dwarf_Bool is_basic_block_begin,
        Dwarf_Bool is_epilogue_begin,
        Dwarf_Bool is_prologue_end,
        Dwarf_Unsigned  isa,
        Dwarf_Unsigned  discriminator,
        Dwarf_Error *error)\fP
.DE
This is the same as 
\f(CWdwarf_add_line_entry_b()\fP
except that it returns
\f(CWDW_DLV_OK\fP
on success and
\f(CWDW_DLV_ERROR\fP
on error.

Function created 01 December 2018.

.H 4 "dwarf_add_line_entry_b()"
.DS
\f(CWDwarf_Unsigned dwarf_add_line_entry_b(
        Dwarf_P_Debug dbg,
        Dwarf_Unsigned file_index, 
        Dwarf_Addr code_offset,
        Dwarf_Unsigned lineno, 
        Dwarf_Signed column_number,
        Dwarf_Bool is_source_stmt_begin, 
        Dwarf_Bool is_basic_block_begin,
        Dwarf_Bool is_epilogue_begin,
        Dwarf_Bool is_prologue_end,
        Dwarf_Unsigned  isa,
        Dwarf_Unsigned  discriminator,
        Dwarf_Error *error)\fP
.DE
The function \f(CWdwarf_add_line_entry_b()\fP
adds an entry to the
section containing information about source lines.  
It specifies
in \f(CWcode_offset\fP, the address of this line.
The function subtracts \f(CWcode_offset\fP from the value given
as the address of a previous line call to compute an offset,
and the offset is what is recorded in the line instructions
so no relocation will be needed on the line instruction generated.
.P
The source file that gave rise
to the instruction is specified by \f(CWfile_index\fP, the source
line number is specified by \f(CWlineno\fP, and the source column 
number is specified by \f(CWcolumn_number\fP
(column numbers begin at 1)
(if the source column is unknown, specify 0).  
\f(CWfile_index\fP 
is the index of the source file in a list of source files which is 
built up using the function \f(CWdwarf_add_file_decl()\fP. 

\f(CWis_source_stmt_begin\fP is a boolean flag that is true only if 
the instruction at \f(CWcode_address\fP is the first instruction in 
the sequence generated for the source line at \f(CWlineno\fP.  Similarly,
\f(CWis_basic_block_begin\fP is a boolean flag that is true only if
the instruction at \f(CWcode_address\fP is the first instruction of
a basic block.

\f(CWis_epilogue_begin\fP is a boolean flag that is true only if 
the instruction at \f(CWcode_address\fP is the first instruction in 
the sequence generated for the function epilogue code.

Similarly, \f(CWis_prolgue_end\fP is a boolean flag that is true only if
the instruction at \f(CWcode_address\fP is the last instruction of
the sequence generated for the function prologue.

\f(CWisa\fP should be zero unless the code 
at \f(CWcode_address\fP is generated in a non-standard isa.
The values assigned to non-standard isas are defined by the compiler
implementation. 

\f(CWdiscriminator\fP should be zero unless the line table
needs to distinguish among multiple blocks
associated with the same source file, line, and column.
The values assigned to \f(CWdiscriminator\fP are defined by the compiler
implementation.

It returns \f(CW0\fP on success, and \f(CWDW_DLV_NOCOUNT\fP on error.

This function is defined as of December 2011.

.H 4 "dwarf_add_line_entry()"
.DS
\f(CWDwarf_Unsigned dwarf_add_line_entry(
        Dwarf_P_Debug dbg,
        Dwarf_Unsigned file_index,
        Dwarf_Addr code_offset,
        Dwarf_Unsigned lineno,
        Dwarf_Signed column_number,
        Dwarf_Bool is_source_stmt_begin,
        Dwarf_Bool is_basic_block_begin,
        Dwarf_Error *error)\fP
.DE
This function is the same as \f(CWdwarf_add_line_entry_b()\fP
except this older version is missing the new 
DWARF3/4 line table fields.

.H 3 "dwarf_lne_set_address_a()"
.DS
\f(CWint dwarf_lne_set_address_a(
        Dwarf_P_Debug dbg,
        Dwarf_Addr offs,
        Dwarf_Unsigned symidx,
        Dwarf_Error *error)\fP
.DE
The function 
\f(CWdwarf_lne_set_address_a()\fP sets the target address
at which a contiguous block of instructions begin.
Information about
the instructions in the block is added to .debug_line using calls to
\f(CWdwarfdwarf_add_line_entry_c()\fP
which specifies the offset of each
instruction in the block relative to the start of the block.  
This is
done so that a single relocation record can be used to obtain the final
target address of every instruction in the block.

The relocatable address of the start of the block of instructions is
specified by 
\f(CWoffs\fP.
The symbol used to relocate the address
is given by 
\f(CWsymidx\fP, which is normally the index of the symbol in the
Elf symbol table.

It returns 
\f(CWDW_DLV_OK\fP on success, and 
\f(CWDW_DLV_ERROR\fP on error.

Function created 01 December 2018.


.H 4 "dwarf_lne_set_address()"
.DS
\f(CWDwarf_Unsigned dwarf_lne_set_address(
        Dwarf_P_Debug dbg,
        Dwarf_Addr offs,
        Dwarf_Unsigned symidx,
        Dwarf_Error *error)\fP
.DE
The function \f(CWdwarf_lne_set_address()\fP sets the target address
at which a contiguous block of instructions begin.  Information about
the instructions in the block is added to .debug_line using calls to
\f(CWdwarfdwarf_add_line_entry()\fP which specifies the offset of each
instruction in the block relative to the start of the block.  This is 
done so that a single relocation record can be used to obtain the final
target address of every instruction in the block.

The relocatable address of the start of the block of instructions is
specified by \f(CWoffs\fP.  The symbol used to relocate the address 
is given by \f(CWsymidx\fP, which is normally the index of the symbol in the
Elf symbol table. 

It returns \f(CW0\fP on success, and \f(CWDW_DLV_NOCOUNT\fP on error.

.H 3 "dwarf_lne_end_sequence_a()"
.DS
\f(CWint dwarf_lne_end_sequence_a(
        Dwarf_P_Debug dbg,
        Dwarf_Addr    address;
        Dwarf_Error *error)\fP
.DE
The function \f(CWdwarf_lne_end_sequence_a()\fP
indicates the end of a
contiguous block of instructions.
\f(CWaddress()\fP
should be just higher than the end of the last address in the
sequence of instructions.
Before the next
block of instructions (if any) a call to 
\f(CWdwarf_lne_set_address_a()\fP will
have to be made to set the address of the start of the target address
of the block, followed by calls to 
\f(CWdwarf_add_line_entry_a()\fP for
each of the instructions in the block.

It returns 
\f(CWDW_DLV_OK\fP
on success and
\f(CWDW_DLV_ERROR\fP
on error.

Function created 01 December 2018.


.H 4 "dwarf_lne_end_sequence()"
.DS
\f(CWDwarf_Unsigned dwarf_lne_end_sequence(
        Dwarf_P_Debug dbg,
	Dwarf_Addr    address;
        Dwarf_Error *error)\fP
.DE
The function \f(CWdwarf_lne_end_sequence()\fP indicates the end of a
contiguous block of instructions.  
\f(CWaddress()\fP 
should be just higher than the end of the last address in the 
sequence of instructions.
Before the next
block of instructions (if any) a call to \f(CWdwarf_lne_set_address()\fP will 
have to be made to set the address of the start of the target address
of the block, followed by calls to \f(CWdwarf_add_line_entry()\fP for
each of the instructions in the block.

It returns \f(CW0\fP on success, and \f(CWDW_DLV_NOCOUNT\fP on error.

.H 3 "dwarf_add_directory_decl_a()"
.DS
\f(CWint dwarf_add_directory_decl_a(
        Dwarf_P_Debug dbg,
        char *name,
        Dwarf_Unsigned *index_in_directories,
        Dwarf_Error *error)\fP
.DE
The function \f(CWdwarf_add_directory_decl()\fP adds the string
specified by \f(CWname\fP to the list of include directories in
the statement program prologue of the .debug_line section.
The
string should therefore name a directory from which source files
have been used to create the present object.

On success it returns 
\f(CWDW_DLV_OK\fP
and
sets the index of the string just added, in the list of include
directories for the object.
This index is then used to refer to this
string.
The index is passed back through
the pointer argument
\f(CWindex_in_directories\fP

The first successful call of this function
returns one, not zero, to be consistent with the directory indices
that \f(CWdwarf_add_file_decl()\fP (below) expects..
DWARF5 is a bit different.
TBD FIXME

It returns 
\f(CWDW_DLV_ERROR\fP on error.


.H 4 "dwarf_add_directory_decl()"
.DS
\f(CWDwarf_Unsigned dwarf_add_directory_decl(
        Dwarf_P_Debug dbg,
        char *name,
        Dwarf_Error *error)\fP
.DE
The function \f(CWdwarf_add_directory_decl()\fP adds the string 
specified by \f(CWname\fP to the list of include directories in 
the statement program prologue of the .debug_line section.  
The
string should therefore name a directory from which source files
have been used to create the present object.

It returns the index of the string just added, in the list of include 
directories for the object.  
This index is then used to refer to this 
string.  The first successful call of this function
returns one, not zero, to be consistent with the directory indices
that \f(CWdwarf_add_file_decl()\fP (below) expects..

\f(CWdwarf_add_directory_decl()\fP
returns \f(CWDW_DLV_NOCOUNT\fP on error.


.H 3 "dwarf_add_file_decl_a()"
.DS
\f(CWint dwarf_add_file_decl_a(
        Dwarf_P_Debug dbg,
        char *name,
        Dwarf_Unsigned dir_idx,
        Dwarf_Unsigned time_mod,
        Dwarf_Unsigned length,
        Dwarf_Unsigned *file_entry_count_out,
        Dwarf_Error *error)\fP
.DE
The function \f(CWdwarf_add_file_decl_a()\fP adds the name of a source
file that contributed to the present object.
The name of the file is
specified by \f(CWname\fP (which must not be the empty string
or a null pointer, it must point to
a string with length greater than 0).

In case the name is not a fully-qualified
pathname, it is
considered prefixed with the name of the directory specified by
\f(CWdir_idx\fP
(which does not mean the 
\f(CWname\fP
is changed or physically prefixed by
this producer function, we simply describe the meaning here).
\f(CWdir_idx\fP
is the index of the directory to be
prefixed in the list builtup using 
\f(CWdwarf_add_directory_decl_a()\fP.
As specified by the DWARF spec, a
\f(CWdir_idx\fP
of zero will be
interpreted as meaning the directory of the compilation and
another index must refer to a valid directory as
FIXME

.P
\f(CWtime_mod\fP
gives the time at which the file was last modified,
and 
\f(CWlength\fP gives the length of the file in bytes.
.P
On success,
it returns
\f(CWDW_DLV_OK\fP
and returns the index of the source file in the list built up so far
through the pointer
\f(CWfile_entry_count_out\fP.
This index can then be used to
refer to this source file in calls to 
\f(CWdwarf_add_line_entry_a()\fP.

On error, it returns \f(CWDW_DLV_ERROR\fP.


.H 4 "dwarf_add_file_decl()"
.DS
\f(CWDwarf_Unsigned dwarf_add_file_decl(
        Dwarf_P_Debug dbg,
        char *name,
        Dwarf_Unsigned dir_idx,
        Dwarf_Unsigned time_mod,
        Dwarf_Unsigned length,
        Dwarf_Error *error)\fP
.DE
The function \f(CWdwarf_add_file_decl()\fP adds the name of a source
file that contributed to the present object.  
The name of the file is
specified by \f(CWname\fP (which must not be the empty string
or a null pointer, it must point to 
a string with length greater than 0).  

In case the name is not a fully-qualified
pathname, it is 
considered prefixed with the name of the directory specified by
\f(CWdir_idx\fP
(which does not mean the
\f(CWname\fP
is changed or physically prefixed by 
this producer function, we simply describe the meaning here).
\f(CWdir_idx\fP is the index of the directory to be
prefixed in the list builtup using \f(CWdwarf_add_directory_decl()\fP.
As specified by the DWARF spec, a 
\f(CWdir_idx\fP of zero will be
interpreted as meaning the directory of the compilation and
another index must refer to a valid directory as
FIXME

.P
\f(CWtime_mod\fP gives the time at which the file was last modified,
and \f(CWlength\fP gives the length of the file in bytes.
.P
It returns the index of the source file in the list built up so far
using this function, on success.  This index can then be used to 
refer to this source file in calls to \f(CWdwarf_add_line_entry()\fP.
On error, it returns \f(CWDW_DLV_NOCOUNT\fP.

.H 2 "Fast Access (aranges) Operations"
These functions operate on the .debug_aranges section.  

.H 3 "dwarf_add_arange_c()"
.DS
\f(CWint dwarf_add_arange_c(
        Dwarf_P_Debug dbg,
        Dwarf_Addr begin_address,
        Dwarf_Unsigned length,
        Dwarf_Unsigned symbol_index,
        Dwarf_Unsigned end_symbol_index,
        Dwarf_Addr     offset_from_end_symbol,
        Dwarf_Error *error)\fP
.DE
The function 
\f(CWdwarf_add_arange_c()\fP adds another address range
to be added to the section containing
address range information, .debug_aranges.

If
\f(CWend_symbol_index is not zero\fP
we are using two symbols to create a length
(must be \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP to be useful)
.sp
.in +2
\f(CWbegin_address\fP
is the offset from the symbol specified by
\f(CWsymbol_index\fP .
\f(CWoffset_from_end_symbol\fP
is the offset from the symbol specified by
\f(CWend_symbol_index\fP.
\f(CWlength\fP is ignored.
This begin-end pair will be show up in the
relocation array returned by
\f(CWdwarf_get_relocation_info() \fP
as a
\f(CWdwarf_drt_first_of_length_pair\fP
and
\f(CWdwarf_drt_second_of_length_pair\fP
pair of relocation records.
The consuming application will turn that pair into
something conceptually identical to
.sp
.nf
.in +4
 .word end_symbol + offset_from_end - \\
   ( start_symbol + begin_address)
.in -4
.fi
.sp
The reason offsets are allowed on the begin and end symbols
is to allow the caller to re-use existing labels
when the labels are available
and the corresponding offset is known  
(economizing on the number of labels in use).
The  'offset_from_end - begin_address'
will actually be in the binary stream, not the relocation
record, so the app processing the relocation array
must read that stream value into (for example)
net_offset and actually emit something like
.sp
.nf
.in +4
 .word end_symbol - start_symbol + net_offset
.in -4
.fi
.sp
.in -2

If
\f(CWend_symbol_index\fP is zero
we must be given a length
(either
\f(CWDW_DLC_STREAM_RELOCATIONS\fP
or
\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP
):
.sp
.in +2
The relocatable start address of the range is
specified by \f(CWbegin_address\fP, and the length of the address
range is specified by \f(CWlength\fP.  
The relocatable symbol to be
used to relocate the start of the address range is specified by
\f(CWsymbol_index\fP, which is normally
the index of the symbol in the Elf
symbol table.
The 
\f(CWoffset_from_end_symbol\fP
is ignored.
.in -2

The function returns
\f(CWDW_DLV_OK\fP
on success and
\f(CWDW_DLV_ERROR\fP
on error.



Function created 01 December 2018.


.H 4 "dwarf_add_arange()"
.DS
\f(CWDwarf_Unsigned dwarf_add_arange(
        Dwarf_P_Debug dbg,
        Dwarf_Addr begin_address,
        Dwarf_Unsigned length,
        Dwarf_Signed symbol_index,
        Dwarf_Error *error)\fP
.DE
The function 
\f(CWdwarf_add_arange()\fP adds another address range 
to be added to the section 
containing address range information, .debug_aranges.  
The relocatable start address of the range is 
specified by 
\f(CWbegin_address\fP, and the length of the address 
range is specified by 
\f(CWlength\fP.  
The relocatable symbol to be 
used to relocate the start of the address range is specified by 
\f(CWsymbol_index\fP, which is normally 
the index of the symbol in the Elf
symbol table.

It returns a non-zero value on success, and \f(CW0\fP on error.

.H 4 "dwarf_add_arange_b()"
.DS
\f(CWDwarf_Unsigned dwarf_add_arange_b(
        Dwarf_P_Debug dbg,
        Dwarf_Addr begin_address,
        Dwarf_Unsigned length,
        Dwarf_Unsigned symbol_index,
	Dwarf_Unsigned end_symbol_index,
	Dwarf_Addr     offset_from_end_symbol,
        Dwarf_Error *error)\fP
.DE
The function 
\f(CWdwarf_add_arange_b()\fP adds another address range
to be added to the section containing 
address range information, .debug_aranges.  

If
\f(CWend_symbol_index is not zero\fP
we are using two symbols to create a length
(must be \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP to be useful)
.sp
.in +2
\f(CWbegin_address\fP
is the offset from the symbol specified by
\f(CWsymbol_index\fP .
\f(CWoffset_from_end_symbol\fP
is the offset from the symbol specified by
\f(CWend_symbol_index\fP.
\f(CWlength\fP is ignored.
This begin-end pair will be show up in the
relocation array returned by
\f(CWdwarf_get_relocation_info() \fP
as a
\f(CWdwarf_drt_first_of_length_pair\fP
and
\f(CWdwarf_drt_second_of_length_pair\fP
pair of relocation records.
The consuming application will turn that pair into
something conceptually identical to
.sp
.nf
.in +4
 .word end_symbol + offset_from_end - \\
   ( start_symbol + begin_address)
.in -4
.fi
.sp
The reason offsets are allowed on the begin and end symbols
is to allow the caller to re-use existing labels
when the labels are available
and the corresponding offset is known  
(economizing on the number of labels in use).
The  'offset_from_end - begin_address'
will actually be in the binary stream, not the relocation
record, so the app processing the relocation array
must read that stream value into (for example)
net_offset and actually emit something like
.sp
.nf
.in +4
 .word end_symbol - start_symbol + net_offset
.in -4
.fi
.sp
.in -2

If
\f(CWend_symbol_index\fP is zero
we must be given a length
(either
\f(CWDW_DLC_STREAM_RELOCATIONS\fP
or
\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP
):
.sp
.in +2
The relocatable start address of the range is
specified by \f(CWbegin_address\fP, and the length of the address
range is specified by \f(CWlength\fP.  
The relocatable symbol to be
used to relocate the start of the address range is specified by
\f(CWsymbol_index\fP, which is normally
the index of the symbol in the Elf
symbol table.
The 
\f(CWoffset_from_end_symbol\fP
is ignored.
.in -2


It returns a non-zero value on success, and \f(CW0\fP on error.

.H 2 "DWARF5 .debug_sup section creation"
The .debug_sup section (see the DWARF5 standard)
enables symbolically linking two DWARF5 
object files together.
.sp
.H 3 "dwarf_add_debug_sup()"
This call provides all the information
that the .debug_sup section has.
.DS
\f(CWint dwarf_add_debug_sup(
    Dwarf_P_Debug dbg,
    Dwarf_Half      version,
    Dwarf_Small     is_supplementary,
    char          * filename,
    Dwarf_Unsigned  checksum_len,
    Dwarf_Small   * checksum,
    Dwarf_Error *error)\fP
.DE
On success it returns
\f(CWDW_DLV_OK\fP
and records the fields for
creating the section.
.sp
The fields are as follows.
.sp
\f(CWversion\fP
should be passed in as 2.
.sp
\f(CWfilename\fP
must be a null-terminated string.
.sp
\f(CWis_supplementary\fP
should be passed in as 0 or 1
depending on which type of
object file is involved 
(see the DWARF5 standard).
.sp
\f(CWchecksum\fP must be a byte
array of length 
\f(CWchecksum_len\fP
used to validate (by a debugger)
the use of the target object file.
.sp
\f(CWDW_DLV_NO ENTRY\fP is never returned.
.sp
\f(CWDW_DLV_ERROR\fP is returned in case
of an error, and
\f(CW*error\fP is set as usual in libdwarf.


.H 2 "Fast Access (pubnames) Operations"
These functions operate on the .debug_pubnames section.
.sp
.H 3 "dwarf_add_pubname_a()"
.DS
\f(CWint dwarf_add_pubname_a(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die die,
        char *pubname_name,
        Dwarf_Error *error)\fP
.DE
It returns
\f(CWDW_DLV_OK\fP
on success and
\f(CWDW_DLV_ERROR\fP
on error.

Function created 01 December 2018.

.H 4 "dwarf_add_pubname()"
.DS
\f(CWDwarf_Unsigned dwarf_add_pubname(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die die,
        char *pubname_name,
        Dwarf_Error *error)\fP
.DE
The function \f(CWdwarf_add_pubname()\fP adds the pubname specified
by \f(CWpubname_name\fP to the section containing pubnames, i.e.
  .debug_pubnames.  The \f(CWDIE\fP that represents the function
being named is specified by \f(CWdie\fP.  

It returns a non-zero value on success, and \f(CW0\fP on error.

.H 2 "Fast Access (pubtypes) Operations"
These functions operate on the .debug_pubtypes section.
An SGI-defined extension.
Not part of standard DWARF.
.sp
.H 3 "dwarf_add_pubtype_a()"
.DS
\f(CWint dwarf_add_pubtype_a(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die die,
        char *pubname_name,
        Dwarf_Error *error)\fP
.DE
It returns
\f(CWDW_DLV_OK\fP
on success and
\f(CWDW_DLV_ERROR\fP
on error.

Function created 01 December 2018.

.H 4 "dwarf_add_pubtype()"
.DS
\f(CWDwarf_Unsigned dwarf_add_pubtype(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die die,
        char *pubname_name,
        Dwarf_Error *error)\fP
.DE
The function \f(CWdwarf_add_pubtype()\fP adds the pubtype specified
by \f(CWpubtype_name\fP to the section containing 
pubtypes, i.e.  .debug_pubtypes.
The \f(CWDIE\fP that represents the function
being named is specified by \f(CWdie\fP.

It returns a non-zero value on success, and \f(CW0\fP on error.


.H 2 "Fast Access (weak names) Operations"
These functions operate on the .debug_weaknames section.
An SGI-defined extension.
Not part of standard DWARF.

.H 3 "dwarf_add_weakname_a()"
.DS
\f(CWint dwarf_add_weakname_a(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die die,
        char *weak_name,
        Dwarf_Error *error)\fP
.DE
It returns
\f(CWDW_DLV_OK\fP
on success and
\f(CWDW_DLV_ERROR\fP
on error.

Function created 01 December 2018.

.H 4 "dwarf_add_weakname()"
.DS
\f(CWDwarf_Unsigned dwarf_add_weakname(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die die,
        char *weak_name,
        Dwarf_Error *error)\fP
.DE
The function \f(CWdwarf_add_weakname()\fP adds the weak name specified
by \f(CWweak_name\fP to the section containing weak names, i.e.  
 .debug_weaknames.  The \f(CWDIE\fP that represents the function
being named is specified by \f(CWdie\fP.  

It returns a non-zero value on success, and \f(CW0\fP on error.

.H 2 "Static Function Names Operations"
The .debug_funcnames section contains the names of static function 
names defined in the object, and also the offsets of the \f(CWDIE\fPs
that represent the definitions of the functions in the .debug_info 
section.
An SGI-defined extension.
Not part of standard DWARF.

.H 3 "dwarf_add_funcname_a()"
.DS
\f(CWint dwarf_add_funcname_a(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die die,
        char *func_name,
        Dwarf_Error *error)\fP
.DE
The function 
\f(CWdwarf_add_funcname_a()\fP adds the name of a static
function specified by 
\f(CWfunc_name\fP to the section containing the
names of static functions defined in the object represented by \f(CWdbg\fP.
The 
\f(CWDIE\fP that represents the definition of the function is
specified by 
\f(CWdie\fP.
.P
It returns 
\f(CWDW_DLV_OK\fP on success.
.P
It returns 
\f(CWDW_DLV_ERROR\fP on error.

Function created 01 December 2018.

.H 4 "dwarf_add_funcname()"
.DS
\f(CWDwarf_Unsigned dwarf_add_funcname(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die die,
        char *func_name,
        Dwarf_Error *error)\fP
.DE
The function 
\f(CWdwarf_add_funcname()\fP adds the name of a static
function specified by 
\f(CWfunc_name\fP to the section containing the
names of static functions defined in the object represented by 
\f(CWdbg\fP.
The 
\f(CWDIE\fP that represents the definition of the function is
specified by 
\f(CWdie\fP.

It returns a non-zero value on success, and 
\f(CW0\fP on error.

.H 2 "File-scope User-defined Type Names Operations"
The .debug_typenames section contains the names of file-scope
user-defined types in the given object, and also the offsets 
of the \f(CWDIE\fPs that represent the definitions of the types 
in the .debug_info section.
An SGI-defined extension.
Not part of standard DWARF.

.H 3 "dwarf_add_typename_a()"
.DS
\f(CWint dwarf_add_typename_a(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die die,
        char *type_name,
        Dwarf_Error *error)\fP
.DE
This the same as
\f(CWdwarf_add_typename()\fP
except that on success this returns
\f(CWDW_DLV_OK\fP
and on failure this returns
\f(CWDW_DLV_ERROR\fP.

Function created 01 December 2018.

.H 4 "dwarf_add_typename()"
.DS
\f(CWDwarf_Unsigned dwarf_add_typename(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die die,
        char *type_name,
        Dwarf_Error *error)\fP
.DE
The function 
\f(CWdwarf_add_typename()\fP
adds the name of a file-scope
user-defined type specified by
\f(CWtype_name\fP to the section that 
contains the names of file-scope user-defined type.  The object that 
this section belongs to is specified by 
\f(CWdbg\fP.
The \f(CWDIE\fP 
that represents the definition of the type is specified by 
\f(CWdie\fP.

It returns a non-zero value on success, and \f(CW0\fP on error.

.H 2 "File-scope Static Variable Names Operations"
The .debug_varnames section contains the names of file-scope static
variables in the given object, and also the offsets of the 
\f(CWDIE\fPs
that represent the definition of the variables in the .debug_info
section.
An SGI-defined section.

.H 3 "dwarf_add_varname_a()"
.DS
\f(CWint dwarf_add_varname_a(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die die,
        char *var_name,
        Dwarf_Error *error)\fP
.DE
This the same as
\f(CWdwarf_add_varname()\fP
except that on success this returns
\f(CWDW_DLV_OK\fP
and on failure this returns
\f(CWDW_DLV_ERROR\fP.

Function created 01 December 2018.

.H 4 "dwarf_add_varname()"
.DS
\f(CWDwarf_Unsigned dwarf_add_varname(
        Dwarf_P_Debug dbg,
        Dwarf_P_Die die,
        char *var_name,
        Dwarf_Error *error)\fP
.DE
The function 
\f(CWdwarf_add_varname()\fP adds the name of a file-scope
static variable specified by 
\f(CWvar_name\fP to the section that 
contains the names of file-scope static variables defined by the 
object represented by 
\f(CWdbg\fP.  
The 
\f(CWDIE\fP that represents
the definition of the static variable is specified by 
\f(CWdie\fP.

It returns a non-zero value on success, and 
\f(CW0\fP on error.

.H 2 "Macro Information Creation"
All strings passed in by the caller are copied by these
functions, so the space in which the caller provides the strings
may be ephemeral (on the stack, or immediately reused or whatever)
without this causing any difficulty.

.H 3 "dwarf_def_macro()"
.DS
\f(CWint dwarf_def_macro(Dwarf_P_Debug dbg,
	Dwarf_Unsigned lineno,
	char *name
	char *value,
        Dwarf_Error *error);\fP
.DE
Adds a macro definition.
The \f(CWname\fP argument should include the parentheses
and parameter names if this is a function-like macro.
Neither string should contain extraneous whitespace.
\f(CWdwarf_def_macro()\fP adds the mandated space after the
name and before the value  in the
output DWARF section(but does not change the
strings pointed to by the arguments).
If this is a definition before any files are read,
\f(CWlineno\fP should be 0.
Returns \f(CWDW_DLV_ERROR\fP
and sets \f(CWerror\fP
if there is an error.
Returns \f(CWDW_DLV_OK\fP if the call was successful.


.H 3 "dwarf_undef_macro()"
.DS
\f(CWint dwarf_undef_macro(Dwarf_P_Debug dbg,
	Dwarf_Unsigned lineno,
	char *name,
        Dwarf_Error *error);\fP
.DE
Adds a macro un-definition note.
If this is a definition before any files are read,
\f(CWlineno\fP should be 0.
Returns \f(CWDW_DLV_ERROR\fP
and sets \f(CWerror\fP
if there is an error.
Returns \f(CWDW_DLV_OK\fP if the call was successful.


.H 3 "dwarf_start_macro_file()"
.DS
\f(CWint dwarf_start_macro_file(Dwarf_P_Debug dbg,
	Dwarf_Unsigned lineno,
        Dwarf_Unsigned fileindex,
        Dwarf_Error *error);\fP
.DE
\f(CWfileindex\fP is an index in the .debug_line header: 
the index of
the file name.
See the function \f(CWdwarf_add_file_decl()\fP.
The \f(CWlineno\fP should be 0 if this file is
the file of the compilation unit source itself
(which, of course, is not a #include in any
file).
Returns \f(CWDW_DLV_ERROR\fP
and sets \f(CWerror\fP
if there is an error.
Returns \f(CWDW_DLV_OK\fP if the call was successful.


.H 3 "dwarf_end_macro_file()"
.DS
\f(CWint dwarf_end_macro_file(Dwarf_P_Debug dbg,
        Dwarf_Error *error);\fP
.DE
Returns \f(CWDW_DLV_ERROR\fP
and sets \f(CWerror\fP
if there is an error.
Returns \f(CWDW_DLV_OK\fP if the call was successful.

.H 3 "dwarf_vendor_ext()"
.DS
\f(CWint dwarf_vendor_ext(Dwarf_P_Debug dbg,
    Dwarf_Unsigned constant,
    char *         string,
    Dwarf_Error*   error); \fP
.DE
The meaning of the \f(CWconstant\fP and the\f(CWstring\fP
in the macro info section
are undefined by DWARF itself, but the string must be
an ordinary null terminated string.
This call is not an extension to DWARF. 
It simply enables storing
macro information as specified in the DWARF document.
Returns \f(CWDW_DLV_ERROR\fP
and sets \f(CWerror\fP
if there is an error.
Returns \f(CWDW_DLV_OK\fP if the call was successful.


.H 2 "Low Level (.debug_frame) operations"
These functions operate on the .debug_frame section.  Refer to 
\f(CWlibdwarf.h\fP for the register names 
and register assignment 
mapping.  
Both of these are necessarily machine dependent.

.H 3 "dwarf_new_fde_a()"
.DS
\f(CWint dwarf_new_fde_a(
        Dwarf_P_Debug dbg, 
        Dwarf_P_Fde *fde_out,
        Dwarf_Error *error)\fP
.DE
On success the function 
\f(CWdwarf_new_fde_a()\fP returns
\f(CWDW_DLV_OK\fP
and returns a pointer to the fde
through
\f(CWfde_out\fP.
The
descriptor should be used to build a complete 
\f(CWFDE\fP.  
Subsequent calls to routines that build up the 
\f(CWFDE\fP should use
the same 
\f(CWDwarf_P_Fde\fP descriptor.
.P
It returns
\f(CWDW_DLV_ERROR\fP on error.

Function created 01 December 2018.

.H 4 "dwarf_new_fde()"
.DS
\f(CWDwarf_P_Fde dwarf_new_fde(
        Dwarf_P_Debug dbg, 
        Dwarf_Error *error)\fP
.DE
The function \f(CWdwarf_new_fde()\fP returns a new \f(CWDwarf_P_Fde\fP
descriptor that should be used to build a complete \f(CWFDE\fP.  
Subsequent calls to routines that build up the \f(CWFDE\fP should use
the same \f(CWDwarf_P_Fde\fP descriptor.

It returns a valid \f(CWDwarf_P_Fde\fP descriptor on success, and
\f(CWDW_DLV_BADADDR\fP on error.

.H 3 "dwarf_add_frame_cie_a()"
.DS
\f(CWint dwarf_add_frame_cie_a(
        Dwarf_P_Debug dbg,
        char *augmenter,
        Dwarf_Small code_align,
        Dwarf_Small data_align,
        Dwarf_Small ret_addr_reg,
        Dwarf_Ptr init_bytes,
        Dwarf_Unsigned init_bytes_len,
        Dwarf_Unsigned *cie_index_out,
        Dwarf_Error *error);\fP
.DE
On success
The function
\f(CWdwarf_add_frame_cie_a()\fP
returns 
\f(CWDW_DLV_OK\fP,
creates a 
\f(CWCIE\fP,
and returns an index to it
through the pointer
\f(CWcie_index_out\fP.
.P
\f(CWCIE\fPs are used by 
\f(CWFDE\fPs to setup
initial values for frames. 
The augmentation string for the 
\f(CWCIE\fP
is specified by 
\f(CWaugmenter\fP. 
The code alignment factor,
data alignment factor, and the return address register for the
\f(CWCIE\fP are specified by 
\f(CWcode_align\fP, 
\f(CWdata_align\fP,
and 
\f(CWret_addr_reg\fP respectively.
\f(CWinit_bytes\fP points
to the bytes that represent the instructions for the 
\f(CWCIE\fP
being created, and 
\f(CWinit_bytes_len\fP specifies the number
of bytes of instructions.
.P
There is no convenient way to generate the  
\f(CWinit_bytes\fP
stream.
One just
has to calculate it by hand or separately
generate something with the
correct sequence and use dwarfdump -v and readelf (or objdump)
and some
kind of hex dumper to see the bytes.
This is a serious inconvenience!

On error it returns 
\f(CWDW_DLV_ERROR\fP.

Function created 01 December 2018.

.H 4 "dwarf_add_frame_cie()"
.DS
\f(CWDwarf_Unsigned dwarf_add_frame_cie(
        Dwarf_P_Debug dbg,
        char *augmenter, 
        Dwarf_Small code_align,
        Dwarf_Small data_align, 
        Dwarf_Small ret_addr_reg, 
        Dwarf_Ptr init_bytes, 
        Dwarf_Unsigned init_bytes_len,
        Dwarf_Error *error);\fP
.DE
The function 
\f(CWDwarf_Unsigned dwarf_add_frame_cie()\fP 
creates a \f(CWCIE\fP,
and returns an index to it, that 
should be used to refer to this
\f(CWCIE\fP.  
\f(CWCIE\fPs are used by
\f(CWFDE\fPs to setup
initial values for frames.  
The augmentation string for the \f(CWCIE\fP
is specified by \f(CWaugmenter\fP.  
The code alignment factor,
data alignment factor, and 
the return address register for the
\f(CWCIE\fP are specified by 
\f(CWcode_align\fP, 
\f(CWdata_align\fP,
and 
\f(CWret_addr_reg\fP respectively.  
\f(CWinit_bytes\fP points
to the bytes that represent the 
instructions for the \f(CWCIE\fP
being created, and 
\f(CWinit_bytes_len\fP specifies the number
of bytes of instructions.

There is no convenient way to generate the  
\f(CWinit_bytes\fP
stream. 
One just
has to calculate it by hand or separately
generate something with the 
correct sequence and use dwarfdump -v and readelf (or objdump)  
and some
kind of hex dumper to see the bytes.
This is a serious inconvenience! 

It returns an index to the \f(CWCIE\fP just created on success.
On error it returns \f(CWDW_DLV_NOCOUNT\fP.

.H 3 "dwarf_add_frame_fde_c()"
.DS
\f(CWint dwarf_add_frame_fde_c(
    Dwarf_P_Debug dbg,
    Dwarf_P_Fde fde,
    Dwarf_P_Die die,
    Dwarf_Unsigned cie,
    Dwarf_Addr virt_addr,
    Dwarf_Unsigned  code_len,
    Dwarf_Unsigned sym_idx,
    Dwarf_Unsigned sym_idx_of_end,
    Dwarf_Addr     offset_from_end_sym,
    Dwarf_Unsigned *index_to_fde,
    Dwarf_Error* error)\fP
.DE

This function is like 
\f(CWdwarf_add_frame_fde()\fP 
except that 
\f(CWdwarf_add_frame_fde_c()\fP 
has new arguments to allow use
with
\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP
and a new argument to return the fde index..

The function \f(CWdwarf_add_frame_fde_c()\fP 
adds the 
\f(CWFDE\fP
specified by \f(CWfde\fP to the list of 
\f(CWFDE\fPs for the
object represented by the given 
\f(CWdbg\fP.  

\f(CWdie\fP specifies
the 
\f(CWDIE\fP that represents the function
whose frame information
is specified by the given 
\f(CWfde\fP.  
If the MIPS/IRIX specific DW_AT_MIPS_fde attribute is not
needed  in .debug_info pass in 0 as the \f(CWdie\fP argument.

\f(CWcie\fP specifies the
index of the 
\f(CWCIE\fP that should be used to setup the initial
conditions for the given frame.  
\f(CWvirt_addr\fP represents the
relocatable address at which the code
for the given function begins,
and 
\f(CWsym_idx\fP gives the index of the relocatable symbol to
be used to relocate this address (\f(CWvirt_addr\fP that is).
\f(CWcode_len\fP specifies the 
size in bytes of the machine instructions
for the given function.

If \f(CWsym_idx_of_end\fP is zero 
(may  be 
\f(CWDW_DLC_STREAM_RELOCATIONS\fP 
or
\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP 
):
.sp
.in +2
\f(CWvirt_addr\fP represents the
relocatable address at which the code for the given function begins,
and \f(CWsym_idx\fP gives the index of the relocatable symbol to
be used to relocate this address (\f(CWvirt_addr\fP that is).
\f(CWcode_len\fP 
specifies the size in bytes of the machine instructions
for the given function.
\f(CWsym_idx_of_end\fP
and
\f(CWoffset_from_end_sym\fP
are unused.
.in -2
.sp


If \f(CWsym_idx_of_end\fP is non-zero 
(must be \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP to be useful):
.sp
.in +2
\f(CWvirt_addr\fP
is the offset from the symbol specified by
\f(CWsym_idx\fP .
\f(CWoffset_from_end_sym\fP
is the offset from the symbol specified by
\f(CWsym_idx_of_end\fP.
\f(CWcode_len\fP is ignored.
This begin-end pair will be show up in the
relocation array returned by
\f(CWdwarf_get_relocation_info() \fP
as a
\f(CWdwarf_drt_first_of_length_pair\fP
and
\f(CWdwarf_drt_second_of_length_pair\fP
pair of relocation records.
The consuming application will turn that pair into
something conceptually identical to
.sp
.nf
.in +4
 .word end_symbol + begin - \\
   ( start_symbol + offset_from_end)
.in -4
.fi
.sp
The reason offsets are allowed on the begin and end symbols
is to allow the caller to re-use existing labels
when the labels are available
and the corresponding offset is known
(economizing on the number of labels in use).
The  'offset_from_end - begin_address'
will actually be in the binary stream, not the relocation
record, so the app processing the relocation array
must read that stream value into (for example)
net_offset and actually emit something like
.sp
.nf
.in +4
 .word end_symbol - start_symbol + net_offset
.in -4
.fi
.sp
.in -2

On success it
returns
\f(CWDW_DLV_OK\fP
and returns index to the given \f(CWfde\fP
through the pointer
\f(CWindex_to_fde\fP.

On error, it returns \f(CWDW_DLV_ERROR\fP.

Function created 01 December 2018.

.H 4 "dwarf_add_frame_fde()"
.DS
\f(CWDwarf_Unsigned dwarf_add_frame_fde(
        Dwarf_P_Debug dbg,
        Dwarf_P_Fde fde,
        Dwarf_P_Die die,
        Dwarf_Unsigned cie,
        Dwarf_Addr virt_addr,
        Dwarf_Unsigned  code_len,
        Dwarf_Unsigned sym_idx,
        Dwarf_Error* error)\fP
.DE
The function \f(CWdwarf_add_frame_fde()\fP adds the \f(CWFDE\fP
specified by \f(CWfde\fP to the list of \f(CWFDE\fPs for the
object represented by the given \f(CWdbg\fP.  
\f(CWdie\fP specifies
the \f(CWDIE\fP that represents the function whose frame information
is specified by the given \f(CWfde\fP.  
\f(CWcie\fP specifies the
index of the \f(CWCIE\fP that should be used to setup the initial
conditions for the given frame.  

If the MIPS/IRIX specific DW_AT_MIPS_fde attribute is not
needed  in .debug_info pass in 0 as the \f(CWdie\fP argument.

It returns an index to the given \f(CWfde\fP.


.H 4 "dwarf_add_frame_fde_b()"
.DS
\f(CWDwarf_Unsigned dwarf_add_frame_fde_b(
        Dwarf_P_Debug dbg,
        Dwarf_P_Fde fde,
        Dwarf_P_Die die,
        Dwarf_Unsigned cie,
        Dwarf_Addr virt_addr,
        Dwarf_Unsigned  code_len,
        Dwarf_Unsigned sym_idx,
	Dwarf_Unsigned sym_idx_of_end,
	Dwarf_Addr     offset_from_end_sym,
        Dwarf_Error* error)\fP
.DE
This function is like 
\f(CWdwarf_add_frame_fde()\fP 
except that 
\f(CWdwarf_add_frame_fde_b()\fP 
has new arguments to allow use
with
\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP.

The function \f(CWdwarf_add_frame_fde_b()\fP 
adds the 
\f(CWFDE\fP
specified by \f(CWfde\fP to the list of \f(CWFDE\fPs for the
object represented by the given \f(CWdbg\fP.  

\f(CWdie\fP specifies
the \f(CWDIE\fP that represents the function whose frame information
is specified by the given \f(CWfde\fP.  
If the MIPS/IRIX specific DW_AT_MIPS_fde attribute is not
needed  in .debug_info pass in 0 as the \f(CWdie\fP argument.

\f(CWcie\fP specifies the
index of the \f(CWCIE\fP that should be used to setup the initial
conditions for the given frame.  
\f(CWvirt_addr\fP represents the
relocatable address at which the code for the given function begins,
and \f(CWsym_idx\fP gives the index of the relocatable symbol to
be used to relocate this address (\f(CWvirt_addr\fP that is).
\f(CWcode_len\fP specifies the size in bytes of the machine instructions
for the given function.

If \f(CWsym_idx_of_end\fP is zero 
(may  be 
\f(CWDW_DLC_STREAM_RELOCATIONS\fP 
or
\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP 
):
.sp
.in +2
\f(CWvirt_addr\fP represents the
relocatable address at which the code for the given function begins,
and \f(CWsym_idx\fP gives the index of the relocatable symbol to
be used to relocate this address (\f(CWvirt_addr\fP that is).
\f(CWcode_len\fP 
specifies the size in bytes of the machine instructions
for the given function.
\f(CWsym_idx_of_end\fP
and
\f(CWoffset_from_end_sym\fP
are unused.
.in -2
.sp


If \f(CWsym_idx_of_end\fP is non-zero 
(must be \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP to be useful):
.sp
.in +2
\f(CWvirt_addr\fP
is the offset from the symbol specified by
\f(CWsym_idx\fP .
\f(CWoffset_from_end_sym\fP
is the offset from the symbol specified by
\f(CWsym_idx_of_end\fP.
\f(CWcode_len\fP is ignored.
This begin-end pair will be show up in the
relocation array returned by
\f(CWdwarf_get_relocation_info() \fP
as a
\f(CWdwarf_drt_first_of_length_pair\fP
and
\f(CWdwarf_drt_second_of_length_pair\fP
pair of relocation records.
The consuming application will turn that pair into
something conceptually identical to
.sp
.nf
.in +4
 .word end_symbol + begin - \\
   ( start_symbol + offset_from_end)
.in -4
.fi
.sp
The reason offsets are allowed on the begin and end symbols
is to allow the caller to re-use existing labels
when the labels are available
and the corresponding offset is known
(economizing on the number of labels in use).
The  'offset_from_end - begin_address'
will actually be in the binary stream, not the relocation
record, so the app processing the relocation array
must read that stream value into (for example)
net_offset and actually emit something like
.sp
.nf
.in +4
 .word end_symbol - start_symbol + net_offset
.in -4
.fi
.sp
.in -2

It returns an index to the given \f(CWfde\fP.

On error, it returns \f(CWDW_DLV_NOCOUNT\fP.

.H 3 "dwarf_add_frame_info_c()"
.DS
\f(CWint dwarf_add_frame_info_c(
        Dwarf_P_Debug   dbg,
        Dwarf_P_Fde     fde,    
        Dwarf_P_Die     die,    
        Dwarf_Unsigned  cie,
        Dwarf_Addr      virt_addr,
        Dwarf_Unsigned  code_len,
        Dwarf_Unsigned  sym_idx,
        Dwarf_Unsigned  end_symbol_index,
        Dwarf_Addr      offset_from_end_symbol,
        Dwarf_Signed    offset_into_exception_tables,
        Dwarf_Unsigned  exception_table_symbol,
        Dwarf_Unsigned *index_to_fde,
        Dwarf_Error*    error)\fP
.DE
New December 2018, this function has
a simpler return value so checking for
failure is easier. 
Otherwise
\f(CWdwarf_add_frame_fde_c()\fP
is essentially similar to
\f(CWdwarf_add_frame_fde_b()\fP.

.P
On success 
The function 
\f(CWdwarf_add_frame_fde_c()\fP
returns 
\f(CWDW_DLV_OK\fP,
adds the 
\f(CWFDE\fP
specified by 
\f(CWfde\fP to the list of 
\f(CWFDE\fPs for the 
object represented by the given 
\f(CWdbg\fP, and.
passes the index of the fde back through 
the pointer 
\f(CWindex_to_fde\fP

On failure it returns 
\f(CWDW_DLV_ERROR\fP.

Function created 01 December 2018.

.H 4 "dwarf_add_frame_info_b()"
.DS
\f(CWDwarf_Unsigned dwarf_add_frame_info_b(
        Dwarf_P_Debug   dbg,
        Dwarf_P_Fde     fde,
        Dwarf_P_Die     die,
        Dwarf_Unsigned  cie,
        Dwarf_Addr      virt_addr,
        Dwarf_Unsigned  code_len,
        Dwarf_Unsigned  sym_idx,
	Dwarf_Unsigned  end_symbol_index,
        Dwarf_Addr      offset_from_end_symbol,
	Dwarf_Signed    offset_into_exception_tables,
	Dwarf_Unsigned  exception_table_symbol,
        Dwarf_Error*    error)\fP
.DE
The function \f(CWdwarf_add_frame_fde()\fP adds the \f(CWFDE\fP
specified by \f(CWfde\fP to the list of \f(CWFDE\fPs for the
object represented by the given \f(CWdbg\fP.  

This function refers to MIPS/IRIX specific exception tables
and is not a function other targets need.

\f(CWdie\fP specifies
the \f(CWDIE\fP that represents the function whose frame information
is specified by the given \f(CWfde\fP.  
If the MIPS/IRIX specific DW_AT_MIPS_fde attribute is not
needed  in .debug_info pass in 0 as the \f(CWdie\fP argument.

\f(CWcie\fP specifies the
index of the \f(CWCIE\fP that should be used to setup the initial
conditions for the given frame.  

\f(CWoffset_into_exception_tables\fP specifies the
MIPS/IRIX specific
offset into \f(CW.MIPS.eh_region\fP elf section where the exception tables 
for this function begins. 
\f(CWexception_table_symbol\fP is also MIPS/IRIX
specific and it specifies the index of 
the relocatable symbol to be used to relocate this offset.


If
\f(CWend_symbol_index is not zero\fP
we are using two symbols to create a length
(must be \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP to be useful)
.sp
.in +2
\f(CWvirt_addr\fP
is the offset from the symbol specified by
\f(CWsym_idx\fP .
\f(CWoffset_from_end_symbol\fP
is the offset from the symbol specified by
\f(CWend_symbol_index\fP.
\f(CWcode_len\fP is ignored.
This begin-end pair will be show up in the
relocation array returned by
\f(CWdwarf_get_relocation_info() \fP
as a
\f(CWdwarf_drt_first_of_length_pair\fP
and
\f(CWdwarf_drt_second_of_length_pair\fP
pair of relocation records.
The consuming application will turn that pair into
something conceptually identical to
.sp
.nf
.in +4
 .word end_symbol + offset_from_end_symbol - \\
   ( start_symbol + virt_addr)
.in -4
.fi
.sp
The reason offsets are allowed on the begin and end symbols
is to allow the caller to re-use existing labels
when the labels are available
and the corresponding offset is known  
(economizing on the number of labels in use).
The  'offset_from_end - begin_address'
will actually be in the binary stream, not the relocation
record, so the app processing the relocation array
must read that stream value into (for example)
net_offset and actually emit something like
.sp
.nf
.in +4
 .word end_symbol - start_symbol + net_offset
.in -4
.fi
.sp
.in -2

If
\f(CWend_symbol_index\fP is zero
we must be given a code_len value
(either
\f(CWDW_DLC_STREAM_RELOCATIONS\fP
or
\f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP
):
.sp
.in +2
The relocatable start address of the range is
specified by \f(CWvirt_addr\fP, and the length of the address
range is specified by \f(CWcode_len\fP.  
The relocatable symbol to be
used to relocate the start of the address range is specified by
\f(CWsymbol_index\fP, which is normally
the index of the symbol in the Elf
symbol table.
The 
\f(CWoffset_from_end_symbol\fP
is ignored.
.in -2


It returns an index to the given \f(CWfde\fP.

On error, it returns \f(CWDW_DLV_NOCOUNT\fP.

.H 4 "dwarf_add_frame_info()"
.DS
\f(CWDwarf_Unsigned dwarf_add_frame_info(
        Dwarf_P_Debug dbg,
        Dwarf_P_Fde fde,
        Dwarf_P_Die die,
        Dwarf_Unsigned cie,
        Dwarf_Addr virt_addr,
        Dwarf_Unsigned  code_len,
        Dwarf_Unsigned sym_idx,
	Dwarf_Signed offset_into_exception_tables,
	Dwarf_Unsigned exception_table_symbol,
        Dwarf_Error* error)\fP
.DE
The function 
\f(CWdwarf_add_frame_info()\fP
adds the \f(CWFDE\fP
specified by \f(CWfde\fP to the list of \f(CWFDE\fPs for the
object represented by the given \f(CWdbg\fP.  

\f(CWdie\fP specifies
the \f(CWDIE\fP that represents the function whose frame information
is specified by the given \f(CWfde\fP.  
If the MIPS/IRIX specific DW_AT_MIPS_fde attribute is not
needed in .debug_info pass in 0 as the \f(CWdie\fP argument.

\f(CWcie\fP specifies the
index of the \f(CWCIE\fP that should be used to setup the initial
conditions for the given frame.  \f(CWvirt_addr\fP represents the
relocatable address at which the code for the given function begins,
and \f(CWsym_idx\fP gives the index of the relocatable symbol to
be used to relocate this address (\f(CWvirt_addr\fP that is).
\f(CWcode_len\fP specifies the size in bytes of the machine instructions
for the given function. 

\f(CWoffset_into_exception_tables\fP specifies the
offset into \f(CW.MIPS.eh_region\fP elf section where the exception tables 
for this function begins. 
\f(CWexception_table_symbol\fP  gives the index of 
the relocatable symbol to be used to relocate this offset.
These arguments are MIPS/IRIX specific, pass in 0 for
other targets.

On success
it returns an index to the given \f(CWfde\fP.

On failure it returns DW_DLV_NOCOUNT.


.H 3 "dwarf_fde_cfa_offset_a()"
.DS
\f(CWint dwarf_fde_cfa_offset_a( Dwarf_P_Fde fde,
        Dwarf_Unsigned reg,
        Dwarf_Signed offset,
        Dwarf_Error *error)\fP
.DE
New December 2018, this function has
a simpler return value so checking for
failure is easier. 
.P
The function 
\f(CWdwarf_fde_cfa_offset()\fP appends a 
\f(CWDW_CFA_offset\fP
operation to the 
\f(CWFDE\fP, specified by 
\f(CWfde\fP,  being constructed.
The first operand of the 
\f(CWDW_CFA_offset\fP operation is specified by
\f(CWreg\P.  
The register specified should not exceed 6 bits.  
The second
operand of the 
\f(CWDW_CFA_offset\fP operation is specified by 
\f(CWoffset\fP.
.P
It returns \f(CWDW_DLV_OK\fP on success.
.P
It returns \f(CWDW_DLV_ERROR\fP on error.

Function created 01 December 2018.

.H 4 "dwarf_fde_cfa_offset()"
.DS
\f(CWDwarf_P_Fde dwarf_fde_cfa_offset(
        Dwarf_P_Fde fde,
        Dwarf_Unsigned reg,
        Dwarf_Signed offset,
        Dwarf_Error *error)\fP
.DE
The function \f(CWdwarf_fde_cfa_offset()\fP appends a \f(CWDW_CFA_offset\fP
operation to the \f(CWFDE\fP, specified by \f(CWfde\fP,  being constructed.  
The first operand of the \f(CWDW_CFA_offset\fP operation is specified by 
\f(CWreg\P.  The register specified should not exceed 6 bits.  The second 
operand of the \f(CWDW_CFA_offset\fP operation is specified by \f(CWoffset\fP.

It returns the given \f(CWfde\fP on success.

It returns \f(CWDW_DLV_BADADDR\fP on error.

.H 3 "dwarf_add_fde_inst_a()"
.DS
\f(CWint dwarf_add_fde_inst_a(
        Dwarf_P_Fde fde,
        Dwarf_Small op,
        Dwarf_Unsigned val1,
        Dwarf_Unsigned val2,
        Dwarf_Error *error)\fP
.DE
The function 
\f(CWdwarf_add_fde_inst()\fP adds the operation specified
by 
\f(CWop\fP to the 
\f(CWFDE\fP specified by 
\f(CWfde\fP.  Up to two
operands can be specified in 
\f(CWval1\fP, and 
\f(CWval2\fP.  Based on
the operand specified 
\f(CWLibdwarf\fP decides how many operands are
meaningful for the operand.
It also converts the operands to the
appropriate datatypes (they are passed to 
\f(CWdwarf_add_fde_inst\fP
as 
\f(CWDwarf_Unsigned\fP).
.P
It returns
\f(CWDW_DLV_OK\fP on success.

It returns
\f(CWDW_DLV_ERROR\fP
on error.

Function created 01 December 2018.


.H 4 "dwarf_add_fde_inst()"
.DS
\f(CWDwarf_P_Fde dwarf_add_fde_inst(
        Dwarf_P_Fde fde,
        Dwarf_Small op,
        Dwarf_Unsigned val1,
        Dwarf_Unsigned val2,
        Dwarf_Error *error)\fP
.DE
The function \f(CWdwarf_add_fde_inst()\fP adds the operation specified
by \f(CWop\fP to the \f(CWFDE\fP specified by \f(CWfde\fP.  Up to two
operands can be specified in \f(CWval1\fP, and \f(CWval2\fP.  Based on
the operand specified \f(CWLibdwarf\fP decides how many operands are
meaningful for the operand.  It also converts the operands to the 
appropriate datatypes (they are passed to \f(CWdwarf_add_fde_inst\fP
as \f(CWDwarf_Unsigned\fP).

It returns the given \f(CWfde\fP on success, and \f(CWDW_DLV_BADADDR\fP
on error.

.H 3 "dwarf_insert_fde_inst_bytes()"
.DS
\f(CWint dwarf_insert_fde_inst_bytes(
        Dwarf_P_Debug dbg,
        Dwarf_P_Fde  fde,
        Dwarf_Unsigned len,
        Dwarf_Ptr ibytes,
        Dwarf_Error *error)\fP
.DE
The function \f(CWdwarf_insert_fde_inst_bytes()\fP inserts
the byte array (pointed at by \f(CWibytes\fP and of length \f(CWlen\fP)
of frame instructions into the fde \f(CWfde\fP.
It is incompatible with \f(CWdwarf_add_fde_inst()\fP, do not use
both functions on any given Dwarf_P_Debug.
At present it may only be called once on a given \f(CWfde\fP.
The \f(CWlen\fP bytes \f(CWibytes\fP may be constructed in any way, but
the assumption is they were copied from an object file
such as is returned by the libdwarf consumer function
\f(CWdwarf_get_fde_instr_bytes\fP.

It returns \f(CWDW_DLV_OK\fP on success, and \f(CWDW_DLV_ERROR\fP
on error.


.S
.TC 1 1 4
.CS