- fixed relocation problems with image loading. Relocation is handled
authormifi <mifi@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Mon, 17 Dec 2007 20:52:37 +0000 (20:52 +0000)
committermifi <mifi@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Mon, 17 Dec 2007 20:52:37 +0000 (20:52 +0000)
  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

src/target/image.c

index d20f9df270fd96dc4e7ac4ce6c8f573802e46f85..5ecbb81d10fb0cb8acfdfad6e178a0799acf00a4 100644 (file)
@@ -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;
 };

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)