aboutsummaryrefslogtreecommitdiffstats
path: root/toolchain/uClibc/patches-0.9.30.3/600-ubicom32-uClibc.patch
blob: 256e022e2fc6651af39dea8e5b05f52f5fbab9ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
Index: uClibc-0.9.30.2/Rules.mak
===================================================================
--- uClibc-0.9.30.2.orig/Rules.mak	2010-01-13 22:22:31.000000000 +0100
+++ uClibc-0.9.30.2/Rules.mak	2010-01-14 11:05:01.000000000 +0100
@@ -406,6 +406,17 @@
       SYMBOL_PREFIX=_
 endif
 
+ifeq ($(TARGET_ARCH),ubicom32)
+	OPTIMIZATION+=-fstrict-aliasing
+	CPU_CFLAGS-$(CONFIG_UBICOM32_V3)+=-march=ubicom32v3
+	CPU_CFLAGS-$(CONFIG_UBICOM32_V4)+=-march=ubicom32v4
+ifeq ($(UCLIBC_FORMAT_FDPIC_ELF),y)
+	CPU_CFLAGS-y:=-mfdpic
+	CPU_LDFLAGS-y += -Wl,-melf32ubicom32fdpic
+endif
+
+endif
+
 ifeq ($(TARGET_ARCH),v850)
       SYMBOL_PREFIX=_
 endif
Index: uClibc-0.9.30.2/extra/Configs/Config.in
===================================================================
--- uClibc-0.9.30.2.orig/extra/Configs/Config.in	2010-01-13 22:22:31.000000000 +0100
+++ uClibc-0.9.30.2/extra/Configs/Config.in	2010-01-14 11:05:01.000000000 +0100
@@ -73,6 +73,9 @@
 config TARGET_sparc
 	bool "sparc"
 
+config TARGET_ubicom32
+	bool "ubicom32"
+
 config TARGET_v850
 	bool "v850 (BROKEN)"
 
@@ -174,6 +177,10 @@
 source "extra/Configs/Config.sparc"
 endif
 
+if TARGET_ubicom32
+source "extra/Configs/Config.ubicom32"
+endif
+
 if TARGET_v850
 source "extra/Configs/Config.v850"
 endif
Index: uClibc-0.9.30.2/extra/Configs/Config.in.arch
===================================================================
--- uClibc-0.9.30.2.orig/extra/Configs/Config.in.arch	2010-01-13 22:22:31.000000000 +0100
+++ uClibc-0.9.30.2/extra/Configs/Config.in.arch	2010-01-14 11:05:01.000000000 +0100
@@ -149,7 +149,7 @@
 config DO_C99_MATH
 	bool "Enable full C99 math library support"
 	depends on UCLIBC_HAS_FLOATS
-	default n
+	default y
 	help
 	  If you want the uClibc math library to contain the full set C99
 	  math library features, then answer Y.  If you leave this set to
Index: uClibc-0.9.30.2/extra/Configs/Config.ubicom32
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/extra/Configs/Config.ubicom32	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,44 @@
+#
+# For a description of the syntax of this configuration file,
+# see extra/config/Kconfig-language.txt
+#
+
+config TARGET_ARCH
+	string
+	default "ubicom32"
+
+config FORCE_OPTIONS_FOR_ARCH
+	bool
+	default y
+	select ARCH_BIG_ENDIAN
+	select ARCH_HAS_NO_MMU
+
+choice
+	prompt "Target Processor Architecture"
+	default CONFIG_UC_UBICOM32_V3
+	help
+	  This selects the instruction set architecture of your Ubicom32 CPU. This
+	  information is used for optimizing purposes. To build a library that
+	  will run on any Ubicom32 CPU, you can specify "v3" here.
+	  If you pick anything other than "v3," there is no
+	  guarantee that uClibc will even run on anything other than the
+	  selected processor type.
+
+	  You should probably select the Ubicom32 ISA that best matches the
+	  CPU you will be using on your device. uClibc will be tuned
+	  for that architecture.
+
+	  If you don't know what to do, choose "v3"
+
+config CONFIG_UC_UBICOM32_V3
+	bool "ISA v3"
+
+config CONFIG_UC_UBICOM32_V4
+	bool "ISA v4"
+endchoice
+
+config ARCH_CFLAGS
+	string
+
+config CROSS
+	string
Index: uClibc-0.9.30.2/include/elf.h
===================================================================
--- uClibc-0.9.30.2.orig/include/elf.h	2010-01-13 22:22:31.000000000 +0100
+++ uClibc-0.9.30.2/include/elf.h	2010-01-14 11:06:14.000000000 +0100
@@ -337,6 +337,8 @@
 
 #define EM_XSTORMY16		0xad45
 
+#define EM_UBICOM32 	        0xde3d	/* Ubicom32; no ABI */
+
 /* FRV magic number - no EABI available??.  */
 #define EM_CYGNUS_FRV	0x5441
 
@@ -3063,6 +3065,55 @@
 /* Keep this the last entry.  */
 #define R_XTENSA_NUM		50
 
+/* Ubicom32 ELF relocation types */
+#define R_UBICOM32_NONE               0
+#define R_UBICOM32_16                         1
+#define R_UBICOM32_32                         2
+#define R_UBICOM32_LO16               3
+#define R_UBICOM32_HI16               4
+#define R_UBICOM32_21_PCREL           5
+#define R_UBICOM32_24_PCREL           6
+#define R_UBICOM32_HI24               7
+#define R_UBICOM32_LO7_S              8
+#define R_UBICOM32_LO7_2_S            9
+#define R_UBICOM32_LO7_4_S            10
+#define R_UBICOM32_LO7_D              11
+#define R_UBICOM32_LO7_2_D            12
+#define R_UBICOM32_LO7_4_D            13
+#define R_UBICOM32_32_HARVARD                 14
+#define R_UBICOM32_LO7_CALLI          15
+#define R_UBICOM32_LO16_CALLI                 16
+#define R_UBICOM32_GOT_HI24           17
+#define R_UBICOM32_GOT_LO7_S          18
+#define R_UBICOM32_GOT_LO7_2_S                19
+#define R_UBICOM32_GOT_LO7_4_S                20
+#define R_UBICOM32_GOT_LO7_D          21
+#define R_UBICOM32_GOT_LO7_2_D                22
+#define R_UBICOM32_GOT_LO7_4_D                23
+#define R_UBICOM32_FUNCDESC_GOT_HI24  24
+#define R_UBICOM32_FUNCDESC_GOT_LO7_S 25
+#define R_UBICOM32_FUNCDESC_GOT_LO7_2_S 26
+#define R_UBICOM32_FUNCDESC_GOT_LO7_4_S 27
+#define R_UBICOM32_FUNCDESC_GOT_LO7_D 28
+#define R_UBICOM32_FUNCDESC_GOT_LO7_2_D 29
+#define R_UBICOM32_FUNCDESC_GOT_LO7_4_D 30
+#define R_UBICOM32_GOT_LO7_CALLI      31
+#define R_UBICOM32_FUNCDESC_GOT_LO7_CALLI 32
+#define R_UBICOM32_FUNCDESC_VALUE     33
+#define R_UBICOM32_FUNCDESC           34
+#define R_UBICOM32_GOTOFFSET_LO               35
+#define R_UBICOM32_GOTOFFSET_HI               36
+#define R_UBICOM32_FUNCDESC_GOTOFFSET_LO 37
+#define R_UBICOM32_FUNCDESC_GOTOFFSET_HI 38
+#define R_UBICOM32_GNU_VTINHERIT      200
+#define R_UBICOM32_GNU_VTENTRY                201
+
+/* Ubicom32 Flags. */
+#define EF_UBICOM32_V3                0x00000001      /* -fmarch=ubicom32v3 */
+#define EF_UBICOM32_V4                0x00000002      /* -fmarch=ubicom32v4 */
+#define EF_UBICOM32_PIC               0x80000000      /* -fpic */
+#define EF_UBICOM32_FDPIC             0x40000000      /* -mfdpic */
+
 #ifdef	__cplusplus
 }
 #endif
Index: uClibc-0.9.30.2/include/features.h
===================================================================
--- uClibc-0.9.30.2.orig/include/features.h	2010-01-13 22:22:31.000000000 +0100
+++ uClibc-0.9.30.2/include/features.h	2010-01-14 11:05:01.000000000 +0100
@@ -451,4 +451,10 @@
 # define __linux__ 1
 #endif
 
+#ifndef libc_hidden_proto
+#define libc_hidden_proto(name, attrs...)
+#endif
+#ifndef libm_hidden_proto
+#define libm_hidden_proto(name, attrs...)
+#endif
 #endif	/* features.h  */
Index: uClibc-0.9.30.2/ldso/ldso/dl-startup.c
===================================================================
--- uClibc-0.9.30.2.orig/ldso/ldso/dl-startup.c	2010-01-13 22:22:31.000000000 +0100
+++ uClibc-0.9.30.2/ldso/ldso/dl-startup.c	2010-01-14 11:05:01.000000000 +0100
@@ -164,10 +164,13 @@
 		aux_dat += 2;
 	}
 
+#if !defined __FDPIC__
 	/* locate the ELF header.   We need this done as soon as possible
 	 * (esp since SEND_STDERR() needs this on some platforms... */
 	if (!auxvt[AT_BASE].a_un.a_val)
 		auxvt[AT_BASE].a_un.a_val = elf_machine_load_address();
+#endif
+
 	DL_INIT_LOADADDR_BOOT(load_addr, auxvt[AT_BASE].a_un.a_val);
 	header = (ElfW(Ehdr) *) auxvt[AT_BASE].a_un.a_val;
 
Index: uClibc-0.9.30.2/ldso/ldso/ldso.c
===================================================================
--- uClibc-0.9.30.2.orig/ldso/ldso/ldso.c	2010-01-13 22:22:31.000000000 +0100
+++ uClibc-0.9.30.2/ldso/ldso/ldso.c	2010-01-14 11:05:01.000000000 +0100
@@ -179,10 +179,12 @@
 		_dl_progname = argv[0];
 	}
 
+#if 0 // blackfin does this, we do to avoid die during reloc
 	if (_start == (void *) auxvt[AT_ENTRY].a_un.a_val) {
 		_dl_dprintf(_dl_debug_file, "Standalone execution is not supported yet\n");
 		_dl_exit(1);
 	}
+#endif
 
 	/* Start to build the tables of the modules that are required for
 	 * this beast to run.  We start with the basic executable, and then
Index: uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-debug.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-debug.h	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,72 @@
+/* vi: set sw=4 ts=4: */
+/* Ubicom32 ELF shared library loader suppport
+ *
+ * Copyright (c) 2009		Ubicom Inc.
+ * Copyright (c) 1994-2000 Eric Youngdale, Peter MacDonald,
+ *                              David Engel, Hongjiu Lu and Mitch D'Souza
+ * Copyright (C) 2001-2004 Erik Andersen
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. The name of the above contributors may not be
+ *    used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+static const char *_dl_reltypes_tab[] =
+{
+	"R_UBICOM32_NONE", /* 0 */
+	"R_UBICOM32_16",
+	"R_UBICOM32_32",
+	"R_UBICOM32_LO16",
+	"R_UBICOM32_HI16",
+	"R_UBICOM32_21_PCREL", /* 5 */
+	"R_UBICOM32_24_PCREL",
+	"R_UBICOM32_HI24",
+	"R_UBICOM32_LO7_S",
+	"R_UBICOM32_LO7_2_S",
+	"R_UBICOM32_LO7_4_S", /* 10 */
+	"R_UBICOM32_LO7_D",
+	"R_UBICOM32_LO7_2_D",
+	"R_UBICOM32_LO7_4_D",
+	"R_UBICOM32_32_HARVARD",
+	"R_UBICOM32_LO7_CALLI", /* 15 */
+	"R_UBICOM32_LO16_CALLI",
+	"R_UBICOM32_GOT_HI24",
+	"R_UBICOM32_GOT_LO7_S",
+	"R_UBICOM32_GOT_LO7_2_S"
+	"R_UBICOM32_GOT_LO7_4_S", /* 20 */
+	"R_UBICOM32_GOT_LO7_D",
+	"R_UBICOM32_GOT_LO7_2_D",
+	"R_UBICOM32_GOT_LO7_4_D",
+	"R_UBICOM32_FUNCDESC_GOT_HI24	24",
+	"R_UBICOM32_FUNCDESC_GOT_LO7_S", /* 25 */
+	"R_UBICOM32_FUNCDESC_GOT_LO7_2_S",
+	"R_UBICOM32_FUNCDESC_GOT_LO7_4_S",
+	"R_UBICOM32_FUNCDESC_GOT_LO7_D",
+	"R_UBICOM32_FUNCDESC_GOT_LO7_2_D",
+	"R_UBICOM32_FUNCDESC_GOT_LO7_4_D", /* 30 */
+	"R_UBICOM32_GOT_LO7_CALLI",
+	"R_UBICOM32_FUNCDESC_VALUE",
+	"R_UBICOM32_FUNCDESC",
+#if 1
+	[200] "R_UBICOM32_GNU_VTINHERIT" , "R_UBICOM32_GNU_VTENTRY"
+#endif
+};
Index: uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-inlines.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-inlines.h	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,582 @@
+     /* Copyright (C) 2003, 2004 Red Hat, Inc.
+	Contributed by Alexandre Oliva <aoliva@redhat.com>
+
+This file is part of uClibc.
+
+uClibc is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of the
+License, or (at your option) any later version.
+
+uClibc is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with uClibc; see the file COPYING.LIB.  If not, write to
+the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
+USA.  */
+
+//#include <bfin_sram.h>
+#define SRAM_TEST(x) 0
+#ifndef _dl_assert
+# define _dl_assert(expr)
+#endif
+
+/* Initialize a DL_LOADADDR_TYPE given a got pointer and a complete
+   load map.  */
+static __always_inline void
+__dl_init_loadaddr_map (struct elf32_fdpic_loadaddr *loadaddr, Elf32_Addr dl_boot_got_pointer,
+			struct elf32_fdpic_loadmap *map)
+{
+  if (map->version != 0)
+    {
+      SEND_EARLY_STDERR ("Invalid loadmap version number\n");
+      _dl_exit(-1);
+    }
+  if (map->nsegs == 0)
+    {
+      SEND_EARLY_STDERR ("Invalid segment count in loadmap\n");
+      _dl_exit(-1);
+    }
+  loadaddr->got_value = (void*)dl_boot_got_pointer;
+  loadaddr->map = map;
+}
+
+/* Figure out how many LOAD segments there are in the given headers,
+   and allocate a block for the load map big enough for them.
+   got_value will be properly initialized later on, with INIT_GOT.  */
+static __always_inline int
+__dl_init_loadaddr (struct elf32_fdpic_loadaddr *loadaddr, Elf32_Phdr *ppnt,
+		    int pcnt)
+{
+  int count = 0, i;
+  size_t size;
+
+  for (i = 0; i < pcnt; i++)
+    if (ppnt[i].p_type == PT_LOAD)
+      count++;
+
+  loadaddr->got_value = 0;
+
+  size = sizeof (struct elf32_fdpic_loadmap)
+    + sizeof (struct elf32_fdpic_loadseg) * count;
+  loadaddr->map = _dl_malloc (size);
+  if (! loadaddr->map)
+    _dl_exit (-1);
+
+  loadaddr->map->version = 0;
+  loadaddr->map->nsegs = 0;
+
+  return count;
+}
+
+#if defined (__SUPPORT_LD_DEBUG__)
+extern char *_dl_debug;
+extern int _dl_debug_file;
+#endif
+
+/* Incrementally initialize a load map.  */
+static __always_inline void
+__dl_init_loadaddr_hdr (struct elf32_fdpic_loadaddr loadaddr, void *addr,
+			Elf32_Phdr *phdr, int maxsegs)
+{
+  struct elf32_fdpic_loadseg *segdata;
+
+  if (loadaddr.map->nsegs == maxsegs)
+    _dl_exit (-1);
+
+  segdata = &loadaddr.map->segs[loadaddr.map->nsegs++];
+  segdata->addr = (Elf32_Addr) addr;
+  segdata->p_vaddr = phdr->p_vaddr;
+  segdata->p_memsz = phdr->p_memsz;
+
+#if defined (__SUPPORT_LD_DEBUG__)
+  {
+    if (_dl_debug)
+      _dl_dprintf(_dl_debug_file, "%i: mapped %x at %x, size %x\n",
+		  loadaddr.map->nsegs-1,
+		  segdata->p_vaddr, segdata->addr, segdata->p_memsz);
+  }
+#endif
+}
+
+static __always_inline void __dl_loadaddr_unmap
+(struct elf32_fdpic_loadaddr loadaddr, struct funcdesc_ht *funcdesc_ht);
+
+/* Figure out whether the given address is in one of the mapped
+   segments.  */
+static __always_inline int
+__dl_addr_in_loadaddr (void *p, struct elf32_fdpic_loadaddr loadaddr)
+{
+  struct elf32_fdpic_loadmap *map = loadaddr.map;
+  int c;
+
+  for (c = 0; c < map->nsegs; c++)
+    if ((void*)map->segs[c].addr <= p
+	&& (char*)p < (char*)map->segs[c].addr + map->segs[c].p_memsz)
+      return 1;
+
+  return 0;
+}
+
+static __always_inline void * _dl_funcdesc_for (void *entry_point, void *got_value);
+
+/* The hashcode handling code below is heavily inspired in libiberty's
+   hashtab code, but with most adaptation points and support for
+   deleting elements removed.
+
+   Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   Contributed by Vladimir Makarov (vmakarov@cygnus.com).  */
+
+static __always_inline unsigned long
+higher_prime_number (unsigned long n)
+{
+  /* These are primes that are near, but slightly smaller than, a
+     power of two.  */
+  static const unsigned long primes[] = {
+    (unsigned long) 7,
+    (unsigned long) 13,
+    (unsigned long) 31,
+    (unsigned long) 61,
+    (unsigned long) 127,
+    (unsigned long) 251,
+    (unsigned long) 509,
+    (unsigned long) 1021,
+    (unsigned long) 2039,
+    (unsigned long) 4093,
+    (unsigned long) 8191,
+    (unsigned long) 16381,
+    (unsigned long) 32749,
+    (unsigned long) 65521,
+    (unsigned long) 131071,
+    (unsigned long) 262139,
+    (unsigned long) 524287,
+    (unsigned long) 1048573,
+    (unsigned long) 2097143,
+    (unsigned long) 4194301,
+    (unsigned long) 8388593,
+    (unsigned long) 16777213,
+    (unsigned long) 33554393,
+    (unsigned long) 67108859,
+    (unsigned long) 134217689,
+    (unsigned long) 268435399,
+    (unsigned long) 536870909,
+    (unsigned long) 1073741789,
+    (unsigned long) 2147483647,
+					/* 4294967291L */
+    ((unsigned long) 2147483647) + ((unsigned long) 2147483644),
+  };
+
+  const unsigned long *low = &primes[0];
+  const unsigned long *high = &primes[sizeof(primes) / sizeof(primes[0])];
+
+  while (low != high)
+    {
+      const unsigned long *mid = low + (high - low) / 2;
+      if (n > *mid)
+	low = mid + 1;
+      else
+	high = mid;
+    }
+
+#if 0
+  /* If we've run out of primes, abort.  */
+  if (n > *low)
+    {
+      fprintf (stderr, "Cannot find prime bigger than %lu\n", n);
+      abort ();
+    }
+#endif
+
+  return *low;
+}
+
+struct funcdesc_ht
+{
+  /* Table itself.  */
+  struct funcdesc_value **entries;
+
+  /* Current size (in entries) of the hash table */
+  size_t size;
+
+  /* Current number of elements.  */
+  size_t n_elements;
+};
+
+static __always_inline int
+hash_pointer (const void *p)
+{
+  return (int) ((long)p >> 3);
+}
+
+static __always_inline struct funcdesc_ht *
+htab_create (void)
+{
+  struct funcdesc_ht *ht = _dl_malloc (sizeof (struct funcdesc_ht));
+
+  if (! ht)
+    return NULL;
+  ht->size = 3;
+  ht->entries = _dl_malloc (sizeof (struct funcdesc_ht_value *) * ht->size);
+  if (! ht->entries)
+    return NULL;
+
+  ht->n_elements = 0;
+
+  _dl_memset (ht->entries, 0, sizeof (struct funcdesc_ht_value *) * ht->size);
+
+  return ht;
+}
+
+/* This is only called from _dl_loadaddr_unmap, so it's safe to call
+   _dl_free().  See the discussion below.  */
+static __always_inline void
+htab_delete (struct funcdesc_ht *htab)
+{
+  int i;
+
+  for (i = htab->size - 1; i >= 0; i--)
+    if (htab->entries[i])
+      _dl_free (htab->entries[i]);
+
+  _dl_free (htab->entries);
+  _dl_free (htab);
+}
+
+/* Similar to htab_find_slot, but without several unwanted side effects:
+    - Does not call htab->eq_f when it finds an existing entry.
+    - Does not change the count of elements/searches/collisions in the
+      hash table.
+   This function also assumes there are no deleted entries in the table.
+   HASH is the hash value for the element to be inserted.  */
+
+static __always_inline struct funcdesc_value **
+find_empty_slot_for_expand (struct funcdesc_ht *htab, int hash)
+{
+  size_t size = htab->size;
+  unsigned int index = hash % size;
+  struct funcdesc_value **slot = htab->entries + index;
+  int hash2;
+
+  if (! *slot)
+    return slot;
+
+  hash2 = 1 + hash % (size - 2);
+  for (;;)
+    {
+      index += hash2;
+      if (index >= size)
+	index -= size;
+
+      slot = htab->entries + index;
+      if (! *slot)
+	return slot;
+    }
+}
+
+/* The following function changes size of memory allocated for the
+   entries and repeatedly inserts the table elements.  The occupancy
+   of the table after the call will be about 50%.  Naturally the hash
+   table must already exist.  Remember also that the place of the
+   table entries is changed.  If memory allocation failures are allowed,
+   this function will return zero, indicating that the table could not be
+   expanded.  If all goes well, it will return a non-zero value.  */
+
+static __always_inline int
+htab_expand (struct funcdesc_ht *htab)
+{
+  struct funcdesc_value **oentries;
+  struct funcdesc_value **olimit;
+  struct funcdesc_value **p;
+  struct funcdesc_value **nentries;
+  size_t nsize;
+
+  oentries = htab->entries;
+  olimit = oentries + htab->size;
+
+  /* Resize only when table after removal of unused elements is either
+     too full or too empty.  */
+  if (htab->n_elements * 2 > htab->size)
+    nsize = higher_prime_number (htab->n_elements * 2);
+  else
+    nsize = htab->size;
+
+  nentries = _dl_malloc (sizeof (struct funcdesc_value *) * nsize);
+  _dl_memset (nentries, 0, sizeof (struct funcdesc_value *) * nsize);
+  if (nentries == NULL)
+    return 0;
+  htab->entries = nentries;
+  htab->size = nsize;
+
+  p = oentries;
+  do
+    {
+      if (*p)
+	*find_empty_slot_for_expand (htab, hash_pointer ((*p)->entry_point))
+	  = *p;
+
+      p++;
+    }
+  while (p < olimit);
+
+#if 0 /* We can't tell whether this was allocated by the _dl_malloc()
+	 built into ld.so or malloc() in the main executable or libc,
+	 and calling free() for something that wasn't malloc()ed could
+	 do Very Bad Things (TM).  Take the conservative approach
+	 here, potentially wasting as much memory as actually used by
+	 the hash table, even if multiple growths occur.  That's not
+	 so bad as to require some overengineered solution that would
+	 enable us to keep track of how it was allocated. */
+  _dl_free (oentries);
+#endif
+  return 1;
+}
+
+/* This function searches for a hash table slot containing an entry
+   equal to the given element.  To delete an entry, call this with
+   INSERT = 0, then call htab_clear_slot on the slot returned (possibly
+   after doing some checks).  To insert an entry, call this with
+   INSERT = 1, then write the value you want into the returned slot.
+   When inserting an entry, NULL may be returned if memory allocation
+   fails.  */
+
+static __always_inline struct funcdesc_value **
+htab_find_slot (struct funcdesc_ht *htab, void *ptr, int insert)
+{
+  unsigned int index;
+  int hash, hash2;
+  size_t size;
+  struct funcdesc_value **entry;
+
+  if (htab->size * 3 <= htab->n_elements * 4
+      && htab_expand (htab) == 0)
+    return NULL;
+
+  hash = hash_pointer (ptr);
+
+  size = htab->size;
+  index = hash % size;
+
+  entry = &htab->entries[index];
+  if (!*entry)
+    goto empty_entry;
+  else if ((*entry)->entry_point == ptr)
+    return entry;
+
+  hash2 = 1 + hash % (size - 2);
+  for (;;)
+    {
+      index += hash2;
+      if (index >= size)
+	index -= size;
+
+      entry = &htab->entries[index];
+      if (!*entry)
+	goto empty_entry;
+      else if ((*entry)->entry_point == ptr)
+	return entry;
+    }
+
+ empty_entry:
+  if (!insert)
+    return NULL;
+
+  htab->n_elements++;
+  return entry;
+}
+
+void *
+_dl_funcdesc_for (void *entry_point, void *got_value)
+{
+  struct elf_resolve *tpnt = ((void**)got_value)[2];
+  struct funcdesc_ht *ht = tpnt->funcdesc_ht;
+  struct funcdesc_value **entry;
+
+  _dl_assert (got_value == tpnt->loadaddr.got_value);
+
+  if (! ht)
+    {
+      ht = htab_create ();
+      if (! ht)
+	return (void*)-1;
+      tpnt->funcdesc_ht = ht;
+    }
+
+  entry = htab_find_slot (ht, entry_point, 1);
+  if (*entry)
+    {
+      _dl_assert ((*entry)->entry_point == entry_point);
+      return _dl_stabilize_funcdesc (*entry);
+    }
+
+  *entry = _dl_malloc (sizeof (struct funcdesc_value));
+  (*entry)->entry_point = entry_point;
+  (*entry)->got_value = got_value;
+
+  return _dl_stabilize_funcdesc (*entry);
+}
+
+static __always_inline void const *
+_dl_lookup_address (void const *address)
+{
+  struct elf_resolve *rpnt;
+  struct funcdesc_value const *fd;
+
+  /* Make sure we don't make assumptions about its alignment.  */
+  __asm__ ("" : "+r" (address));
+
+  if ((Elf32_Addr)address & 7)
+    /* It's not a function descriptor.  */
+    return address;
+
+  fd = (struct funcdesc_value const *)address;
+
+  for (rpnt = _dl_loaded_modules; rpnt; rpnt = rpnt->next)
+    {
+      if (! rpnt->funcdesc_ht)
+	continue;
+
+      if (fd->got_value != rpnt->loadaddr.got_value)
+	continue;
+
+      address = htab_find_slot (rpnt->funcdesc_ht, (void*)fd->entry_point, 0);
+
+      if (address && *(struct funcdesc_value *const*)address == fd)
+	{
+	  address = (*(struct funcdesc_value *const*)address)->entry_point;
+	  break;
+	}
+      else
+	address = fd;
+    }
+
+  return address;
+}
+
+void
+__dl_loadaddr_unmap (struct elf32_fdpic_loadaddr loadaddr,
+		     struct funcdesc_ht *funcdesc_ht)
+{
+  int i;
+
+  for (i = 0; i < loadaddr.map->nsegs; i++)
+    {
+      struct elf32_fdpic_loadseg *segdata;
+      ssize_t offs;
+      segdata = loadaddr.map->segs + i;
+
+#if 0 /* SRAM */
+      /* FIXME:
+	A more cleaner way is to add type for struct elf32_fdpic_loadseg,
+	and release the memory according to the type.
+	Currently, we hardcode the memory address of L1 SRAM.  */
+      if ((segdata->addr & 0xff800000) == 0xff800000)
+       {
+	 _dl_sram_free ((void *)segdata->addr);
+	 continue;
+       }
+#endif
+      offs = (segdata->p_vaddr & ADDR_ALIGN);
+      _dl_munmap ((void*)segdata->addr - offs,
+		  segdata->p_memsz + offs);
+    }
+  /* _dl_unmap is only called for dlopen()ed libraries, for which
+     calling free() is safe, or before we've completed the initial
+     relocation, in which case calling free() is probably pointless,
+     but still safe.  */
+  _dl_free (loadaddr.map);
+  if (funcdesc_ht)
+    htab_delete (funcdesc_ht);
+}
+
+#if 0 /* XXX TODO will look at enabling this if we decide to add support for OCM
+       * code/data */
+// OLD BLACKFIN CODE
+static __always_inline int
+__dl_is_special_segment (Elf32_Ehdr *epnt,
+			 Elf32_Phdr *ppnt)
+{
+  if (ppnt->p_type != PT_LOAD)
+    return 0;
+
+  if ((epnt->e_flags & EF_BFIN_CODE_IN_L1)
+      && !(ppnt->p_flags & PF_W)
+      && (ppnt->p_flags & PF_X))
+    return 1;
+
+  if ((epnt->e_flags & EF_BFIN_DATA_IN_L1)
+      && (ppnt->p_flags & PF_W)
+      && !(ppnt->p_flags & PF_X))
+    return 1;
+
+  /* 0xff700000, 0xff800000, 0xff900000 and 0xffa00000 are also used in
+     GNU ld and linux kernel. They need to be keep synchronized.  */
+  if (ppnt->p_vaddr == 0xff700000
+      || ppnt->p_vaddr == 0xff800000
+      || ppnt->p_vaddr == 0xff900000
+      || ppnt->p_vaddr == 0xffa00000)
+    return 1;
+
+  return 0;
+}
+
+static __always_inline char *
+__dl_map_segment (Elf32_Ehdr *epnt,
+		  Elf32_Phdr *ppnt,
+		  int infile,
+		  int flags)
+{
+  char *status, *tryaddr, *l1addr;
+  size_t size;
+
+
+  if (((epnt->e_flags & EF_BFIN_CODE_IN_L1) || ppnt->p_vaddr == 0xffa00000)
+      && !(ppnt->p_flags & PF_W)
+      && (ppnt->p_flags & PF_X)) {
+    status = (char *) _dl_mmap
+      (tryaddr = 0,
+       size = (ppnt->p_vaddr & ADDR_ALIGN) + ppnt->p_filesz,
+       LXFLAGS(ppnt->p_flags),
+       flags | MAP_EXECUTABLE | MAP_DENYWRITE,
+       infile, ppnt->p_offset & OFFS_ALIGN);
+    if (_dl_mmap_check_error(status)
+	|| (tryaddr && tryaddr != status))
+      return NULL;
+    l1addr = (char *) _dl_sram_alloc (ppnt->p_filesz, L1_INST_SRAM);
+    if (l1addr != NULL)
+      _dl_dma_memcpy (l1addr, status + (ppnt->p_vaddr & ADDR_ALIGN), ppnt->p_filesz);
+    _dl_munmap (status, size);
+    if (l1addr == NULL)
+      _dl_dprintf(2, "%s:%i: L1 allocation failed\n", _dl_progname, __LINE__);
+    return l1addr;
+  }
+
+  if (((epnt->e_flags & EF_BFIN_DATA_IN_L1)
+       || ppnt->p_vaddr == 0xff700000
+       || ppnt->p_vaddr == 0xff800000
+       || ppnt->p_vaddr == 0xff900000)
+      && (ppnt->p_flags & PF_W)
+      && !(ppnt->p_flags & PF_X)) {
+    if (ppnt->p_vaddr == 0xff800000)
+      l1addr = (char *) _dl_sram_alloc (ppnt->p_memsz, L1_DATA_A_SRAM);
+    else if (ppnt->p_vaddr == 0xff900000)
+      l1addr = (char *) _dl_sram_alloc (ppnt->p_memsz, L1_DATA_B_SRAM);
+    else
+      l1addr = (char *) _dl_sram_alloc (ppnt->p_memsz, L1_DATA_SRAM);
+    if (l1addr == NULL) {
+      _dl_dprintf(2, "%s:%i: L1 allocation failed\n", _dl_progname, __LINE__);
+    } else {
+      if (_DL_PREAD (infile, l1addr, ppnt->p_filesz, ppnt->p_offset) != ppnt->p_filesz) {
+	_dl_sram_free (l1addr);
+	return NULL;
+      }
+      if (ppnt->p_filesz < ppnt->p_memsz)
+       _dl_memset (l1addr + ppnt->p_filesz, 0, ppnt->p_memsz - ppnt->p_filesz);
+    }
+    return l1addr;
+  }
+  return 0;
+}
+#endif
Index: uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-startup.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-startup.h	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,232 @@
+/*
+  Copyright (C) 2009 Ubicom, Inc.
+  Copyright (C) 2003 Red Hat, Inc.
+  Contributed by Alexandre Oliva <aoliva@redhat.com>
+
+This file is part of uClibc.
+
+uClibc is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of the
+License, or (at your option) any later version.
+
+uClibc is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with uClibc; see the file COPYING.LIB.  If not, write to
+the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
+USA.  */
+
+/* Any assembly language/system dependent hacks needed to setup
+ * boot1.c so it will work as expected and cope with whatever platform
+ * specific wierdness is needed for this architecture.
+
+ * We override the default _dl_boot function, and replace it with a
+ * bit of asm.  Then call the real _dl_boot function, which is now
+ * named _dl_boot2.  */
+
+/* At program start-up, p0 contains a pointer to a
+   elf32_fdpic_loadmap that describes how the executable was loaded
+   into memory.  p1 contains a pointer to the interpreter (our!)
+   loadmap, if there is an interpreter, or 0 if we're being run as an
+   executable.  p2 holds a pointer to the interpreter's dynamic
+   section, if there is an interpreter, or to the executable's dynamic
+   section, otherwise.  If the executable is not dynamic, gr18 is 0.
+
+   We rely on the fact that the linker adds a pointer to the
+   _GLOBAL_OFFSET_TABLE_ as the last ROFIXUP entry, and that
+   __self_reloc returns the relocated pointer to us, so that we can
+   use this value to initialize the PIC register.  */
+
+
+/*
+ *  _dl_boot is the entry point for ldso.
+ *
+ * The kernel leaves the main apps args on the stack (positive offsets), and
+ * communicates the load maps as follows
+ *
+ * - d1 is set to the exec_map_addr (struct elf32_fdpic_loadmap *), which is the
+ *   current state of the mapped application.
+ *
+ * - d2 is set to interp_map_addr (struct elf32_fdpic_loadmap *), which is use
+ *    by ldso to relocate itself.
+ *
+ * - d3 is dynamic_addr which as far as I can tell is the stack pointer.
+ *
+ * - a1 is set to zero and will later be initialised to ldso _dl_fini funcdesc
+ */
+
+__asm__(
+	"	.text							\n\t"
+	"	.global	_start						\n\t"
+	"	.type	_start,@function				\n\t"
+	"_start:\n\t"
+	/*
+	 * Jump to .Lcall storing the location .Lcall in a5
+	 */
+	"	call	a5, .Lcall					\n\t"
+	".Lcall:							\n\t"
+	/*
+	 * Reserve and Push inputs to stack.
+	 * 32 byte  stack layout as follows
+	 * offset	0  exec_map_addr
+	 *		4  interp_map_addr
+	 *		8  dynamic_addr
+	 *		12 not used
+	 *		16 dl_main_funcdesc structure for _dl_boot
+	 *		   (12 bytes sizeof funcdesc_value)
+	 *		28 reserved
+	 *		32  start of &original stack
+	 */
+	"	pdec	sp, 32(sp); reserve stack space			\n\t"
+	"	move.4	0(sp), d1 ; exec_map_addr			\n\t"
+	"	move.4	4(sp), d2 ; interp_map_addr			\n\t"
+	"	move.4	8(sp), d3; dynamic_addr				\n\t"
+
+	/*
+	 * Load linker version of .Lcall in to d0
+	 */
+	"	moveai	a3, #%hi(.Lcall)				\n\t"
+	"	lea.1	d0, %lo(.Lcall)(a3)				\n\t"
+
+	/*
+	 * Determine the offset from loaded .Lcall and put it in d0.
+	 */
+	"	sub.4 d0, a5, d0					\n\t"
+
+	/*
+	 * Load linker version of __ROFIXUP_LIST__ and __ROFIXUP_END__ in to d1
+	 * and d2.
+	 */
+	"	moveai	a3, #%hi(__ROFIXUP_LIST__)			\n\t"
+	"	lea.1	d1, %lo(__ROFIXUP_LIST__)(a3)			\n\t"
+	"	moveai	a3, #%hi(__ROFIXUP_END__)			\n\t"
+	"	lea.1	d2, %lo(__ROFIXUP_END__)(a3)			\n\t"
+	/*
+	 * Use offset determined above to find the loaded versions.
+	 */
+	"	add.4	d1, d1, d0					\n\t"
+	"	add.4	d2, d2, d0					\n\t"
+
+	/*
+	 * Load interp_map_addr into d0, if interp_map_addr is null use
+	 * exec_map_addr.
+	 */
+	"	move.4	d0, 4(sp) ; load interp_map_addr	       	\n\t"
+	"	cmpi	d0, #0						\n\t"
+	"	jmpne.f	1f						\n\t"
+	"	move.4	d0, 0(sp) ; load exec_map_addr			\n\t"
+
+	/*
+	 * call __self_reloc(map, void ***p, void ***e)
+	 * it returns the the GOT in d0.
+	 */
+	"1:	call	a5, __self_reloc ; returns a0 in d0		\n\t"
+	"	move.4	a0, d0 ; set GOT				\n\t"
+	"	move.4	a2, d0 ; save GOT				\n\t"
+
+	/*
+	 * now setup to call
+	 * _dl_start (Elf32_Addr dl_boot_got_pointer,		(d0)
+	 *	struct elf32_fdpic_loadmap *dl_boot_progmap,	(d1)
+	 *	struct elf32_fdpic_loadmap *dl_boot_ldsomap,	(d2)
+	 *	Elf32_Dyn *dl_boot_ldso_dyn_pointer,		(d3)
+	 *	struct funcdesc_value *dl_main_funcdesc,	(d4)
+	 *	unsigned long args				(d5)
+	 *
+	 * NOTE: for dl_main_funcdesc we reserved space on the stack for this
+	 * structure.
+	 */
+	"	move.4	d1, 0(sp)	; d1 = exec_map_addr		\n\t"
+	"	move.4	d2, 4(sp)	; d2 = interp_map_addr		\n\t"
+	"	move.4	d3, 8(sp)	; d3 = dynamic_addr		\n\t"
+	"	lea.1	d4, 16(sp)	; d4 = &dl_main_funcdesc	\n\t"
+	"	lea.1	d5, 32(sp)	; d5 = original stack ptr (args)\n\t"
+	"	call	a5, _dl_start					\n\t"
+
+	/*
+	 * Setup to call the main entry point, starting with passing our FINI
+	 * ptr() to the user in a1 (remember we saved the got in a2)
+	 */
+	"	movei	d15, #%got_funcdesc_lo(_dl_fini)		\n\t"
+	"	move.4	a1, (a2, d15)					\n\t"
+
+	/*
+	 * restore the load map from the kernel.
+	 */
+	"	move.4	d1, 0(sp)	; restore exec_map_addr		\n\t"
+	"	move.4	d2, 4(sp)	; restore interp_map_addr	\n\t"
+	"	move.4	d3, 8(sp)	; restore dynamic_addr		\n\t"
+
+	/*
+	 * _dl_start returned the main apps entry point in dl_main_funcdesc,
+	 * load that information now.
+	 */
+	"	move.4	a5, 16(sp) ; a5 = dl_main_funcdesc.entry_point	\n\t"
+	"	move.4	a0, 20(sp) ; a0 = dl_main_funcdesc.got_value	\n\t"
+	"	lea.1	sp, 32(sp); restore original stack ptr (args)	\n\t"
+	"	calli	a5, 0(a5)					\n\t"
+	"	bkpt	-1; should never get here			\n\t"
+	"	.size	_start, . - _start				\n\t"
+);
+
+#undef DL_START
+#define DL_START(X)   \
+static void  __attribute__ ((used)) \
+_dl_start (Elf32_Addr dl_boot_got_pointer, \
+	   struct elf32_fdpic_loadmap *dl_boot_progmap, \
+	   struct elf32_fdpic_loadmap *dl_boot_ldsomap, \
+	   Elf32_Dyn *dl_boot_ldso_dyn_pointer, \
+	   struct funcdesc_value *dl_main_funcdesc, \
+	   X)
+
+struct elf32_fdpic_loadmap;
+
+/*
+ * Get a pointer to the argv array.  On many platforms this can be just
+ * the address if the first argument, on other platforms we need to
+ * do something a little more subtle here.
+ */
+#define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long*) ARGS) + 1)
+
+/*
+ * Here is a macro to perform a relocation.  This is only used when
+ * bootstrapping the dynamic loader.  RELP is the relocation that we
+ * are performing, REL is the pointer to the address we are relocating.
+ * SYMBOL is the symbol involved in the relocation, and LOAD is the
+ * load address.
+ */
+#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB) \
+	switch(ELF32_R_TYPE((RELP)->r_info)){				\
+	case R_UBICOM32_32:						\
+	  *(REL) += (SYMBOL);						\
+	  break;							\
+	case R_UBICOM32_FUNCDESC_VALUE:					\
+	  {								\
+	    struct funcdesc_value fv = {				\
+	      (void*)((SYMBOL) + *(REL)),				\
+	      (LOAD).got_value						\
+	    };								\
+	    *(struct funcdesc_value volatile *)(REL) = fv;		\
+	    break;							\
+	  }								\
+	default:							\
+	  _dl_exit(1);							\
+	}
+
+/*
+ * Transfer control to the user's application, once the dynamic loader
+ * is done.  We return the address of the function's entry point to
+ * _dl_boot, see boot1_arch.h.
+ */
+#define START()	do {							\
+  struct elf_resolve *exec_mod = _dl_loaded_modules;			\
+  dl_main_funcdesc->entry_point = _dl_elf_main;				\
+  while (exec_mod->libtype != elf_executable)				\
+    exec_mod = exec_mod->next;						\
+  dl_main_funcdesc->got_value = exec_mod->loadaddr.got_value;		\
+  return;								\
+} while (0)
Index: uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-syscalls.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-syscalls.h	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,206 @@
+/* Copyright (C) 2003, 2004 Red Hat, Inc.
+   Contributed by Alexandre Oliva <aoliva@redhat.com>
+
+This file is part of uClibc.
+
+uClibc is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of the
+License, or (at your option) any later version.
+
+uClibc is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with uClibc; see the file COPYING.LIB.  If not, write to
+the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
+USA.  */
+
+/* We can't use the real errno in ldso, since it has not yet
+ * been dynamicly linked in yet. */
+#include "sys/syscall.h"
+extern int _dl_errno;
+#undef __set_errno
+#define __set_errno(X) {(_dl_errno) = (X);}
+#include <sys/mman.h>
+
+/* The code below is extracted from libc/sysdeps/linux/frv/_mmap.c */
+
+#if defined(DYNAMIC_LOADER_IN_SIMULATOR) && DYNAMIC_LOADER_IN_SIMULATOR
+#define __NR___syscall_mmap2	    __NR_mmap2
+static __inline__ _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr,
+	size_t, len, int, prot, int, flags, int, fd, off_t, offset);
+
+/* Make sure we don't get another definition of _dl_mmap from the
+   machine-independent code.  */
+#undef __NR_mmap
+#undef __NR_mmap2
+
+/* This is always 12, even on architectures where PAGE_SHIFT != 12.  */
+# ifndef MMAP2_PAGE_SHIFT
+#  define MMAP2_PAGE_SHIFT 12
+# endif
+
+#include <bits/uClibc_page.h> /* for PAGE_SIZE */
+static __always_inline void *_dl_memset(void*,int,size_t);
+static __always_inline ssize_t _dl_pread(int fd, void *buf, size_t count, off_t offset);
+
+static __ptr_t
+_dl_mmap(__ptr_t addr, size_t len, int prot, int flags, int fd, __off_t offset)
+{
+  size_t plen = (len + PAGE_SIZE - 1) & -PAGE_SIZE;
+
+/* This is a hack to enable the dynamic loader to run within a
+   simulator that doesn't support mmap, with a number of very ugly
+   tricks.  Also, it's not as useful as it sounds, since only dynamic
+   executables without DT_NEEDED dependencies can be run.  AFAIK, they
+   can only be created with -pie.  This trick suffices to enable the
+   dynamic loader to obtain a blank page that it maps early in the
+   bootstrap. */
+  if ((flags & MAP_FIXED) == 0)
+    {
+      void *_dl_mmap_base = 0;
+      __ptr_t *ret = 0;
+
+      if (! _dl_mmap_base)
+	{
+	  void *stack;
+	  __asm__ ("mov sp, %0" : "=r" (stack));
+	  _dl_mmap_base = (void *)(((long)stack + 2 * PAGE_SIZE) & -PAGE_SIZE);
+	retry:
+	  if (((void **)_dl_mmap_base)[0] == _dl_mmap_base
+	      && ((void **)_dl_mmap_base)[1023] == _dl_mmap_base
+	      && (((void **)_dl_mmap_base)[177]
+		  == ((void **)_dl_mmap_base)[771]))
+	    {
+	      while (((void**)_dl_mmap_base)[177])
+		{
+		  _dl_mmap_base = ((void**)_dl_mmap_base)[177];
+		  if (!(((void **)_dl_mmap_base)[0] == _dl_mmap_base
+			&& ((void **)_dl_mmap_base)[1023] == _dl_mmap_base
+			&& (((void **)_dl_mmap_base)[177]
+			    == ((void**)_dl_mmap_base)[771])))
+		    ((void(*)())0)();
+		}
+	    }
+	  else
+	    {
+	      int i;
+	      for (i = 0; i < (int)PAGE_SIZE; i++)
+		if (*(char*)(_dl_mmap_base + i))
+		  break;
+	      if (i != PAGE_SIZE)
+		{
+		  _dl_mmap_base = (void*)((long)_dl_mmap_base + PAGE_SIZE);
+		  goto retry;
+		}
+	      ((void**)_dl_mmap_base)[-1] =
+		((void**)_dl_mmap_base)[0] =
+		((void**)_dl_mmap_base)[1023] =
+		_dl_mmap_base;
+	    }
+	}
+
+      if (_dl_mmap_base)
+	{
+	  if (!(((void **)_dl_mmap_base)[0] == _dl_mmap_base
+		&& ((void **)_dl_mmap_base)[1023] == _dl_mmap_base
+		&& (((void **)_dl_mmap_base)[177]
+		    == ((void**)_dl_mmap_base)[771])))
+	    ((void(*)())0)();
+	  ret = (__ptr_t)((char*)_dl_mmap_base + PAGE_SIZE);
+	  _dl_mmap_base =
+	    ((void**)_dl_mmap_base)[177] =
+	    ((void**)_dl_mmap_base)[771] =
+	    (char*)_dl_mmap_base + plen + PAGE_SIZE;
+	  ((void**)_dl_mmap_base)[0] =
+	    ((void**)_dl_mmap_base)[1023] =
+	    _dl_mmap_base;
+	}
+
+      if ((flags & MAP_ANONYMOUS) != 0)
+	{
+	  _dl_memset (ret, 0, plen);
+	  return ret;
+	}
+
+      flags |= MAP_FIXED;
+      addr = ret;
+    }
+    if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1)) {
+#if 0
+	__set_errno (EINVAL);
+#endif
+	return MAP_FAILED;
+    }
+    if ((flags & MAP_FIXED) != 0)
+      {
+	if (_dl_pread(fd, addr, len, offset) != (ssize_t)len)
+	  return (void*)MAP_FAILED;
+	if (plen != len)
+	  _dl_memset (addr + len, 0, plen - len);
+	return addr;
+      }
+    return(__syscall_mmap2(addr, len, prot, flags, fd, (off_t) (offset >> MMAP2_PAGE_SHIFT)));
+}
+#endif
+
+#ifdef __NR_pread64
+#ifdef DYNAMIC_LOADER_IN_SIMULATOR
+#include <unistd.h>
+
+#define __NR___syscall_lseek __NR_lseek
+static __always_inline unsigned long _dl_read(int fd, const void *buf, unsigned long count);
+
+static __always_inline _syscall3(__off_t, __syscall_lseek, int, fd, __off_t, offset,
+			int, whence);
+static __always_inline ssize_t
+_dl_pread(int fd, void *buf, size_t count, off_t offset)
+{
+  __off_t orig = __syscall_lseek (fd, 0, SEEK_CUR);
+  ssize_t ret;
+
+  if (orig == -1)
+    return -1;
+
+  if (__syscall_lseek (fd, offset, SEEK_SET) != offset)
+    return -1;
+
+  ret = _dl_read (fd, buf, count);
+
+  if (__syscall_lseek (fd, orig, SEEK_SET) != orig)
+    ((void(*)())0)();
+
+  return ret;
+}
+#else
+#define __NR___syscall_pread __NR_pread64
+static __always_inline _syscall5(ssize_t, __syscall_pread, int, fd, void *, buf,
+			size_t, count, off_t, offset_hi, off_t, offset_lo);
+
+static __always_inline ssize_t
+_dl_pread(int fd, void *buf, size_t count, off_t offset)
+{
+  return(__syscall_pread(fd,buf,count,__LONG_LONG_PAIR (offset >> 31, offset)));
+}
+#endif
+#endif
+
+#ifdef __NR_sram_alloc
+#define __NR__dl_sram_alloc __NR_sram_alloc
+static __always_inline _syscall2(__ptr_t, _dl_sram_alloc,
+			size_t, len, unsigned long, flags);
+#endif
+
+#ifdef __NR_sram_free
+#define __NR__dl_sram_free __NR_sram_free
+static __always_inline _syscall1(int, _dl_sram_free, __ptr_t, addr);
+#endif
+
+#ifdef __NR_dma_memcpy
+#define __NR__dl_dma_memcpy __NR_dma_memcpy
+static __always_inline _syscall3(__ptr_t, _dl_dma_memcpy,
+			__ptr_t, dest, __ptr_t, src, size_t, len);
+#endif
Index: uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-sysdep.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-sysdep.h	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,243 @@
+     /* Copyright (C) 2003, 2004 Red Hat, Inc.
+	Contributed by Alexandre Oliva <aoliva@redhat.com>
+	Based on ../i386/dl-sysdep.h
+
+This file is part of uClibc.
+
+uClibc is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of the
+License, or (at your option) any later version.
+
+uClibc is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with uClibc; see the file COPYING.LIB.  If not, write to
+the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
+USA.  */
+
+/*
+ * Various assembly language/system dependent  hacks that are required
+ * so that we can minimize the amount of platform specific code.
+ */
+
+/*
+ * Define this if the system uses RELOCA.
+ */
+#undef ELF_USES_RELOCA
+
+/* JMPREL relocs are inside the DT_RELA table.  */
+#define ELF_MACHINE_PLTREL_OVERLAP
+
+#define DL_NO_COPY_RELOCS
+
+#define HAVE_DL_INLINES_H
+
+/*
+ * Initialization sequence for a GOT.  Copy the resolver function
+ * descriptor and the pointer to the elf_resolve/link_map data
+ * structure.  Initialize the got_value in the module while at that.
+ */
+#define INIT_GOT(GOT_BASE,MODULE) \
+{				\
+  (MODULE)->loadaddr.got_value = (GOT_BASE); \
+  GOT_BASE[0] = ((unsigned long *)&_dl_linux_resolve)[0]; \
+  GOT_BASE[1] = ((unsigned long *)&_dl_linux_resolve)[1]; \
+  GOT_BASE[2] = (unsigned long) MODULE; \
+}
+
+/* Here we define the magic numbers that this dynamic loader should accept */
+#define MAGIC1 EM_UBICOM32
+#undef  MAGIC2
+
+/* Used for error messages */
+#define ELF_TARGET "UBICOM32"
+
+struct elf_resolve;
+
+struct funcdesc_value
+{
+  void *entry_point;
+  void *got_value;
+/*int  relocation; not sure if this required, but it does exist */
+};
+
+extern int _dl_linux_resolve(void) __attribute__((__visibility__("hidden")));
+extern struct funcdesc_value volatile *__attribute__((__visibility__("hidden")))
+	_dl_linux_resolver (struct elf_resolve *tpnt, int reloc_entry);
+
+/* 4KiB page alignment.  Should perhaps be made dynamic using
+   getpagesize(), based on AT_PAGESZ from auxvt?  */
+#define PAGE_ALIGN 0xfffff000
+#define ADDR_ALIGN 0xfff
+#define OFFS_ALIGN 0x7ffff000
+
+struct funcdesc_ht;
+
+/*
+ * This asm does a quick relcation of string S (which is stored in the text
+ * section as thats all we can use
+ */
+#undef SEND_EARLY_STDERR
+#define SEND_EARLY_STDERR(S)						\
+do {									\
+	static const char __attribute__((section(".text"))) __s[] = (S); \
+	const char *__p, *__scratch;					\
+	__asm__ (							\
+	"	call a3, 1f;				\n\t"		\
+	"1:	movei	%0, #%%got_lo(1b)		\n\t"		\
+	"	move.4	%0, (%3, %0)			\n\t"		\
+	"	sub.4	%1, a3, %0;			\n\t"		\
+	"	add.4	%1, %1, %2;			\n\t"		\
+	: "=&d" (__scratch), "=&d" (__p)				\
+	: "d" (__s), "a" (dl_boot_got_pointer)				\
+	: "a3", "a4", "d15");						\
+	SEND_STDERR (__p);						\
+	{	int __t;						\
+		for (__t = 0; __t < 0x100000; __t++) __asm__ __volatile__ (""); } \
+} while (0)
+
+#define DL_LOADADDR_TYPE struct elf32_fdpic_loadaddr
+
+#define DL_RELOC_ADDR(LOADADDR, ADDR) \
+    ((ElfW(Addr))__reloc_pointer ((void*)(ADDR), (LOADADDR).map))
+
+#define DL_ADDR_TO_FUNC_PTR(ADDR, LOADADDR) \
+  ((void(*)(void)) _dl_funcdesc_for ((void*)(ADDR), (LOADADDR).got_value))
+
+#define _dl_stabilize_funcdesc(val) \
+  ({ __asm__ ("" : "+m" (*(val))); (val); })
+
+#define DL_CALL_FUNC_AT_ADDR(ADDR, LOADADDR, SIGNATURE, ...) \
+  ({ struct funcdesc_value fd = { (void*)(ADDR), (LOADADDR).got_value }; \
+     void (*pf)(void) = (void*) _dl_stabilize_funcdesc (&fd); \
+     (* SIGNATURE pf)(__VA_ARGS__); })
+
+#define DL_INIT_LOADADDR_BOOT(LOADADDR, BASEADDR) \
+  (__dl_init_loadaddr_map (&(LOADADDR), dl_boot_got_pointer, \
+			   dl_boot_ldsomap ?: dl_boot_progmap))
+
+#define DL_INIT_LOADADDR_PROG(LOADADDR, BASEADDR) \
+  (__dl_init_loadaddr_map (&(LOADADDR), 0, dl_boot_progmap))
+
+#define DL_INIT_LOADADDR_EXTRA_DECLS \
+  int dl_init_loadaddr_load_count;
+#define DL_INIT_LOADADDR(LOADADDR, BASEADDR, PHDR, PHDRCNT) \
+  (dl_init_loadaddr_load_count = \
+     __dl_init_loadaddr (&(LOADADDR), (PHDR), (PHDRCNT)))
+#define DL_INIT_LOADADDR_HDR(LOADADDR, ADDR, PHDR) \
+  (__dl_init_loadaddr_hdr ((LOADADDR), (ADDR), (PHDR), \
+			   dl_init_loadaddr_load_count))
+#define DL_LOADADDR_UNMAP(LOADADDR, LEN) \
+  (__dl_loadaddr_unmap ((LOADADDR), (NULL)))
+#define DL_LIB_UNMAP(LIB, LEN) \
+  (__dl_loadaddr_unmap ((LIB)->loadaddr, (LIB)->funcdesc_ht))
+#define DL_LOADADDR_BASE(LOADADDR) \
+  ((LOADADDR).got_value)
+
+/* This is called from dladdr(), such that we map a function
+   descriptor's address to the function's entry point before trying to
+   find in which library it's defined.  */
+#define DL_LOOKUP_ADDRESS(ADDRESS) (_dl_lookup_address (ADDRESS))
+
+#define DL_ADDR_IN_LOADADDR(ADDR, TPNT, TFROM) \
+  (! (TFROM) && __dl_addr_in_loadaddr ((void*)(ADDR), (TPNT)->loadaddr))
+
+/*
+ * Compute the GOT address.  On several platforms, we use assembly
+ * here.  on FR-V FDPIC, there's no way to compute the GOT address,
+ * since the offset between text and data is not fixed, so we arrange
+ * for the assembly _dl_boot to pass this value as an argument to
+ * _dl_boot.  */
+#define DL_BOOT_COMPUTE_GOT(got) ((got) = dl_boot_got_pointer)
+
+#define DL_BOOT_COMPUTE_DYN(dpnt, got, load_addr) \
+  ((dpnt) = dl_boot_ldso_dyn_pointer)
+
+/* We only support loading FDPIC independently-relocatable shared
+   libraries.  It probably wouldn't be too hard to support loading
+   shared libraries that require relocation by the same amount, but we
+   don't know that they exist or would be useful, and the dynamic
+   loader code could leak the whole-library map unless we keeping a
+   bit more state for DL_LOADADDR_UNMAP and DL_LIB_UNMAP, so let's
+   keep things simple for now.  */
+#define DL_CHECK_LIB_TYPE(epnt, piclib, _dl_progname, libname) \
+do \
+{ \
+  if (((epnt)->e_flags & EF_UBICOM32_FDPIC) && ! ((epnt)->e_flags & EF_UBICOM32_PIC)) \
+    (piclib) = 2; \
+  else \
+    { \
+      _dl_internal_error_number = LD_ERROR_NOTDYN; \
+      _dl_dprintf(2, "%s: '%s' is not an FDPIC shared library" \
+		  "\n", (_dl_progname), (libname)); \
+      _dl_close(infile); \
+      return NULL; \
+    } \
+\
+} \
+while (0)
+
+/* We want want to apply all relocations in the interpreter during
+   bootstrap.  Because of this, we have to skip the interpreter
+   relocations in _dl_parse_relocation_information(), see
+   elfinterp.c.  */
+#define DL_SKIP_BOOTSTRAP_RELOC(SYMTAB, INDEX, STRTAB) 0
+
+#ifdef __NR_pread64
+#define _DL_PREAD(FD, BUF, SIZE, OFFSET) \
+  (_dl_pread((FD), (BUF), (SIZE), (OFFSET)))
+#endif
+
+/* We want to return to dlsym() a function descriptor if the symbol
+   turns out to be a function.  */
+#define DL_FIND_HASH_VALUE(TPNT, TYPE_CLASS, SYM) \
+  (((TYPE_CLASS) & ELF_RTYPE_CLASS_DLSYM) \
+   && ELF32_ST_TYPE((SYM)->st_info) == STT_FUNC \
+   ? _dl_funcdesc_for ((void *)DL_RELOC_ADDR ((TPNT)->loadaddr, (SYM)->st_value), \
+		       (TPNT)->loadaddr.got_value)			     \
+   : DL_RELOC_ADDR ((TPNT)->loadaddr, (SYM)->st_value))
+
+#if 0 /* XXX TODO will look at enabling this if we decide to add support for OCM
+       * code/data */
+
+#define DL_IS_SPECIAL_SEGMENT(EPNT, PPNT) \
+  __dl_is_special_segment(EPNT, PPNT)
+#define DL_MAP_SEGMENT(EPNT, PPNT, INFILE, FLAGS) \
+  __dl_map_segment (EPNT, PPNT, INFILE, FLAGS)
+
+#endif
+
+
+#define DL_GET_READY_TO_RUN_EXTRA_PARMS \
+    , struct elf32_fdpic_loadmap *dl_boot_progmap, Elf32_Addr dl_boot_got_pointer
+#define DL_GET_READY_TO_RUN_EXTRA_ARGS \
+    , dl_boot_progmap, dl_boot_got_pointer
+
+
+#ifdef __USE_GNU
+# include <link.h>
+#else
+# define __USE_GNU
+# include <link.h>
+# undef __USE_GNU
+#endif
+
+#include <elf.h>
+static __inline__ void
+elf_machine_relative (DL_LOADADDR_TYPE load_off, const Elf32_Addr rel_addr,
+		      Elf32_Word relative_count)
+{
+#if 0
+	 Elf32_Rel * rpnt = (void *) rel_addr;
+	--rpnt;
+	do {
+		Elf32_Addr *const reloc_addr = (void *) (load_off + (++rpnt)->r_offset);
+
+		*reloc_addr = DL_RELOC_ADDR (load_off, *reloc_addr);
+	} while (--relative_count);
+#endif
+}
Index: uClibc-0.9.30.2/ldso/ldso/ubicom32/elfinterp.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/ldso/ldso/ubicom32/elfinterp.c	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,366 @@
+/* Blackfin ELF shared library loader suppport
+   Copyright (C) 2003, 2004 Red Hat, Inc.
+   Contributed by Alexandre Oliva <aoliva@redhat.com>
+   Lots of code copied from ../i386/elfinterp.c, so:
+   Copyright (c) 1994-2000 Eric Youngdale, Peter MacDonald,
+				David Engel, Hongjiu Lu and Mitch D'Souza
+   Copyright (C) 2001-2002, Erik Andersen
+   All rights reserved.
+
+This file is part of uClibc.
+
+uClibc is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of the
+License, or (at your option) any later version.
+
+uClibc is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with uClibc; see the file COPYING.LIB.  If not, write to
+the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
+USA.  */
+
+#include <sys/cdefs.h>	    /* __attribute_used__ */
+
+/* Program to load an ELF binary on a linux system, and run it.
+   References to symbols in sharable libraries can be resolved by either
+   an ELF sharable library or a linux style of shared library. */
+
+/* Disclaimer:  I have never seen any AT&T source code for SVr4, nor have
+   I ever taken any courses on internals.  This program was developed using
+   information available through the book "UNIX SYSTEM V RELEASE 4,
+   Programmers guide: Ansi C and Programming Support Tools", which did
+   a more than adequate job of explaining everything required to get this
+   working. */
+extern int _dl_ubicom32_resolve_pending(void) __attribute__((__visibility__("hidden")));
+
+struct funcdesc_value volatile *__attribute__((__visibility__("hidden")))
+_dl_linux_resolver (struct elf_resolve *tpnt, int reloc_entry)
+{
+	int reloc_type;
+	ELF_RELOC *this_reloc;
+	char *strtab;
+	ElfW(Sym) *symtab;
+	int symtab_index;
+	char *rel_addr;
+	struct elf_resolve *new_tpnt;
+	char *new_addr;
+	struct funcdesc_value funcval;
+	struct funcdesc_value volatile *got_entry;
+	char *symname;
+
+	rel_addr = (char *)tpnt->dynamic_info[DT_JMPREL];
+
+	this_reloc = (ELF_RELOC *)(intptr_t)(rel_addr + reloc_entry);
+	reloc_type = ELF_R_TYPE(this_reloc->r_info);
+	symtab_index = ELF_R_SYM(this_reloc->r_info);
+
+	symtab = (Elf32_Sym *) tpnt->dynamic_info[DT_SYMTAB];
+	strtab = (char *) tpnt->dynamic_info[DT_STRTAB];
+	symname= strtab + symtab[symtab_index].st_name;
+
+	if (reloc_type != R_UBICOM32_FUNCDESC_VALUE) {
+		_dl_dprintf(2, "%s: Incorrect relocation type in jump relocations\n",
+			    _dl_progname);
+		_dl_exit(1);
+	}
+
+	/* Address of GOT entry fix up */
+	got_entry = (struct funcdesc_value *) DL_RELOC_ADDR(tpnt->loadaddr, this_reloc->r_offset);
+
+	/* Get the address to be used to fill in the GOT entry.  */
+	new_addr = _dl_lookup_hash(symname, tpnt->symbol_scope, NULL, 0, &new_tpnt);
+	if (!new_addr) {
+		new_addr = _dl_lookup_hash(symname, NULL, NULL, 0, &new_tpnt);
+		if (!new_addr) {
+			_dl_dprintf(2, "%s: can't resolve symbol '%s'\n",
+				    _dl_progname, symname);
+			_dl_exit(1);
+		}
+	}
+
+	funcval.entry_point = new_addr;
+	funcval.got_value = new_tpnt->loadaddr.got_value;
+
+#if defined (__SUPPORT_LD_DEBUG__)
+	if (_dl_debug_bindings) {
+		_dl_dprintf(_dl_debug_file, "\nresolve function: %s", symname);
+		if (_dl_debug_detail)
+			_dl_dprintf(_dl_debug_file,
+				    "\n\tpatched (%x,%x) ==> (%x,%x) @ %x\n",
+				    got_entry->entry_point, got_entry->got_value,
+				    funcval.entry_point, funcval.got_value,
+				    got_entry);
+	}
+	if (1 || !_dl_debug_nofixups) {
+		got_entry->entry_point = ((unsigned long *)&_dl_ubicom32_resolve_pending)[0];
+		got_entry->got_value = funcval.got_value;
+		got_entry->entry_point = funcval.entry_point;
+	}
+#else
+	/*
+	 * initially set the entry point to resolve pending before starting
+	 * the update. This has the effect of putting all other requests in a
+	 * holding pattern until the resolution is completed.
+	 */
+	got_entry->entry_point = ((unsigned long *)&_dl_ubicom32_resolve_pending)[0];
+	got_entry->got_value = funcval.got_value;
+	got_entry->entry_point = funcval.entry_point;
+#endif
+
+	return got_entry;
+}
+
+static int
+_dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
+	  unsigned long rel_addr, unsigned long rel_size,
+	  int (*reloc_fnc) (struct elf_resolve *tpnt, struct dyn_elf *scope,
+			    ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab))
+{
+	unsigned int i;
+	char *strtab;
+	ElfW(Sym) *symtab;
+	ELF_RELOC *rpnt;
+	int symtab_index;
+
+	/* Now parse the relocation information */
+	rpnt = (ELF_RELOC *) rel_addr;
+	rel_size = rel_size / sizeof(ELF_RELOC);
+
+	symtab = (ElfW(Sym) *) tpnt->dynamic_info[DT_SYMTAB];
+	strtab = (char *) tpnt->dynamic_info[DT_STRTAB];
+
+	for (i = 0; i < rel_size; i++, rpnt++) {
+		int res;
+
+		symtab_index = ELF_R_SYM(rpnt->r_info);
+		debug_sym(symtab,strtab,symtab_index);
+		debug_reloc(symtab,strtab,rpnt);
+
+		res = reloc_fnc (tpnt, scope, rpnt, symtab, strtab);
+
+		if (res==0) continue;
+
+		_dl_dprintf(2, "\n%s: ",_dl_progname);
+
+		if (symtab_index)
+			_dl_dprintf(2, "symbol '%s': ", strtab + symtab[symtab_index].st_name);
+
+		if (res <0) {
+			int reloc_type = ELF_R_TYPE(rpnt->r_info);
+#if defined (__SUPPORT_LD_DEBUG__)
+			_dl_dprintf(2, "can't handle reloc type %s\n ", _dl_reltypes(reloc_type));
+#else
+			_dl_dprintf(2, "can't handle reloc type %x\n", reloc_type);
+#endif
+			_dl_exit(-res);
+		} else if (res >0) {
+			_dl_dprintf(2, "can't resolve symbol\n");
+			return res;
+		}
+	  }
+	  return 0;
+}
+
+static int
+_dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
+	      ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
+{
+	int reloc_type;
+	int symtab_index;
+	char *symname;
+	unsigned long reloc_value = 0, *reloc_addr;
+	struct { unsigned long v; } __attribute__((__packed__))
+					    *reloc_addr_packed;
+	unsigned long symbol_addr;
+	struct elf_resolve *symbol_tpnt;
+	struct funcdesc_value funcval;
+#if defined (__SUPPORT_LD_DEBUG__)
+	unsigned long old_val;
+#endif
+
+	reloc_addr   = (unsigned long *) DL_RELOC_ADDR(tpnt->loadaddr, rpnt->r_offset);
+	__asm__ ("" : "=r" (reloc_addr_packed) : "0" (reloc_addr));
+	reloc_type   = ELF_R_TYPE(rpnt->r_info);
+	symtab_index = ELF_R_SYM(rpnt->r_info);
+	symbol_addr  = 0;
+	symname      = strtab + symtab[symtab_index].st_name;
+
+	if (ELF_ST_BIND (symtab[symtab_index].st_info) == STB_LOCAL) {
+		symbol_addr = (unsigned long) DL_RELOC_ADDR(tpnt->loadaddr, symtab[symtab_index].st_value);
+		symbol_tpnt = tpnt;
+	} else {
+
+		symbol_addr = (unsigned long)
+		  _dl_lookup_hash(symname, scope, NULL, 0, &symbol_tpnt);
+
+		/*
+		 * We want to allow undefined references to weak symbols - this might
+		 * have been intentional.  We should not be linking local symbols
+		 * here, so all bases should be covered.
+		 */
+
+		if (!symbol_addr && ELF_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK) {
+			_dl_dprintf (2, "%s: can't resolve symbol '%s'\n",
+				     _dl_progname, strtab + symtab[symtab_index].st_name);
+			_dl_exit (1);
+		}
+	}
+
+#if defined (__SUPPORT_LD_DEBUG__)
+	if (_dl_debug_reloc && _dl_debug_detail)
+	  {
+	    if ((long)reloc_addr_packed & 3)
+	      old_val = reloc_addr_packed->v;
+	    else
+	      old_val = *reloc_addr;
+	  }
+	else
+	  old_val = 0;
+#endif
+	switch (reloc_type) {
+	case R_UBICOM32_NONE:
+		break;
+	case R_UBICOM32_32:
+		if ((long)reloc_addr_packed & 3)
+			reloc_value = reloc_addr_packed->v += symbol_addr;
+		else
+			reloc_value = *reloc_addr += symbol_addr;
+		break;
+	case R_UBICOM32_FUNCDESC_VALUE:
+		funcval.entry_point = (void*)symbol_addr;
+		/* The addend of FUNCDESC_VALUE
+		   relocations referencing global
+		   symbols must be ignored, because it
+		   may hold the address of a lazy PLT
+		   entry.  */
+		if (ELF_ST_BIND(symtab[symtab_index].st_info) == STB_LOCAL)
+			funcval.entry_point += *reloc_addr;
+		reloc_value = (unsigned long)funcval.entry_point;
+		if (symbol_addr)
+			funcval.got_value
+				= symbol_tpnt->loadaddr.got_value;
+		else
+			funcval.got_value = 0;
+
+/// XXX this is my best guess as to what I should be doing, but I'm
+/// putting a break-point here so I can inspect the first time this is
+/// used.
+		__asm__ (
+		"	move.4 4(%0), 4(%1)		\n\t"
+		"	move.4 0(%0), 0(%1)		\n\t" /* Must to entry_point last */
+			:
+			: "a" (reloc_addr), "a" (&funcval)
+			: "memory" );
+		break;
+	case R_UBICOM32_FUNCDESC:
+		if ((long)reloc_addr_packed & 3)
+			reloc_value = reloc_addr_packed->v;
+		else
+			reloc_value = *reloc_addr;
+		if (symbol_addr)
+			reloc_value = (unsigned long)_dl_funcdesc_for
+				((char *)symbol_addr + reloc_value,
+				 symbol_tpnt->loadaddr.got_value);
+		else
+			reloc_value = 0;
+		if ((long)reloc_addr_packed & 3)
+			reloc_addr_packed->v = reloc_value;
+		else
+			*reloc_addr = reloc_value;
+		break;
+	default:
+		return -1;
+	}
+#if defined (__SUPPORT_LD_DEBUG__)
+	if (_dl_debug_reloc && _dl_debug_detail) {
+		_dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x", old_val, reloc_value, reloc_addr);
+		switch (reloc_type) {
+		case R_UBICOM32_FUNCDESC_VALUE:
+			_dl_dprintf(_dl_debug_file, " got %x", ((struct funcdesc_value *)reloc_value)->got_value);
+			break;
+		case R_UBICOM32_FUNCDESC:
+			if (! reloc_value)
+				break;
+			_dl_dprintf(_dl_debug_file, " funcdesc (%x,%x)",
+				    ((struct funcdesc_value *)reloc_value)->entry_point,
+				    ((struct funcdesc_value *)reloc_value)->got_value);
+			break;
+		}
+	}
+#endif
+
+	return 0;
+}
+
+static int
+_dl_do_lazy_reloc (struct elf_resolve *tpnt,
+		   struct dyn_elf *scope __attribute__((unused)),
+		   ELF_RELOC *rpnt, ElfW(Sym) *symtab __attribute__((unused)),
+		   char *strtab __attribute__((unused)))
+{
+	int reloc_type;
+	struct funcdesc_value volatile *reloc_addr;
+	struct funcdesc_value funcval;
+#if defined (__SUPPORT_LD_DEBUG__)
+	unsigned long old_val;
+#endif
+
+	reloc_addr = (struct funcdesc_value *) DL_RELOC_ADDR(tpnt->loadaddr, rpnt->r_offset);
+	reloc_type = ELF_R_TYPE(rpnt->r_info);
+
+#if defined (__SUPPORT_LD_DEBUG__)
+	old_val = (unsigned long)reloc_addr->entry_point;
+#endif
+		switch (reloc_type) {
+			case R_UBICOM32_NONE:
+				break;
+			case R_UBICOM32_FUNCDESC_VALUE:
+				funcval = *reloc_addr;
+				funcval.entry_point = (void*)DL_RELOC_ADDR(tpnt->loadaddr, funcval.entry_point);
+				funcval.got_value = tpnt->loadaddr.got_value;
+				*reloc_addr = funcval;
+				break;
+			default:
+				return -1;
+		}
+#if defined (__SUPPORT_LD_DEBUG__)
+	if (_dl_debug_reloc && _dl_debug_detail)
+		_dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x", old_val, reloc_addr->entry_point, reloc_addr);
+#endif
+	return 0;
+
+}
+
+void
+_dl_parse_lazy_relocation_information
+(struct dyn_elf *rpnt, unsigned long rel_addr, unsigned long rel_size)
+{
+  _dl_parse(rpnt->dyn, NULL, rel_addr, rel_size, _dl_do_lazy_reloc);
+}
+
+int
+_dl_parse_relocation_information
+(struct dyn_elf *rpnt, unsigned long rel_addr, unsigned long rel_size)
+{
+  return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size, _dl_do_reloc);
+}
+
+#if 0
+/* We don't have copy relocs.  */
+int
+_dl_parse_copy_information
+(struct dyn_elf *rpnt __attribute__((unused)),
+ unsigned long rel_addr __attribute__((unused)),
+ unsigned long rel_size __attribute__((unused)))
+{
+  return 0;
+}
+#endif
+#ifndef IS_IN_libdl
+# include "../../libc/sysdeps/linux/ubicom32/crtreloc.c"
+#endif
Index: uClibc-0.9.30.2/ldso/ldso/ubicom32/resolve.S
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/ldso/ldso/ubicom32/resolve.S	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,161 @@
+     /* Copyright (C) 2003 Red Hat, Inc.
+	Contributed by Alexandre Oliva <aoliva@redhat.com>
+
+	Copyright (C) 2009 Ubicom Inc.
+	Ported to Ubicom32 by Ubicom Inc.
+
+This file is part of uClibc.
+
+uClibc is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of the
+License, or (at your option) any later version.
+
+uClibc is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with uClibc; see the file COPYING.LIB.  If not, write to
+the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
+USA.  */
+
+
+/*
+ * The function below is tail-called by resolver stubs when a lazily-bound *
+ * function is called.  It must preserve all registers that could * be used to
+ * pass arguments to the actual function.
+ *
+ * On entry to the function d0-d13 contain parameters to the actual function of
+ * interest
+ *
+ * a5 contains the return address
+ * a0 is pointing to the GOT table for the original function
+ *  (a0) _dl_linux_resolve
+ * 4(a0) GOT for _dl_linux_resolve
+ * 8(a0) is pointer to "structure elf_resolve" of the module where the call
+ *	originated from
+ *
+ * a3 is pointing to the function descriptor in the GOT table, and 8(a3) the
+ * resolver lookup information.
+ *
+ * _dl_linux_resolve calls _dl_linux_resolver passing it pointer to
+ * struct elf_resolve and the relocation entry.
+ *
+ * _dl_linux_resolver() figures out where the jump symbol is _really_ supposed
+ * to have jumped to and returns that to us. Once we have that, we prepare to
+ * tail-call the actual function, clean up after ourselves, restoring the
+ * original arguments, then jump to the fixed up address.
+ */
+
+#if 0
+	/*
+	 * Here is what the linker will use for the PLT.
+	 */
+sample_PLT_functionX:	/* (at entry a0 contains GOT for this library)  */
+	movei	d15, # -%lo(got_funcdescX) ; load offset for GOT
+	lea.4	a3, (a0, d15)	; a4 is now the function descriptor
+	move.4	a4, 0(a3)	; get entry_point
+	move.4	a0, 4(a3)	; set new GOT
+
+	/*
+	 * jump to resovled function OR PLT_trampoline Nat had some code here
+	 * that uses the stack instead of a3 to reduces hazards.
+	 */
+	calli	a4, 0(a4)
+
+
+sample_PLT_trampoline:
+	/*
+	 * find the old got by undoing what was done above. An alternative
+	 * could have been to ‘save’ the old got in say d14 but that would add 1
+	 * instruction to every PLT and there is only 1 PLT trampoline per library.
+	 */
+	ret	(a0)		; jump to _dl_linux_resolve
+#endif
+
+	.text
+	.p2align 4
+
+	.hidden	_dl_linux_resolve
+	.global	_dl_linux_resolve
+	.type	_dl_linux_resolve,@function
+_dl_linux_resolve:
+	/* Preserve arguments and return address  */
+	move.4	-4(sp)++, d0
+	move.4	-4(sp)++, d1
+	move.4	-4(sp)++, d2
+	move.4	-4(sp)++, d3
+	move.4	-4(sp)++, d4
+	move.4	-4(sp)++, d5
+	move.4	-4(sp)++, d6
+	move.4	-4(sp)++, d7
+	move.4	-4(sp)++, d8
+	move.4	-4(sp)++, d9
+	move.4	-4(sp)++, d10
+	move.4	-4(sp)++, d11
+	move.4	-4(sp)++, d12
+	move.4	-4(sp)++, d13
+	move.4	-4(sp)++, a5
+
+	/* Prepare to call _dl_linux_resolver.  */
+	move.4 d0, 8(a0)	; reference to elf_resolve
+	/* Not aligned for space reasons.  */
+	move.4 d1, mac_hi 	; reference to GOT table entry which
+				; contains the relocation information.
+
+	move.4 a0, 4(a0) ; switch to GOT for _dl_linux_resolve
+	call	a5, _dl_linux_resolver;
+
+	/* Move aside return value that contains the FUNCDESC_VALUE.  */
+	;P3 = R0;
+	move.4 a3, d0;
+
+	/* Restore arguments.  */
+	move.4	a5, (sp)4++
+	move.4	d13, (sp)4++
+	move.4	d12, (sp)4++
+	move.4	d11, (sp)4++
+	move.4	d10, (sp)4++
+	move.4	d9, (sp)4++
+	move.4	d8, (sp)4++
+	move.4	d7, (sp)4++
+	move.4	d6, (sp)4++
+	move.4	d5, (sp)4++
+	move.4	d4, (sp)4++
+	move.4	d3, (sp)4++
+	move.4	d2, (sp)4++
+	move.4	d1, (sp)4++
+	move.4	d0, (sp)4++
+
+	/* Now jump to the actual function.  */
+	/* a3 contains func_desc resolution */
+	move.4 a4, 0(a3)	; address of function X
+	move.4 a0, 4(a3)	; switch to GOT for function X
+	calli  a4, 0(a4)	; call through a4, a5 remains
+
+	.size	_dl_linux_resolve, . - _dl_linux_resolve
+
+	.hidden	_dl_ubicom32_resolve_pending
+	.global	_dl_ubicom32_resolve_pending
+	.type	_dl_ubicom32_resolve_pending,@function
+
+_dl_ubicom32_resolve_pending:
+	/*
+	 * A special function that is used to ensure thread saftly when the fd
+	 * for a particular resolution is being updated.
+	 *
+	 * At entry, a3 must point to the FD.  While the FD is being updated the
+	 * entry_point will continue to point to _dl_ubicom32_resolve_pending so
+	 * we will effectively spin until the resolver update is complete.
+	 */
+
+	move.4	a4, 0(a3)	; get entry_point
+	move.4	a0, 4(a3)	; set new GOT
+
+	/*
+	 * jump to resovled function or back to _dl_ubicom32_resolve_pending.
+	 */
+	calli	a4, 0(a4)
+	.size	_dl_ubicom32_resolve_pending, . - _dl_ubicom32_resolve_pending
Index: uClibc-0.9.30.2/libc/misc/Makefile.in
===================================================================
--- uClibc-0.9.30.2.orig/libc/misc/Makefile.in	2010-01-13 22:22:31.000000000 +0100
+++ uClibc-0.9.30.2/libc/misc/Makefile.in	2010-01-14 11:05:01.000000000 +0100
@@ -12,7 +12,9 @@
 include $(top_srcdir)libc/misc/ctype/Makefile.in
 include $(top_srcdir)libc/misc/dirent/Makefile.in
 include $(top_srcdir)libc/misc/error/Makefile.in
+ifneq ($(ARCH_HAS_NO_LDSO),y)
 include $(top_srcdir)libc/misc/elf/Makefile.in
+endif
 include $(top_srcdir)libc/misc/file/Makefile.in
 include $(top_srcdir)libc/misc/fnmatch/Makefile.in
 include $(top_srcdir)libc/misc/ftw/Makefile.in
Index: uClibc-0.9.30.2/libc/misc/elf/dl-iterate-phdr.c
===================================================================
--- uClibc-0.9.30.2.orig/libc/misc/elf/dl-iterate-phdr.c	2010-01-13 22:22:31.000000000 +0100
+++ uClibc-0.9.30.2/libc/misc/elf/dl-iterate-phdr.c	2010-01-14 11:05:01.000000000 +0100
@@ -14,7 +14,7 @@
 
 #include <link.h>
 #include <ldso.h>
-
+#include <memory.h>
 /* we want this in libc but nowhere else */
 #ifdef __USE_GNU
 
Index: uClibc-0.9.30.2/libc/stdlib/malloc/malloc.c
===================================================================
--- uClibc-0.9.30.2.orig/libc/stdlib/malloc/malloc.c	2010-01-13 22:22:31.000000000 +0100
+++ uClibc-0.9.30.2/libc/stdlib/malloc/malloc.c	2010-01-14 11:05:01.000000000 +0100
@@ -25,7 +25,7 @@
 
 /* The malloc heap.  We provide a bit of initial static space so that
    programs can do a little mallocing without mmaping in more space.  */
-HEAP_DECLARE_STATIC_FREE_AREA (initial_fa, 256);
+HEAP_DECLARE_STATIC_FREE_AREA (initial_fa, 32768);
 struct heap_free_area *__malloc_heap = HEAP_INIT_WITH_FA (initial_fa);
 #ifdef HEAP_USE_LOCKING
 pthread_mutex_t __malloc_heap_lock = PTHREAD_MUTEX_INITIALIZER;
Index: uClibc-0.9.30.2/libc/string/ubicom32/Makefile
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/string/ubicom32/Makefile	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,13 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir:=../../../
+top_builddir:=../../../
+all: objs
+include $(top_builddir)Rules.mak
+include ../Makefile.in
+include $(top_srcdir)Makerules
Index: uClibc-0.9.30.2/libc/string/ubicom32/memcpy.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/string/ubicom32/memcpy.c	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,152 @@
+/* Copy memory to memory until the specified number of bytes
+   has been copied.  Overlap is NOT handled correctly.
+   Copyright (C) 1991, 1997, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Torbjorn Granlund (tege@sics.se).
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <string.h>
+
+typedef unsigned long addr_t;
+
+libc_hidden_proto(memcpy)
+
+void *memcpy (void *dest, const void *src, size_t n)
+{
+	void *dest_ret = dest;
+	void *aligned_start;
+
+	if (likely((((addr_t)dest ^ (addr_t)src) & 3) == 0) && likely(n > 6)) {
+		size_t m;
+		n -= (4 - (addr_t)dest) & 0x03;
+		m = n >> 2;
+		__asm__ volatile (
+		"	call		%4, 99f			\n\t"	// load %4 with address of 99
+		"99:	movei		d15, #%%lo(1f-99b)	\n\t"	// load d15 with offset to 1 from 99
+		"	add.4		%4, %4, d15		\n\t"	// add difference
+
+		"	sub.4		d15, #0, %2		\n\t"	// set up for jump table
+		"	and.4		d15, #(32-1), d15	\n\t"	// d15 = (-m) & (32 - 1)
+		"	lea.4		%4, (%4,d15)		\n\t"
+
+		"	bfextu		d15, %0, #2		\n\t"	// d15 = (dest & 3)
+		"	jmpne.w.f	100f			\n\t"
+		"	calli		%4, 0(%4)		\n\t"	// 4-byte alignment
+
+		"100:	cmpi		d15, #2			\n\t"
+		"	jmpne.s.f	101f			\n\t"
+		"	move.2		(%0)2++, (%1)2++	\n\t"
+		"	calli		%4, 0(%4)		\n\t"	// 2-byte alignment
+
+		"101:	move.1		(%0)1++, (%1)1++	\n\t"
+		"	jmpgt.s.f	102f			\n\t"	// 3-byte alignment
+		"	move.2		(%0)2++, (%1)2++	\n\t"	// 1-byte alignment
+		"102:	calli		%4, 0(%4)		\n\t"
+
+		"200:	cmpi		%3, #2			\n\t"
+		"	jmplt.s.f	201f			\n\t"
+		"	move.2		(%0)2++, (%1)2++	\n\t"
+		"	jmpeq.s.t	2f			\n\t"
+		"201:	move.1		(%0)1++, (%1)1++	\n\t"
+		"	jmpt.w.t	2f			\n\t"
+
+		"1:	.rept		25			\n\t"
+		"	movea		(%0)4++, (%1)4++	\n\t"
+		"	.endr					\n\t"
+		"	.rept		7			\n\t"
+		"	move.4		(%0)4++, (%1)4++	\n\t"
+		"	.endr					\n\t"
+		"	add.4		%2, #-32, %2		\n\t"
+		"	jmpgt.w.f	1b			\n\t"
+
+		"	and.4		%3, #3, %3		\n\t"	// check n
+		"	jmpne.w.f	200b			\n\t"
+		"2:						\n\t"
+			: "+a"(dest), "+a"(src), "+d"(m), "+d"(n), "=a"(aligned_start)
+			:
+			: "d15", "memory", "cc"
+		);
+
+		return dest_ret;
+	}
+
+	if (likely((((addr_t)dest ^ (addr_t)src) & 1) == 0) && likely(n > 2)) {
+		size_t m;
+		n -= (addr_t)dest & 0x01;
+		m = n >> 1;
+		__asm__ volatile (
+		"	call		%4, 99f			\n\t"	// load %4 with address of 99
+		"99:	movei		d15, #%%lo(1f-99b)	\n\t"	// load d15 with offset to 1 from 99
+		"	add.4		%4, %4, d15		\n\t"	// add difference
+
+		"	sub.4		d15, #0, %2		\n\t"	// set up for jump table
+		"	and.4		d15, #(32-1), d15	\n\t"	// d15 = (-m) & (32 - 1)
+		"	lea.4		%4, (%4,d15)		\n\t"
+
+		"	btst		%0, #0			\n\t"	// check bit 0
+		"	jmpne.w.f	100f			\n\t"
+		"	calli		%4, 0(%4)		\n\t"	// 4-byte alignment
+
+		"100:	move.1		(%0)1++, (%1)1++	\n\t"
+		"	calli		%4, 0(%4)		\n\t"
+
+		"200:	move.1		(%0)1++, (%1)1++	\n\t"
+		"	jmpt.w.t	2f			\n\t"
+
+		"1:	.rept		32			\n\t"
+		"	move.2		(%0)2++, (%1)2++	\n\t"
+		"	.endr					\n\t"
+		"	add.4		%2, #-32, %2		\n\t"
+		"	jmpgt.w.f	1b			\n\t"
+
+		"	and.4		%3, #1, %3		\n\t"	// check n
+		"	jmpne.w.f	200b			\n\t"
+		"2:						\n\t"
+
+			: "+a"(dest), "+a"(src), "+d"(m), "+d"(n), "=a"(aligned_start)
+			:
+			: "d15", "memory", "cc"
+		);
+		return dest_ret;
+	}
+
+	__asm__ volatile (
+	"	call		%3, 99f			\n\t"	// load %3 with address of 99
+	"99:	movei		d15, #%%lo(1f-99b)	\n\t"	// load d15 with offset to 1 from 99
+	"	add.4		%3, %3, d15		\n\t"	// add difference
+
+	"	sub.4		d15, #0, %2		\n\t"
+	"	jmpeq.w.f	2f			\n\t"
+	"	and.4		d15, #(16-1), d15	\n\t"	// d15 = (-n) & (16 - 1)
+	"	lea.4		%3, (%3,d15)		\n\t"
+	"	calli		%3, 0(%3)		\n\t"
+
+	"1:	.rept		16			\n\t"
+	"	move.1		(%0)1++, (%1)1++	\n\t"
+	"	.endr					\n\t"
+	"	add.4		%2, #-16, %2		\n\t"
+	"	jmpgt.w.f	1b			\n\t"
+	"2:						\n\t"
+
+		: "+a"(dest), "+a"(src), "+d"(n), "=a"(aligned_start)
+		:
+		: "d15", "memory", "cc"
+	);
+
+	return dest_ret;
+}
+libc_hidden_def(memcpy)
Index: uClibc-0.9.30.2/libc/string/ubicom32/memset.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/string/ubicom32/memset.c	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,107 @@
+/* Copyright (C) 1991, 1997, 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <string.h>
+
+typedef unsigned long addr_t;
+
+libc_hidden_proto(memset)
+void *memset (void *s, int c, size_t n)
+{
+	void *s_ret = s;
+	void *aligned_start;
+	if (likely(n > 6)) {
+		size_t m;
+		n -= (4 - (addr_t)s) & 0x03;
+		m = n >> 2;
+		__asm__ volatile (
+		"	call		%4, 99f			\n\t"	// load %4 with address of 99
+		"99:	movei		d15, #%%lo(1f-99b)	\n\t"	// load d15 with offset to 1 from 99
+		"	add.4		%4, %4, d15		\n\t"	// add difference
+
+		"	sub.4		d15, #0, %2		\n\t"	// set up for jump table
+		"	and.4		d15, #(32-1), d15	\n\t"	// d15 = (-m) & (32 - 1)
+		"	shmrg.1		%1, %1, %1		\n\t"
+		"	shmrg.2		%1, %1, %1		\n\t"	// %1 = (c<<24)|(c<<16)|(c<<8)|c
+		"	lea.4		%4, (%4,d15)		\n\t"
+
+		"	bfextu		d15, %0, #2		\n\t"	// d15 = (s & 3)
+		"	jmpne.w.f	100f			\n\t"
+		"	calli		%4, 0(%4)		\n\t"	// 4-byte alignment
+
+		"100:	cmpi		d15, #2			\n\t"
+		"	jmpne.s.f	101f			\n\t"
+		"	move.2		(%0)2++, %1		\n\t"
+		"	calli		%4, 0(%4)		\n\t"	// 2-byte alignment
+
+		"101:	move.1		(%0)1++, %1		\n\t"
+		"	jmpgt.s.f	102f			\n\t"	// 3-byte alignment
+		"	move.2		(%0)2++, %1		\n\t"	// 1-byte alignment
+		"102:	calli		%4, 0(%4)		\n\t"
+
+		"200:	cmpi		%3, #2			\n\t"
+		"	jmplt.s.f	201f			\n\t"
+		"	move.2		(%0)2++, %1		\n\t"
+		"	jmpeq.s.t	2f			\n\t"
+		"201:	move.1		(%0)1++, %1		\n\t"
+		"	jmpt.w.t	2f			\n\t"
+
+		"1:	.rept		25			\n\t"
+		"	movea		(%0)4++, %1		\n\t"
+		"	.endr					\n\t"
+		"	.rept		7			\n\t"
+		"	move.4		(%0)4++, %1		\n\t"
+		"	.endr					\n\t"
+		"	add.4		%2, #-32, %2		\n\t"
+		"	jmpgt.w.f	1b			\n\t"
+
+		"	and.4		%3, #3, %3		\n\t"	// test bit 1 of n
+		"	jmpne.w.f	200b			\n\t"
+		"2:						\n\t"
+			: "+a"(s), "+d"(c), "+d"(m), "+d"(n), "=a"(aligned_start)
+			:
+			: "d15", "memory", "cc"
+		);
+
+		return s_ret;
+	}
+
+	__asm__ volatile (
+	"	call		%3, 99f			\n\t"	// load %3 with address of 99
+	"99:	movei		d15, #%%lo(1f-99b)	\n\t"	// load d15 with offset to 1 from 99
+	"	add.4		%3, %3, d15		\n\t"	// add difference
+
+	"	sub.4		d15, #0, %2		\n\t"
+	"	jmpeq.w.f	2f			\n\t"
+	"	and.4		d15, #(8-1), d15	\n\t"	// d15 = (-%2) & (16 - 1)
+	"	lea.4		%3, (%3,d15)		\n\t"
+	"	calli		%3, 0(%3)		\n\t"
+
+	"1:	.rept		8			\n\t"
+	"	move.1		(%0)1++, %1		\n\t"
+	"	.endr					\n\t"
+	"2:						\n\t"
+
+		: "+a"(s), "+d"(c), "+d"(n), "=a"(aligned_start)
+		:
+		: "d15", "memory", "cc"
+	);
+
+	return s_ret;
+}
+libc_hidden_def(memset)
Index: uClibc-0.9.30.2/libc/sysdeps/linux/common/sys/user.h
===================================================================
--- uClibc-0.9.30.2.orig/libc/sysdeps/linux/common/sys/user.h	2010-01-13 22:22:31.000000000 +0100
+++ uClibc-0.9.30.2/libc/sysdeps/linux/common/sys/user.h	2010-01-14 11:05:01.000000000 +0100
@@ -1 +1,4 @@
+#if 0
+/* As of linux v2.6.25 this is not part of the exported linux headers */
 #include <linux/user.h>
+#endif
Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/Makefile
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/Makefile	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,13 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir=../../../../
+top_builddir=../../../../
+all: objs
+include $(top_builddir)Rules.mak
+include Makefile.arch
+include $(top_srcdir)Makerules
Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/Makefile.arch
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/Makefile.arch	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,28 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+#CSRC := \
+#	brk.c \
+#	crtbegin.c \
+#	crtend.c
+#
+#SSRC := \
+#	__longjmp.S \
+#	bsd-_setjmp.S \
+#	bsd-setjmp.S \
+#	setjmp.S \
+#	clone.S \
+#	vfork.S
+
+CSRC := \
+	syscall.c __syscall_error.c
+ 
+SSRC := \
+	clone.S setjmp.S vfork.S
+
+ARCH_CFLAGS := $(CPU_CFLAGS-y)
+include $(top_srcdir)libc/sysdeps/linux/Makefile.commonarch
Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/__syscall_error.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/__syscall_error.c	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,11 @@
+#include <errno.h>
+#include <features.h>
+
+/* This routine is jumped to by some of the syscall handlers, to stash
+ * an error number into errno.  */
+int __syscall_error(int err_no) attribute_hidden;
+int __syscall_error(int err_no)
+{
+	__set_errno(err_no);
+	return -1;
+}
Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/elf-fdpic.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/elf-fdpic.h	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,115 @@
+/* Copyright 2003, 2004 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of the
+License, or (at your option) any later version.
+
+In addition to the permissions in the GNU Lesser General Public
+License, the Free Software Foundation gives you unlimited
+permission to link the compiled version of this file with other
+programs, and to distribute those programs without any restriction
+coming from the use of this file.  (The GNU Lesser General Public
+License restrictions do apply in other respects; for example, they
+cover modification of the file, and distribution when not linked
+into another program.)
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#ifndef _BITS_ELF_FDPIC_H
+#define _BITS_ELF_FDPIC_H
+
+/* These data structures are described in the FDPIC ABI extension.
+   The kernel passes a process a memory map, such that for every LOAD
+   segment there is an elf32_fdpic_loadseg entry.  A pointer to an
+   elf32_fdpic_loadmap is passed in d8 at start-up, and a pointer to
+   an additional such map is passed in d9 for the interpreter, when
+   there is one.  */
+
+#include <elf.h>
+
+/* This data structure represents a PT_LOAD segment.  */
+struct elf32_fdpic_loadseg
+{
+  /* Core address to which the segment is mapped.  */
+  Elf32_Addr addr;
+  /* VMA recorded in the program header.  */
+  Elf32_Addr p_vaddr;
+  /* Size of this segment in memory.  */
+  Elf32_Word p_memsz;
+};
+
+struct elf32_fdpic_loadmap {
+  /* Protocol version number, must be zero.  */
+  Elf32_Half version;
+  /* Number of segments in this map.  */
+  Elf32_Half nsegs;
+  /* The actual memory map.  */
+  struct elf32_fdpic_loadseg segs[/*nsegs*/];
+};
+
+struct elf32_fdpic_loadaddr {
+  struct elf32_fdpic_loadmap *map;
+  void *got_value;
+};
+
+/* Map a pointer's VMA to its corresponding address according to the
+   load map.  */
+static __always_inline void *
+__reloc_pointer (void *p,
+		 const struct elf32_fdpic_loadmap *map)
+{
+  int c;
+
+#if 0
+  if (map->version != 0)
+    /* Crash.  */
+    ((void(*)())0)();
+#endif
+
+  /* No special provision is made for NULL.  We don't want NULL
+     addresses to go through relocation, so they shouldn't be in
+     .rofixup sections, and, if they're present in dynamic
+     relocations, they shall be mapped to the NULL address without
+     undergoing relocations.  */
+
+  for (c = 0;
+       /* Take advantage of the fact that the loadmap is ordered by
+	  virtual addresses.  In general there will only be 2 entries,
+	  so it's not profitable to do a binary search.  */
+       c < map->nsegs && p >= (void*)map->segs[c].p_vaddr;
+       c++)
+    {
+      /* This should be computed as part of the pointer comparison
+	 above, but we want to use the carry in the comparison, so we
+	 can't convert it to an integer type beforehand.  */
+      unsigned long offset = p - (void*)map->segs[c].p_vaddr;
+      /* We only check for one-past-the-end for the last segment,
+	 assumed to be the data segment, because other cases are
+	 ambiguous in the absence of padding between segments, and
+	 rofixup already serves as padding between text and data.
+	 Unfortunately, unless we special-case the last segment, we
+	 fail to relocate the _end symbol.  */
+      if (offset < map->segs[c].p_memsz
+	  || (offset == map->segs[c].p_memsz && c + 1 == map->nsegs))
+	return (char*)map->segs[c].addr + offset;
+    }
+
+  /* We might want to crash instead.  */
+  return (void*)-1;
+}
+
+# define __RELOC_POINTER(ptr, loadaddr) \
+  (__reloc_pointer ((void*)(ptr), \
+		    (loadaddr).map))
+
+#endif /* _BITS_ELF_FDPIC_H */
Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/endian.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/endian.h	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,7 @@
+/* Ubicom32 is big-endian.  */
+
+#ifndef _ENDIAN_H
+# error "Never use <bits/endian.h> directly; include <endian.h> instead."
+#endif
+
+#define __BYTE_ORDER __BIG_ENDIAN
Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/fcntl.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/fcntl.h	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,224 @@
+/* O_*, F_*, FD_* bit values for Linux.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef	_FCNTL_H
+# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
+
+
+#include <sys/types.h>
+#ifdef __USE_GNU
+# include <bits/uio.h>
+#endif
+
+/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
+   located on an ext2 file system */
+#define O_ACCMODE	   0003
+#define O_RDONLY	     00
+#define O_WRONLY	     01
+#define O_RDWR		     02
+#define O_CREAT		   0100	/* not fcntl */
+#define O_EXCL		   0200	/* not fcntl */
+#define O_NOCTTY	   0400	/* not fcntl */
+#define O_TRUNC		  01000	/* not fcntl */
+#define O_APPEND	  02000
+#define O_NONBLOCK	  04000
+#define O_NDELAY	O_NONBLOCK
+#define O_SYNC		 010000
+#define O_FSYNC		 O_SYNC
+#define O_ASYNC		 020000
+
+#ifdef __USE_GNU
+# define O_DIRECTORY	 040000	/* Must be a directory.	 */
+# define O_NOFOLLOW	0100000	/* Do not follow links.	 */
+# define O_DIRECT	0200000	/* Direct disk access.	*/
+# define O_STREAMING	04000000/* streaming access */
+#endif
+
+/* For now Linux has synchronisity options for data and read operations.
+   We define the symbols here but let them do the same as O_SYNC since
+   this is a superset.	*/
+#if defined __USE_POSIX199309 || defined __USE_UNIX98
+# define O_DSYNC	O_SYNC	/* Synchronize data.  */
+# define O_RSYNC	O_SYNC	/* Synchronize read operations.	 */
+#endif
+
+#ifdef __USE_LARGEFILE64
+# define O_LARGEFILE	0400000
+#endif
+
+/* Values for the second argument to `fcntl'.  */
+#define F_DUPFD		0	/* Duplicate file descriptor.  */
+#define F_GETFD		1	/* Get file descriptor flags.  */
+#define F_SETFD		2	/* Set file descriptor flags.  */
+#define F_GETFL		3	/* Get file status flags.  */
+#define F_SETFL		4	/* Set file status flags.  */
+#ifndef __USE_FILE_OFFSET64
+# define F_GETLK	5	/* Get record locking info.  */
+# define F_SETLK	6	/* Set record locking info (non-blocking).  */
+# define F_SETLKW	7	/* Set record locking info (blocking).	*/
+#else
+# define F_GETLK	F_GETLK64  /* Get record locking info.	*/
+# define F_SETLK	F_SETLK64  /* Set record locking info (non-blocking).*/
+# define F_SETLKW	F_SETLKW64 /* Set record locking info (blocking).  */
+#endif
+#define F_GETLK64	12	/* Get record locking info.  */
+#define F_SETLK64	13	/* Set record locking info (non-blocking).  */
+#define F_SETLKW64	14	/* Set record locking info (blocking).	*/
+
+#if defined __USE_BSD || defined __USE_XOPEN2K
+# define F_SETOWN	8	/* Get owner of socket (receiver of SIGIO).  */
+# define F_GETOWN	9	/* Set owner of socket (receiver of SIGIO).  */
+#endif
+
+#ifdef __USE_GNU
+# define F_SETSIG	10	/* Set number of signal to be sent.  */
+# define F_GETSIG	11	/* Get number of signal to be sent.  */
+#endif
+
+#ifdef __USE_GNU
+# define F_SETLEASE	1024	/* Set a lease.	 */
+# define F_GETLEASE	1025	/* Enquire what lease is active.  */
+# define F_NOTIFY	1026	/* Request notfications on a directory.	 */
+#endif
+
+/* For F_[GET|SET]FL.  */
+#define FD_CLOEXEC	1	/* actually anything with low bit set goes */
+
+/* For posix fcntl() and `l_type' field of a `struct flock' for lockf().  */
+#define F_RDLCK		0	/* Read lock.  */
+#define F_WRLCK		1	/* Write lock.	*/
+#define F_UNLCK		2	/* Remove lock.	 */
+
+/* For old implementation of bsd flock().  */
+#define F_EXLCK		4	/* or 3 */
+#define F_SHLCK		8	/* or 4 */
+
+#ifdef __USE_BSD
+/* Operations for bsd flock(), also used by the kernel implementation.	*/
+# define LOCK_SH	1	/* shared lock */
+# define LOCK_EX	2	/* exclusive lock */
+# define LOCK_NB	4	/* or'd with one of the above to prevent
+				   blocking */
+# define LOCK_UN	8	/* remove lock */
+#endif
+
+#ifdef __USE_GNU
+# define LOCK_MAND	32	/* This is a mandatory flock:	*/
+# define LOCK_READ	64	/* ... which allows concurrent read operations.	 */
+# define LOCK_WRITE	128	/* ... which allows concurrent write operations.  */
+# define LOCK_RW	192	/* ... Which allows concurrent read & write operations.	 */
+#endif
+
+#ifdef __USE_GNU
+/* Types of directory notifications that may be requested with F_NOTIFY.  */
+# define DN_ACCESS	0x00000001	/* File accessed.  */
+# define DN_MODIFY	0x00000002	/* File modified.  */
+# define DN_CREATE	0x00000004	/* File created.  */
+# define DN_DELETE	0x00000008	/* File removed.  */
+# define DN_RENAME	0x00000010	/* File renamed.  */
+# define DN_ATTRIB	0x00000020	/* File changed attibutes.  */
+# define DN_MULTISHOT	0x80000000	/* Don't remove notifier.  */
+#endif
+
+struct flock
+  {
+    short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.	*/
+    short int l_whence;	/* Where `l_start' is relative to (like `lseek').  */
+#ifndef __USE_FILE_OFFSET64
+    __off_t l_start;	/* Offset where the lock begins.  */
+    __off_t l_len;	/* Size of the locked area; zero means until EOF.  */
+#else
+    __off64_t l_start;	/* Offset where the lock begins.  */
+    __off64_t l_len;	/* Size of the locked area; zero means until EOF.  */
+#endif
+    __pid_t l_pid;	/* Process holding the lock.  */
+  };
+
+#ifdef __USE_LARGEFILE64
+struct flock64
+  {
+    short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.	*/
+    short int l_whence;	/* Where `l_start' is relative to (like `lseek').  */
+    __off64_t l_start;	/* Offset where the lock begins.  */
+    __off64_t l_len;	/* Size of the locked area; zero means until EOF.  */
+    __pid_t l_pid;	/* Process holding the lock.  */
+  };
+#endif
+
+/* Define some more compatibility macros to be backward compatible with
+   BSD systems which did not managed to hide these kernel macros.  */
+#ifdef	__USE_BSD
+# define FAPPEND	O_APPEND
+# define FFSYNC		O_FSYNC
+# define FASYNC		O_ASYNC
+# define FNONBLOCK	O_NONBLOCK
+# define FNDELAY	O_NDELAY
+#endif /* Use BSD.  */
+
+/* Advise to `posix_fadvise'.  */
+#ifdef __USE_XOPEN2K
+# define POSIX_FADV_NORMAL	0 /* No further special treatment.  */
+# define POSIX_FADV_RANDOM	1 /* Expect random page references.  */
+# define POSIX_FADV_SEQUENTIAL	2 /* Expect sequential page references.	 */
+# define POSIX_FADV_WILLNEED	3 /* Will need these pages.  */
+# define POSIX_FADV_DONTNEED	4 /* Don't need these pages.  */
+# define POSIX_FADV_NOREUSE	5 /* Data will be accessed once.  */
+#endif
+
+#ifdef __USE_GNU
+# define SYNC_FILE_RANGE_WAIT_BEFORE	1 /* Wait upon writeout of all pages
+					     in the range before performing the
+					     write.  */
+# define SYNC_FILE_RANGE_WRITE		2 /* Initiate writeout of all those
+					     dirty pages in the range which are
+					     not presently under writeback.  */
+# define SYNC_FILE_RANGE_WAIT_AFTER	4 /* Wait upon writeout of all pages in
+					     the range after performing the
+					     write.  */
+#endif
+
+__BEGIN_DECLS
+
+#ifdef __USE_GNU
+
+/* Provide kernel hint to read ahead.  */
+extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count)
+    __THROW;
+
+/* Selective file content synch'ing.  */
+extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
+			    unsigned int __flags);
+
+/* Splice address range into a pipe.  */
+extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
+			 size_t __count, unsigned int __flags);
+
+/* Splice two files together.  */
+extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout,
+		       __off64_t *__offout, size_t __len,
+		       unsigned int __flags);
+
+/* In-kernel implementation of tee for pipe buffers.  */
+extern ssize_t tee (int __fdin, int __fdout, size_t __len,
+		    unsigned int __flags);
+
+#endif
+
+__END_DECLS
Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/kernel_stat.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/kernel_stat.h	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,61 @@
+#ifndef _BITS_STAT_STRUCT_H
+#define _BITS_STAT_STRUCT_H
+
+#ifndef _LIBC
+#error bits/kernel_stat.h is for internal uClibc use only!
+#endif
+
+/* This file provides whatever this particular arch's kernel thinks 
+ * struct kernel_stat should look like...  It turns out each arch has a 
+ * different opinion on the subject... */
+
+struct kernel_stat {
+	unsigned short st_dev;
+	unsigned short __pad1;
+	unsigned long st_ino;
+	unsigned short st_mode;
+	unsigned short st_nlink;
+	unsigned short st_uid;
+	unsigned short st_gid;
+	unsigned short st_rdev;
+	unsigned short __pad2;
+	unsigned long  st_size;
+	unsigned long  st_blksize;
+	unsigned long  st_blocks;
+	unsigned long  st_atime;
+	unsigned long  __unused1;
+	unsigned long  st_mtime;
+	unsigned long  __unused2;
+	unsigned long  st_ctime;
+	unsigned long  __unused3;
+	unsigned long  __unused4;
+	unsigned long  __unused5;
+};
+
+struct kernel_stat64 {
+	unsigned char	__pad0[6];
+	unsigned short	st_dev;
+	unsigned char	__pad1[4];
+#define _HAVE_STAT64___ST_INO
+	unsigned long	__st_ino;
+	unsigned int	st_mode;
+	unsigned int	st_nlink;
+	unsigned long	st_uid;
+	unsigned long	st_gid;
+	unsigned char	__pad2[6];
+	unsigned short	st_rdev;
+	unsigned char	__pad3[4];
+	long long	st_size;
+	unsigned long	st_blksize;
+	unsigned long	st_blocks;	/* Number 512-byte blocks allocated. */
+	unsigned long	__pad4;		/* future possible st_blocks high bits */
+	unsigned long	st_atime;
+	unsigned long	__pad5;
+	unsigned long	st_mtime;
+	unsigned long	__pad6;
+	unsigned long	st_ctime;
+	unsigned long	__pad7;		/* will be high 32 bits of ctime someday */
+	unsigned long long	st_ino;
+};
+
+#endif	/*  _BITS_STAT_STRUCT_H */
Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/kernel_types.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/kernel_types.h	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,44 @@
+/* Note that we use the exact same include guard #define names
+ * as asm/posix_types.h.  This will avoid gratuitous conflicts 
+ * with the posix_types.h kernel header, and will ensure that 
+ * our private content, and not the kernel header, will win.
+ *  -Erik
+ */
+#ifndef __ARCH_UBICOM32_POSIX_TYPES_H
+#define __ARCH_UBICOM32_POSIX_TYPES_H
+
+typedef unsigned long	__kernel_dev_t;
+typedef unsigned long	__kernel_ino_t;
+typedef unsigned short	__kernel_mode_t;
+typedef unsigned short	__kernel_nlink_t;
+typedef long		__kernel_off_t;
+typedef int		__kernel_pid_t;
+typedef unsigned short	__kernel_ipc_pid_t;
+typedef unsigned short	__kernel_uid_t;
+typedef unsigned short	__kernel_gid_t;
+typedef unsigned int	__kernel_size_t;
+typedef int		__kernel_ssize_t;
+typedef int		__kernel_ptrdiff_t;
+typedef long		__kernel_time_t;
+typedef long		__kernel_suseconds_t;
+typedef long		__kernel_clock_t;
+typedef int		__kernel_daddr_t;
+typedef char *		__kernel_caddr_t;
+typedef unsigned short	__kernel_uid16_t;
+typedef unsigned short	__kernel_gid16_t;
+typedef unsigned int	__kernel_uid32_t;
+typedef unsigned int	__kernel_gid32_t;
+typedef unsigned short	__kernel_old_uid_t;
+typedef unsigned short	__kernel_old_gid_t;
+typedef unsigned short	__kernel_old_dev_t;
+typedef long long	__kernel_loff_t;
+
+typedef struct {
+#ifdef __USE_ALL
+	int val[2];
+#else
+	int __val[2];
+#endif
+} __kernel_fsid_t;
+
+#endif /* __ARCH_UBICOM32_POSIX_TYPES_H */
Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/mman.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/mman.h	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,102 @@
+/* Definitions for POSIX memory map interface.  Linux/m68k version.
+   Copyright (C) 1997, 2000, 2003, 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _SYS_MMAN_H
+# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
+#endif
+
+/* The following definitions basically come from the kernel headers.
+   But the kernel header is not namespace clean.  */
+
+
+/* Protections are chosen from these bits, OR'd together.  The
+   implementation does not necessarily support PROT_EXEC or PROT_WRITE
+   without PROT_READ.  The only guarantees are that no writing will be
+   allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
+
+#define PROT_READ	0x1		/* Page can be read.  */
+#define PROT_WRITE	0x2		/* Page can be written.  */
+#define PROT_EXEC	0x4		/* Page can be executed.  */
+#define PROT_NONE	0x0		/* Page can not be accessed.  */
+#define PROT_GROWSDOWN	0x01000000	/* Extend change to start of
+					   growsdown vma (mprotect only).  */
+#define PROT_GROWSUP	0x02000000	/* Extend change to start of
+					   growsup vma (mprotect only).  */
+
+/* Sharing types (must choose one and only one of these).  */
+#define MAP_SHARED	0x01		/* Share changes.  */
+#define MAP_PRIVATE	0x02		/* Changes are private.  */
+#ifdef __USE_MISC
+# define MAP_TYPE	0x0f		/* Mask for type of mapping.  */
+#endif
+
+/* Other flags.  */
+#define MAP_FIXED	0x10		/* Interpret addr exactly.  */
+#ifdef __USE_MISC
+# define MAP_FILE	0
+# define MAP_ANONYMOUS	0x20		/* Don't use a file.  */
+# define MAP_ANON	MAP_ANONYMOUS
+#endif
+
+/* These are Linux-specific.  */
+#ifdef __USE_MISC
+# define MAP_GROWSDOWN	0x00100		/* Stack-like segment.  */
+# define MAP_DENYWRITE	0x00800		/* ETXTBSY */
+# define MAP_EXECUTABLE	0x01000		/* Mark it as an executable.  */
+# define MAP_LOCKED	0x02000		/* Lock the mapping.  */
+# define MAP_NORESERVE	0x04000		/* Don't check for reservations.  */
+# define MAP_POPULATE	0x08000		/* Populate (prefault) pagetables.  */
+# define MAP_NONBLOCK	0x10000		/* Do not block on IO.  */
+#endif
+
+/* Flags to `msync'.  */
+#define MS_ASYNC	1		/* Sync memory asynchronously.  */
+#define MS_SYNC		4		/* Synchronous memory sync.  */
+#define MS_INVALIDATE	2		/* Invalidate the caches.  */
+
+/* Flags for `mlockall'.  */
+#define MCL_CURRENT	1		/* Lock all currently mapped pages.  */
+#define MCL_FUTURE	2		/* Lock all additions to address
+					   space.  */
+
+/* Flags for `mremap'.  */
+#ifdef __USE_GNU
+# define MREMAP_MAYMOVE	1
+# define MREMAP_FIXED	2
+#endif
+
+/* Advice to `madvise'.  */
+#ifdef __USE_BSD
+# define MADV_NORMAL	 0	/* No further special treatment.  */
+# define MADV_RANDOM	 1	/* Expect random page references.  */
+# define MADV_SEQUENTIAL 2	/* Expect sequential page references.  */
+# define MADV_WILLNEED	 3	/* Will need these pages.  */
+# define MADV_DONTNEED	 4	/* Don't need these pages.  */
+# define MADV_DONTFORK	 10	/* Do not inherit across fork.  */
+# define MADV_DOFORK	 11	/* Do inherit across fork.  */
+#endif
+
+/* The POSIX people had to invent similar names for the same things.  */
+#ifdef __USE_XOPEN2K
+# define POSIX_MADV_NORMAL	0 /* No further special treatment.  */
+# define POSIX_MADV_RANDOM	1 /* Expect random page references.  */
+# define POSIX_MADV_SEQUENTIAL	2 /* Expect sequential page references.  */
+# define POSIX_MADV_WILLNEED	3 /* Will need these pages.  */
+# define POSIX_MADV_DONTNEED	4 /* Don't need these pages.  */
+#endif
Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/setjmp.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/setjmp.h	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,52 @@
+/* Define the machine-dependent type `jmp_buf'.  Ubicom32 version.
+   Copyright (C) 1992,93,95,97,2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _BITS_SETJMP_H
+#define _BITS_SETJMP_H	1
+
+#if !defined _SETJMP_H && !defined _PTHREAD_H
+# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
+#endif
+
+#ifndef	_ASM
+/* 
+ * This is the structure where we are going to save D10-D13, A0, A1, A2, A5, A6 and SP(A7).
+ * A5 is the return address. Call to setjmp will save these. Call to longjmp will return
+ * Control to the address in A5.
+ */
+typedef struct setjmp_save_struct {
+	unsigned long  d10;		/* D10 */
+	unsigned long  d11;		/* D11 */
+	unsigned long  d12;		/* D12 */
+	unsigned long  d13;		/* D13 */
+	unsigned long  a1;		/* A1  */
+	unsigned long  a2;		/* A2  */
+	unsigned long  a5;		/* A5 return address. */
+	unsigned long  a6;		/* A6 */
+	unsigned long  sp;		/* A7 stack pointer. */
+} __jmp_buf[1];
+
+#endif
+
+/* Test if longjmp to JMPBUF would unwind the frame
+   containing a local variable at ADDRESS.  */
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+  ((void *) (address) < (void*)(jmpbuf)->sp)
+
+#endif	/* bits/setjmp.h */
Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/stackinfo.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/stackinfo.h	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,28 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* This file contains a bit of information about the stack allocation
+   of the processor.  */
+
+#ifndef _STACKINFO_H
+#define _STACKINFO_H	1
+
+/* On Ubicom32 the stack grows down.  */
+#define _STACK_GROWS_DOWN	1
+
+#endif	/* stackinfo.h */
Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/syscalls.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/syscalls.h	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,169 @@
+#ifndef _BITS_SYSCALLS_H
+#define _BITS_SYSCALLS_H
+#ifndef _SYSCALL_H
+# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
+#endif
+
+/* m68k headers does stupid stuff with __NR_iopl / __NR_vm86:
+ * #define __NR_iopl   not supported
+ * #define __NR_vm86   not supported
+ */
+#undef __NR_iopl
+#undef __NR_vm86
+
+#ifndef __ASSEMBLER__
+
+#include <errno.h>
+
+/* Linux takes system call arguments in registers:
+
+	syscall number	%d8
+	arg 1		%d0
+	arg 2		%d1
+	arg 3		%d2
+	arg 4		%d3
+	arg 5		%d4
+	arg 6		%d5
+*/
+
+#define __syscall_return(type, res)					\
+	do {								\
+		if (likely((unsigned long)(res) < (unsigned long)(-125))) { \
+			return (type) (res);				\
+		} else {						\
+			/* avoid using res which is declared to be in register d0; \
+			   errno might expand to a function call and clobber it.  */ \
+			int __err = -(res);				\
+			__set_errno(__err);				\
+			return (type) -1;				\
+		}							\
+	} while (0)
+
+extern void __illegally_sized_syscall_arg1 (void);
+extern void __illegally_sized_syscall_arg2 (void);
+extern void __illegally_sized_syscall_arg3 (void);
+extern void __illegally_sized_syscall_arg4 (void);
+extern void __illegally_sized_syscall_arg5 (void);
+extern void __illegally_sized_syscall_arg6 (void);
+
+#define __loadargs_0(name, dummy)					      \
+	d8 = name
+
+#define __loadargs_1(name, __arg1)					\
+	__loadargs_0(name, 0);						\
+	if (__builtin_classify_type (__arg1) != 5 && sizeof (__arg1) > 4) \
+		__illegally_sized_syscall_arg1 ();			\
+	d0_retval = (long int) __arg1
+#define __loadargs_2(name, __arg1, __arg2)    \
+	__loadargs_1(name, __arg1);			   \
+	if (__builtin_classify_type (__arg2) != 5 && sizeof (__arg2) > 4) \
+	  __illegally_sized_syscall_arg2 (); \
+	d1 = (long int) __arg2
+
+#define __loadargs_3(name, __arg1, __arg2, __arg3) \
+	__loadargs_2(name, __arg1, __arg2); \
+	if (__builtin_classify_type (__arg3) != 5 && sizeof (__arg3) > 4) \
+	  __illegally_sized_syscall_arg3 (); \
+	d2 = (long int) __arg3
+
+#define __loadargs_4(name, __arg1, __arg2, __arg3, __arg4)	\
+	__loadargs_3(name, __arg1, __arg2, __arg3); \
+	if (__builtin_classify_type (__arg4) != 5 && sizeof (__arg4) > 4) \
+	  __illegally_sized_syscall_arg4 (); \
+	d3 = (long int)__arg4
+
+#define __loadargs_5(name, __arg1, __arg2, __arg3, __arg4, __arg5) \
+	__loadargs_4(name, __arg1, __arg2, __arg3, __arg4); \
+	if (__builtin_classify_type (__arg5) != 5 && sizeof (__arg5) > 4) \
+	  __illegally_sized_syscall_arg5 (); \
+	d4 = (long int)__arg5
+
+#define __loadargs_6(name, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6) \
+	__loadargs_5(name, __arg1, __arg2, __arg3, __arg4, __arg5); \
+	if (__builtin_classify_type (__arg6) != 5 && sizeof (__arg6) > 4) \
+	  __illegally_sized_syscall_arg6 (); \
+	d5 = (long int)__arg6
+
+#define __internal_syscall_body(name, nr, args...)			\
+	register long int d0_retval  __asm__ ("d0");			\
+	register long int d1  __asm__ ("d1");				\
+	register long int d2  __asm__ ("d2");				\
+	register long int d3  __asm__ ("d3");				\
+	register long int d4  __asm__ ("d4");				\
+	register long int d5  __asm__ ("d5");				\
+	register long int d8  __asm__ ("d8");				\
+	__loadargs_##nr (__NR_##name, args);				\
+	__asm__ __volatile__ (						\
+	"	moveai a5, #%%hi(0x40400000)\n\t"			\
+	"	calli a5, 16(a5)\n\t"					\
+		: "+r" (d0_retval), "+r" (d1), "+r" (d2), "+r" (d3),	\
+		  "+r" (d4), "+r" (d5),  "+r" (d8) :			\
+		: "cc", "memory",					\
+		  "acc0_lo", "acc0_hi", "acc1_lo", "acc1_hi",		\
+		  "source3",						\
+		  "a0", "a3", "a4", "a5",				\
+		  "d6", "d7", "d9", "d14", "d15"			\
+	);
+
+#define INLINE_SYSCALL(name, nr, args...)				\
+	({								\
+		__internal_syscall_body(name, nr, args);		\
+		if (unlikely((unsigned long)(d0_retval) >= (unsigned long)(-125))) { \
+			__set_errno (-d0_retval);			\
+			d0_retval = -1L;				\
+		}							\
+		d0_retval;						\
+	})
+
+
+#undef _syscall0
+#define _syscall0(type,name) \
+type name(void){ \
+	__internal_syscall_body(name, 0); \
+	__syscall_return(type, d0_retval); \
+}
+
+#undef _syscall1
+#define _syscall1(type,name,type1,arg1) \
+type name(type1 arg1){ \
+	__internal_syscall_body(name, 1, arg1); \
+	__syscall_return(type, d0_retval); \
+}
+
+#undef _syscall2
+#define _syscall2(type,name,type1,arg1,type2,arg2) \
+type name(type1 arg1, type2 arg2){ \
+	__internal_syscall_body(name, 2, arg1, arg2); \
+	__syscall_return(type, d0_retval); \
+}
+
+#undef _syscall3
+#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
+type name(type1 arg1, type2 arg2, type3 arg3){ \
+	__internal_syscall_body(name, 3, arg1, arg2, arg3); \
+	__syscall_return(type, d0_retval); \
+}
+
+#undef _syscall4
+#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
+type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4){ \
+	__internal_syscall_body(name, 4, arg1, arg2, arg3, arg4); \
+	__syscall_return(type, d0_retval);			  \
+}
+
+#undef _syscall5
+#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
+type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5){  \
+	__internal_syscall_body(name, 5, arg1, arg2, arg3, arg4, arg5); \
+	__syscall_return(type, d0_retval); \
+}
+
+#undef _syscall6
+#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
+type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6){ \
+	__internal_syscall_body(name, 6, arg1, arg2, arg3, arg4, arg5, arg6); \
+	__syscall_return(type, d0_retval); \
+}
+
+#endif /* __ASSEMBLER__ */
+#endif /* _BITS_SYSCALLS_H */
Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/uClibc_arch_features.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/uClibc_arch_features.h	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,45 @@
+/*
+ * Track misc arch-specific features that aren't config options
+ */
+
+#ifndef _BITS_UCLIBC_ARCH_FEATURES_H
+#define _BITS_UCLIBC_ARCH_FEATURES_H
+
+/* instruction used when calling abort() to kill yourself */
+/*#define __UCLIBC_ABORT_INSTRUCTION__ "asm instruction"*/
+#undef __UCLIBC_ABORT_INSTRUCTION__
+
+/* can your target use syscall6() for mmap ? */
+#undef __UCLIBC_MMAP_HAS_6_ARGS__
+
+/* does your target use syscall4() for truncate64 ? (32bit arches only) */
+#undef __UCLIBC_TRUNCATE64_HAS_4_ARGS__
+
+/* does your target have a broken create_module() ? */
+#undef __UCLIBC_BROKEN_CREATE_MODULE__
+
+/* does your target have to worry about older [gs]etrlimit() ? */
+#undef __UCLIBC_HANDLE_OLDER_RLIMIT__
+
+/* does your target prefix all symbols with an _ ? */
+#define __UCLIBC_NO_UNDERSCORES__
+
+/* does your target have an asm .set ? */
+#define __UCLIBC_HAVE_ASM_SET_DIRECTIVE__
+
+/* define if target doesn't like .global */
+#undef __UCLIBC_ASM_GLOBAL_DIRECTIVE__
+
+/* define if target supports .weak */
+#define __UCLIBC_HAVE_ASM_WEAK_DIRECTIVE__
+
+/* define if target supports .weakext */
+#undef __UCLIBC_HAVE_ASM_WEAKEXT_DIRECTIVE__
+
+/* needed probably only for ppc64 */
+#undef __UCLIBC_HAVE_ASM_GLOBAL_DOT_NAME__
+
+/* define if target supports IEEE signed zero floats */
+#define __UCLIBC_HAVE_SIGNED_ZERO__
+
+#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/wordsize.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/wordsize.h	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,19 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#define __WORDSIZE	32
Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/clone.S
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/clone.S	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,71 @@
+#include <sys/syscall.h>
+
+	.global __syscall_error
+
+/* int _clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
+	.text
+	.type   clone,@function
+	.global clone
+clone:
+	/* Sanity check arguments.  */
+	sub.4	#0, #0, d0	/* Test if fn is zero. */
+	jmpeq.f 1f		/* arg bad */
+	sub.4	#0, #0, d1	/* Test if child_stack is zero. */
+	jmpeq.f	1f		/* arg bad */
+
+	/* Set up child_stack frame.. arg and fn */
+	move.4	a3, d1
+	move.4	-4(a3)++, d3	/* push 'arg' to child stack */
+	move.4	-4(a3)++, d0	/* push fn to child stack, this will become a5
+				 * on new child */
+	move.4	d1, a3
+	move.4	-4(sp)++, a5	/* push a5 to our stack */
+
+	/*
+	 * The syscall clone is clone(int flags, void *child_stack) so we set
+	 * that up now
+	 */
+	move.4	d0, d2		/* Move flags to d0 */
+
+	/* Do Clone syscall */
+	movei	d8, #__NR_clone
+	moveai	a5, #%hi(0x40400000)
+	calli	a5, 0x10(a5)
+	move.4	a5, (sp)4++	/* pop a5 from stack */
+
+	/* Clone Complete */
+	cmpi	d0, #0		/* Test if d0 is less than zero. If it is we
+				 * return the error */
+	jmplt.f	2f		/* If return is less than we had an error */
+	jmpeq.f	3f		/* If return is 0 we are in the clone, jump to
+				 * thread start */
+	ret	a5		/* d0 is pid */
+
+	/* Invalid Value */
+1:	movei   d0, #-22	/* EINVAL */
+
+	/* Call syscall Error */
+2:	sub.4	d0, #0, d0	/* d0 = -d0 */
+#if defined(__UBICOM32_FDPIC__)
+	call	a3, __syscall_error
+#else
+	moveai	a3, #%hi(__syscall_error)
+	calli	a3, %lo(__syscall_error)(a3)
+#endif
+	/* Child Thread Start */
+3:
+#if defined(__UBICOM32_FDPIC__)
+	/* a5 actually contains a function descriptor for fdpic */
+	move.4	a0, 4(a5)	/* set GOT for this function */
+	move.4	a5, 0(a5)	/* get address of entry point */
+#endif
+	move.4	d0, (sp)4++	/* pop 'arg' to stack */
+	calli	a5, 0(a5)
+	movei	d8, #__NR_exit
+	moveai	a3, #%hi(0x40400000)
+	calli	a3, 0x10(a3)
+
+	.size clone, . - clone
+	.global __GI_clone
+	.hidden __GI_clone
+	.set __GI_clone,clone
Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/crt1.S
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/crt1.S	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,179 @@
+/* Startup code compliant to the ELF m68k ABI.
+   Copyright (C) 1996, 1997, 1998, 2001, 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   In addition to the permissions in the GNU Lesser General Public
+   License, the Free Software Foundation gives you unlimited
+   permission to link the compiled version of this file with other
+   programs, and to distribute those programs without any restriction
+   coming from the use of this file. (The GNU Lesser General Public
+   License restrictions do apply in other respects; for example, they
+   cover modification of the file, and distribution when not linked
+   into another program.)
+
+   Note that people who make modified versions of this file are not
+   obligated to grant this special exception for their modified
+   versions; it is their choice whether to do so. The GNU Lesser
+   General Public License gives permission to release a modified
+   version without this exception; this exception also makes it
+   possible to release a modified version which carries forward this
+   exception.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <features.h>
+
+/* This is the canonical entry point, usually the first thing in the text
+   segment.  The SVR4/m68k ABI says that when the entry point runs,
+   most registers' values are unspecified, except for:
+
+   %a1		Contains a function pointer to be registered with `atexit'.
+		This is how the dynamic linker arranges to have DT_FINI
+		functions called for shared libraries that have been loaded
+		before this code runs.
+
+   %sp		The stack contains the arguments and environment:
+		0(%sp)			argc
+		4(%sp)			argv[0]
+		...
+		(4*argc)(%sp)		NULL
+		(4*(argc+1))(%sp)	envp[0]
+		...
+					NULL
+
+   The uclinux conventions are different.  %a1 is not defined on entry
+   and the stack is laid out as follows:
+
+		0(%sp)			argc
+		4(%sp)			argv
+		8(%sp)			envp
+*/
+
+
+	.text
+	.type   main,@function
+	.type	_init,%function
+	.type	_fini,%function
+#ifndef __UCLIBC_CTOR_DTOR__
+	.weak	_init
+	.weak	_fini
+#endif
+	.globl	_start
+	.global __uClibc_main;
+	.type	__uClibc_main,@function;
+	.type	_start,@function
+_start:
+
+#if defined(__UBICOM32_FDPIC__) && !defined(L_Scrt1)
+	/* P0 contains a pointer to the program's load map.  */
+	call	a3, .Lcall;
+.Lcall:
+	move.4	d0, d1 ; load exec_map_addr
+	moveai	a4, #%hi(.Lcall)
+	lea.1	d15, %lo(.Lcall)(a4)
+	sub.4	d15, a3, d15	;  difference between .Lcall and actual address of .Lcall
+	moveai	a3, #%hi(__ROFIXUP_LIST__)
+	lea.1	d1, %lo(__ROFIXUP_LIST__)(a3)
+	moveai	a3, #%hi(__ROFIXUP_END__)
+	lea.1	d2, %lo(__ROFIXUP_END__)(a3)
+	add.4	d1, d1, d15
+	add.4	d2, d2, d15
+	call	a5, __self_reloc	; returns GOT in d0
+	move.4	a0, d0	; set GOT
+#endif
+
+/*
+	all this is setup to make the following call.
+
+	void __uClibc_main(
+		d0 - int (*main)(int, char **, char **),
+		d1 - int argc, (d1)
+		d2 - char **argv,
+		d3 - void (*app_init)(void),
+		d4 - void (*app_fini)(void),
+		d5 - void (*rtld_fini)(void),
+		d6 - void *stack_end
+	);
+ */
+
+	/*
+	 * Load pointer to main into d0
+	 */
+#ifdef __UBICOM32_FDPIC__
+	movei	d0, #%got_funcdesc_lo(main)
+	move.4	d0, (a0, d0)
+#else
+	moveai	a3, #%hi(main)
+	lea.1	d0, %lo(main)(a3)
+#endif
+
+	/*
+	 * Grab the environment stuff from stack and set up d1, d2 with it.
+	 */
+	move.4	d1, (sp)
+#ifdef __UBICOM32_FDPIC__
+	/* For FDPIC the calling convention is different than flat */
+	lea.1	d2, 4(sp)
+#else
+	move.4	d2, 4(sp)
+#endif
+
+#ifdef __UCLIBC_CTOR_DTOR__
+	/*
+	 * Load pointer to _init into d3
+	 */
+#ifdef __UBICOM32_FDPIC__
+	movei	d3, #%got_funcdesc_lo(_init)
+	move.4	d3, (a0, d3)
+#else
+	moveai	a3, #%hi(_init)
+	lea.1	d3, %lo(_init)(a3)
+#endif
+
+	/*
+	 * Load pointer to _fini into d4
+	 */
+#ifdef __UBICOM32_FDPIC__
+	movei	d4, #%got_funcdesc_lo(_fini)
+	move.4	d4, (a0, d4)
+#else
+	moveai	a3, #%hi(_fini)
+	lea.1	d4, %lo(_fini)(a3)
+#endif
+
+#else /* !__UCLIBC_CTOR_DTOR__ */
+	move.4	d3, #0		; _init
+	move.4	d4, #0		; _fini
+#endif
+
+#ifdef __UBICOM32_FDPIC__
+	move.4	d5, a1		; ldso _fini funcdesc (see dl-startup.h)
+#else
+	movei	d5, #0		; rtld_fini (not used)
+#endif
+
+	move.4	d6, sp		; Stack End.
+
+	/* Call the user's main function, and exit with its value.  But
+	   let the libc call main.  */
+#ifdef __UBICOM32_FDPIC__
+	call	a5, __uClibc_main
+#else
+	moveai	a5, #%hi(__uClibc_main)
+	calli	a5, %lo(__uClibc_main)(a5)
+#endif
+
+	bkpt #-1		; Crash if somehow `exit' does return.
Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/crti.S
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/crti.S	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,54 @@
+/* Specialized code needed to support construction and destruction of
+   file-scope objects in C++ and Java code, and to support exception handling.
+   Copyright (C) 1999 Free Software Foundation, Inc.
+   Contributed by Charles-Antoine Gauthier (charles.gauthier@iit.nrc.ca).
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING.  If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* As a special exception, if you link this library with files
+   compiled with GCC to produce an executable, this does not cause
+   the resulting executable to be covered by the GNU General Public License.
+   This exception does not however invalidate any other reasons why
+   the executable file might be covered by the GNU General Public License.  */
+
+/*
+ * This file just supplies function prologues for the .init and .fini
+ * sections.  It is linked in before crtbegin.o.
+ */
+	.file   "crti.o"
+	.ident  "GNU C crti.o"
+
+	.section .init
+	.align	2
+	.globl	_init
+	.type	_init, @function
+_init:
+	move.4 -4(sp)++, a5
+#ifdef __UBICOM32_FDPIC__
+	move.4 -4(sp)++, a0
+#endif
+
+	.section .fini
+	.align	2
+	.globl	_fini
+	.type	_fini, @function
+_fini:
+	move.4 -4(sp)++, a5
+#ifdef __UBICOM32_FDPIC__
+	move.4 -4(sp)++, a0
+#endif
Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/crtn.S
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/crtn.S	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,47 @@
+/* Specialized code needed to support construction and destruction of
+   file-scope objects in C++ and Java code, and to support exception handling.
+   Copyright (C) 1999 Free Software Foundation, Inc.
+   Contributed by Charles-Antoine Gauthier (charles.gauthier@iit.nrc.ca).
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING.  If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* As a special exception, if you link this library with files
+   compiled with GCC to produce an executable, this does not cause
+   the resulting executable to be covered by the GNU General Public License.
+   This exception does not however invalidate any other reasons why
+   the executable file might be covered by the GNU General Public License.  */
+
+/*
+ * This file supplies function epilogues for the .init and .fini sections.
+ * It is linked in after all other files.
+ */
+
+	.file   "crtn.o"
+	.ident  "GNU C crtn.o"
+
+	.section .init
+#ifdef __UBICOM32_FDPIC__
+	move.4	a0, (sp)4++
+#endif
+	ret	(sp)4++
+
+	.section .fini
+#ifdef __UBICOM32_FDPIC__
+	move.4	a0, (sp)4++
+#endif
+	ret	(sp)4++
Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/crtreloc.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/crtreloc.c	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,145 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   written by Alexandre Oliva <aoliva@redhat.com>
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of the
+License, or (at your option) any later version.
+
+In addition to the permissions in the GNU Lesser General Public
+License, the Free Software Foundation gives you unlimited
+permission to link the compiled version of this file with other
+programs, and to distribute those programs without any restriction
+coming from the use of this file.  (The GNU Lesser General Public
+License restrictions do apply in other respects; for example, they
+cover modification of the file, and distribution when not linked
+into another program.)
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#ifdef __UBICOM32_FDPIC__
+
+#include <sys/types.h>
+#include <link.h>
+
+/* This file is to be compiled into crt object files, to enable
+   executables to easily self-relocate.  */
+
+union word {
+    char c[4];
+    void *v;
+};
+
+/* Compute the runtime address of pointer in the range [p,e), and then
+   map the pointer pointed by it.  */
+static __always_inline void ***
+reloc_range_indirect (void ***p, void ***e,
+		      const struct elf32_fdpic_loadmap *map)
+{
+  while (p < e)
+    {
+      if (*p != (void **)-1)
+	{
+	  void *ptr = __reloc_pointer (*p, map);
+	  if (ptr != (void *)-1)
+	    {
+	      void *pt;
+	      if ((long)ptr & 3)
+		{
+		  unsigned char *c = ptr;
+		  int i;
+		  unsigned long v = 0;
+		  for (i = 0; i < 4; i++)
+		    v |= c[i] << 8 * i;
+		  pt = (void *)v;
+		}
+	      else
+		pt = *(void**)ptr;
+	      pt = __reloc_pointer (pt, map);
+	      if ((long)ptr & 3)
+		{
+		  unsigned char *c = ptr;
+		  int i;
+		  unsigned long v = (unsigned long)pt;
+		  for (i = 0; i < 4; i++, v >>= 8)
+		    c[i] = v;
+		}
+	      else
+		*(void**)ptr = pt;
+	    }
+	}
+      p++;
+    }
+  return p;
+}
+
+/* Call __reloc_range_indirect for the given range except for the last
+   entry, whose contents are only relocated.  It's expected to hold
+   the GOT value.  */
+void* attribute_hidden
+__self_reloc (const struct elf32_fdpic_loadmap *map,
+	      void ***p, void ***e)
+{
+  p = reloc_range_indirect (p, e-1, map);
+
+  if (p >= e)
+    return (void*)-1;
+
+  return __reloc_pointer (*p, map);
+}
+
+#if 0
+/* These are other functions that might be useful, but that we don't
+   need.  */
+
+/* Remap pointers in [p,e).  */
+static __always_inline void**
+reloc_range (void **p, void **e,
+	     const struct elf32_fdpic_loadmap *map)
+{
+  while (p < e)
+    {
+      *p = __reloc_pointer (*p, map);
+      p++;
+    }
+  return p;
+}
+
+/* Remap p, adjust e by the same offset, then map the pointers in the
+   range determined by them.  */
+void attribute_hidden
+__reloc_range (const struct elf32_fdpic_loadmap *map,
+	       void **p, void **e)
+{
+  void **old = p;
+
+  p = __reloc_pointer (p, map);
+  e += p - old;
+  reloc_range (p, e, map);
+}
+
+/* Remap p, adjust e by the same offset, then map pointers referenced
+   by the (unadjusted) pointers in the range.  Return the relocated
+   value of the last pointer in the range.  */
+void* attribute_hidden
+__reloc_range_indirect (const struct elf32_fdpic_loadmap *map,
+			void ***p, void ***e)
+{
+  void ***old = p;
+
+  p = __reloc_pointer (p, map);
+  e += p - old;
+  return reloc_range_indirect (p, e, map);
+}
+#endif
+
+#endif /* __UBICOM32_FDPIC__ */
Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/setjmp.S
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/setjmp.S	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,72 @@
+/* Setjmp for Ubicom32 */
+	.text
+	.global _setjmp
+	.type   _setjmp,@function
+_setjmp:
+	movea	a3, d0		; A3 now holds the jmp buf that was passed in.
+	move.4	(a3)4++, d10
+	move.4	(a3)4++, d11
+	move.4	(a3)4++, d12
+	move.4	(a3)4++, d13
+	move.4  (a3)4++, a1
+	move.4  (a3)4++, a2
+	move.4  (a3)4++, a5
+	move.4  (a3)4++, a6
+	move.4  (a3)4++, a7
+	move.4	d0, #0
+
+	calli	a5, 0(a5)
+	.size _setjmp, . - _setjmp
+
+/*
+ * __sigsetjmp for Ubicom32
+ *     d0 holds sigjmp_buf and d1 holds the savemask. We will save the frame and then just call __sigjmp_save to do the mask save.
+ */
+	.global __sigsetjmp
+	.type   __sigsetjmp,@function
+__sigsetjmp:
+	movea	a3, d0		; A3 now holds the jmp buf that was passed in.
+	move.4	(a3)4++, d10
+	move.4	(a3)4++, d11
+	move.4	(a3)4++, d12
+	move.4	(a3)4++, d13
+	move.4  (a3)4++, a1
+	move.4  (a3)4++, a2
+	move.4  (a3)4++, a5
+	move.4  (a3)4++, a6
+	move.4  (a3)4++, a7
+
+	;; The frame has been saved. Call _sigjmp_save to get sigmask saved. a5 still has the return address and it will go back to that.
+#if defined(__UBICOM32_FDPIC__)
+	call	a3, __sigjmp_save
+#else
+	moveai	a3, #%hi(__sigjmp_save)
+	calli	a3, %lo(__sigjmp_save)(a3)
+#endif
+	.size __sigjmp_save, . - __sigjmp_save
+
+	.global	__longjmp
+	.type   __longjmp,@function
+__longjmp:
+	movea	a3, d0		; A3 now holds the jmp buf that was passed in.
+	move.4  d10, (a3)4++
+	move.4  d11, (a3)4++
+	move.4  d12, (a3)4++
+	move.4  d13, (a3)4++
+	move.4  a1 , (a3)4++
+	move.4  a2 , (a3)4++
+	move.4  a5 , (a3)4++
+	move.4  a6 , (a3)4++
+	move.4  a7 , (a3)4++
+
+	sub.4	#0, #0, d1	; Test if d1 is zero. If it is we have to return 1 other wise return content of d1
+	jmpeq.t	2f
+	move.4	d0, d1		; d1 is non zero load it into d0
+	jmpt.t	3f
+
+2:	move.4	d0, #1
+3:	calli	a5, 0(a5)
+	.size __longjmp, . - __longjmp
+	.global __GI___longjmp
+	.hidden __GI___longjmp
+	.set __GI___longjmp,__longjmp
Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/sys/procfs.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/sys/procfs.h	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,122 @@
+/* Copyright (C) 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _SYS_PROCFS_H
+#define _SYS_PROCFS_H	1
+
+/* This is somehow modelled after the file of the same name on SysVr4
+   systems.  It provides a definition of the core file format for ELF
+   used on Linux.  */
+
+#include <features.h>
+#include <signal.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/ucontext.h>
+#include <bits/wordsize.h>
+
+__BEGIN_DECLS
+
+#define ELF_NGREG		38
+
+typedef struct
+  {
+    union
+      {
+	unsigned long	pr_regs[32];
+	double		pr_dregs[16];
+      }			pr_fr;
+    unsigned long	__unused;
+    unsigned long	pr_fsr;
+    unsigned char	pr_qcnt;
+    unsigned char	pr_q_entrysize;
+    unsigned char	pr_en;
+    unsigned int	pr_q[64];
+  } elf_fpregset_t;
+
+typedef unsigned long elf_greg_t;
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
+struct elf_siginfo
+  {
+    int si_signo;			/* Signal number.  */
+    int si_code;			/* Extra code.  */
+    int si_errno;			/* Errno.  */
+  };
+
+/* Definitions to generate Intel SVR4-like core files.  These mostly
+   have the same names as the SVR4 types with "elf_" tacked on the
+   front to prevent clashes with linux definitions, and the typedef
+   forms have been avoided.  This is mostly like the SVR4 structure,
+   but more Linuxy, with things that Linux does not support and which
+   gdb doesn't really use excluded.  Fields present but not used are
+   marked with "XXX".  */
+struct elf_prstatus
+  {
+    struct elf_siginfo pr_info;		/* Info associated with signal.  */
+    short int pr_cursig;		/* Current signal.  */
+    unsigned long int pr_sigpend;	/* Set of pending signals.  */
+    unsigned long int pr_sighold;	/* Set of held signals.  */
+    __pid_t pr_pid;
+    __pid_t pr_ppid;
+    __pid_t pr_pgrp;
+    __pid_t pr_sid;
+    struct timeval pr_utime;		/* User time.  */
+    struct timeval pr_stime;		/* System time.  */
+    struct timeval pr_cutime;		/* Cumulative user time.  */
+    struct timeval pr_cstime;		/* Cumulative system time.  */
+    elf_gregset_t pr_reg;		/* GP registers.  */
+    int pr_fpvalid;			/* True if math copro being used.  */
+  };
+
+
+#define ELF_PRARGSZ     (80)    /* Number of chars for args */
+
+struct elf_prpsinfo
+  {
+    char pr_state;			/* Numeric process state.  */
+    char pr_sname;			/* Char for pr_state.  */
+    char pr_zomb;			/* Zombie.  */
+    char pr_nice;			/* Nice val.  */
+    unsigned long int pr_flag;		/* Flags.  */
+    unsigned short int pr_uid;
+    unsigned short int pr_gid;
+    int pr_pid, pr_ppid, pr_pgrp, pr_sid;
+    /* Lots missing */
+    char pr_fname[16];			/* Filename of executable.  */
+    char pr_psargs[ELF_PRARGSZ];	/* Initial part of arg list.  */
+  };
+
+/* Addresses.  */
+typedef void *psaddr_t;
+
+/* Register sets.  Linux has different names.  */
+typedef elf_gregset_t prgregset_t;
+typedef elf_fpregset_t prfpregset_t;
+
+/* We don't have any differences between processes and threads,
+   therefore have only one PID type.  */
+typedef __pid_t lwpid_t;
+
+
+typedef struct elf_prstatus prstatus_t;
+typedef struct elf_prpsinfo prpsinfo_t;
+
+__END_DECLS
+
+#endif	/* sys/procfs.h */
Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/sys/ucontext.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/sys/ucontext.h	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,104 @@
+/* Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _SYS_UCONTEXT_H
+#define _SYS_UCONTEXT_H	1
+
+#include <features.h>
+#include <signal.h>
+/*
+ * Location of the users' stored registers relative to R0.
+ * Usage is as an index into a gregset_t array or as u.u_ar0[XX].
+ */
+#define REG_PSR (0)
+#define REG_PC  (1)
+#define REG_SPARE   (2)
+#define REG_WVALID  (3)
+#define REG_G1  (4)
+#define REG_G2  (5)
+#define REG_G3  (6)
+#define REG_G4  (7)
+#define REG_G5  (8)
+#define REG_G6  (9)
+#define REG_G7  (10)
+#define REG_O0  (11)
+#define REG_O1  (12)
+#define REG_O2  (13)
+#define REG_O3  (14)
+#define REG_O4  (15)
+#define REG_O5  (16)
+#define REG_O6  (17)
+#define REG_O7  (18)
+#define REG_GLOBALS (19)
+
+/*
+ * A gregset_t is defined as an array type for compatibility with the reference
+ * source. This is important due to differences in the way the C language
+ * treats arrays and structures as parameters.
+ *
+ * Note that NGREG is really (sizeof (struct regs) / sizeof (greg_t)),
+ * but that the ABI defines it absolutely to be 21 (resp. 19).
+ */
+
+#define NGREG   20
+typedef int greg_t;
+
+typedef greg_t  gregset_t[NGREG];
+
+/*
+ * The following structures define how a register window can appear on the
+ * stack. This structure is available (when required) through the `gwins'
+ * field of an mcontext (nested within ucontext). NIOS_MAXWINDOW is the
+ * maximum number of outstanding register windows defined in the NIOS
+ * architecture (*not* implementation).
+ */
+#define NIOS_MAXREGWINDOW	31	/* max windows in NIOS arch. */
+struct  rwindow
+  {
+    greg_t rw_local[8];			/* locals */
+    greg_t rw_in[8];			/* ins */
+  };
+
+#define rw_fp   rw_in[6]		/* frame pointer */
+#define rw_rtn  rw_in[7]		/* return address */
+
+typedef struct gwindows
+  {
+    int            wbcnt;
+    int           *spbuf[NIOS_MAXREGWINDOW];
+    struct rwindow wbuf[NIOS_MAXREGWINDOW];
+  } gwindows_t;
+
+typedef struct
+  {
+    gregset_t   gregs;		/* general register set */
+    gwindows_t  *gwins;		/* POSSIBLE pointer to register windows */
+  } mcontext_t;
+
+
+/* Userlevel context.  */
+typedef struct ucontext
+  {
+    unsigned long   uc_flags;
+    struct ucontext *uc_link;
+    __sigset_t	    uc_sigmask;
+    stack_t         uc_stack;
+    mcontext_t      uc_mcontext;
+  } ucontext_t;
+
+#endif /* sys/ucontext.h */
Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/syscall.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/syscall.c	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,32 @@
+/* vi: set sw=4 ts=4: */
+/* syscall for ubicom32/uClibc
+ *
+ * Copyright (C) 2008 by Ubicom Inc.
+ * Copyright (C) 2002 by Erik Andersen <andersen@uclibc.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <features.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+
+extern long syscall(long sysnum, long a, long b, long c, long d, long e, long f);
+long syscall(long sysnum, long a, long b, long c, long d, long e, long f)
+{
+	int __NR_syscall_number = sysnum;
+	return (long) INLINE_SYSCALL(syscall_number, 6, a, b, c, d, e, f);
+}
Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/vfork.S
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/vfork.S	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,35 @@
+#include <sys/syscall.h>
+
+	.text
+	.type   vfork,@function
+	.global vfork
+vfork:
+	move.4	-4(sp)++, a5	; Save return address on the stack.
+	movei	d8, #__NR_vfork
+	moveai	a3, #%hi(0x40400000)
+	calli	a5, 0x10(a3)
+
+	/*
+	 * You get here only if the syscall bombed. If things had worked out the
+	 * parent and child would have both returned to the instruction after
+	 * the vfork call.
+	 */
+	move.4	a5, (sp)4++	; Pop the return address off the stack.
+	movei	d1, #-125
+	sub.4	#0, d0, d1
+	jmplt.t	1f
+
+	;; We have an error.
+	sub.4	d0, #0, d0	; d0 = -res. Call __set_errno with that.
+#if defined(__UBICOM32_FDPIC__)
+	call	a3, __syscall_error
+#else
+	moveai	a3, #%hi(__syscall_error)
+	calli	a3, %lo(__syscall_error)(a3)	; __syscall_error will return -1 and not come back here.
+#endif
+1:
+	calli	a5, 0(a5)
+	.size vfork, . - vfork
+	.global __GI_vfork
+	.hidden __GI_vfork
+	.set __GI_vfork,vfork
Index: uClibc-0.9.30.2/libpthread/linuxthreads.old/pthread.c
===================================================================
--- uClibc-0.9.30.2.orig/libpthread/linuxthreads.old/pthread.c	2010-01-13 22:22:31.000000000 +0100
+++ uClibc-0.9.30.2/libpthread/linuxthreads.old/pthread.c	2010-01-14 11:05:01.000000000 +0100
@@ -393,6 +393,10 @@
 #endif
 
     __libc_multiple_threads_ptr = __libc_pthread_init (ptr_pthread_functions);
+#ifndef __ARCH_USE_MMU__
+    __pthread_initial_thread_tos =
+      (char *)(((long)CURRENT_STACK_FRAME + getpagesize()) & ~(getpagesize() - 1));
+#endif /* __ARCH_USE_MMU__ */
 }
 
 
@@ -461,8 +465,11 @@
    * __pthread_initial_thread_bos at address 0. These bounds are refined as we
    * malloc other stack frames such that they don't overlap. -StS
    */
-  __pthread_initial_thread_tos =
-    (char *)(((long)CURRENT_STACK_FRAME + getpagesize()) & ~(getpagesize() - 1));
+  if (__pthread_initial_thread_tos == NULL) {
+    __pthread_initial_thread_tos =
+      (char *)(((long)CURRENT_STACK_FRAME + getpagesize()) & ~(getpagesize() - 1));
+  }
+
   __pthread_initial_thread_bos = (char *) 1; /* set it non-zero so we know we have been here */
   PDEBUG("initial thread stack bounds: bos=%p, tos=%p\n",
 	 __pthread_initial_thread_bos, __pthread_initial_thread_tos);
Index: uClibc-0.9.30.2/libpthread/linuxthreads.old/sysdeps/ubicom32/pt-machine.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libpthread/linuxthreads.old/sysdeps/ubicom32/pt-machine.h	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,68 @@
+/* Machine-dependent pthreads configuration and inline functions.
+
+   Copyright (C) 1996, 1997, 1998, 2000, 2002, 2003, 2004
+   Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ralf Baechle <ralf@gnu.org>.
+   Based on the Alpha version by Richard Henderson <rth@tamu.edu>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If
+   not, write to the Free Software Foundation, Inc.,
+   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#ifndef _PT_MACHINE_H
+#define _PT_MACHINE_H   1
+
+#include <features.h>
+
+/*
+ * XXX try to make this inline
+ */
+extern long int testandset (int *spinlock);
+
+#ifndef PT_EI
+#define PT_EI
+#else
+/* Spinlock implementation; required.  */
+
+/*
+ * testandset() is the basis for the pthread spin lock.
+ *
+ * This implementation only requires that we 'set' the state of *spinlock. As
+ * bset is allows us to atomically 'testandset' a single bit define our 'set' is
+ * such that we will set bit 0 (ignoring all other bits, which should also be
+ * zero).
+ * Return value of 1 implies that the bit was already set and is still
+ * set.
+ * Return value of 0 implies that the bit was not previously set but it
+ * now is.
+ */
+long int
+testandset (int *spinlock)
+{
+	int ret; 
+	__asm__ volatile (
+		"	move.4	%0, #0		\n\t" /* Assume that the bit is not currently set */
+		"	bset	%1, %1, #0	\n\t" /* Attempt to 'set' bit 0 */
+		"	jmpeq.t	1f		\n\t"
+		"	move.4	%0, #1		\n\t" /* Bit was already set, so return 1 */
+		" 1:				\n\t"
+		: "=r"(ret), "+U4"(*spinlock)
+		:
+		: "memory", "cc"
+		);
+	return ret;
+}
+#endif
+#endif /* pt-machine.h */
Index: uClibc-0.9.30.2/libpthread/linuxthreads.old/sysdeps/ubicom32/tls.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.30.2/libpthread/linuxthreads.old/sysdeps/ubicom32/tls.h	2010-01-14 11:05:01.000000000 +0100
@@ -0,0 +1,26 @@
+/* Definitions for thread-local data handling.  linuxthreads/MIPS version.
+   Copyright (C) 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _TLS_H
+#define _TLS_H
+#ifdef HAVE_TLS_SUPPORT
+#warning no tls support 
+#undef USE_TLS
+#endif
+#endif	/* tls.h */