This patch adds zero compression for bss segments. One of the reasons
for this is that currently, if you select no compression, the bss segment of filo takes up 153K with just zeroes. With this patch, it always takes up a lar header + 1 byte. I left the one byte so that the checksum wouldn't be broken. This patch could have taken out the calloc in the compression area, but since it only uses compile-time memory, I decided to keep this simple. Myles Signed-off-by: Myles Watson <myles@pel.cs.byu.edu> Acked-by: Ronald G. Minnich <rminnich@gmail.com> git-svn-id: svn://coreboot.org/repository/coreboot-v3@601 f3766cd6-281f-0410-b1cd-43a5c92072e9
This commit is contained in:
parent
31b60b34ec
commit
2f5c48d0b2
5 changed files with 33 additions and 2 deletions
|
|
@ -67,6 +67,7 @@ struct lar_header {
|
|||
* 0 = no compression
|
||||
* 1 = lzma
|
||||
* 2 = nrv2b
|
||||
* 3 = zeroes
|
||||
*/
|
||||
u32 compression;
|
||||
u64 entry;
|
||||
|
|
|
|||
|
|
@ -170,6 +170,11 @@ int process_file(const struct mem_file *archive, void *where)
|
|||
return 0;
|
||||
}
|
||||
#endif
|
||||
/* zeroes */
|
||||
if (archive->compression == 3) {
|
||||
memset(archive->start, 0, archive->reallen);
|
||||
return 0;
|
||||
}
|
||||
printk(BIOS_INFO, "LAR: Compression algorithm #%i not supported!\n", archive->compression);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ struct lar_header {
|
|||
* 0 = no compression
|
||||
* 1 = lzma
|
||||
* 2 = nrv2b
|
||||
* 3 = zeroes
|
||||
*/
|
||||
u32 compression;
|
||||
u64 entry;
|
||||
|
|
@ -91,7 +92,7 @@ struct lar {
|
|||
u32 size; /**< Size of the mmaped file */
|
||||
};
|
||||
|
||||
enum compalgo { none = 0, lzma = 1, nrv2b = 2 };
|
||||
enum compalgo { none = 0, lzma = 1, nrv2b = 2, zeroes = 3 };
|
||||
|
||||
typedef void (*compress_func) (char *, int, char *, int *);
|
||||
typedef void (*uncompress_func) (char *, int, char *, int);
|
||||
|
|
@ -100,26 +101,31 @@ void compress_impossible(char *in, int in_len, char *out, int *out_len);
|
|||
void do_no_compress(char *in, int in_len, char *out, int *out_len);
|
||||
void do_lzma_compress(char *in, int in_len, char *out, int *out_len);
|
||||
void do_nrv2b_compress(char *in, int in_len, char *out, int *out_len);
|
||||
void do_zeroes_compress(char *in, int in_len, char *out, int *out_len);
|
||||
|
||||
void uncompress_impossible(char *dst, int dst_len, char *src, int src_len);
|
||||
void do_no_uncompress(char *dst, int dst_len, char *src, int src_len);
|
||||
void do_lzma_uncompress(char *dst, int dst_len, char *src, int src_len);
|
||||
void do_nrv2b_uncompress(char *dst, int dst_len, char *src, int src_len);
|
||||
void do_zeroes_uncompress(char *dst, int dst_len, char *src, int src_len);
|
||||
|
||||
static compress_func compress_functions[] = {
|
||||
do_no_compress,
|
||||
do_lzma_compress,
|
||||
do_nrv2b_compress,
|
||||
do_zeroes_compress,
|
||||
};
|
||||
|
||||
static uncompress_func uncompress_functions[] = {
|
||||
do_no_uncompress,
|
||||
do_lzma_uncompress,
|
||||
do_nrv2b_uncompress,
|
||||
do_zeroes_uncompress,
|
||||
};
|
||||
|
||||
static const char *algo_name[] = {
|
||||
"",
|
||||
"lzma",
|
||||
"nrv2b",
|
||||
"zeroes",
|
||||
};
|
||||
|
|
|
|||
|
|
@ -56,6 +56,25 @@ void do_no_compress(char *in, int in_len, char *out, int *out_len)
|
|||
out_len[0] = in_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* The zeroes "compress" hook
|
||||
* Leave one byte for calculating the checksum.
|
||||
*/
|
||||
void do_zeroes_compress(char *in, int in_len, char *out, int *out_len)
|
||||
{
|
||||
out[0] = 0;
|
||||
out_len[0] = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* The zeroes "uncompress" hook
|
||||
*/
|
||||
|
||||
void do_zeroes_uncompress(char *dst, int dst_len, char *src, int src_len)
|
||||
{
|
||||
memset(dst, 0, dst_len);
|
||||
}
|
||||
|
||||
/**
|
||||
* The default "uncompress" hook to call when no other compression is used
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ int output_elf_segments(struct lar *lar, char *name, char *filebuf,
|
|||
fprintf(stderr, "Dropping empty section\n");
|
||||
continue;
|
||||
}
|
||||
thisalgo = algo;
|
||||
thisalgo = zeroes;
|
||||
if (verbose())
|
||||
fprintf(stderr, "New section addr %#x size %#x\n",
|
||||
(u32)shdr[i].sh_addr, (u32)shdr[i].sh_size);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue