summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/cbfstool/cbfs-mkstage.c27
-rw-r--r--util/cbfstool/cbfstool.c5
-rw-r--r--util/cbfstool/common.h3
3 files changed, 9 insertions, 26 deletions
diff --git a/util/cbfstool/cbfs-mkstage.c b/util/cbfstool/cbfs-mkstage.c
index bfe7bf8c33..bd1cf54b6b 100644
--- a/util/cbfstool/cbfs-mkstage.c
+++ b/util/cbfstool/cbfs-mkstage.c
@@ -93,8 +93,7 @@ static void fill_cbfs_stage(struct buffer *outheader, enum cbfs_compression algo
* works for all elf files, not just the restricted set.
*/
int parse_elf_to_stage(const struct buffer *input, struct buffer *output,
- enum cbfs_compression algo, uint32_t *location,
- const char *ignore_section)
+ enum cbfs_compression algo, const char *ignore_section)
{
struct parsed_elf pelf;
Elf64_Phdr *phdr;
@@ -113,8 +112,6 @@ int parse_elf_to_stage(const struct buffer *input, struct buffer *output,
if (!compress)
return -1;
- DEBUG("start: parse_elf_to_stage(location=0x%x)\n", *location);
-
int flags = ELF_PARSE_PHDR | ELF_PARSE_SHDR | ELF_PARSE_STRTAB;
if (parse_elf(input, &pelf, flags)) {
@@ -174,10 +171,6 @@ int parse_elf_to_stage(const struct buffer *input, struct buffer *output,
virt_to_phys = phdr[i].p_paddr - phdr[i].p_vaddr;
}
- if (data_start < *location) {
- data_start = *location;
- }
-
if (data_end <= data_start) {
ERROR("data ends (%08lx) before it starts (%08lx). Make sure "
"the ELF file is correct and resides in ROM space.\n",
@@ -196,27 +189,19 @@ int parse_elf_to_stage(const struct buffer *input, struct buffer *output,
/* Copy the file data into the buffer */
for (i = 0; i < headers; i++) {
- uint64_t l_start, l_offset = 0;
-
if (phdr[i].p_type != PT_LOAD)
continue;
if (phdr[i].p_memsz == 0)
continue;
- l_start = phdr[i].p_paddr;
- if (l_start < *location) {
- l_offset = *location - l_start;
- l_start = *location;
- }
-
/* A legal ELF file can have a program header with
* non-zero length but zero-length file size and a
* non-zero offset which, added together, are > than
* input->size (i.e. the total file size). So we need
* to not even test in the case that p_filesz is zero.
*/
- if (! phdr[i].p_filesz)
+ if (!phdr[i].p_filesz)
continue;
if (input->size < (phdr[i].p_offset + phdr[i].p_filesz)){
ERROR("Underflow copying out the segment."
@@ -225,9 +210,9 @@ int parse_elf_to_stage(const struct buffer *input, struct buffer *output,
free(buffer);
goto err;
}
- memcpy(buffer + (l_start - data_start),
- &input->data[phdr[i].p_offset + l_offset],
- phdr[i].p_filesz - l_offset);
+ memcpy(buffer + (phdr[i].p_paddr - data_start),
+ &input->data[phdr[i].p_offset],
+ phdr[i].p_filesz);
}
/* Now make the output buffer */
@@ -303,8 +288,6 @@ int parse_elf_to_stage(const struct buffer *input, struct buffer *output,
fill_cbfs_stage(&outheader, algo, ehdr->e_entry + virt_to_phys,
data_start, outlen, mem_end - data_start);
- if (*location)
- *location -= sizeof(struct cbfs_stage);
output->size = sizeof(struct cbfs_stage) + outlen;
ret = 0;
diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c
index 2f920e0988..c7330a493e 100644
--- a/util/cbfstool/cbfstool.c
+++ b/util/cbfstool/cbfstool.c
@@ -926,9 +926,10 @@ static int cbfstool_convert_mkstage(struct buffer *buffer, uint32_t *offset,
ret = parse_elf_to_xip_stage(buffer, &output, offset,
param.ignore_section);
- } else
+ } else {
ret = parse_elf_to_stage(buffer, &output, param.compression,
- offset, param.ignore_section);
+ param.ignore_section);
+ }
if (ret != 0)
return -1;
diff --git a/util/cbfstool/common.h b/util/cbfstool/common.h
index 1c83045eee..db9c7e7297 100644
--- a/util/cbfstool/common.h
+++ b/util/cbfstool/common.h
@@ -174,8 +174,7 @@ int parse_flat_binary_to_payload(const struct buffer *input,
enum cbfs_compression algo);
/* cbfs-mkstage.c */
int parse_elf_to_stage(const struct buffer *input, struct buffer *output,
- enum cbfs_compression algo, uint32_t *location,
- const char *ignore_section);
+ enum cbfs_compression algo, const char *ignore_section);
/* location is TOP aligned. */
int parse_elf_to_xip_stage(const struct buffer *input, struct buffer *output,
uint32_t *location, const char *ignore_section);