diff options
author | Patrick Georgi <patrick.georgi@coresystems.de> | 2009-12-23 12:52:56 +0000 |
---|---|---|
committer | Patrick Georgi <patrick.georgi@coresystems.de> | 2009-12-23 12:52:56 +0000 |
commit | 9341acda13aa2e8d8df4f04f80c14ace52f9aa27 (patch) | |
tree | 5b65f3604728fcc7a3b0ce061290af9bae0ff14f /util | |
parent | 336daa76faa6255cf487100a9741c740802bb32f (diff) | |
download | coreboot-9341acda13aa2e8d8df4f04f80c14ace52f9aa27.tar.xz |
Tiny Bootblock, step 1/n.
Introduce the tiny bootblock infrastructure and use it on QEmu.
Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>
Acked-by: Myles Watson <mylesgw@gmail.com>
Acked-by: Ronald G. Minnich <rminnich@gmail.com>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@4989 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util')
-rw-r--r-- | util/cbfstool/cbfs-mkstage.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/util/cbfstool/cbfs-mkstage.c b/util/cbfstool/cbfs-mkstage.c index 693d7cc099..6e8daef508 100644 --- a/util/cbfstool/cbfs-mkstage.c +++ b/util/cbfstool/cbfs-mkstage.c @@ -122,6 +122,10 @@ int parse_elf_to_stage(unsigned char *input, unsigned char **output, mem_end = mend; } + if (data_start < *location) { + data_start = *location; + } + /* allocate an intermediate buffer for the data */ buffer = calloc(data_end - data_start, 1); @@ -133,6 +137,7 @@ int parse_elf_to_stage(unsigned char *input, unsigned char **output, /* Copy the file data into the buffer */ for (i = 0; i < headers; i++) { + unsigned int l_start, l_offset = 0; if (elf32_to_native(phdr[i].p_type) != PT_LOAD) continue; @@ -140,9 +145,15 @@ int parse_elf_to_stage(unsigned char *input, unsigned char **output, if (elf32_to_native(phdr[i].p_memsz) == 0) continue; - memcpy(buffer + (elf32_to_native(phdr[i].p_paddr) - data_start), - &header[elf32_to_native(phdr[i].p_offset)], - elf32_to_native(phdr[i].p_filesz)); + l_start = elf32_to_native(phdr[i].p_paddr); + if (l_start < *location) { + l_offset = *location - l_start; + l_start = *location; + } + + memcpy(buffer + (l_start - data_start), + &header[elf32_to_native(phdr[i].p_offset)+l_offset], + elf32_to_native(phdr[i].p_filesz)-l_offset); } /* Now make the output buffer */ |