<HTML><HEAD></HEAD>
<BODY dir=ltr>
<DIV dir=ltr>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: 'Calibri'; COLOR: #000000">
<DIV>rtems-tools/linkers/rtems-ld.cpp</DIV>
<DIV>rtems-tools/linkers/rtems-ra.cpp</DIV>
<DIV>rtems-tools/linkers/rtems-rapper.cpp</DIV>
<DIV>rtems-tools/linkers/wscript</DIV>
<DIV>rtems-tools/rtemstoolkit/rld-compression.cpp</DIV>
<DIV>rtems-tools/rtemstoolkit/rld-compression.h</DIV>
<DIV>rtems-tools/rtemstoolkit/rld-outputter.cpp</DIV>
<DIV>rtems-tools/rtemstoolkit/rld-outputter.h</DIV>
<DIV>rtems-tools/rtemstoolkit/rld-rap.cpp</DIV>
<DIV>rtems-tools/rtemstoolkit/rld-rap.h</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>diff -Naur rtems-tools/linkers/rtems-ld.cpp 
rtems-tools_patched/linkers/rtems-ld.cpp</DIV>
<DIV>--- rtems-tools/linkers/rtems-ld.cpp    2018-12-03 11:40:06 
+0400</DIV>
<DIV>+++ rtems-tools_patched/linkers/rtems-ld.cpp    2019-02-21 
16:07:57 +0400</DIV>
<DIV>@@ -76,6 +76,7 @@</DIV>
<DIV>   { "one-file",    
no_argument,            
NULL,           's' },</DIV>
<DIV>   { "rtems",       
required_argument,      
NULL,           'r' },</DIV>
<DIV>   { "rtems-bsp",   
required_argument,      
NULL,           'B' },</DIV>
<DIV>+  { "compress",    
required_argument,      
NULL,           'z' },</DIV>
<DIV>   { NULL,          
0,                      
NULL,            0 
}</DIV>
<DIV>};</DIV>
<DIV> </DIV>
<DIV>@@ -119,6 +120,7 @@</DIV>
<DIV>             
<< " -R        : include file paths 
(also --rpath)" << std::endl</DIV>
<DIV>             
<< " -P        : place objects from 
archives (also --runtime-lib)" << std::endl</DIV>
<DIV>             
<< " -s        : Include archive elf 
object files (also --one-file)" << std::endl</DIV>
<DIV>+            
<< " -z        : Compression algorithm 
0,1,2 (default 1) NONE, LZ77, ZLIB" << std::endl</DIV>
<DIV>             
<< " -Wl,opts  : link compatible flags, ignored" << 
std::endl</DIV>
<DIV>             
<< " -r path   : RTEMS path (also --rtems)" << 
std::endl</DIV>
<DIV>             
<< " -B bsp    : RTEMS arch/bsp (also --rtems-bsp)" 
<< std::endl</DIV>
<DIV>@@ -192,6 +194,7 @@</DIV>
<DIV>     
std::string          output = 
"a.out";</DIV>
<DIV>     
std::string          outra;</DIV>
<DIV>     
std::string          
base_name;</DIV>
<DIV>+    
std::string          algorithm = 
"1";</DIV>
<DIV>     
std::string          output_type = 
"rap";</DIV>
<DIV>     
bool                 
standard_libs = true;</DIV>
<DIV>     
bool                 
map = false;</DIV>
<DIV>@@ -204,7 +207,7 @@</DIV>
<DIV> </DIV>
<DIV>     while (true)</DIV>
<DIV>     {</DIV>
<DIV>-      int opt = ::getopt_long (argc, argv, 
"hvwVMnsSb:E:o:O:L:l:c:e:d:u:C:W:R:P:r:B:", rld_opts, NULL);</DIV>
<DIV>+      int opt = ::getopt_long (argc, argv, 
"hvwVMnsSb:E:o:O:L:l:c:e:d:u:z:C:W:R:P:r:B:", rld_opts, NULL);</DIV>
<DIV>       if (opt < 0)</DIV>
<DIV>         break;</DIV>
<DIV> </DIV>
<DIV>@@ -301,6 +304,10 @@</DIV>
<DIV>           base_name = 
optarg;</DIV>
<DIV>           break;</DIV>
<DIV> </DIV>
<DIV>+        case 'z':</DIV>
<DIV>+          algorithm = 
optarg;</DIV>
<DIV>+          break;</DIV>
<DIV>+</DIV>
<DIV>         case 'S':</DIV>
<DIV>           
rld::rap::add_obj_details = false;</DIV>
<DIV>           break;</DIV>
<DIV>@@ -504,9 +511,13 @@</DIV>
<DIV>                                            
dependents, cache);</DIV>
<DIV>         else if (output_type == 
"rap")</DIV>
<DIV>         {</DIV>
<DIV>-          
rld::outputter::rap_application (output, entry, exit,</DIV>
<DIV>-                                           
dependents, cache, symbols,</DIV>
<DIV>-                                           
one_file);</DIV>
<DIV>+          int i = 
atoi(algorithm.c_str());</DIV>
<DIV>+</DIV>
<DIV>+          if ((i < 0) || 
(i > 2))</DIV>
<DIV>+            
rld::error("Unknown compression", "output");</DIV>
<DIV>+</DIV>
<DIV>+          
rld::outputter::rap_application(output, entry, exit, dependents,</DIV>
<DIV>+                            
cache, symbols, one_file, i);</DIV>
<DIV>           if 
(!outra.empty ())</DIV>
<DIV>           {</DIV>
<DIV>             
rld::path::paths ra_libs;</DIV>
<DIV>diff -Naur rtems-tools/linkers/rtems-ra.cpp 
rtems-tools_patched/linkers/rtems-ra.cpp</DIV>
<DIV>--- rtems-tools/linkers/rtems-ra.cpp    2018-12-03 11:40:06 
+0400</DIV>
<DIV>+++ rtems-tools_patched/linkers/rtems-ra.cpp    2019-02-21 
16:08:04 +0400</DIV>
<DIV>@@ -376,8 +376,8 @@</DIV>
<DIV>             /* 
Todo: include absolute name for rap_name */</DIV>
<DIV> </DIV>
<DIV>             
rld::outputter::rap_application (rap_name, entry, exit,</DIV>
<DIV>-                                             
dependents, *cache, symbols,</DIV>
<DIV>-                                             
true);</DIV>
<DIV>+                                         
dependents, *cache, symbols,</DIV>
<DIV>+                                         
true, 1);</DIV>
<DIV>           }</DIV>
<DIV> </DIV>
<DIV>           
dependents.clear ();</DIV>
<DIV>diff -Naur rtems-tools/linkers/rtems-rapper.cpp 
rtems-tools_patched/linkers/rtems-rapper.cpp</DIV>
<DIV>--- rtems-tools/linkers/rtems-rapper.cpp    2018-12-03 
11:40:05 +0400</DIV>
<DIV>+++ rtems-tools_patched/linkers/rtems-rapper.cpp    
2019-02-21 14:36:07 +0400</DIV>
<DIV>@@ -468,6 +468,14 @@</DIV>
<DIV>       rhdr_compression = "LZ77";</DIV>
<DIV>       eptr = sptr + 4;</DIV>
<DIV>     }</DIV>
<DIV>+    else if ((sptr[0] == 'Z') &&</DIV>
<DIV>+             
(sptr[1] == 'L') &&</DIV>
<DIV>+             
(sptr[2] == 'I') &&</DIV>
<DIV>+             
(sptr[3] == 'B'))</DIV>
<DIV>+    {</DIV>
<DIV>+      rhdr_compression = "ZLIB";</DIV>
<DIV>+      eptr = sptr + 4;</DIV>
<DIV>+    }</DIV>
<DIV>     else</DIV>
<DIV>       throw rld::error ("Cannot parse RAP 
header", "open: " + name);</DIV>
<DIV> </DIV>
<DIV>@@ -543,8 +551,15 @@</DIV>
<DIV>   file::load ()</DIV>
<DIV>   {</DIV>
<DIV>     image.seek (rhdr_len);</DIV>
<DIV>+    int i;</DIV>
<DIV>+    if (rhdr_compression == "NONE")</DIV>
<DIV>+      i = 0;</DIV>
<DIV>+    if (rhdr_compression == "LZ77")</DIV>
<DIV>+      i = 1;</DIV>
<DIV>+    if (rhdr_compression == "ZLIB")</DIV>
<DIV>+      i = 2;</DIV>
<DIV> </DIV>
<DIV>-    rld::compress::compressor comp (image, rap_comp_buffer, 
false);</DIV>
<DIV>+    rld::compress::compressor comp (image, rap_comp_buffer, 
false, i);</DIV>
<DIV> </DIV>
<DIV>     /*</DIV>
<DIV>      * uint32_t: machinetype</DIV>
<DIV>@@ -645,7 +660,15 @@</DIV>
<DIV> </DIV>
<DIV>     image.seek (rhdr_len);</DIV>
<DIV> </DIV>
<DIV>-    rld::compress::compressor comp (image, rap_comp_buffer, 
false);</DIV>
<DIV>+        int i;</DIV>
<DIV>+    if (rhdr_compression == "NONE")</DIV>
<DIV>+      i = 0;</DIV>
<DIV>+    if (rhdr_compression == "LZ77")</DIV>
<DIV>+      i = 1;</DIV>
<DIV>+    if (rhdr_compression == "ZLIB")</DIV>
<DIV>+      i = 2;</DIV>
<DIV>+    rld::compress::compressor comp (image, rap_comp_buffer, 
false, i);</DIV>
<DIV>+</DIV>
<DIV>     
rld::files::image         out 
(name);</DIV>
<DIV> </DIV>
<DIV>     out.open (true);</DIV>
<DIV>diff -Naur rtems-tools/linkers/wscript 
rtems-tools_patched/linkers/wscript</DIV>
<DIV>--- rtems-tools/linkers/wscript    2018-06-19 10:43:47 
+0400</DIV>
<DIV>+++ rtems-tools_patched/linkers/wscript    2019-02-21 
14:28:43 +0400</DIV>
<DIV>@@ -90,6 +90,7 @@</DIV>
<DIV>                 
cflags = conf['cflags'] + conf['warningflags'],</DIV>
<DIV>                 
cxxflags = conf['cxxflags'] + conf['warningflags'],</DIV>
<DIV>                 
linkflags = conf['linkflags'],</DIV>
<DIV>+                
lib = ['z'],</DIV>
<DIV>                 
use = modules)</DIV>
<DIV> </DIV>
<DIV>     #</DIV>
<DIV>@@ -102,6 +103,7 @@</DIV>
<DIV>                 
cflags = conf['cflags'] + conf['warningflags'],</DIV>
<DIV>                 
cxxflags = conf['cxxflags'] + conf['warningflags'],</DIV>
<DIV>                 
linkflags = conf['linkflags'],</DIV>
<DIV>+                
lib = ['z'],</DIV>
<DIV>                 
use = modules)</DIV>
<DIV> </DIV>
<DIV>     #</DIV>
<DIV>@@ -140,6 +142,7 @@</DIV>
<DIV>                 
cflags = conf['cflags'] + conf['warningflags'],</DIV>
<DIV>                 
cxxflags = conf['cxxflags'] + conf['warningflags'],</DIV>
<DIV>                 
linkflags = conf['linkflags'],</DIV>
<DIV>+                
lib = ['z'],</DIV>
<DIV>                 
use = modules)</DIV>
<DIV> </DIV>
<DIV>     #</DIV>
<DIV>@@ -152,6 +155,7 @@</DIV>
<DIV>                 
cflags = conf['cflags'] + conf['warningflags'],</DIV>
<DIV>                 
cxxflags = conf['cxxflags'] + conf['warningflags'],</DIV>
<DIV>                 
linkflags = conf['linkflags'],</DIV>
<DIV>+                
lib = ['z'],</DIV>
<DIV>                 
use = modules)</DIV>
<DIV> </DIV>
<DIV>     #</DIV>
<DIV>diff -Naur rtems-tools/rtemstoolkit/rld-compression.cpp 
rtems-tools_patched/rtemstoolkit/rld-compression.cpp</DIV>
<DIV>--- rtems-tools/rtemstoolkit/rld-compression.cpp    
2017-09-18 15:01:39 +0400</DIV>
<DIV>+++ rtems-tools_patched/rtemstoolkit/rld-compression.cpp    
2019-02-21 16:08:37 +0400</DIV>
<DIV>@@ -35,8 +35,18 @@</DIV>
<DIV>#include <rld.h></DIV>
<DIV>#include <rld-compression.h></DIV>
<DIV> </DIV>
<DIV>+#include <zlib.h></DIV>
<DIV>#include "fastlz.h"</DIV>
<DIV> </DIV>
<DIV>+static int ret_z;</DIV>
<DIV>+static unsigned have_z, wr, count_z;</DIV>
<DIV>+static z_stream strm;</DIV>
<DIV>+static unsigned char *in_z;</DIV>
<DIV>+static unsigned char *out_z;</DIV>
<DIV>+static unsigned char *ptr_in;</DIV>
<DIV>+static unsigned char *ptr_out;</DIV>
<DIV>+#define CHUNK 16384</DIV>
<DIV>+</DIV>
<DIV>namespace rld</DIV>
<DIV>{</DIV>
<DIV>   namespace compress</DIV>
<DIV>@@ -44,7 +54,7 @@</DIV>
<DIV>     compressor::compressor (files::image& 
image,</DIV>
<DIV>                             
size_t        size,</DIV>
<DIV>                             
bool          out,</DIV>
<DIV>-                            
bool          compress)</DIV>
<DIV>+                            
int           compress)</DIV>
<DIV>       : image (image),</DIV>
<DIV>         size (size),</DIV>
<DIV>         out (out),</DIV>
<DIV>@@ -234,32 +244,64 @@</DIV>
<DIV>     void</DIV>
<DIV>     compressor::output (bool forced)</DIV>
<DIV>     {</DIV>
<DIV>-      if (out && ((forced && 
level) || (level >= size)))</DIV>
<DIV>-      {</DIV>
<DIV>-        if (compress)</DIV>
<DIV>+        if (out && ((forced 
&& level) || (level >= size)))</DIV>
<DIV>         {</DIV>
<DIV>-          
int     writing = ::fastlz_compress (buffer, level, 
io);</DIV>
<DIV>-          uint8_t 
header[2];</DIV>
<DIV>-</DIV>
<DIV>-          if (rld::verbose () 
>= RLD_VERBOSE_FULL_DEBUG)</DIV>
<DIV>-            
std::cout << "rtl: comp: offset=" << total_compressed</DIV>
<DIV>-                      
<< " block-size=" << writing << std::endl;</DIV>
<DIV>-</DIV>
<DIV>-          header[0] = writing 
>> 8;</DIV>
<DIV>-          header[1] = 
writing;</DIV>
<DIV>-</DIV>
<DIV>-          image.write 
(header, 2);</DIV>
<DIV>-          image.write (io, 
writing);</DIV>
<DIV>-</DIV>
<DIV>-          total_compressed += 
2 + writing;</DIV>
<DIV>+            switch 
(compress) {</DIV>
<DIV>+              
case 0: {</DIV>
<DIV>+                
image.write(buffer, level);</DIV>
<DIV>+                
total_compressed += level;</DIV>
<DIV>+                
break;</DIV>
<DIV>+              
}</DIV>
<DIV>+              
case 1: {</DIV>
<DIV>+                
int writing = ::fastlz_compress(buffer, level, io);</DIV>
<DIV>+                
uint8_t header[2];</DIV>
<DIV>+                
if (rld::verbose() >= RLD_VERBOSE_FULL_DEBUG)</DIV>
<DIV>+                     
std::cout << "rtl: comp: offset=" << total_compressed </DIV>
<DIV>+                               
<< " block-size=" << writing << std::endl;</DIV>
<DIV>+                
header[0] = writing >> 8;</DIV>
<DIV>+                
header[1] = writing;</DIV>
<DIV>+                
image.write(header, 2);</DIV>
<DIV>+                
image.write(io, writing);</DIV>
<DIV>+                
total_compressed += 2 + writing;</DIV>
<DIV>+                
break;</DIV>
<DIV>+              
}</DIV>
<DIV>+              
case 2: {</DIV>
<DIV>+                
if (start)</DIV>
<DIV>+                
{</DIV>
<DIV>+                  
start = false;</DIV>
<DIV>+                  
strm.zalloc = Z_NULL;</DIV>
<DIV>+                  
strm.zfree = Z_NULL;</DIV>
<DIV>+                  
strm.opaque = Z_NULL;</DIV>
<DIV>+                  
out_z = new uint8_t[CHUNK];</DIV>
<DIV>+                  
ret_z = ::deflateInit(&strm, Z_BEST_COMPRESSION);</DIV>
<DIV>+                  
if (ret_z != Z_OK)</DIV>
<DIV>+                          
throw rld::error("Invalid init deflate", "compression");</DIV>
<DIV>+                
}</DIV>
<DIV>+                
int flush = (forced != 0) ? Z_FINISH : Z_NO_FLUSH;</DIV>
<DIV>+                
strm.next_in = buffer;</DIV>
<DIV>+                
strm.avail_in = level;</DIV>
<DIV>+                
do</DIV>
<DIV>+                
{</DIV>
<DIV>+                  
strm.avail_out = CHUNK;</DIV>
<DIV>+                  
strm.next_out = out_z;</DIV>
<DIV>+                  
ret_z = ::deflate(&strm, flush);</DIV>
<DIV>+                  
if (ret_z == Z_STREAM_ERROR)</DIV>
<DIV>+                          
throw rld::error("Invalid deflate", "compression");</DIV>
<DIV>+                  
have_z = CHUNK - strm.avail_out;</DIV>
<DIV>+                  
image.write(out_z, have_z);</DIV>
<DIV>+                  
total_compressed += have_z;</DIV>
<DIV>+                
} while (strm.avail_out == 0);</DIV>
<DIV>+                
if (forced != 0)</DIV>
<DIV>+                
{</DIV>
<DIV>+                  
start = true;</DIV>
<DIV>+                  
delete[] out_z;</DIV>
<DIV>+                  
(void) ::deflateEnd(&strm);</DIV>
<DIV>+                
}</DIV>
<DIV>+                
break;</DIV>
<DIV>+              
}</DIV>
<DIV>+            }</DIV>
<DIV>+            level = 
0;</DIV>
<DIV>         }</DIV>
<DIV>-        else</DIV>
<DIV>-        {</DIV>
<DIV>-          image.write 
(buffer, level);</DIV>
<DIV>-        }</DIV>
<DIV>-</DIV>
<DIV>-        level = 0;</DIV>
<DIV>-      }</DIV>
<DIV>     }</DIV>
<DIV> </DIV>
<DIV>     void</DIV>
<DIV>@@ -267,37 +309,100 @@</DIV>
<DIV>     {</DIV>
<DIV>       if (!out && (level == 
0))</DIV>
<DIV>       {</DIV>
<DIV>-        if (compress)</DIV>
<DIV>-        {</DIV>
<DIV>-          uint8_t 
header[2];</DIV>
<DIV>-</DIV>
<DIV>-          if (image.read 
(header, 2) == 2)</DIV>
<DIV>-          {</DIV>
<DIV>-            ssize_t 
block_size =</DIV>
<DIV>-              
(((ssize_t) header[0]) << 8) | (ssize_t) header[1];</DIV>
<DIV>-</DIV>
<DIV>-            if 
(block_size == 0)</DIV>
<DIV>-              
throw rld::error ("Block size is invalid (0)", "compression");</DIV>
<DIV>-</DIV>
<DIV>-            
total_compressed += 2 + block_size;</DIV>
<DIV>-</DIV>
<DIV>-            if 
(rld::verbose () >= RLD_VERBOSE_FULL_DEBUG)</DIV>
<DIV>-              
std::cout << "rtl: decomp: block-size=" << block_size</DIV>
<DIV>-                        
<< std::endl;</DIV>
<DIV>-</DIV>
<DIV>-            if 
(image.read (io, block_size) != block_size)</DIV>
<DIV>-              
throw rld::error ("Read past end", "compression");</DIV>
<DIV>-</DIV>
<DIV>-            level = 
::fastlz_decompress (io, block_size, buffer, size);</DIV>
<DIV>+        switch (compress) {</DIV>
<DIV>+          case 0: {</DIV>
<DIV>+            level = 
image.read(buffer, size);</DIV>
<DIV>+            
total_compressed += level;</DIV>
<DIV>+            
break;</DIV>
<DIV>+          }</DIV>
<DIV>+          case 1: {</DIV>
<DIV>+            uint8_t 
header[2];</DIV>
<DIV>+            if 
(image.read(header, 2) == 2)</DIV>
<DIV>+            {</DIV>
<DIV>+              
uint32_t block_size = (((uint32_t) header[0]) << 8) | (uint32_t) 
header[1];</DIV>
<DIV>+              
if (block_size == 0)</DIV>
<DIV>+                  
throw rld::error("Block size is invalid (0)", "uncompression");</DIV>
<DIV>+              
total_compressed += 2 + block_size;</DIV>
<DIV>+              
if (rld::verbose() >= RLD_VERBOSE_FULL_DEBUG)</DIV>
<DIV>+                  
std::cout << "rtl: decomp: block-size=" << block_size << 
std::endl;</DIV>
<DIV>+              
if ((uint32_t) image.read(io, block_size) != block_size)</DIV>
<DIV>+                  
throw rld::error("Read past end", "uncompression");</DIV>
<DIV>+              
level = ::fastlz_decompress(io, block_size, buffer, size);</DIV>
<DIV>+            }</DIV>
<DIV>+            
break;</DIV>
<DIV>+          }</DIV>
<DIV>+          case 2: {</DIV>
<DIV>+            if 
(start)</DIV>
<DIV>+            {</DIV>
<DIV>+              
start = false;</DIV>
<DIV>+              
strm.zalloc = Z_NULL;</DIV>
<DIV>+              
strm.zfree = Z_NULL;</DIV>
<DIV>+              
strm.opaque = Z_NULL;</DIV>
<DIV>+              
strm.avail_in = 0;</DIV>
<DIV>+              
strm.next_in = Z_NULL;</DIV>
<DIV>+              
ret_z = inflateInit(&strm);</DIV>
<DIV>+              
if (ret_z != Z_OK)</DIV>
<DIV>+                      
throw rld::error("Invalid init inflate", "uncompression");</DIV>
<DIV>+              
out_z = new uint8_t[CHUNK];</DIV>
<DIV>+              
in_z = new uint8_t[CHUNK];</DIV>
<DIV>+              
have_z = 0;</DIV>
<DIV>+              
count_z = 0;</DIV>
<DIV>+            }</DIV>
<DIV>+            ptr_out 
= buffer;</DIV>
<DIV>+            wr = 
0;</DIV>
<DIV>+            while 
(1) {</DIV>
<DIV>+              
if (have_z > 0) </DIV>
<DIV>+              
{</DIV>
<DIV>+                
wr = have_z > (size - (ptr_out - buffer)) ? size - (ptr_out - buffer) : 
have_z;</DIV>
<DIV>+                
memcpy(ptr_out, ptr_in, wr);</DIV>
<DIV>+                
ptr_out += wr;</DIV>
<DIV>+                
ptr_in += wr;</DIV>
<DIV>+                
have_z -= wr;</DIV>
<DIV>+                
if ((size_t)(ptr_out - buffer) == size)</DIV>
<DIV>+                   
break;</DIV>
<DIV>+              
} else </DIV>
<DIV>+              
{</DIV>
<DIV>+                
if (strm.avail_in == 0)</DIV>
<DIV>+                
{</DIV>
<DIV>+                  
strm.avail_in = image.read(in_z, CHUNK);</DIV>
<DIV>+                  
count_z += strm.avail_in;</DIV>
<DIV>+                  
strm.next_in = in_z;</DIV>
<DIV>+                
}</DIV>
<DIV>+                
if (strm.avail_in == 0)</DIV>
<DIV>+                  
break;</DIV>
<DIV>+              
}</DIV>
<DIV>+              
strm.avail_out = CHUNK;</DIV>
<DIV>+              
strm.next_out = out_z;</DIV>
<DIV>+              
ptr_in = out_z;</DIV>
<DIV>+              
ret_z = inflate(&strm, Z_NO_FLUSH);</DIV>
<DIV>+              
if ((ret_z == Z_STREAM_ERROR) || (ret_z == Z_NEED_DICT) ||</DIV>
<DIV>+                  
(ret_z == Z_DATA_ERROR) || (ret_z == Z_MEM_ERROR)) </DIV>
<DIV>+              
{</DIV>
<DIV>+                
delete[] out_z;</DIV>
<DIV>+                
delete[] in_z;</DIV>
<DIV>+                
(void) inflateEnd(&strm);</DIV>
<DIV>+                
throw rld::error("Invalid inflate", "uncompression");</DIV>
<DIV>+              
}</DIV>
<DIV>+              
have_z = CHUNK - strm.avail_out;</DIV>
<DIV>+              
if (have_z > 0)</DIV>
<DIV>+              
{</DIV>
<DIV>+                
wr = have_z > (size - (ptr_out - buffer)) ? size - (ptr_out - buffer) : 
have_z;</DIV>
<DIV>+                
memcpy(ptr_out, ptr_in, wr);</DIV>
<DIV>+                
ptr_out += wr;</DIV>
<DIV>+                
ptr_in += wr;</DIV>
<DIV>+                
have_z -= wr;</DIV>
<DIV>+                
if ((size_t)(ptr_out - buffer) == size)</DIV>
<DIV>+                  
break;</DIV>
<DIV>+              
}</DIV>
<DIV>+            }</DIV>
<DIV>+            level = 
ptr_out - buffer;</DIV>
<DIV>+            
total_compressed += count_z;</DIV>
<DIV>+            count_z 
= 0;</DIV>
<DIV>+            
break;</DIV>
<DIV>           }</DIV>
<DIV>         }</DIV>
<DIV>-        else</DIV>
<DIV>-        {</DIV>
<DIV>-          image.read (buffer, 
size);</DIV>
<DIV>-          level = size;</DIV>
<DIV>-        }</DIV>
<DIV>-      }</DIV>
<DIV>     }</DIV>
<DIV> </DIV>
<DIV>   }</DIV>
<DIV>}</DIV>
<DIV>+}</DIV>
<DIV>diff -Naur rtems-tools/rtemstoolkit/rld-compression.h 
rtems-tools_patched/rtemstoolkit/rld-compression.h</DIV>
<DIV>--- rtems-tools/rtemstoolkit/rld-compression.h    2016-01-13 
15:35:31 +0400</DIV>
<DIV>+++ rtems-tools_patched/rtemstoolkit/rld-compression.h    
2019-02-21 14:40:07 +0400</DIV>
<DIV>@@ -48,7 +48,7 @@</DIV>
<DIV>       compressor (files::image& 
image,</DIV>
<DIV>                   
size_t        size,</DIV>
<DIV>                   
bool          out = true,</DIV>
<DIV>-                  
bool          compress = 
true);</DIV>
<DIV>+                  
int           compress = 
1);</DIV>
<DIV> </DIV>
<DIV>       /**</DIV>
<DIV>        * Destruct the compressor.</DIV>
<DIV>@@ -147,7 +147,7 @@</DIV>
<DIV>       files::image& 
image;            //< 
The image to read or write to or from.</DIV>
<DIV>       
size_t        
size;             
//< The size of the buffer.</DIV>
<DIV>       
bool          
out;              
//< If true the it is compression.</DIV>
<DIV>-      
bool          
compress;         //< If true 
compress the data.</DIV>
<DIV>+      
int           
compress;         //< The type of 
compressor the data.</DIV>
<DIV>       uint8_t*      
buffer;           //< The 
decompressed buffer</DIV>
<DIV>       uint8_t*      
io;               
//< The I/O buffer.</DIV>
<DIV>       
size_t        
level;            //< 
The amount of data in the buffer.</DIV>
<DIV>@@ -155,6 +155,7 @@</DIV>
<DIV>                                       
//  transferred.</DIV>
<DIV>       
size_t        total_compressed; //< The 
amount of compressed data</DIV>
<DIV>                                       
//  transferred.</DIV>
<DIV>+      
bool        start;</DIV>
<DIV>     };</DIV>
<DIV> </DIV>
<DIV>     /**</DIV>
<DIV>diff -Naur rtems-tools/rtemstoolkit/rld-outputter.cpp 
rtems-tools_patched/rtemstoolkit/rld-outputter.cpp</DIV>
<DIV>--- rtems-tools/rtemstoolkit/rld-outputter.cpp    2018-04-18 
10:52:00 +0400</DIV>
<DIV>+++ rtems-tools_patched/rtemstoolkit/rld-outputter.cpp    
2019-02-21 14:41:49 +0400</DIV>
<DIV>@@ -435,7 +435,8 @@</DIV>
<DIV>                      
const files::object_list& dependents,</DIV>
<DIV>                      
const files::cache&       cache,</DIV>
<DIV>                      
const symbols::table&     symbols,</DIV>
<DIV>-                     
bool                      
one_file)</DIV>
<DIV>+                     
bool                      
one_file,</DIV>
<DIV>+                     
int                       
algorithm)</DIV>
<DIV>     {</DIV>
<DIV>       if (rld::verbose () >= 
RLD_VERBOSE_INFO)</DIV>
<DIV>         std::cout << 
"outputter:application: " << name << std::endl;</DIV>
<DIV>@@ -456,7 +457,7 @@</DIV>
<DIV> </DIV>
<DIV>       try</DIV>
<DIV>       {</DIV>
<DIV>-        rap::write (app, entry, exit, 
objects, symbols);</DIV>
<DIV>+        rap::write (app, entry, exit, 
objects, symbols, algorithm);</DIV>
<DIV>       }</DIV>
<DIV>       catch (...)</DIV>
<DIV>       {</DIV>
<DIV>diff -Naur rtems-tools/rtemstoolkit/rld-outputter.h 
rtems-tools_patched/rtemstoolkit/rld-outputter.h</DIV>
<DIV>--- rtems-tools/rtemstoolkit/rld-outputter.h    2018-04-18 
10:52:00 +0400</DIV>
<DIV>+++ rtems-tools_patched/rtemstoolkit/rld-outputter.h    
2019-02-21 14:42:55 +0400</DIV>
<DIV>@@ -117,7 +117,8 @@</DIV>
<DIV>                           
const files::object_list& dependents,</DIV>
<DIV>                           
const files::cache&       cache,</DIV>
<DIV>                           
const symbols::table&     symbols,</DIV>
<DIV>-                          
bool                      
one_file);</DIV>
<DIV>+                          
bool                      
one_file,</DIV>
<DIV>+                          
int                       
algorithm);</DIV>
<DIV> </DIV>
<DIV>   }</DIV>
<DIV>}</DIV>
<DIV>diff -Naur rtems-tools/rtemstoolkit/rld-rap.cpp 
rtems-tools_patched/rtemstoolkit/rld-rap.cpp</DIV>
<DIV>--- rtems-tools/rtemstoolkit/rld-rap.cpp    2018-04-18 
10:52:00 +0400</DIV>
<DIV>+++ rtems-tools_patched/rtemstoolkit/rld-rap.cpp    
2019-02-21 14:46:37 +0400</DIV>
<DIV>@@ -1684,15 +1684,22 @@</DIV>
<DIV>            const 
std::string&        init,</DIV>
<DIV>            const 
std::string&        fini,</DIV>
<DIV>            const 
files::object_list& app_objects,</DIV>
<DIV>-           const 
symbols::table&     /* symbols */) /* Add back for 
incremental</DIV>
<DIV>-                                                     
* linking */</DIV>
<DIV>+           const 
symbols::table&,    /* symbols */ /* Add back for 
incremental</DIV>
<DIV>+                                                    
* linking */</DIV>
<DIV>+           int 
type_compress)</DIV>
<DIV>     {</DIV>
<DIV>       std::string header;</DIV>
<DIV>+      </DIV>
<DIV>+      if (type_compress == 0)</DIV>
<DIV>+        header = 
"RAP,00000000,0002,NONE,00000000\n";</DIV>
<DIV>+      if (type_compress == 1)</DIV>
<DIV>+        header = 
"RAP,00000000,0002,LZ77,00000000\n";</DIV>
<DIV>+      if (type_compress == 2)</DIV>
<DIV>+        header = 
"RAP,00000000,0002,ZLIB,00000000\n";</DIV>
<DIV> </DIV>
<DIV>-      header = 
"RAP,00000000,0002,LZ77,00000000\n";</DIV>
<DIV>       app.write (header.c_str (), 
header.size ());</DIV>
<DIV> </DIV>
<DIV>-      compress::compressor compressor (app, 2 * 
1024);</DIV>
<DIV>+      compress::compressor compressor (app, 2 * 
1024, true, type_compress);</DIV>
<DIV>       
image                
rap;</DIV>
<DIV> </DIV>
<DIV>       rap.layout (app_objects, init, 
fini);</DIV>
<DIV>diff -Naur rtems-tools/rtemstoolkit/rld-rap.h 
rtems-tools_patched/rtemstoolkit/rld-rap.h</DIV>
<DIV>--- rtems-tools/rtemstoolkit/rld-rap.h    2016-01-13 
15:35:31 +0400</DIV>
<DIV>+++ rtems-tools_patched/rtemstoolkit/rld-rap.h    2019-02-21 
14:46:12 +0400</DIV>
<DIV>@@ -90,7 +90,8 @@</DIV>
<DIV>                 
const std::string&        init,</DIV>
<DIV>                 
const std::string&        fini,</DIV>
<DIV>                 
const files::object_list& objects,</DIV>
<DIV>-                
const symbols::table&     symbols);</DIV>
<DIV>+                
const symbols::table&     symbols,</DIV>
<DIV>+                
int                       
compress);</DIV>
<DIV>   }</DIV>
<DIV>}</DIV>
<DIV> </DIV></DIV></DIV></BODY></HTML>