summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormifi <mifi@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2007-12-17 20:52:37 +0000
committermifi <mifi@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2007-12-17 20:52:37 +0000
commit9491aa15cd6d07fb12132b4b4160d10cdfc013e6 (patch)
tree660bb2c0fbe318902a853106240d9d18693c7598 /src
parent835e0436e8e982ab218b8ad6a68aee2f9507252d (diff)
downloadopenocd+libswd-9491aa15cd6d07fb12132b4b4160d10cdfc013e6.tar.gz
openocd+libswd-9491aa15cd6d07fb12132b4b4160d10cdfc013e6.tar.bz2
openocd+libswd-9491aa15cd6d07fb12132b4b4160d10cdfc013e6.tar.xz
openocd+libswd-9491aa15cd6d07fb12132b4b4160d10cdfc013e6.zip
- fixed relocation problems with image loading. Relocation is handled
in a single centralized place, and it now works for binaries. (thanks to oyvind Harboe) git-svn-id: svn://svn.berlios.de/openocd/trunk@238 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src')
-rw-r--r--src/target/image.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/target/image.c b/src/target/image.c
index d20f9df2..5ecbb81d 100644
--- a/src/target/image.c
+++ b/src/target/image.c
@@ -231,8 +231,7 @@ int image_ihex_buffer_complete(image_t *image)
for (i = 0; i < image->num_sections; i++)
{
image->sections[i].private = section[i].private;
- image->sections[i].base_address = section[i].base_address +
- ((image->base_address_set) ? image->base_address : 0);
+ image->sections[i].base_address = section[i].base_address;
image->sections[i].size = section[i].size;
image->sections[i].flags = section[i].flags;
}
@@ -589,8 +588,7 @@ int image_mot_buffer_complete(image_t *image)
for (i = 0; i < image->num_sections; i++)
{
image->sections[i].private = section[i].private;
- image->sections[i].base_address = section[i].base_address +
- ((image->base_address_set) ? image->base_address : 0);
+ image->sections[i].base_address = section[i].base_address;
image->sections[i].size = section[i].size;
image->sections[i].flags = section[i].flags;
}
@@ -647,11 +645,6 @@ int image_open(image_t *image, char *url, char *type_string)
image->sections[0].base_address = 0x0;
image->sections[0].size = image_binary->fileio.size;
image->sections[0].flags = 0;
-
- if (image->base_address_set == 1)
- image->sections[0].base_address = image->base_address;
-
- return ERROR_OK;
}
else if (image->type == IMAGE_IHEX)
{
@@ -741,6 +734,21 @@ int image_open(image_t *image, char *url, char *type_string)
image->sections = NULL;
image->type_private = NULL;
}
+
+ if (image->base_address_set)
+ {
+ // relocate
+ int section;
+ for (section=0; section < image->num_sections; section++)
+ {
+ image->sections[section].base_address+=image->base_address;
+ }
+ // we're done relocating. The two statements below are mainly
+ // for documenation purposes: stop anyone from empirically
+ // thinking they should use these values henceforth.
+ image->base_address=0;
+ image->base_address_set=0;
+ }
return retval;
};