2004-08-12 11:19:13     ZFLAT support?

Document created by Aaronwu Employee on Aug 11, 2013
Version 1Show Document
  • View in full screen mode

2004-08-12 11:19:13     ZFLAT support?

Alon Levy (ISRAEL)

Message: 342    Is it working?

How good is it - is it comparable to gzip on the file?

How do I create a ZFLAT file? (flags to elf2flt)?

 

Thanks,

 

Alon

QuoteReplyEditDelete

 

 

2004-08-18 10:25:23     RE: ZFLAT support?

Alon Levy (ISRAEL)

Message: 352    to answer myself:

to compress a file you use bfin-elf-elf2flt. you can compress all of the sections or just the data section. The size benefits can be significant (It cut my executable from 2.5MB to 0.5MB with just the data section compressed, and to 0.25MB with all compressed).

but it isn't working I submitted a bug report, hope it gets fixed soon

 

Alon

QuoteReplyEditDelete

 

 

2004-08-22 08:15:36     RE: ZFLAT support?

Alon Levy (ISRAEL)

Message: 359    more updates: zflat of both code and data is now working.

 

The changes required:

small changed to the bfin-elf-flthdr tool, basically uncommenting some code that was commented out.

I think I left binfmt_flat.c unchanged (except for some debugging code).

then just "bfin-elf-flthdr -z file -o file.z" and it works!

 

I'm using the latest alpha2 release.

 

FIY,

 

Alon

 

p.s. I'll post the patch later, or if anyone is interested earlier you can ask for it on this list.

QuoteReplyEditDelete

 

 

2004-08-24 05:12:19     RE: ZFLAT support?

Pradip Shah (INDIA)

Message: 375    Alon,

 

I would be interested in knowing your latest change.

 

Regards

Pradip

QuoteReplyEditDelete

 

 

2004-08-24 07:42:43     RE: ZFLAT support?

Alon Levy (ISRAEL)

Message: 377    I find that I didn't need to change binfmt_flat.c afterall. Only had to remove comments in flthdr.c and elf2flt.c. I only used flthdr at the end: compile as usual to a regular flat file, and then run bfin-elf-flthdr -z flatfilename. To make sure it has the correct ZFLAT flag run bfin-elf-flthdr on it again and look at the last line. Here is the patch to return to use the existing commented out regions (I assumed that you commented them out originally, wanting to get everything else working before you got to this. guess what - it works!

 

elf2flt-bf533-alpha-1_zflat_enable.patch contents follows:

 

Only in elf2flt.zflat: CVS

diff -cdr elf2flt.orig/config.status elf2flt.zflat/config.status

*** elf2flt.orig/config.status Thu Jul 15 17:12:16 2004

--- elf2flt.zflat/config.status Thu Aug 12 15:29:40 2004

***************

*** 2,8 ****

# Generated automatically by configure.

# Run this file to recreate the current configuration.

# This directory was configured as follows,

! # on host colinux:

#

# ./configure -target=bfin-elf --with-libbfd=/extra/bfin-build/binutils-current/bfd/libbfd.a --with-libiberty=/extra/bfin-build/binutils-current/libiberty/libiberty.a --with-bfd-include-dir=/extra/bfin-build/binutils-current/bfd --with-binutils-include-dir=/extra/bfin-build/binutils-current/include --prefix=/extra/output --exec-prefix=/extra/output

#

--- 2,8 ----

# Generated automatically by configure.

# Run this file to recreate the current configuration.

# This directory was configured as follows,

! # on host crate:

#

# ./configure -target=bfin-elf --with-libbfd=/extra/bfin-build/binutils-current/bfd/libbfd.a --with-libiberty=/extra/bfin-build/binutils-current/libiberty/libiberty.a --with-bfd-include-dir=/extra/bfin-build/binutils-current/bfd --with-binutils-include-dir=/extra/bfin-build/binutils-current/include --prefix=/extra/output --exec-prefix=/extra/output

#

Files elf2flt.orig/elf2flt and elf2flt.zflat/elf2flt differ

diff -cdr elf2flt.orig/elf2flt.c elf2flt.zflat/elf2flt.c

*** elf2flt.orig/elf2flt.c Thu Jul 8 13:38:59 2004

--- elf2flt.zflat/elf2flt.c Wed Aug 18 16:17:17 2004

***************

*** 1751,1757 ****

hdr.reloc_start = htonl(sizeof(struct flat_hdr) + real_address_bits(data_vma) + data_len);

hdr.reloc_count = htonl(reloc_len);

#ifdef TARGET_bfin

! hdr.flags = htonl(FLAT_FLAG_RAM);

#else

hdr.flags = htonl(0

| (load_to_ram ? FLAT_FLAG_RAM : 0)

--- 1751,1763 ----

hdr.reloc_start = htonl(sizeof(struct flat_hdr) + real_address_bits(data_vma) + data_len);

hdr.reloc_count = htonl(reloc_len);

#ifdef TARGET_bfin

! //hdr.flags = htonl(FLAT_FLAG_RAM);

! hdr.flags = htonl(0

! | (load_to_ram ? FLAT_FLAG_RAM : 0)

! | (ktrace ? FLAT_FLAG_KTRACE : 0)

! | (pic_with_got ? FLAT_FLAG_GOTPIC : 0)

! | (compress ? (compress == 2 ? FLAT_FLAG_GZDATA : FLAT_FLAG_GZIP) : 0)

! );

#else

hdr.flags = htonl(0

| (load_to_ram ? FLAT_FLAG_RAM : 0)

Files elf2flt.orig/flthdr and elf2flt.zflat/flthdr differ

diff -cdr elf2flt.orig/flthdr.c elf2flt.zflat/flthdr.c

*** elf2flt.orig/flthdr.c Mon May 31 11:06:16 2004

--- elf2flt.zflat/flthdr.c Wed Aug 18 16:21:18 2004

***************

*** 84,90 ****

new_flags = old_flags = ntohl(old_hdr.flags);

new_stack = old_stack = ntohl(old_hdr.stack_size);

new_hdr = old_hdr;

! #ifndef TARGET_bfin

if (compress == 1) {

new_flags |= FLAT_FLAG_GZIP;

new_flags &= ~FLAT_FLAG_GZDATA;

--- 84,90 ----

new_flags = old_flags = ntohl(old_hdr.flags);

new_stack = old_stack = ntohl(old_hdr.stack_size);

new_hdr = old_hdr;

! //#ifndef TARGET_bfin

if (compress == 1) {

new_flags |= FLAT_FLAG_GZIP;

new_flags &= ~FLAT_FLAG_GZDATA;

***************

*** 93,99 ****

new_flags &= ~FLAT_FLAG_GZIP;

} else if (compress < 0)

new_flags &= ~(FLAT_FLAG_GZIP|FLAT_FLAG_GZDATA);

! #endif //TARGET_bfin

 

if (ramload > 0)

new_flags |= FLAT_FLAG_RAM;

--- 93,99 ----

new_flags &= ~FLAT_FLAG_GZIP;

} else if (compress < 0)

new_flags &= ~(FLAT_FLAG_GZIP|FLAT_FLAG_GZDATA);

! //#endif //TARGET_bfin

 

if (ramload > 0)

new_flags |= FLAT_FLAG_RAM;

***************

*** 135,145 ****

printf("Has-PIC-GOT ");

if (old_flags & FLAT_FLAG_GZIP)

printf("Gzip-Compressed ");

! #ifndef TARGET_bfin

 

if (old_flags & FLAT_FLAG_GZDATA)

printf("Gzip-Data-Compressed ");

! #endif //TARGET_bfin

 

if (old_flags & FLAT_FLAG_KTRACE)

printf("Kernel-Traced-Load ");

--- 135,145 ----

printf("Has-PIC-GOT ");

if (old_flags & FLAT_FLAG_GZIP)

printf("Gzip-Compressed ");

! //#ifndef TARGET_bfin

 

if (old_flags & FLAT_FLAG_GZDATA)

printf("Gzip-Data-Compressed ");

! //#endif //TARGET_bfin

 

if (old_flags & FLAT_FLAG_KTRACE)

printf("Kernel-Traced-Load ");

***************

*** 221,227 ****

* so that we can manipulate it more easily

*/

 

! #ifndef TARGET_bfin

if (old_flags & (FLAT_FLAG_GZIP|FLAT_FLAG_GZDATA)) {

FILE *tfp;

 

--- 221,227 ----

* so that we can manipulate it more easily

*/

 

! //#ifndef TARGET_bfin

if (old_flags & (FLAT_FLAG_GZIP|FLAT_FLAG_GZDATA)) {

FILE *tfp;

 

***************

*** 267,273 ****

sprintf(cmd, "gzip -9 -f >> %s", tfile);

ofp = popen(cmd, "w");

}

! #endif //TARGET_bfin

 

if (!ofp) { /* can only happen if using gzip/gunzip */

fprintf(stderr, "Can't run cmd %s\n", cmd);

--- 267,273 ----

sprintf(cmd, "gzip -9 -f >> %s", tfile);

ofp = popen(cmd, "w");

}

! //#endif //TARGET_bfin

 

if (!ofp) { /* can only happen if using gzip/gunzip */

fprintf(stderr, "Can't run cmd %s\n", cmd);

QuoteReplyEditDelete

 

 

2009-02-05 12:25:36     RE: ZFLAT support?

Michael McTernan (UNITED KINGDOM)

Message: 68922   

 

We've been using zflat for a while on 2008R1.5, just compressing the executables with "bfin-uclinux-flthdr -z".  Works fine out of the box for us, and yes, it can save a lot of space.

Attachments

    Outcomes