@@ -1461,7 +1461,7 @@ elf_zlib_inflate_table (unsigned char *codes, size_t codes_len,
1461
1461
#include <stdio.h>
1462
1462
1463
1463
static uint16_t table [ZDEBUG_TABLE_SIZE ];
1464
- static unsigned char codes [287 ];
1464
+ static unsigned char codes [288 ];
1465
1465
1466
1466
int
1467
1467
main ()
@@ -1476,7 +1476,7 @@ main ()
1476
1476
codes [i ] = 7 ;
1477
1477
for (i = 280 ; i <= 287 ; ++ i )
1478
1478
codes [i ] = 8 ;
1479
- if (!elf_zlib_inflate_table (& codes [0 ], 287 , & table [0 ], & table [0 ]))
1479
+ if (!elf_zlib_inflate_table (& codes [0 ], 288 , & table [0 ], & table [0 ]))
1480
1480
{
1481
1481
fprintf (stderr , "elf_zlib_inflate_table failed\n" );
1482
1482
exit (EXIT_FAILURE );
@@ -1495,48 +1495,72 @@ main ()
1495
1495
printf ("\n" );
1496
1496
}
1497
1497
printf ("};\n" );
1498
+ printf ("\n" );
1499
+
1500
+ for (i = 0 ; i < 32 ; ++ i )
1501
+ codes [i ] = 5 ;
1502
+ if (!elf_zlib_inflate_table (& codes [0 ], 32 , & table [0 ], & table [0 ]))
1503
+ {
1504
+ fprintf (stderr , "elf_zlib_inflate_table failed\n" );
1505
+ exit (EXIT_FAILURE );
1506
+ }
1507
+
1508
+ printf ("static const uint16_t elf_zlib_default_dist_table[%#zx] =\n" ,
1509
+ final_next_secondary + 0x100 );
1510
+ printf ("{\n" );
1511
+ for (i = 0 ; i < final_next_secondary + 0x100 ; i += 8 )
1512
+ {
1513
+ size_t j ;
1514
+
1515
+ printf (" " );
1516
+ for (j = i ; j < final_next_secondary + 0x100 && j < i + 8 ; ++ j )
1517
+ printf (" %#x," , table [j ]);
1518
+ printf ("\n" );
1519
+ }
1520
+ printf ("};\n" );
1521
+
1498
1522
return 0 ;
1499
1523
}
1500
1524
1501
1525
#endif
1502
1526
1503
- /* The fixed table generated by the #ifdef'ed out main function
1527
+ /* The fixed tables generated by the #ifdef'ed out main function
1504
1528
above. */
1505
1529
1506
1530
static const uint16_t elf_zlib_default_table [0x170 ] =
1507
1531
{
1508
- 0xd00 , 0xe50 , 0xe10 , 0xf18 , 0xd10 , 0xe70 , 0xe30 , 0x1232 ,
1509
- 0xd08 , 0xe60 , 0xe20 , 0x1212 , 0xe00 , 0xe80 , 0xe40 , 0x1252 ,
1510
- 0xd04 , 0xe58 , 0xe18 , 0x1202 , 0xd14 , 0xe78 , 0xe38 , 0x1242 ,
1511
- 0xd0c , 0xe68 , 0xe28 , 0x1222 , 0xe08 , 0xe88 , 0xe48 , 0x1262 ,
1512
- 0xd02 , 0xe54 , 0xe14 , 0xf1c , 0xd12 , 0xe74 , 0xe34 , 0x123a ,
1513
- 0xd0a , 0xe64 , 0xe24 , 0x121a , 0xe04 , 0xe84 , 0xe44 , 0x125a ,
1514
- 0xd06 , 0xe5c , 0xe1c , 0x120a , 0xd16 , 0xe7c , 0xe3c , 0x124a ,
1515
- 0xd0e , 0xe6c , 0xe2c , 0x122a , 0xe0c , 0xe8c , 0xe4c , 0x126a ,
1516
- 0xd01 , 0xe52 , 0xe12 , 0xf1a , 0xd11 , 0xe72 , 0xe32 , 0x1236 ,
1517
- 0xd09 , 0xe62 , 0xe22 , 0x1216 , 0xe02 , 0xe82 , 0xe42 , 0x1256 ,
1518
- 0xd05 , 0xe5a , 0xe1a , 0x1206 , 0xd15 , 0xe7a , 0xe3a , 0x1246 ,
1519
- 0xd0d , 0xe6a , 0xe2a , 0x1226 , 0xe0a , 0xe8a , 0xe4a , 0x1266 ,
1520
- 0xd03 , 0xe56 , 0xe16 , 0xf1e , 0xd13 , 0xe76 , 0xe36 , 0x123e ,
1521
- 0xd0b , 0xe66 , 0xe26 , 0x121e , 0xe06 , 0xe86 , 0xe46 , 0x125e ,
1522
- 0xd07 , 0xe5e , 0xe1e , 0x120e , 0xd17 , 0xe7e , 0xe3e , 0x124e ,
1523
- 0xd0f , 0xe6e , 0xe2e , 0x122e , 0xe0e , 0xe8e , 0xe4e , 0x126e ,
1524
- 0xd00 , 0xe51 , 0xe11 , 0xf19 , 0xd10 , 0xe71 , 0xe31 , 0x1234 ,
1525
- 0xd08 , 0xe61 , 0xe21 , 0x1214 , 0xe01 , 0xe81 , 0xe41 , 0x1254 ,
1526
- 0xd04 , 0xe59 , 0xe19 , 0x1204 , 0xd14 , 0xe79 , 0xe39 , 0x1244 ,
1527
- 0xd0c , 0xe69 , 0xe29 , 0x1224 , 0xe09 , 0xe89 , 0xe49 , 0x1264 ,
1528
- 0xd02 , 0xe55 , 0xe15 , 0xf1d , 0xd12 , 0xe75 , 0xe35 , 0x123c ,
1529
- 0xd0a , 0xe65 , 0xe25 , 0x121c , 0xe05 , 0xe85 , 0xe45 , 0x125c ,
1530
- 0xd06 , 0xe5d , 0xe1d , 0x120c , 0xd16 , 0xe7d , 0xe3d , 0x124c ,
1531
- 0xd0e , 0xe6d , 0xe2d , 0x122c , 0xe0d , 0xe8d , 0xe4d , 0x126c ,
1532
- 0xd01 , 0xe53 , 0xe13 , 0xf1b , 0xd11 , 0xe73 , 0xe33 , 0x1238 ,
1533
- 0xd09 , 0xe63 , 0xe23 , 0x1218 , 0xe03 , 0xe83 , 0xe43 , 0x1258 ,
1534
- 0xd05 , 0xe5b , 0xe1b , 0x1208 , 0xd15 , 0xe7b , 0xe3b , 0x1248 ,
1535
- 0xd0d , 0xe6b , 0xe2b , 0x1228 , 0xe0b , 0xe8b , 0xe4b , 0x1268 ,
1536
- 0xd03 , 0xe57 , 0xe17 , 0x1200 , 0xd13 , 0xe77 , 0xe37 , 0x1240 ,
1537
- 0xd0b , 0xe67 , 0xe27 , 0x1220 , 0xe07 , 0xe87 , 0xe47 , 0x1260 ,
1538
- 0xd07 , 0xe5f , 0xe1f , 0x1210 , 0xd17 , 0xe7f , 0xe3f , 0x1250 ,
1539
- 0xd0f , 0xe6f , 0xe2f , 0x1230 , 0xe0f , 0xe8f , 0xe4f , 0 ,
1532
+ 0xd00 , 0xe50 , 0xe10 , 0xf18 , 0xd10 , 0xe70 , 0xe30 , 0x1230 ,
1533
+ 0xd08 , 0xe60 , 0xe20 , 0x1210 , 0xe00 , 0xe80 , 0xe40 , 0x1250 ,
1534
+ 0xd04 , 0xe58 , 0xe18 , 0x1200 , 0xd14 , 0xe78 , 0xe38 , 0x1240 ,
1535
+ 0xd0c , 0xe68 , 0xe28 , 0x1220 , 0xe08 , 0xe88 , 0xe48 , 0x1260 ,
1536
+ 0xd02 , 0xe54 , 0xe14 , 0xf1c , 0xd12 , 0xe74 , 0xe34 , 0x1238 ,
1537
+ 0xd0a , 0xe64 , 0xe24 , 0x1218 , 0xe04 , 0xe84 , 0xe44 , 0x1258 ,
1538
+ 0xd06 , 0xe5c , 0xe1c , 0x1208 , 0xd16 , 0xe7c , 0xe3c , 0x1248 ,
1539
+ 0xd0e , 0xe6c , 0xe2c , 0x1228 , 0xe0c , 0xe8c , 0xe4c , 0x1268 ,
1540
+ 0xd01 , 0xe52 , 0xe12 , 0xf1a , 0xd11 , 0xe72 , 0xe32 , 0x1234 ,
1541
+ 0xd09 , 0xe62 , 0xe22 , 0x1214 , 0xe02 , 0xe82 , 0xe42 , 0x1254 ,
1542
+ 0xd05 , 0xe5a , 0xe1a , 0x1204 , 0xd15 , 0xe7a , 0xe3a , 0x1244 ,
1543
+ 0xd0d , 0xe6a , 0xe2a , 0x1224 , 0xe0a , 0xe8a , 0xe4a , 0x1264 ,
1544
+ 0xd03 , 0xe56 , 0xe16 , 0xf1e , 0xd13 , 0xe76 , 0xe36 , 0x123c ,
1545
+ 0xd0b , 0xe66 , 0xe26 , 0x121c , 0xe06 , 0xe86 , 0xe46 , 0x125c ,
1546
+ 0xd07 , 0xe5e , 0xe1e , 0x120c , 0xd17 , 0xe7e , 0xe3e , 0x124c ,
1547
+ 0xd0f , 0xe6e , 0xe2e , 0x122c , 0xe0e , 0xe8e , 0xe4e , 0x126c ,
1548
+ 0xd00 , 0xe51 , 0xe11 , 0xf19 , 0xd10 , 0xe71 , 0xe31 , 0x1232 ,
1549
+ 0xd08 , 0xe61 , 0xe21 , 0x1212 , 0xe01 , 0xe81 , 0xe41 , 0x1252 ,
1550
+ 0xd04 , 0xe59 , 0xe19 , 0x1202 , 0xd14 , 0xe79 , 0xe39 , 0x1242 ,
1551
+ 0xd0c , 0xe69 , 0xe29 , 0x1222 , 0xe09 , 0xe89 , 0xe49 , 0x1262 ,
1552
+ 0xd02 , 0xe55 , 0xe15 , 0xf1d , 0xd12 , 0xe75 , 0xe35 , 0x123a ,
1553
+ 0xd0a , 0xe65 , 0xe25 , 0x121a , 0xe05 , 0xe85 , 0xe45 , 0x125a ,
1554
+ 0xd06 , 0xe5d , 0xe1d , 0x120a , 0xd16 , 0xe7d , 0xe3d , 0x124a ,
1555
+ 0xd0e , 0xe6d , 0xe2d , 0x122a , 0xe0d , 0xe8d , 0xe4d , 0x126a ,
1556
+ 0xd01 , 0xe53 , 0xe13 , 0xf1b , 0xd11 , 0xe73 , 0xe33 , 0x1236 ,
1557
+ 0xd09 , 0xe63 , 0xe23 , 0x1216 , 0xe03 , 0xe83 , 0xe43 , 0x1256 ,
1558
+ 0xd05 , 0xe5b , 0xe1b , 0x1206 , 0xd15 , 0xe7b , 0xe3b , 0x1246 ,
1559
+ 0xd0d , 0xe6b , 0xe2b , 0x1226 , 0xe0b , 0xe8b , 0xe4b , 0x1266 ,
1560
+ 0xd03 , 0xe57 , 0xe17 , 0xf1f , 0xd13 , 0xe77 , 0xe37 , 0x123e ,
1561
+ 0xd0b , 0xe67 , 0xe27 , 0x121e , 0xe07 , 0xe87 , 0xe47 , 0x125e ,
1562
+ 0xd07 , 0xe5f , 0xe1f , 0x120e , 0xd17 , 0xe7f , 0xe3f , 0x124e ,
1563
+ 0xd0f , 0xe6f , 0xe2f , 0x122e , 0xe0f , 0xe8f , 0xe4f , 0x126e ,
1540
1564
0x290 , 0x291 , 0x292 , 0x293 , 0x294 , 0x295 , 0x296 , 0x297 ,
1541
1565
0x298 , 0x299 , 0x29a , 0x29b , 0x29c , 0x29d , 0x29e , 0x29f ,
1542
1566
0x2a0 , 0x2a1 , 0x2a2 , 0x2a3 , 0x2a4 , 0x2a5 , 0x2a6 , 0x2a7 ,
@@ -1553,6 +1577,42 @@ static const uint16_t elf_zlib_default_table[0x170] =
1553
1577
0x2f8 , 0x2f9 , 0x2fa , 0x2fb , 0x2fc , 0x2fd , 0x2fe , 0x2ff ,
1554
1578
};
1555
1579
1580
+ static const uint16_t elf_zlib_default_dist_table [0x100 ] =
1581
+ {
1582
+ 0x800 , 0x810 , 0x808 , 0x818 , 0x804 , 0x814 , 0x80c , 0x81c ,
1583
+ 0x802 , 0x812 , 0x80a , 0x81a , 0x806 , 0x816 , 0x80e , 0x81e ,
1584
+ 0x801 , 0x811 , 0x809 , 0x819 , 0x805 , 0x815 , 0x80d , 0x81d ,
1585
+ 0x803 , 0x813 , 0x80b , 0x81b , 0x807 , 0x817 , 0x80f , 0x81f ,
1586
+ 0x800 , 0x810 , 0x808 , 0x818 , 0x804 , 0x814 , 0x80c , 0x81c ,
1587
+ 0x802 , 0x812 , 0x80a , 0x81a , 0x806 , 0x816 , 0x80e , 0x81e ,
1588
+ 0x801 , 0x811 , 0x809 , 0x819 , 0x805 , 0x815 , 0x80d , 0x81d ,
1589
+ 0x803 , 0x813 , 0x80b , 0x81b , 0x807 , 0x817 , 0x80f , 0x81f ,
1590
+ 0x800 , 0x810 , 0x808 , 0x818 , 0x804 , 0x814 , 0x80c , 0x81c ,
1591
+ 0x802 , 0x812 , 0x80a , 0x81a , 0x806 , 0x816 , 0x80e , 0x81e ,
1592
+ 0x801 , 0x811 , 0x809 , 0x819 , 0x805 , 0x815 , 0x80d , 0x81d ,
1593
+ 0x803 , 0x813 , 0x80b , 0x81b , 0x807 , 0x817 , 0x80f , 0x81f ,
1594
+ 0x800 , 0x810 , 0x808 , 0x818 , 0x804 , 0x814 , 0x80c , 0x81c ,
1595
+ 0x802 , 0x812 , 0x80a , 0x81a , 0x806 , 0x816 , 0x80e , 0x81e ,
1596
+ 0x801 , 0x811 , 0x809 , 0x819 , 0x805 , 0x815 , 0x80d , 0x81d ,
1597
+ 0x803 , 0x813 , 0x80b , 0x81b , 0x807 , 0x817 , 0x80f , 0x81f ,
1598
+ 0x800 , 0x810 , 0x808 , 0x818 , 0x804 , 0x814 , 0x80c , 0x81c ,
1599
+ 0x802 , 0x812 , 0x80a , 0x81a , 0x806 , 0x816 , 0x80e , 0x81e ,
1600
+ 0x801 , 0x811 , 0x809 , 0x819 , 0x805 , 0x815 , 0x80d , 0x81d ,
1601
+ 0x803 , 0x813 , 0x80b , 0x81b , 0x807 , 0x817 , 0x80f , 0x81f ,
1602
+ 0x800 , 0x810 , 0x808 , 0x818 , 0x804 , 0x814 , 0x80c , 0x81c ,
1603
+ 0x802 , 0x812 , 0x80a , 0x81a , 0x806 , 0x816 , 0x80e , 0x81e ,
1604
+ 0x801 , 0x811 , 0x809 , 0x819 , 0x805 , 0x815 , 0x80d , 0x81d ,
1605
+ 0x803 , 0x813 , 0x80b , 0x81b , 0x807 , 0x817 , 0x80f , 0x81f ,
1606
+ 0x800 , 0x810 , 0x808 , 0x818 , 0x804 , 0x814 , 0x80c , 0x81c ,
1607
+ 0x802 , 0x812 , 0x80a , 0x81a , 0x806 , 0x816 , 0x80e , 0x81e ,
1608
+ 0x801 , 0x811 , 0x809 , 0x819 , 0x805 , 0x815 , 0x80d , 0x81d ,
1609
+ 0x803 , 0x813 , 0x80b , 0x81b , 0x807 , 0x817 , 0x80f , 0x81f ,
1610
+ 0x800 , 0x810 , 0x808 , 0x818 , 0x804 , 0x814 , 0x80c , 0x81c ,
1611
+ 0x802 , 0x812 , 0x80a , 0x81a , 0x806 , 0x816 , 0x80e , 0x81e ,
1612
+ 0x801 , 0x811 , 0x809 , 0x819 , 0x805 , 0x815 , 0x80d , 0x81d ,
1613
+ 0x803 , 0x813 , 0x80b , 0x81b , 0x807 , 0x817 , 0x80f , 0x81f ,
1614
+ };
1615
+
1556
1616
/* Inflate a zlib stream from PIN/SIN to POUT/SOUT. Return 1 on
1557
1617
success, 0 on some error parsing the stream. */
1558
1618
@@ -1701,7 +1761,7 @@ elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table,
1701
1761
if (type == 1 )
1702
1762
{
1703
1763
tlit = elf_zlib_default_table ;
1704
- tdist = elf_zlib_default_table ;
1764
+ tdist = elf_zlib_default_dist_table ;
1705
1765
}
1706
1766
else
1707
1767
{
0 commit comments