summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-08-06 15:46:09 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2013-08-06 21:24:38 +0200
commit8b13d2f5f100d088746a1f8dd94f8ab82acc9b5b (patch)
treea9308e2e5ff87a637b467cc95b839a616c178785 /utils
parent48ccea96f25318b951607f192d1bfbe76b12eadf (diff)
elf: fix handling of virtual/physical addresses
Remove the hackish elf_translate_addresses which should not have existed in the first place, on write always compute the physical address of a section using elf_translate_virtual_address which makes it possible to specify any virtual to physical mapping and fail nicely if there is none. Change-Id: I4f436945e90280a6fd9430de6c642dbeb8e23d40
Diffstat (limited to 'utils')
-rw-r--r--utils/imxtools/sbtools/elf.c15
-rw-r--r--utils/imxtools/sbtools/elf.h1
-rw-r--r--utils/imxtools/sbtools/elftosb.c1
-rw-r--r--utils/imxtools/sbtools/elftosb1.c2
4 files changed, 3 insertions, 16 deletions
diff --git a/utils/imxtools/sbtools/elf.c b/utils/imxtools/sbtools/elf.c
index adf876e5c7..5017251da3 100644
--- a/utils/imxtools/sbtools/elf.c
+++ b/utils/imxtools/sbtools/elf.c
@@ -519,8 +519,8 @@ void elf_write_file(struct elf_params_t *params, elf_write_fn_t write,
phdr.p_offset = sec->offset;
else
phdr.p_offset = 0;
- phdr.p_paddr = sec->addr;
- phdr.p_vaddr = phdr.p_paddr; /* assume identity map ? */
+ phdr.p_paddr = elf_translate_virtual_address(params, sec->addr);
+ phdr.p_vaddr = sec->addr; /* assume identity map ? */
phdr.p_memsz = sec->size;
if(sec->type == EST_LOAD)
phdr.p_filesz = phdr.p_memsz;
@@ -795,17 +795,6 @@ uint32_t elf_translate_virtual_address(struct elf_params_t *params, uint32_t add
return addr;
}
-void elf_translate_addresses(struct elf_params_t *params)
-{
- struct elf_section_t *sec = params->first_section;
- while(sec)
- {
- sec->addr = elf_translate_virtual_address(params, sec->addr);
- sec = sec->next;
- }
- params->start_addr = elf_translate_virtual_address(params, params->start_addr);
-}
-
bool elf_is_empty(struct elf_params_t *params)
{
return params->first_section == NULL;
diff --git a/utils/imxtools/sbtools/elf.h b/utils/imxtools/sbtools/elf.h
index 09cbe251a1..4200850e74 100644
--- a/utils/imxtools/sbtools/elf.h
+++ b/utils/imxtools/sbtools/elf.h
@@ -101,7 +101,6 @@ void elf_add_load_section(struct elf_params_t *params,
void elf_add_fill_section(struct elf_params_t *params,
uint32_t fill_addr, uint32_t size, uint32_t pattern, const char *name);
uint32_t elf_translate_virtual_address(struct elf_params_t *params, uint32_t addr);
-void elf_translate_addresses(struct elf_params_t *params);
void elf_simplify(struct elf_params_t *params);
void elf_sort_by_address(struct elf_params_t *params);
void elf_write_file(struct elf_params_t *params, elf_write_fn_t write, elf_printf_fn_t printf, void *user);
diff --git a/utils/imxtools/sbtools/elftosb.c b/utils/imxtools/sbtools/elftosb.c
index a18bad6437..e264337d11 100644
--- a/utils/imxtools/sbtools/elftosb.c
+++ b/utils/imxtools/sbtools/elftosb.c
@@ -88,7 +88,6 @@ static void load_elf_by_id(struct cmd_file_t *cmd_file, const char *id)
fclose(fd);
if(!src->loaded)
bug("error loading elf file '%s' (id '%s')\n", src->filename, id);
- elf_translate_addresses(&src->elf);
}
static void load_bin_by_id(struct cmd_file_t *cmd_file, const char *id)
diff --git a/utils/imxtools/sbtools/elftosb1.c b/utils/imxtools/sbtools/elftosb1.c
index 79b7621844..43f9b1e9be 100644
--- a/utils/imxtools/sbtools/elftosb1.c
+++ b/utils/imxtools/sbtools/elftosb1.c
@@ -19,6 +19,7 @@
*
****************************************************************************/
+#define _POSIX_C_SOURCE 200809L /* for strdup */
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
@@ -405,7 +406,6 @@ static int load_elf(struct sb1_file_t *sb, const char *filename, int act)
fclose(fd);
if(!loaded)
bug("error loading elf file '%s'\n", filename);
- elf_translate_addresses(&elf);
elf_sort_by_address(&elf);
struct elf_section_t *esec = elf.first_section;