Update QNX IPC loader to RIDL 2.1.0
authorvwan@ti.com <vwan@ti.com>
Wed, 21 Jan 2015 19:37:27 +0000 (11:37 -0800)
committerRobert Tivy <rtivy@ti.com>
Fri, 23 Jan 2015 22:02:51 +0000 (14:02 -0800)
This commit updates the loader in QNX IPC to the latest codebase in RIDL 2.1.0,
which can be found at https://gforge.ti.com/gf/project/ridl_oss. It also brings
in any relevant differences between SysLink 2 and RIDL 2.0.

This addresses SDOCM00101007.

Signed-off-by: VW <vwan@ti.com>
47 files changed:
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_DYN/Makefile.inc [deleted file]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_DYN/c60_dynamic.c
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_DYN/c60_dynamic.h
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_REL/Makefile.inc [deleted file]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_REL/c60_reloc.c
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_REL/c60_reloc.h [new file with mode: 0644]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_SYM/README [new file with mode: 0644]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/ArrayList.c
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/ArrayList.h
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/Makefile.inc [deleted file]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/Queue.h
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/Stack.h [new file with mode: 0644]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/dload.c
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/dload.h
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/elf32.h
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/relocate.h
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/symtab.h
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/util.h
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/virtual_targets.h [new file with mode: 0644]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD_API/api_version_change.log
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD_API/dload_api.h
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD_SYM/Makefile.inc [deleted file]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD_SYM/symtab.c
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/Makefile.ridl [deleted file]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/arm_export.cmd [deleted file]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/c60_export.cmd [deleted file]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/dlmodules.c [deleted file]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/dlw.c [deleted file]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/dlw_client.c [deleted file]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/dlw_debug.c [deleted file]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/dlw_debug.h [deleted file]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/dlw_trgmem.c [deleted file]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/dlw_trgmem.h [deleted file]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/read_me_dlwrapper.txt [deleted file]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/Makefile [deleted file]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/README.txt [new file with mode: 0644]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/TMS470_DLOAD_DYN/arm_dynamic.c
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/TMS470_DLOAD_DYN/arm_dynamic.h
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/TMS470_DLOAD_REL/Makefile.inc [deleted file]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/TMS470_DLOAD_REL/arm_reloc.c
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/TMS470_DLOAD_REL/arm_reloc.h [new file with mode: 0644]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/TMS470_DLOAD_SYM/README [new file with mode: 0644]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/lnk.cmd [deleted file]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/ElfLoader.c
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/dlw_client/Makefile.inc [deleted file]
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/dlw_client/dlw_client.c
qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/dlw_client/dlw_dsbt.c

diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_DYN/Makefile.inc b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_DYN/Makefile.inc
deleted file mode 100644 (file)
index 34bb06b..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#   ============================================================================
-#   @file   Makefile.inc
-#
-#   @brief  Makefile definitions
-#
-#
-#   @ver        02.00.00.19
-#
-#   ============================================================================
-#
-#   Copyright (c) 2008-2009, Texas Instruments Incorporated
-#   All rights reserved.
-#
-#   Redistribution and use in source and binary forms, with or without
-#   modification, are permitted provided that the following conditions
-#   are met:
-#
-#   *  Redistributions of source code must retain the above copyright
-#      notice, this list of conditions and the following disclaimer.
-#
-#   *  Redistributions in binary form must reproduce the above copyright
-#      notice, this list of conditions and the following disclaimer in the
-#      documentation and/or other materials provided with the distribution.
-#
-#   *  Neither the name of Texas Instruments Incorporated nor the names of
-#      its contributors may be used to endorse or promote products derived
-#      from this software without specific prior written permission.
-#
-#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-#   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-#   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-#   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-#   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-#   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-#   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-#   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-#   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-#   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
-#   EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#   Contact information for paper mail:
-#   Texas Instruments
-#   Post Office Box 655303
-#   Dallas, Texas 75265
-#   Contact information:
-#   http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
-#   DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
-#   ============================================================================
-
-
-
-
-
-OBJECTS := c60_dynamic.o
index 92633cb5799a09a7ae503ee0a6c0972a5ca520e5..467c92097a5373e0b94f568e545c96c6f84f1231 100644 (file)
@@ -3,7 +3,7 @@
 *
 * C6x-specific dynamic loader functionality
 *
-* Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
+* Copyright (C) 2009-2015 Texas Instruments Incorporated - http://www.ti.com/
 *
 *
 * Redistribution and use in source and binary forms, with or without
 
 #ifdef C60_TARGET
 #include "c60_elf32.h"
-#if defined (__KERNEL__)
-#include <linux/types.h>
-#else
 #include <inttypes.h>
-#include <stdlib.h>
-#endif
 #include "dload.h"
 
 /*****************************************************************************/
index 185855e73071d0e7e2536fbdc3a750dab4abf588..a0cee7dcaa7cb3910b034e46d7bfefc71063f386 100644 (file)
@@ -3,7 +3,7 @@
 *
 * Interface into C6x-specific dynamic loader functionality
 *
-* Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
+* Copyright (C) 2009-2015 Texas Instruments Incorporated - http://www.ti.com/
 *
 *
 * Redistribution and use in source and binary forms, with or without
 
 BOOL DLDYN_c60_process_dynamic_tag(DLIMP_Dynamic_Module* dyn_module, int i);
 BOOL DLDYN_c60_process_eiosabi(DLIMP_Dynamic_Module* dyn_module);
-BOOL DLDYN_c60_relocate_dynamic_tag_info(DLIMP_Dynamic_Module *dyn_module,
-                                         int32_t i);
+BOOL DLDYN_c60_relocate_dynamic_tag_info(DLIMP_Dynamic_Module *dyn_module, int32_t i);
+
+#define T_INTSZ 32
+#define T_CHARSZ 8
+#define MEM_INC 8
+#define PTR_SZ  32
 
 #endif
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_REL/Makefile.inc b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_REL/Makefile.inc
deleted file mode 100644 (file)
index 0a657f5..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#   ============================================================================
-#   @file   Makefile.inc
-#
-#   @brief  Makefile definitions
-#
-#
-#   @ver        02.00.00.19
-#
-#   ============================================================================
-#
-#   Copyright (c) 2008-2009, Texas Instruments Incorporated
-#   All rights reserved.
-#
-#   Redistribution and use in source and binary forms, with or without
-#   modification, are permitted provided that the following conditions
-#   are met:
-#
-#   *  Redistributions of source code must retain the above copyright
-#      notice, this list of conditions and the following disclaimer.
-#
-#   *  Redistributions in binary form must reproduce the above copyright
-#      notice, this list of conditions and the following disclaimer in the
-#      documentation and/or other materials provided with the distribution.
-#
-#   *  Neither the name of Texas Instruments Incorporated nor the names of
-#      its contributors may be used to endorse or promote products derived
-#      from this software without specific prior written permission.
-#
-#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-#   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-#   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-#   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-#   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-#   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-#   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-#   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-#   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-#   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
-#   EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#   Contact information for paper mail:
-#   Texas Instruments
-#   Post Office Box 655303
-#   Dallas, Texas 75265
-#   Contact information:
-#   http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
-#   DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
-#   ============================================================================
-
-OBJECTS := c60_reloc.o
index 7a67d121bf4afe4975836b98452a676a648b9290..a99f91383aa2a256dfebc88fb68abc6fff8ef594 100644 (file)
@@ -3,7 +3,7 @@
 *
 * Process C6x-specific dynamic relocations for core dynamic loader.
 *
-* Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
+* Copyright (C) 2009-2015 Texas Instruments Incorporated - http://www.ti.com/
 *
 *
 * Redistribution and use in source and binary forms, with or without
 *
 */
 
-#if defined (__KERNEL__)
-#include <linux/limits.h>
-#else
 #include <limits.h>
-#endif
 #include "relocate.h"
+#include "symtab.h"
 #include "c60_elf32.h"
 #include "dload_api.h"
 #include "util.h"
 #include "dload_endian.h"
-#include "symtab.h"
+#include "c60_reloc.h"
 
 #define MASK(n,s) (((1 << n) - 1) << s)
 
@@ -104,8 +101,9 @@ static void write_reloc_r(uint8_t* buffered_segment,
    if(debugging_on)
    {
           DLIF_trace("RWRT: segment_offset: %d\n", segment_offset);
-          DLIF_trace("RWRT: buffered_segment: 0x%x\n", buffered_segment);
-          DLIF_trace("RWRT: rel_field_ptr: 0x%x\n", rel_field_ptr);
+          DLIF_trace("RWRT: buffered_segment: 0x%x\n",
+                                             (uint32_t)buffered_segment);
+          DLIF_trace("RWRT: rel_field_ptr: 0x%x\n", (uint32_t)rel_field_ptr);
           DLIF_trace("RWRT: result: 0x%x\n", r);
    }
 #endif
@@ -358,22 +356,29 @@ static BOOL rel_overflow(C60_RELOC_TYPE r_type, int32_t reloc_value)
       case R_C6000_PREL31:
          return 0;
 
-      /*----------------------------------------------------------------------*/
-      /* If relocation type did not appear in the above cases, then we didn't */
-      /* expect to see it.                                                    */
-      /*----------------------------------------------------------------------*/
+      /*---------------------------------------------------------------------*/
+      /* If relocation type did not appear in the above switch, then we      */
+      /* didn't expect to see it.                                            */
+      /*---------------------------------------------------------------------*/
       default:
-        DLIF_error(DLET_RELOC,
-                 "rel_overflow called with invalid relocation type!\n");
-        return 1;
-        }
+         DLIF_error(DLET_RELOC,
+                    "rel_overflow called with invalid relocation type!\n");
+   }
+
+   return 1;
 }
 
+#if LOADER_DEBUG || LOADER_PROFILE
+extern int DLREL_relocations;
+extern time_t DLREL_total_reloc_time;
+#endif
+
 /*****************************************************************************/
 /* RELOC_DO() - Process a single relocation entry.                           */
 /*****************************************************************************/
 static void reloc_do(C60_RELOC_TYPE r_type,
-                     uint8_t *segment_address,
+                     uint32_t segment_vaddr,
+                     uint8_t *segment_buffer,
                      uint32_t addend,
                      uint32_t symval,
                      uint32_t spc,
@@ -388,7 +393,7 @@ static void reloc_do(C60_RELOC_TYPE r_type,
    /* In debug mode, keep a count of the number of relocations processed.    */
    /* In profile mode, start the clock on a given relocation.                */
    /*------------------------------------------------------------------------*/
-   int start_time;
+   int start_time = 0;
    if (debugging_on || profiling_on)
    {
       DLREL_relocations++;
@@ -426,7 +431,7 @@ static void reloc_do(C60_RELOC_TYPE r_type,
          /* Add SPC to segment address to get the PC. Mask for exec-packet   */
          /* boundary.                                                        */
          /*------------------------------------------------------------------*/
-         int32_t opnd_p = (spc + (int32_t)segment_address) & 0xffffffe0;
+         int32_t opnd_p = (spc + segment_vaddr) & 0xffffffe0;
          reloc_value = symval + addend - opnd_p;
          break;
       }
@@ -454,7 +459,7 @@ static void reloc_do(C60_RELOC_TYPE r_type,
          /*------------------------------------------------------------------*/
          /* Offset is not fetch-packet relative; doesn't need to be masked.  */
          /*------------------------------------------------------------------*/
-         int32_t opnd_p = (spc + (int32_t)segment_address);
+         int32_t opnd_p = (spc + segment_vaddr);
          reloc_value = symval + addend - opnd_p;
          break;
       }
@@ -526,18 +531,18 @@ static void reloc_do(C60_RELOC_TYPE r_type,
    /* If necessary, Swap endianness of data at relocation address.           */
    /*------------------------------------------------------------------------*/
    if (wrong_endian)
-      DLIMP_change_endian32((int32_t*)(segment_address + spc));
+      DLIMP_change_endian32((int32_t*)(segment_buffer + spc));
 
    /*------------------------------------------------------------------------*/
    /* Write the relocated 4-byte packet back to the segment buffer.          */
    /*------------------------------------------------------------------------*/
-   write_reloc_r(segment_address, spc, r_type, reloc_value);
+   write_reloc_r(segment_buffer, spc, r_type, reloc_value);
 
    /*------------------------------------------------------------------------*/
    /* Change endianness of segment address back to original.                 */
    /*------------------------------------------------------------------------*/
    if (wrong_endian)
-      DLIMP_change_endian32((int32_t*)(segment_address + spc));
+      DLIMP_change_endian32((int32_t*)(segment_buffer + spc));
 
 #if LOADER_DEBUG && LOADER_PROFILE
    /*------------------------------------------------------------------------*/
@@ -549,7 +554,6 @@ static void reloc_do(C60_RELOC_TYPE r_type,
    if (debugging_on)
       DLIF_trace("reloc_value = 0x%x\n", reloc_value);
 #endif
-
 }
 
 /*****************************************************************************/
@@ -560,7 +564,7 @@ static void reloc_do(C60_RELOC_TYPE r_type,
 /*****************************************************************************/
 static void rel_unpack_addend(C60_RELOC_TYPE r_type,
                               uint8_t *address,
-                             uint32_t *addend)
+                  uint32_t *addend)
 {
    /*------------------------------------------------------------------------*/
    /* C6000 does not support Elf32_Rel type relocations in the dynamic       */
@@ -572,11 +576,9 @@ static void rel_unpack_addend(C60_RELOC_TYPE r_type,
 
    DLIF_error(DLET_RELOC,
               "Internal Error: unpacking addend values from the relocation "
-             "field is not supported in the C6000 dynamic loader at this "
-             "time; aborting\n");
-#if !defined (__KERNEL__)
-   exit(1);
-#endif
+          "field is not supported in the C6000 dynamic loader at this "
+          "time; aborting\n");
+   DLIF_exit(1);
 }
 
 /*****************************************************************************/
@@ -617,9 +619,11 @@ static void rel_change_endian(C60_RELOC_TYPE r_type, uint8_t *address)
 /*****************************************************************************/
 static void read_rel_table(struct Elf32_Rel **rel_table,
                            int32_t table_offset,
-                          uint32_t relnum, uint32_t relent,
-                          LOADER_FILE_DESC *fd, BOOL wrong_endian)
+               uint32_t relnum, uint32_t relent,
+               LOADER_FILE_DESC *fd, BOOL wrong_endian)
 {
+   if (relnum == 0) { *rel_table = NULL; return; }
+
    *rel_table = (struct Elf32_Rel *)DLIF_malloc(relnum * relent);
    if (NULL == *rel_table) {
        DLIF_error(DLET_MEMORY, "Failed to Allocate read_rel_table\n");
@@ -642,12 +646,13 @@ static void read_rel_table(struct Elf32_Rel **rel_table,
 /*    Process table of Elf32_Rel type relocations.                           */
 /*                                                                           */
 /*****************************************************************************/
-static void process_rel_table(DLOAD_HANDLE handle, DLIMP_Loaded_Segment* seg,
+static void process_rel_table(DLOAD_HANDLE handle,
+                              DLIMP_Loaded_Segment* seg,
                               struct Elf32_Rel *rel_table,
-                             uint32_t relnum,
-                             int32_t *start_relidx,
-                             uint32_t ti_static_base,
-                             DLIMP_Dynamic_Module* dyn_module)
+                  uint32_t relnum,
+                  int32_t *start_relidx,
+                  uint32_t ti_static_base,
+                  DLIMP_Dynamic_Module* dyn_module)
 {
    Elf32_Addr seg_start_addr = seg->input_vaddr;
    Elf32_Addr seg_end_addr   = seg_start_addr + seg->phdr.p_memsz;
@@ -672,49 +677,48 @@ static void process_rel_table(DLOAD_HANDLE handle, DLIMP_Loaded_Segment* seg,
           rel_table[relidx].r_offset < seg_end_addr)
       {
          Elf32_Addr     r_symval = 0;
-        C60_RELOC_TYPE r_type  =
-                      (C60_RELOC_TYPE)ELF32_R_TYPE(rel_table[relidx].r_info);
-        int32_t        r_symid = ELF32_R_SYM(rel_table[relidx].r_info);
+     C60_RELOC_TYPE r_type  =
+                   (C60_RELOC_TYPE)ELF32_R_TYPE(rel_table[relidx].r_info);
+     int32_t        r_symid = ELF32_R_SYM(rel_table[relidx].r_info);
 
-        uint8_t *reloc_address = NULL;
-        uint32_t pc     = 0;
-        uint32_t addend = 0;
+     uint8_t *reloc_address = NULL;
+     uint32_t pc     = 0;
+     uint32_t addend = 0;
 
-        BOOL     change_endian = FALSE;
+     BOOL     change_endian = FALSE;
 
-        found = TRUE;
+     found = TRUE;
 
          /*------------------------------------------------------------------*/
-        /* If symbol definition is not found, don't do the relocation.      */
-        /* An error is generated by the lookup function.                    */
-        /*------------------------------------------------------------------*/
+     /* If symbol definition is not found, don't do the relocation.      */
+     /* An error is generated by the lookup function.                    */
+     /*------------------------------------------------------------------*/
          if (!DLSYM_canonical_lookup(handle, r_symid, dyn_module, &r_symval))
             continue;
 
          /*------------------------------------------------------------------*/
-        /* Addend value is stored in the relocation field.                  */
-        /* We'll need to unpack it from the data for the segment that is    */
-        /* currently being relocated.                                       */
+     /* Addend value is stored in the relocation field.                  */
+     /* We'll need to unpack it from the data for the segment that is    */
+     /* currently being relocated.                                       */
          /*------------------------------------------------------------------*/
-        reloc_address =
-                      (((uint8_t *)(seg->phdr.p_vaddr) + seg->reloc_offset) +
-                       rel_table[relidx].r_offset - seg->input_vaddr);
-         pc = (uint32_t)reloc_address;
+         pc            = rel_table[relidx].r_offset - seg->input_vaddr;
+     reloc_address = (uint8_t *)seg->host_address + pc;
 
-        change_endian = rel_swap_endian(dyn_module, r_type);
-        if (change_endian)
-           rel_change_endian(r_type, reloc_address);
+     change_endian = rel_swap_endian(dyn_module, r_type);
+     if (change_endian)
+        rel_change_endian(r_type, reloc_address);
 
-        rel_unpack_addend(
-                       (C60_RELOC_TYPE)ELF32_R_TYPE(rel_table[relidx].r_info),
-                                                      reloc_address, &addend);
+     rel_unpack_addend(
+                    (C60_RELOC_TYPE)ELF32_R_TYPE(rel_table[relidx].r_info),
+                                                   reloc_address, &addend);
 
          /*------------------------------------------------------------------*/
-        /* Perform actual relocation.  This is a really wide function       */
-        /* interface and could do with some encapsulation.                  */
-        /*------------------------------------------------------------------*/
+     /* Perform actual relocation.  This is a really wide function       */
+     /* interface and could do with some encapsulation.                  */
+     /*------------------------------------------------------------------*/
          reloc_do(r_type,
-                  reloc_address,
+                  seg->phdr.p_vaddr,
+                  seg->host_address,
                   addend,
                   r_symval,
                   pc,
@@ -738,9 +742,10 @@ static void process_rel_table(DLOAD_HANDLE handle, DLIMP_Loaded_Segment* seg,
 /*****************************************************************************/
 static void read_rela_table(struct Elf32_Rela **rela_table,
                             int32_t table_offset,
-                           uint32_t relanum, uint32_t relaent,
-                           LOADER_FILE_DESC *fd, BOOL wrong_endian)
+                uint32_t relanum, uint32_t relaent,
+                LOADER_FILE_DESC *fd, BOOL wrong_endian)
 {
+   if (relanum == 0) { *rela_table = NULL; return; }
    *rela_table = (struct Elf32_Rela *)DLIF_malloc(relanum * relaent);
    if (NULL == *rela_table) {
        DLIF_error(DLET_MEMORY, "Failed to Allocate read_rela_table\n");
@@ -763,12 +768,13 @@ static void read_rela_table(struct Elf32_Rela **rela_table,
 /*    Process a table of Elf32_Rela type relocations.                        */
 /*                                                                           */
 /*****************************************************************************/
-static void process_rela_table(DLOAD_HANDLE handle, DLIMP_Loaded_Segment *seg,
+static void process_rela_table(DLOAD_HANDLE handle,
+                               DLIMP_Loaded_Segment *seg,
                                struct Elf32_Rela *rela_table,
-                              uint32_t relanum,
-                              int32_t *start_relidx,
-                              uint32_t ti_static_base,
-                              DLIMP_Dynamic_Module *dyn_module)
+                   uint32_t relanum,
+                   int32_t *start_relidx,
+                   uint32_t ti_static_base,
+                   DLIMP_Dynamic_Module *dyn_module)
 {
     Elf32_Addr seg_start_addr = seg->input_vaddr;
     Elf32_Addr seg_end_addr   = seg_start_addr + seg->phdr.p_memsz;
@@ -792,16 +798,16 @@ static void process_rela_table(DLOAD_HANDLE handle, DLIMP_Loaded_Segment *seg,
         if (rela_table[relidx].r_offset >= seg_start_addr &&
             rela_table[relidx].r_offset < seg_end_addr)
         {
-           Elf32_Addr     r_symval;
-           C60_RELOC_TYPE r_type  =
-                     (C60_RELOC_TYPE)ELF32_R_TYPE(rela_table[relidx].r_info);
-           int32_t        r_symid = ELF32_R_SYM(rela_table[relidx].r_info);
+        Elf32_Addr     r_symval;
+        C60_RELOC_TYPE r_type  =
+                  (C60_RELOC_TYPE)ELF32_R_TYPE(rela_table[relidx].r_info);
+        int32_t        r_symid = ELF32_R_SYM(rela_table[relidx].r_info);
 
-           found = TRUE;
+        found = TRUE;
 
             /*---------------------------------------------------------------*/
-           /* If symbol definition is not found, don't do the relocation.   */
-           /* An error is generated by the lookup function.                 */
+        /* If symbol definition is not found, don't do the relocation.   */
+        /* An error is generated by the lookup function.                 */
             /*---------------------------------------------------------------*/
             if (!DLSYM_canonical_lookup(handle, r_symid, dyn_module, &r_symval))
                 continue;
@@ -811,7 +817,8 @@ static void process_rela_table(DLOAD_HANDLE handle, DLIMP_Loaded_Segment *seg,
             /* interface and could do with some encapsulation.               */
             /*---------------------------------------------------------------*/
             reloc_do(r_type,
-                     (uint8_t*)(seg->phdr.p_vaddr) + seg->reloc_offset,
+                     seg->phdr.p_vaddr,
+                     seg->host_address,
                      rela_table[relidx].r_addend,
                      r_symval,
                      rela_table[relidx].r_offset - seg->input_vaddr,
@@ -836,7 +843,7 @@ static void process_rela_table(DLOAD_HANDLE handle, DLIMP_Loaded_Segment *seg,
 static void process_got_relocs(DLOAD_HANDLE handle,
                                struct Elf32_Rel* rel_table, uint32_t relnum,
                                struct Elf32_Rela* rela_table, uint32_t relanum,
-                              DLIMP_Dynamic_Module* dyn_module)
+                   DLIMP_Dynamic_Module* dyn_module)
 {
    DLIMP_Loaded_Segment *seg =
        (DLIMP_Loaded_Segment*)(dyn_module->loaded_module->loaded_segments.buf);
@@ -866,13 +873,13 @@ static void process_got_relocs(DLOAD_HANDLE handle,
 
       if (rela_table)
          process_rela_table(handle, (seg + seg_idx),
-                           rela_table, relanum, &rela_relidx,
-                           ti_static_base, dyn_module);
+                        rela_table, relanum, &rela_relidx,
+                ti_static_base, dyn_module);
 
       if (rel_table)
          process_rel_table(handle, (seg + seg_idx),
-                           rel_table, relnum, &rel_relidx,
-                           ti_static_base, dyn_module);
+                        rel_table, relnum, &rel_relidx,
+                ti_static_base, dyn_module);
    }
 }
 
@@ -884,14 +891,15 @@ static void process_got_relocs(DLOAD_HANDLE handle,
 /*    ar guaranteed to belong to the same segment.                           */
 /*                                                                           */
 /*****************************************************************************/
-static void process_pltgot_relocs(DLOAD_HANDLE handle, void* plt_reloc_table,
+static void process_pltgot_relocs(DLOAD_HANDLE handle,
+                                  void* plt_reloc_table,
                                   int reltype,
                                   uint32_t pltnum,
-                                 DLIMP_Dynamic_Module* dyn_module)
+                  DLIMP_Dynamic_Module* dyn_module)
 {
    Elf32_Addr r_offset = (reltype == DT_REL) ?
                              ((struct Elf32_Rel *)plt_reloc_table)->r_offset :
-                            ((struct Elf32_Rela *)plt_reloc_table)->r_offset;
+                 ((struct Elf32_Rela *)plt_reloc_table)->r_offset;
 
    DLIMP_Loaded_Segment* seg =
       (DLIMP_Loaded_Segment*)(dyn_module->loaded_module->loaded_segments.buf);
@@ -928,15 +936,15 @@ static void process_pltgot_relocs(DLOAD_HANDLE handle, void* plt_reloc_table,
           r_offset < seg_end_addr)
       {
          if (reltype == DT_REL)
-           process_rel_table(handle, (seg + seg_idx),
-                             (struct Elf32_Rel *)plt_reloc_table,
-                             pltnum, &plt_relidx,
-                             ti_static_base, dyn_module);
-        else
-           process_rela_table(handle, (seg + seg_idx),
-                              (struct Elf32_Rela *)plt_reloc_table,
-                              pltnum, &plt_relidx,
-                              ti_static_base, dyn_module);
+        process_rel_table(handle, (seg + seg_idx),
+                          (struct Elf32_Rel *)plt_reloc_table,
+                  pltnum, &plt_relidx,
+                  ti_static_base, dyn_module);
+     else
+        process_rela_table(handle, (seg + seg_idx),
+                           (struct Elf32_Rela *)plt_reloc_table,
+                   pltnum, &plt_relidx,
+                   ti_static_base, dyn_module);
 
          break;
       }
@@ -947,13 +955,14 @@ static void process_pltgot_relocs(DLOAD_HANDLE handle, void* plt_reloc_table,
 /* RELOCATE() - Perform RELA and REL type relocations for given ELF object   */
 /*      file that we are in the process of loading and relocating.           */
 /*****************************************************************************/
-void DLREL_relocate_c60(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd,
-                        DLIMP_Dynamic_Module *dyn_module)
+void DLREL_c60_relocate(DLOAD_HANDLE handle,
+                        LOADER_FILE_DESC *fd, DLIMP_Dynamic_Module *dyn_module)
 {
    struct Elf32_Dyn  *dyn_nugget = dyn_module->dyntab;
    struct Elf32_Rela *rela_table = NULL;
    struct Elf32_Rel  *rel_table  = NULL;
-   void              *plt_table  = NULL;
+   struct Elf32_Rela *rela_plt_table = NULL;
+   struct Elf32_Rel  *rel_plt_table  = NULL;
 
    /*------------------------------------------------------------------------*/
    /* Read the size of the relocation table (DT_RELASZ) and the size per     */
@@ -994,38 +1003,38 @@ void DLREL_relocate_c60(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd,
    /* includes the size of the PLTGOT table.  So it must be adjusted so that */
    /* the GOT relocation tables only contain actual GOT relocations.         */
    /*------------------------------------------------------------------------*/
-   if (pltrelsz != INT_MAX)
+   if (pltrelsz != INT_MAX && pltrelsz != 0)
    {
       if (pltreltyp == DT_REL)
       {
          pltnum = pltrelsz/relent;
-        relsz -= pltrelsz;
-        read_rel_table(((struct Elf32_Rel**) &plt_table),
-                       DLIMP_get_first_dyntag(DT_JMPREL, dyn_nugget),
-                       pltnum, relent, fd, dyn_module->wrong_endian);
+         relsz -= pltrelsz;
+         read_rel_table((&rel_plt_table),
+             DLIMP_get_first_dyntag(DT_JMPREL, dyn_nugget),
+             pltnum, relent, fd, dyn_module->wrong_endian);
       }
 
       else if (pltreltyp == DT_RELA)
       {
          pltnum = pltrelsz/relaent;
-        relasz -= pltrelsz;
-        read_rela_table(((struct Elf32_Rela**) &plt_table),
-                        DLIMP_get_first_dyntag(DT_JMPREL, dyn_nugget),
-                        pltnum, relaent, fd, dyn_module->wrong_endian);
+         relasz -= pltrelsz;
+         read_rela_table((&rela_plt_table),
+             DLIMP_get_first_dyntag(DT_JMPREL, dyn_nugget),
+             pltnum, relaent, fd, dyn_module->wrong_endian);
       }
 
       else
       {
          DLIF_error(DLET_RELOC,
-                   "DT_PLTREL is invalid: must be either %d or %d\n",
-                   DT_REL, DT_RELA);
+             "DT_PLTREL is invalid: must be either %d or %d\n",
+             DT_REL, DT_RELA);
       }
    }
 
    /*------------------------------------------------------------------------*/
    /* Read the DT_RELA GOT relocation table from the file                    */
    /*------------------------------------------------------------------------*/
-   if (relasz != INT_MAX)
+   if (relasz != INT_MAX && relasz != 0)
    {
       relanum = relasz/relaent;
       read_rela_table(&rela_table, DLIMP_get_first_dyntag(DT_RELA, dyn_nugget),
@@ -1035,7 +1044,7 @@ void DLREL_relocate_c60(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd,
    /*------------------------------------------------------------------------*/
    /* Read the DT_REL GOT relocation table from the file                     */
    /*------------------------------------------------------------------------*/
-   if (relsz != INT_MAX)
+   if (relsz != INT_MAX && relsz != 0)
    {
       relnum = relsz/relent;
       read_rel_table(&rel_table, DLIMP_get_first_dyntag(DT_REL, dyn_nugget),
@@ -1045,21 +1054,28 @@ void DLREL_relocate_c60(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd,
    /*------------------------------------------------------------------------*/
    /* Process the PLTGOT relocations                                         */
    /*------------------------------------------------------------------------*/
-   if (plt_table)
-      process_pltgot_relocs(handle, plt_table, pltreltyp, pltnum, dyn_module);
+   if (rela_plt_table)
+      process_pltgot_relocs(handle, rela_plt_table, pltreltyp, pltnum,
+                            dyn_module);
+
+   if (rel_plt_table)
+      process_pltgot_relocs(handle, rel_plt_table, pltreltyp, pltnum,
+                            dyn_module);
 
    /*------------------------------------------------------------------------*/
    /* Process the GOT relocations                                            */
    /*------------------------------------------------------------------------*/
    if (rel_table || rela_table)
-      process_got_relocs(handle, rel_table, relnum, rela_table, relanum, dyn_module);
+      process_got_relocs(handle, rel_table, relnum, rela_table, relanum,
+                         dyn_module);
 
    /*-------------------------------------------------------------------------*/
    /* Free memory used for ELF relocation table copies.                       */
    /*-------------------------------------------------------------------------*/
    if (rela_table) DLIF_free(rela_table);
    if (rel_table)  DLIF_free(rel_table);
-   if (plt_table)  DLIF_free(plt_table);
+   if (rela_plt_table) DLIF_free(rela_plt_table);
+   if (rel_plt_table)  DLIF_free(rel_plt_table);
 }
 
 /*****************************************************************************/
@@ -1072,13 +1088,14 @@ void unit_c60_reloc_do(C60_RELOC_TYPE r_type,
                        uint32_t static_base, int wrong_endian,
                        int32_t dsbt_index)
 {
-    reloc_do(r_type, address_space, addend, symval, pc, FALSE, static_base, dsbt_index);
+    reloc_do(r_type, (uint32_t)address_space, address_space,
+             addend, symval, pc, FALSE, static_base, dsbt_index);
 }
 
 #if 0 /* RELA TYPE RELOCATIONS HAVE ADDEND IN RELOCATION ENTRY */
 void unit_c60_rel_unpack_addend(C60_RELOC_TYPE r_type,
                                 uint8_t* address,
-                               uint32_t* addend)
+                uint32_t* addend)
 {
     rel_unpack_addend(r_type, address, addend);
 }
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_REL/c60_reloc.h b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_REL/c60_reloc.h
new file mode 100644 (file)
index 0000000..ff08550
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2015, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+void DLREL_c60_relocate(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd,
+                        DLIMP_Dynamic_Module *dyn_module);
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_SYM/README b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_SYM/README
new file mode 100644 (file)
index 0000000..c360fc6
--- /dev/null
@@ -0,0 +1,4 @@
+C60_DLOAD_SYM:
+
+This module is for C60 specific symbol table features.  Currently there are
+no target specific features in the symbol table implementation.
\ No newline at end of file
index 53a096e88a3517015dc4b5d1a71e13992d29c50a..bcb6e9cc0ca1f4ae2ad3d433efc8853b7200e7a5 100644 (file)
@@ -26,7 +26,7 @@
 * AL_destroy(&obj);
 *
 *
-* Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
+* Copyright (C) 2009-2015 Texas Instruments Incorporated - http://www.ti.com/
 *
 *
 * Redistribution and use in source and binary forms, with or without
 *
 */
 
-#if defined (__KERNEL__)
-#include <linux/types.h>
-#include <linux/string.h>
-#else
 #include <inttypes.h>
-#include <stdlib.h>
 #include <string.h>
-#endif
 #include "ArrayList.h"
 #include "dload_api.h"
 
index 5807fdf68fbbaa2a68cd315b9f7071ba0f6dfd0f..76c67f30cd4eabe5172d5a341afd237287a9edc9 100644 (file)
@@ -26,7 +26,7 @@
 *
 * AL_destroy(&obj);
 *
-* Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
+* Copyright (C) 2009-2015 Texas Instruments Incorporated - http://www.ti.com/
 *
 *
 * Redistribution and use in source and binary forms, with or without
 #ifndef ARRAYLIST_H
 #define ARRAYLIST_H
 
-#if defined (__KERNEL__)
-#include <linux/types.h>
-#else
 #include <inttypes.h>
-#endif
 
 /**********************************************************************/
 /* Array_List - structure type specification.                         */
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/Makefile.inc b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/Makefile.inc
deleted file mode 100644 (file)
index 6fc023a..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#   ============================================================================
-#   @file   Makefile.inc
-#
-#   @brief  Makefile definitions
-#
-#
-#   @ver        02.00.00.19
-#
-#   ============================================================================
-#
-#   Copyright (c) 2008-2009, Texas Instruments Incorporated
-#   All rights reserved.
-#
-#   Redistribution and use in source and binary forms, with or without
-#   modification, are permitted provided that the following conditions
-#   are met:
-#
-#   *  Redistributions of source code must retain the above copyright
-#      notice, this list of conditions and the following disclaimer.
-#
-#   *  Redistributions in binary form must reproduce the above copyright
-#      notice, this list of conditions and the following disclaimer in the
-#      documentation and/or other materials provided with the distribution.
-#
-#   *  Neither the name of Texas Instruments Incorporated nor the names of
-#      its contributors may be used to endorse or promote products derived
-#      from this software without specific prior written permission.
-#
-#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-#   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-#   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-#   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-#   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-#   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-#   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-#   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-#   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-#   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
-#   EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#   Contact information for paper mail:
-#   Texas Instruments
-#   Post Office Box 655303
-#   Dallas, Texas 75265
-#   Contact information:
-#   http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
-#   DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
-#   ============================================================================
-
-OBJECTS := ArrayList.o dload.o dload_endian.o elf32.o
index 3e9eaadf2057308abd6f5a00bcac5fd9c2083762..59b28d9593f1efd33e0e2719bb8bab8c1f56a95f 100644 (file)
@@ -36,7 +36,7 @@
 *   predecessor_node->next_ptr = deleted_node->next_ptr;
 *   name.size--;
 *
-* Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
+* Copyright (C) 2009-2015 Texas Instruments Incorporated - http://www.ti.com/
 *
 *
 * Redistribution and use in source and binary forms, with or without
 #ifndef QUEUE_H
 #define QUEUE_H
 
-#if defined (__KERNEL__)
-#include <linux/types.h>
-#else
 #include <inttypes.h>
-#endif
 #include "dload_api.h"
 
 /*****************************************************************************/
@@ -103,6 +99,11 @@ extern void t_name##_enqueue(t_name##_Queue* queue, t to_enqueue);        \
 extern t    t_name##_dequeue(t_name##_Queue* queue);                      \
 extern void t_name##_remove(t_name##_Queue* queue, t to_remove);
 
+/*****************************************************************************/
+/* TYPE_QUEUE_INITIALIZER() - Define the initializer to initialize Queues.   */
+/*****************************************************************************/
+#define TYPE_QUEUE_INITIALIZER   {NULL, NULL, 0}
+
 
 /*****************************************************************************/
 /* TYPE_QUEUE_IMPLEMENTATION() - Define member functions of new linked list  */
@@ -147,7 +148,7 @@ t t_name##_dequeue(t_name##_Queue* queue)                                \
      t to_ret;                                                           \
      t_name##_Queue_Node* next_ptr = NULL;                               \
                                                                          \
-     if (!queue->size) return ((t)(NULL));                               \
+     if (!queue->size) return (t) NULL;                                  \
                                                                          \
      next_ptr = queue->front_ptr->next_ptr;                              \
      queue->size--;                                                      \
@@ -170,15 +171,15 @@ void t_name##_remove(t_name##_Queue* queue, t to_remove)                 \
                                                                          \
      for (; curr_ptr; curr_ptr = next_ptr)                               \
      {                                                                   \
-       next_ptr = curr_ptr->next_ptr;                                   \
+    next_ptr = curr_ptr->next_ptr;                                   \
         if (curr_ptr->value == to_remove) break;                         \
-       prev_ptr = curr_ptr;                                             \
+    prev_ptr = curr_ptr;                                             \
      }                                                                   \
                                                                          \
      if (curr_ptr)                                                       \
      {                                                                   \
         if (prev_ptr) prev_ptr->next_ptr = next_ptr;                     \
-       queue->size--;                                                   \
+    queue->size--;                                                   \
         DLIF_free((void*)(curr_ptr));                                    \
      }                                                                   \
                                                                          \
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/Stack.h b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/Stack.h
new file mode 100644 (file)
index 0000000..ddad87b
--- /dev/null
@@ -0,0 +1,155 @@
+/*
+* Stack.h
+*
+* Interface to Stack
+* ------------------
+*
+* This is an implementation of a type-independent stack implemented as
+* a signly linked list class for C.  It's basically a template class, but
+* uses macros instead, so that it can be compiled with a C-only compiler.
+*
+* To define a Stack class:
+* #include "Stack.h"
+* TYPE_STACK_DEFINITION(object_type,Class_Identifier)
+*
+* In a separate C file:
+* #include "Stack.h"
+* TYPE_STACK_DEFINITION(object_type,Class_Identifier)
+* TYPE_STACK_IMPLEMENTATION(object_type,Class_Identifier)
+*
+* Now, to create a stack:
+* struct Class_Identifier_Stack name;
+* Get it initialized to zero everywhere somehow, maybe like this:
+* initialize_stack_Class_Identifier(&name);
+*
+* To add to the stack:
+* push_Class_Identifier(&name, object);
+*
+* To access the top of the stack:
+* Class_Identifier_Stack_Node *tos = name.top_ptr;
+* do_something_to_(tos->value);
+*
+* To delete from the stack:
+*   if (name.size > 0) pop_Class_Identifier(&name);
+*
+* Copyright (C) 2009-2015 Texas Instruments Incorporated - http://www.ti.com/
+*
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+*
+* Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the
+* distribution.
+*
+* Neither the name of Texas Instruments Incorporated nor the names of
+* its contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+
+#ifndef STACK_H
+#define STACK_H
+
+#include <inttypes.h>
+#include "dload_api.h"
+
+/*****************************************************************************/
+/* TYPE_STACK_DEFINITION() - Define structure specifications for a last-in,  */
+/*  first-out linked list of t_name objects.                             */
+/*****************************************************************************/
+#define TYPE_STACK_DEFINITION(t, t_name)                                      \
+struct t_name##_Stack_Node_                                                   \
+{                                                                             \
+     t value;                                                                 \
+     struct t_name##_Stack_Node_* next_ptr;                                   \
+};                                                                            \
+typedef struct t_name##_Stack_Node_ t_name##_Stack_Node;                      \
+                                                                              \
+typedef struct                                                                \
+{                                                                             \
+     t_name##_Stack_Node* top_ptr;                                            \
+     t_name##_Stack_Node* bottom_ptr;                                         \
+     int size;                                                                \
+} t_name##_Stack;                                                             \
+                                                                              \
+extern void t_name##_initialize_stack(t_name##_Stack* stack);                 \
+extern void t_name##_push(t_name##_Stack* stack, t to_push);                  \
+extern t    t_name##_pop(t_name##_Stack* stack);
+
+/*****************************************************************************/
+/* TYPE_STACK_DEFINITION() - Define the initializer to initalize Stacks.     */
+/*****************************************************************************/
+#define TYPE_STACK_INITIALIZER  {NULL, NULL, 0 }
+
+/*****************************************************************************/
+/* TYPE_STACK_IMPLEMENTATION() - Define member functions of new LIFO linked  */
+/*  list "class" of t_name objects.                                      */
+/*                                                                           */
+/* <type>_initialize_stack() - clears the stack                              */
+/* <type>_push() - pushes a <t> type object to the top of the stack          */
+/* <type>_pop() - pop a <t> type object from the top of the stack            */
+/*  and provide access to it to the caller                               */
+/*****************************************************************************/
+#define TYPE_STACK_IMPLEMENTATION(t, t_name)                                  \
+void t_name##_initialize_stack (t_name##_Stack* stack)                        \
+{                                                                             \
+     stack->top_ptr = stack->bottom_ptr = NULL;                               \
+     stack->size = 0;                                                         \
+}                                                                             \
+void t_name##_push(t_name##_Stack* stack, t to_push)                          \
+{                                                                             \
+     stack->size++;                                                           \
+                                                                              \
+     if(!stack->top_ptr)                                                      \
+     {                                                                        \
+      stack->bottom_ptr = stack->top_ptr =                                \
+        (t_name##_Stack_Node*)(DLIF_malloc(sizeof(t_name##_Stack_Node))); \
+          stack->top_ptr->next_ptr = NULL;                                    \
+     }                                                                        \
+     else                                                                     \
+     {                                                                        \
+          t_name##_Stack_Node* next_ptr = stack->top_ptr;                     \
+      stack->top_ptr =                                                    \
+        (t_name##_Stack_Node*)(DLIF_malloc(sizeof(t_name##_Stack_Node))); \
+      stack->top_ptr->next_ptr = next_ptr;                                \
+     }                                                                        \
+                                                                              \
+     stack->top_ptr->value = to_push;                                         \
+}                                                                             \
+                                                                              \
+t t_name##_pop(t_name##_Stack* stack)                                         \
+{                                                                             \
+     t to_ret;                                                                \
+     t_name##_Stack_Node* next_ptr = stack->top_ptr->next_ptr;                \
+                                                                              \
+     stack->size--;                                                           \
+     to_ret = stack->top_ptr->value;                                          \
+     DLIF_free((void*)(stack->top_ptr));                                      \
+                                                                              \
+     if(!stack->size)                                                         \
+      stack->top_ptr = stack->bottom_ptr = NULL;                          \
+     else                                                                     \
+      stack->top_ptr = next_ptr;                                          \
+                                                                              \
+     return to_ret;                                                           \
+}
+
+#endif
index 45ea19b1e5568483de76e62724c0eafed6a23222..c341c9abfc5f505ec1294f6f7ecb15f0f219b34e 100644 (file)
@@ -7,7 +7,7 @@
 * but it is object file format dependent.  In particular, this
 * implementation supports ELF object file format.
 *
-* Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
+* Copyright (C) 2009-2015 Texas Instruments Incorporated - http://www.ti.com/
 *
 *
 * Redistribution and use in source and binary forms, with or without
 *
 */
 
-#if defined (__KERNEL__)
-#include <linux/kernel.h>  // For INT_MAX
-#define INT16_MAX 0x7fff
-#define UINT16_MAX (__CONCAT(INT16_MAX, U) * 2U + 1U)
-#include <linux/types.h>   // For uintNN_t types
-#include <linux/string.h>  // For strc* fxns.
-#else
 #include <limits.h>
 #include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
-#endif
 
 #include "ArrayList.h"
 #include "Queue.h"
+#include "Stack.h"
 
 #include "symtab.h"
 #include "dload_endian.h"
 #include "c60_dynamic.h"
 #endif
 
-#undef LOADER_DEBUG
-#define LOADER_DEBUG 0
+#include "virtual_targets.h"
+
+/* #undef LOADER_DEBUG
+#define LOADER_DEBUG 0*/
+/*---------------------------------------------------------------------------*/
+/* These globals are used only to test the reference client implementation.  */
+/*---------------------------------------------------------------------------*/
+int global_argc;
+char **global_argv;
+
+/*---------------------------------------------------------------------------*/
+/* Contains filenames (type const char*) the system is in the process of     */
+/* loading.  Used to detect cycles in incorrectly compiled ELF binaries.     */
+/*---------------------------------------------------------------------------*/
+Array_List DLIMP_module_dependency_list;
+
 /*---------------------------------------------------------------------------*/
 /* Contains objects (type DLIMP_Loaded_Module) that the system has loaded into     */
 /* target memory.                                                            */
 /*---------------------------------------------------------------------------*/
 TYPE_QUEUE_IMPLEMENTATION(DLIMP_Loaded_Module*, loaded_module_ptr)
-
+loaded_module_ptr_Queue DLIMP_loaded_objects = TYPE_QUEUE_INITIALIZER;
 
 /*---------------------------------------------------------------------------*/
 /* Dependency Graph Queue - FIFO queue of dynamic modules that are loaded    */
@@ -89,6 +96,13 @@ TYPE_QUEUE_IMPLEMENTATION(DLIMP_Loaded_Module*, loaded_module_ptr)
 /* appear on this queue.                                                     */
 /*---------------------------------------------------------------------------*/
 TYPE_STACK_IMPLEMENTATION(DLIMP_Dynamic_Module*, dynamic_module_ptr)
+dynamic_module_ptr_Stack DLIMP_dependency_stack = TYPE_STACK_INITIALIZER;
+
+/*---------------------------------------------------------------------------*/
+/* Current virtual target set after reading the file headers. This is used   */
+/* to access target specific functions.                                      */
+/*---------------------------------------------------------------------------*/
+VIRTUAL_TARGET *cur_target = NULL;
 
 /*---------------------------------------------------------------------------*/
 /* Support for profiling performance of dynamic loader core.                 */
@@ -102,6 +116,23 @@ static clock_t cycle_end = 0;
 #endif
 
 /*---------------------------------------------------------------------------*/
+/* The dynamic loader will now create a table TI_init_table to store         */
+/* pre-init and init data. This is done because pre-init and                 */
+/* init functions could reference as-yet unrelocated symbols from other      */
+/* modules. As such it is safer to store relevant function addresses and     */
+/* execute them only after all modules are relocated.                        */
+/*---------------------------------------------------------------------------*/
+TYPE_QUEUE_IMPLEMENTATION(IF_single_record*, IF_table)
+IF_table_Queue TI_init_table = TYPE_QUEUE_INITIALIZER;
+
+static VIRTUAL_TARGET *get_vt_obj(int given_id);
+static void read_args_from_section(DLIMP_Loaded_Module* ep_module);
+static BOOL seg_has_space_for_write(DLIMP_Loaded_Module* lmodule, int sz);
+static BOOL write_arguments_to_args_section(DLOAD_HANDLE handle,
+                                            int argc, char** argv,
+                        DLIMP_Loaded_Module *ep_module);
+
+/*****************************************************************************/
 /* DLOAD_create()                                                            */
 /*                                                                           */
 /*    Create an instance of the dynamic loader core.                         */
@@ -111,8 +142,8 @@ static clock_t cycle_end = 0;
 /*                                                                           */
 /*    returns: an opaque DLOAD core loader handle, identifying this instance.*/
 /*                                                                           */
-/*---------------------------------------------------------------------------*/
-DLOAD_HANDLE  DLOAD_create(void * client_handle)
+/*****************************************************************************/
+DLOAD_HANDLE DLOAD_create(void *client_handle)
 {
     LOADER_OBJECT     * pLoaderObject;
 
@@ -134,8 +165,6 @@ DLOAD_HANDLE  DLOAD_create(void * client_handle)
 
         pLoaderObject->file_handle = 1;
 
-        pLoaderObject->DLOAD_TARGET_MACHINE = DLOAD_DEFAULT_TARGET_MACHINE;
-
         /* Store client token, so it can be handed back during DLIF calls */
         pLoaderObject->client_handle = client_handle;
     }
@@ -143,7 +172,7 @@ DLOAD_HANDLE  DLOAD_create(void * client_handle)
     return((DLOAD_HANDLE)pLoaderObject);
 }
 
-/*---------------------------------------------------------------------------*/
+/*****************************************************************************/
 /* DLOAD_destroy()                                                           */
 /*                                                                           */
 /*    Remove an instance of the dynamic loader core, and free all resources  */
@@ -154,7 +183,7 @@ DLOAD_HANDLE  DLOAD_create(void * client_handle)
 /*    Preconditions: 1) handle must be valid.                                */
 /*                   2) Loader instance must be in "UNLOADED" state.         */
 /*                                                                           */
-/*---------------------------------------------------------------------------*/
+/*****************************************************************************/
 void  DLOAD_destroy(DLOAD_HANDLE handle)
 {
     LOADER_OBJECT     * pLoaderObject;
@@ -163,7 +192,9 @@ void  DLOAD_destroy(DLOAD_HANDLE handle)
 
     AL_destroy(&(pLoaderObject->DLIMP_module_dependency_list));
 
+    /*--------------------------*/
     /* Free the instance object */
+    /*--------------------------*/
     DLIF_free (pLoaderObject);
 }
 
@@ -296,6 +327,185 @@ static int load_object(LOADER_FILE_DESC *fd, DLIMP_Dynamic_Module *dyn_module)
    return 1;
 }
 
+/*****************************************************************************/
+/* write_arguments_to_args_section()                                         */
+/*                                                                           */
+/*    Write argv and argc to .args section.                                  */
+/*                                                                           */
+/*****************************************************************************/
+static BOOL write_arguments_to_args_section(DLOAD_HANDLE handle,
+                                            int argc, char** argv,
+                                            DLIMP_Loaded_Module *ep_module)
+{
+   int mem_inc   = MEM_INC;
+   int ptr_sz    = PTR_SZ;
+   int p_size    = ptr_sz / mem_inc;
+   int i_size    = T_INTSZ / mem_inc;
+   int c_size    = T_CHARSZ /mem_inc;
+   int argv_offset = 0;
+   int str_offset  = 0;
+   int size        = 0;
+   int arg;
+   int *targ_argv_pointers = NULL;
+   LOADER_OBJECT *pHandle = (LOADER_OBJECT *)handle;
+
+   uint8_t *c_args = NULL;
+
+#if LOADER_DEBUG
+   if (debugging_on)
+      DLIF_trace("Write_arguments_to_args_section:\n");
+#endif
+
+   /*-----------------------------------------------------------------------*/
+   /* IF NO ARGUMENTS, ABORT QUIETLY, WITH a SUCCESSFUL CODE.               */
+   /*-----------------------------------------------------------------------*/
+   if (argc == 0) return TRUE;
+
+   /*-----------------------------------------------------------------------*/
+   /* __c_args__ points to the beginning of the .args section, if there     */
+   /* is one.  This is stored in the Loaded Module, and must have a         */
+   /* legitimate address. If not, abort with Warning.                       */
+   /*-----------------------------------------------------------------------*/
+   c_args = ep_module->c_args;
+   if (!c_args || c_args == (uint8_t *)0xFFFFFFFF)
+   {
+      DLIF_warning(DLWT_MISC, "__c_args__ does not have valid value.\n");
+      return FALSE;
+   }
+
+   /*-----------------------------------------------------------------------*/
+   /* WE OUGHT TO WORRY ABOUT ALIGNMENT: IF SECTION ISN'T PROPERLY ALIGNED, */
+   /* ABORT THE PROCESSING OF ARGUMENTS WITH A NICE ERROR MESSAGE.          */
+   /*-----------------------------------------------------------------------*/
+   if (c_args && ((Elf32_Addr)c_args & (MAX(p_size, i_size) - 1)))
+   {
+      DLIF_warning(DLWT_MISC, ".args section not properly aligned\n");
+      return FALSE;
+   }
+
+   /*-----------------------------------------------------------------------*/
+   /* CALCULATE OFFSET IN TABLE WHERE ARGV AND THE STRINGS WILL BE STORED.  */
+   /* NOTE THAT argv MAY NEED MORE ALIGNMENT THAN AN INTEGER, SO ITS OFFSET */
+   /* IS REALLY THE MAXIMUM OF A POINTER SIZE AND INTEGER SIZE.  ALSO NOTE  */
+   /* WE NEED TO ALLOCATE AN EXTRA POINTER FOR argv[argc].                  */
+   /*-----------------------------------------------------------------------*/
+   argv_offset = MAX(p_size, i_size);
+   str_offset  = argv_offset + (argc * p_size) + p_size ;
+
+   /*-----------------------------------------------------------------------*/
+   /* CALCULATE SPACE REQUIRED FOR WRITING OUT .args SECTION. CHECK IF THE  */
+   /* SEGMENT HAS ENOUGH SPACE AVAILABLE. IF NOT, RETURN WITH ERROR CODE.   */
+   /*-----------------------------------------------------------------------*/
+   size = str_offset;
+
+   for (arg = 0; arg < argc; arg++)
+        size += (c_size * (strlen(argv[arg]) + 1));
+
+   if (!seg_has_space_for_write(ep_module, size))
+   {
+      DLIF_warning(DLWT_MISC,
+                 "Segment has insufficient space for .args contents\n");
+      return FALSE;
+   }
+
+   /*-----------------------------------------------------------------------*/
+   /* OVERALL, WE NEED TO CREATE A TARGET IMAGE THAT CORRESPONDS TO:        */
+   /*     int argc;                                                         */
+   /*     char *argv[argc];                                                 */
+   /*     <strings pointed to by argv>                                      */
+   /* So say, for C6x, for "-v -d", we would need 22 bytes:                 */
+   /*     4 bytes // argc                                                   */
+   /*     4 bytes // argv[0] pointer value                                  */
+   /*     4 bytes // argv[1] pointer value                                  */
+   /*     4 bytes // argv[argc] end of pointer value array, normally 0      */
+   /*     3 bytes // "-v"                                                   */
+   /*     3 bytes // "-d"                                                   */
+   /*-----------------------------------------------------------------------*/
+
+   /*-----------------------------------------------------------------------*/
+   /* FIRST WRITE OUT ARGC.                                                 */
+   /*-----------------------------------------------------------------------*/
+#if LOADER_DEBUG
+   if (debugging_on)
+      DLIF_trace ("-- Copy %d bytes from 0x%x to 0x%x\n",
+                  i_size, (uint32_t) &argc, (uint32_t) c_args);
+#endif
+
+   DLIF_memcpy(pHandle->client_handle, c_args, &argc, i_size);
+
+   /*-----------------------------------------------------------------------*/
+   /* CREATE AN INTERNAL ARRAY OF ARGV POINTER VALUES, THEN WRITE THEM OUT  */
+   /*-----------------------------------------------------------------------*/
+   targ_argv_pointers = (int *)DLIF_malloc((argc + 1) * sizeof(int));
+   for (arg = 0; arg < argc ; arg++)
+   {
+       targ_argv_pointers[arg] = (int)(str_offset + c_args);
+       str_offset += (strlen(argv[arg]) + 1) * c_size;
+
+#if LOADER_DEBUG
+   if (debugging_on)
+       DLIF_trace ("\t\ttarg_argv_pointers[%d] : 0x%x\n",
+                   arg, targ_argv_pointers[arg]);
+#endif
+   }
+
+   targ_argv_pointers[argc] = 0;
+
+   /*-----------------------------------------------------------------------*/
+   /* WRITE OUT THIS INTERNAL ARRAY OF ARGV POINTER VALUES                  */
+   /*-----------------------------------------------------------------------*/
+   for (arg = 0; arg <= argc; arg++)
+   {
+#if LOADER_DEBUG
+   if (debugging_on)
+       DLIF_trace ("-- Copy %d bytes from 0x%x to 0x%x\n",
+                   p_size, (uint32_t) &targ_argv_pointers[arg],
+                   (uint32_t) (c_args + argv_offset));
+#endif
+       DLIF_memcpy(pHandle->client_handle,
+                   (void *)(c_args + argv_offset),
+                   &targ_argv_pointers[arg],
+           p_size);
+       argv_offset += p_size;
+   }
+
+#if LOADER_DEBUG
+if (debugging_on)
+{
+   DLIF_trace ("\t\targv being copied : 0x%x\n",(uint32_t)argv);
+   for (arg = 0; arg < argc; arg++)
+   {
+       DLIF_trace ("\t\t---\n\t\t&argv[%d] being copied : 0x%x\n", arg,
+                   (uint32_t)&argv[arg]);
+       DLIF_trace ("\t\targv[%d] being copied : 0x%x\n",arg,
+                   (uint32_t)argv[arg]);
+       DLIF_trace ("\t\targv[%d] being copied : %s\n",arg, (char *)argv[arg]);
+   }
+}
+#endif
+
+   /*-----------------------------------------------------------------------*/
+   /* LASTLY WRITE OUT ALL THE STRINGS.                                     */
+   /*-----------------------------------------------------------------------*/
+   for (arg = 0; arg < argc; arg++)
+   {
+#if LOADER_DEBUG
+   if (debugging_on)
+      DLIF_trace ("-- Copy %d bytes from 0x%x to 0x%x\n",
+                  (uint32_t)strlen(argv[arg]) + 1,
+                  (uint32_t)&argv[arg],
+                  (uint32_t)(targ_argv_pointers[arg]));
+#endif
+      DLIF_memcpy(pHandle->client_handle,
+                  (void *)(targ_argv_pointers[arg]),
+                  argv[arg],
+                  strlen(argv[arg]) + 1);
+   }
+
+  return TRUE;
+}
+
+
 /*****************************************************************************/
 /* initialize_loaded_module()                                                */
 /*                                                                           */
@@ -346,21 +556,27 @@ static void initialize_loaded_module(DLOAD_HANDLE handle,
    }
 #endif
 
-   loaded_module->name = DLIF_malloc(strlen(dyn_module->name) + 1);
-   if (NULL == loaded_module->name) {
-      DLIF_error(DLET_MISC, "Error allocating memory %d...\n",__LINE__);
-      return;
+   if (dyn_module->name)
+   {
+      loaded_module->name = DLIF_malloc(strlen(dyn_module->name) + 1);
+      if (NULL == loaded_module->name) {
+          DLIF_error(DLET_MISC, "Error allocating memory %d...\n",__LINE__);
+          return;
+      }
+      strcpy(loaded_module->name, dyn_module->name);
    }
-   strcpy(loaded_module->name, dyn_module->name);
+   else
+      loaded_module->name = "<unknown>";
 
-    loaded_module->file_handle = pHandle->file_handle++;
+   loaded_module->file_handle = pHandle->file_handle++;
    loaded_module->direct_dependent_only = dyn_module->direct_dependent_only;
    loaded_module->use_count = 1;
+   loaded_module->c_args = 0;
 
    /*------------------------------------------------------------------------*/
    /* In case we wrapped around the file handle, return error.               */
    /*------------------------------------------------------------------------*/
-    if (pHandle->file_handle == 0)
+   if (pHandle->file_handle == 0)
       DLIF_error(DLET_MISC, "DLOAD File handle overflowed.\n");
 
    /*------------------------------------------------------------------------*/
@@ -413,47 +629,9 @@ static void initialize_loaded_module(DLOAD_HANDLE handle,
          }
          seg.phdr.p_align = dyn_module->phdr[i].p_align;
          seg.phdr.p_flags = dyn_module->phdr[i].p_flags;
-         seg.input_vaddr = 0;
-         seg.phdr.p_paddr = 0;
-         seg.phdr.p_type = PT_LOAD;
-         seg.reloc_offset = 0;
          AL_append(&(loaded_module->loaded_segments), &seg);
       }
 
-   /*------------------------------------------------------------------------*/
-   /* Initialize the module sections Array_List.                             */
-   /*------------------------------------------------------------------------*/
-   AL_initialize(&(loaded_module->sections),
-                 sizeof(DLIMP_Section_Info), dyn_module->shnum);
-
-   /*------------------------------------------------------------------------*/
-   /* Spin thru section headers and process each section encountered.   */
-   /*------------------------------------------------------------------------*/
-   for (i = 0; i < dyn_module->shnum; i++) {
-         /*------------------------------------------------------------------*/
-         /* Note that this is parallel to and does not supplant the ELF      */
-         /* shdr tables.                                                     */
-         /*------------------------------------------------------------------*/
-         DLIMP_Section_Info sect;
-         sect.shdr.sh_name = dyn_module->shdr[i].sh_name;
-         sect.sh_name = (char *)(sect.shdr.sh_name + (Elf32_Word) dyn_module->shstrtab);
-         sect.shdr.sh_type = dyn_module->shdr[i].sh_type;
-         sect.shdr.sh_flags = dyn_module->shdr[i].sh_flags;
-         sect.shdr.sh_addr = dyn_module->shdr[i].sh_addr;
-         sect.shdr.sh_offset = dyn_module->shdr[i].sh_offset;
-         sect.shdr.sh_size = dyn_module->shdr[i].sh_size;
-         sect.shdr.sh_link = dyn_module->shdr[i].sh_link;
-         sect.shdr.sh_info = dyn_module->shdr[i].sh_info;
-         sect.shdr.sh_addralign = dyn_module->shdr[i].sh_addralign;
-         sect.shdr.sh_entsize = dyn_module->shdr[i].sh_entsize;
-#if LOADER_DEBUG
-         if (debugging_on) {
-            DLIF_trace("Found section name %s @ addr 0x%08x\n", sect.sh_name ? : "(no name)", sect.shdr.sh_addr);
-         }
-#endif
-         AL_append(&(loaded_module->sections), &sect);
-   }
-
    /*------------------------------------------------------------------------*/
    /* Initialize the DSO termination information for this module.            */
    /* It will be copied over from the enclosing dyn_module object when       */
@@ -471,7 +649,8 @@ static void initialize_loaded_module(DLOAD_HANDLE handle,
       if (profiling_on)
       {
          profile_stop_clock();
-         DLIF_trace("Took %d cycles.\n", (int32_t)profile_cycle_count());
+         DLIF_trace("Took %lu cycles.\n",
+                (unsigned long)profile_cycle_count());
       }
    }
 #endif
@@ -572,17 +751,7 @@ static BOOL load_static_segment(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd,
 static BOOL relocate_target_dynamic_tag_info(DLIMP_Dynamic_Module *dyn_module,
                                              int i)
 {
-#ifdef ARM_TARGET
-   if (is_arm_module(&dyn_module->fhdr))
-       return DLDYN_arm_relocate_dynamic_tag_info(dyn_module, i);
-#endif
-
-#ifdef C60_TARGET
-   if (is_c60_module(&dyn_module->fhdr))
-      return DLDYN_c60_relocate_dynamic_tag_info(dyn_module, i);
-#endif
-
-   return FALSE;
+   return cur_target->relocate_dynamic_tag_info(dyn_module, i);
 }
 
 /*****************************************************************************/
@@ -600,6 +769,14 @@ BOOL DLIMP_update_dyntag_section_address(DLIMP_Dynamic_Module *dyn_module,
    int j;
    DLIMP_Loaded_Segment *seg = (DLIMP_Loaded_Segment *)
                               (dyn_module->loaded_module->loaded_segments.buf);
+
+   /*------------------------------------------------------------------------*/
+   /* If dynamic tag does not access an existing section, then no update     */
+   /* is required.                                                           */
+   /*------------------------------------------------------------------------*/
+   if (dyn_module->dyntab[i].d_un.d_ptr == (Elf32_Addr)0)
+      { return TRUE; }
+
    for (j = 0; j < dyn_module->loaded_module->loaded_segments.size; j++)
    {
       if ((dyn_module->dyntab[i].d_un.d_ptr >= seg[j].input_vaddr) &&
@@ -773,7 +950,8 @@ static BOOL allocate_dynamic_segments_and_relocate_symbols
    if (debugging_on || profiling_on)
    {
       DLIF_trace("Dynamic executable found.\n"
-             "Starting allocate_dynamic_segments_and_relocate_symbols() ...\n");
+                 "Starting allocate_dynamic_segments_and_relocate_symbols()"
+                 "...\n");
       if (profiling_on) profile_start_clock();
    }
 #endif
@@ -800,10 +978,6 @@ static BOOL allocate_dynamic_segments_and_relocate_symbols
       targ_req.offset = seg[i].phdr.p_offset;
       targ_req.flip_endian = dyn_module->wrong_endian;
 
-#if LOADER_DEBUG
-        if (debugging_on)
-            DLIF_trace("Segment %d flags 0x%x\n", i, targ_req.flags);
-#endif
       if (!DLIF_allocate(pHandle->client_handle, &targ_req))
       {
          DLIF_error(DLET_MEMORY, "DLIF allocation failure.\n");
@@ -834,8 +1008,9 @@ static BOOL allocate_dynamic_segments_and_relocate_symbols
       /*--------------------------------------------------------------------*/
       if (dyn_module->relocate_entry_point &&
           fhdr->e_entry >= (Elf32_Addr)(seg[i].phdr.p_vaddr) &&
-          fhdr->e_entry < (Elf32_Addr)((uint8_t*)(seg[i].phdr.p_vaddr) +
-                                       (uint32_t)(seg[i].phdr.p_memsz)))
+          fhdr->e_entry <
+            (Elf32_Addr)((uint8_t*)(seg[i].phdr.p_vaddr) +
+                                             (uint32_t)(seg[i].phdr.p_memsz)))
       {
 #if LOADER_DEBUG
          if (debugging_on)
@@ -931,11 +1106,11 @@ static BOOL allocate_dynamic_segments_and_relocate_symbols
 #if LOADER_DEBUG && LOADER_PROFILE
    if (debugging_on || profiling_on)
    {
-      DLIF_trace("allocate_dynamic_segments_and_relocate_symbols() Done\n");
+      DLIF_trace("Finished allocate_dynamic_segments_and_relocate_symbols()\n");
       if (profiling_on)
       {
          profile_stop_clock();
-         DLIF_trace("Took %d cycles.\n", (int)profile_cycle_count());
+         DLIF_trace("Took %lu cycles.\n", (unsigned long) profile_cycle_count());
       }
    }
 #endif
@@ -987,7 +1162,6 @@ static void delete_DLIMP_Loaded_Module(DLOAD_HANDLE handle,
     loaded_module->gsymnum = 0;
     if (loaded_module->gstrtab) DLIF_free(loaded_module->gstrtab);
     loaded_module->gstrsz = 0;
-    AL_destroy(&(loaded_module->sections));
     AL_destroy(&(loaded_module->loaded_segments));
     AL_destroy(&(loaded_module->dependencies));
 
@@ -1024,8 +1198,6 @@ static DLIMP_Dynamic_Module *new_DLIMP_Dynamic_Module(LOADER_FILE_DESC *fd)
     dyn_module->fd = fd;
     dyn_module->phdr = NULL;
     dyn_module->phnum = 0;
-    dyn_module->shdr = NULL;
-    dyn_module->shnum = 0;
     dyn_module->strtab = NULL;
     dyn_module->strsz = 0;
     dyn_module->dyntab = NULL;
@@ -1067,7 +1239,8 @@ static DLIMP_Dynamic_Module *new_DLIMP_Dynamic_Module(LOADER_FILE_DESC *fd)
 /*    be released as part of the destruction of the dynamic module.          */
 /*                                                                           */
 /*****************************************************************************/
-static DLIMP_Loaded_Module *detach_loaded_module(DLIMP_Dynamic_Module *dyn_module)
+static
+DLIMP_Loaded_Module *detach_loaded_module(DLIMP_Dynamic_Module *dyn_module)
 {
     if (dyn_module && dyn_module->loaded_module)
     {
@@ -1095,9 +1268,7 @@ static void delete_DLIMP_Dynamic_Module(DLOAD_HANDLE handle,
       DLIF_error(DLET_MISC,
                  "Internal Error: invalid argument to dynamic module "
          "destructor function; aborting loader\n");
-#if !defined (__KERNEL__)
-      exit(1);
-#endif
+      DLIF_exit(1);
    }
 
    dyn_module = *ppdm;
@@ -1105,9 +1276,7 @@ static void delete_DLIMP_Dynamic_Module(DLOAD_HANDLE handle,
    if (dyn_module->strtab)   DLIF_free(dyn_module->strtab);
    if (dyn_module->symtab)   DLIF_free(dyn_module->symtab);
    if (dyn_module->phdr)     DLIF_free(dyn_module->phdr);
-   if (dyn_module->shdr)     DLIF_free(dyn_module->shdr);
    if (dyn_module->dyntab)   DLIF_free(dyn_module->dyntab);
-   if (dyn_module->shstrtab) DLIF_free(dyn_module->shstrtab);
 
    /*------------------------------------------------------------------------*/
    /* If we left the loaded module attached to the dynamic module, then      */
@@ -1159,17 +1328,22 @@ static BOOL file_header_magic_number_is_valid(struct Elf32_Ehdr* header)
 /*    the machine will be initially set to EM_NONE.  Once a module has been  */
 /*    loaded, all remaining modules must have the same machine value.        */
 /*****************************************************************************/
-static BOOL file_header_machine_is_valid(DLOAD_HANDLE handle, Elf32_Half e_machine)
+static int file_header_machine_is_valid(Elf32_Half e_machine)
 {
-    LOADER_OBJECT *pHandle = (LOADER_OBJECT *)handle;
-
-    if (pHandle->DLOAD_TARGET_MACHINE == EM_NONE)
-        pHandle->DLOAD_TARGET_MACHINE = e_machine;
-
-    if (e_machine != pHandle->DLOAD_TARGET_MACHINE)
-      return FALSE;
+   /*------------------------------------------------------------------------*/
+   /* Currently we support only ARM or C6x                                   */
+   /*------------------------------------------------------------------------*/
+   switch(e_machine)
+   {
+#ifdef ARM_TARGET
+      case EM_ARM :      return TRUE;
+#endif
+#ifdef C60_TARGET
+      case EM_TI_C6000 : return TRUE;
+#endif
 
-   return TRUE;
+      default :          return FALSE;
+   }
 }
 
 /*****************************************************************************/
@@ -1260,17 +1434,7 @@ static BOOL is_valid_elf_object_file(LOADER_FILE_DESC *fd,
 /*****************************************************************************/
 static BOOL process_eiosabi(DLIMP_Dynamic_Module* dyn_module)
 {
-#ifdef ARM_TARGET
-   if (is_arm_module(&dyn_module->fhdr))
-      return DLDYN_arm_process_eiosabi(dyn_module);
-#endif
-
-#ifdef C60_TARGET
-   if (is_c60_module(&dyn_module->fhdr))
-      return DLDYN_c60_process_eiosabi(dyn_module);
-#endif
-
-   return FALSE;
+   return cur_target->process_eiosabi(dyn_module);
 }
 /*****************************************************************************/
 /* dload_file_header()                                                       */
@@ -1279,7 +1443,7 @@ static BOOL process_eiosabi(DLIMP_Dynamic_Module* dyn_module)
 /*    DLIMP_Dynamic_Module record.  Check file header for validity.          */
 /*                                                                           */
 /*****************************************************************************/
-static BOOL dload_file_header(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd,
+static BOOL dload_file_header(LOADER_FILE_DESC *fd,
                               DLIMP_Dynamic_Module *dyn_module)
 {
    /*------------------------------------------------------------------------*/
@@ -1301,15 +1465,13 @@ static BOOL dload_file_header(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd,
       DLIMP_change_ehdr_endian(&(dyn_module->fhdr));
 
 #if LOADER_DEBUG
-   if (debugging_on) {
-      /*---------------------------------------------------------------------*/
-      /* Write out magic ELF information for debug purposes.                 */
-      /*---------------------------------------------------------------------*/
-      DLIF_trace("ELF: %c%c%c\n", dyn_module->fhdr.e_ident[1],
-                              dyn_module->fhdr.e_ident[2],
-                              dyn_module->fhdr.e_ident[3]);
-      DLIF_trace("ELF file header entry point: %x\n",
-                 dyn_module->fhdr.e_entry);
+   if (debugging_on)
+   {
+       DLIF_trace("ELF: %c%c%c\n", dyn_module->fhdr.e_ident[1],
+                               dyn_module->fhdr.e_ident[2],
+                               dyn_module->fhdr.e_ident[3]);
+       DLIF_trace("ELF file header entry point: %x\n",
+                               dyn_module->fhdr.e_entry);
    }
 #endif
 
@@ -1322,7 +1484,7 @@ static BOOL dload_file_header(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd,
       return FALSE;
    }
 
-   if (!file_header_machine_is_valid(handle, dyn_module->fhdr.e_machine))
+   if (!file_header_machine_is_valid(dyn_module->fhdr.e_machine))
    {
        DLIF_error(DLET_FILE, "Invalid ELF file target machine.\n");
        return FALSE;
@@ -1350,7 +1512,8 @@ static BOOL dload_file_header(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd,
       if (profiling_on)
       {
          profile_stop_clock();
-         DLIF_trace("Took %d cycles.\n", (int)profile_cycle_count());
+         DLIF_trace("Took %lu cycles.\n",
+                (unsigned long)profile_cycle_count());
          profile_start_clock();
       }
    }
@@ -1393,39 +1556,7 @@ static void dload_program_header_table(LOADER_FILE_DESC *fd,
    }
 }
 
-/*****************************************************************************/
-/* dload_section_header_table()                                              */
-/*                                                                           */
-/*    Make a local copy of the ELF object file's section header table in the */
-/*    dynamic module data structure.                                         */
-/*                                                                           */
-/*****************************************************************************/
-static void dload_section_header_table(LOADER_FILE_DESC *fd,
-                                       DLIMP_Dynamic_Module *dyn_module)
-{
-   /*------------------------------------------------------------------------*/
-   /* Read the section header tables from the object file.                   */
-   /*------------------------------------------------------------------------*/
-   struct Elf32_Ehdr *fhdr = &(dyn_module->fhdr);
-   dyn_module->shdr = (struct Elf32_Shdr*)
-                              (DLIF_malloc(fhdr->e_shnum * fhdr->e_shentsize));
-   DLIF_fseek(fd, fhdr->e_shoff, LOADER_SEEK_SET);
-   if(dyn_module->shdr) {
-      DLIF_fread(dyn_module->shdr, fhdr->e_shentsize, fhdr->e_shnum,fd);
-      dyn_module->shnum = fhdr->e_shnum;
 
-      /*---------------------------------------------------------------------*/
-      /* Byte swap the section header tables if the target endian-ness is not*/
-      /* the same as the host endian-ness.                                   */
-      /*---------------------------------------------------------------------*/
-      if (dyn_module->wrong_endian)
-      {
-         int i;
-         for (i = 0; i < dyn_module->shnum; i++)
-            DLIMP_change_shdr_endian(dyn_module->shdr + i);
-      }
-   }
-}
 
 /*****************************************************************************/
 /* dload_headers()                                                           */
@@ -1439,7 +1570,7 @@ static void dload_section_header_table(LOADER_FILE_DESC *fd,
 /*    provide some assurance that the file is not corrupted.                 */
 /*                                                                           */
 /*****************************************************************************/
-static BOOL dload_headers(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd,
+static BOOL dload_headers(LOADER_FILE_DESC *fd,
                           DLIMP_Dynamic_Module *dyn_module)
 {
 #if LOADER_DEBUG && LOADER_PROFILE
@@ -1457,7 +1588,7 @@ static BOOL dload_headers(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd,
    /* Read file header information and check vs. expected ELF object file    */
    /* header content.                                                        */
    /*------------------------------------------------------------------------*/
-    if (!dload_file_header(handle, fd, dyn_module))
+   if (!dload_file_header(fd, dyn_module))
       return FALSE;
 
    /*------------------------------------------------------------------------*/
@@ -1466,73 +1597,14 @@ static BOOL dload_headers(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd,
    dload_program_header_table(fd, dyn_module);
 
    /*------------------------------------------------------------------------*/
-   /* Read section header table information into the dynamic module object.  */
-   /*------------------------------------------------------------------------*/
-   dload_section_header_table(fd, dyn_module);
-
-   return TRUE;
-}
-
-/*****************************************************************************/
-/* process_section_table()                                                   */
-/*                                                                           */
-/*    Process section tag entries from the section table.  At the conclusion */
-/*    of this function, we should have made a copy of the global symbols     */
-/*    and the global symbol names.                                           */
-/*                                                                           */
-/*****************************************************************************/
-static BOOL process_section_table(LOADER_FILE_DESC *fd,
-                                  DLIMP_Dynamic_Module *dyn_module)
-{
-   int        i;
-   Elf32_Addr shstrtab_offset = 0;
-
-   /*------------------------------------------------------------------------*/
-   /* Iterate over the section table in order to find the string table info.       */
-   /*------------------------------------------------------------------------*/
-   for (i = 0; i < dyn_module->shnum; i++)
-   {
-      switch(dyn_module->shdr[i].sh_type)
-      {
-         /*------------------------------------------------------------------*/
-         /* SHT_STRTAB: Contains the section information of the string table.  The    */
-         /*------------------------------------------------------------------*/
-         case SHT_STRTAB:
-            if (i == dyn_module->fhdr.e_shstrndx) {
-               dyn_module->shstrsz = dyn_module->shdr[i].sh_size;
-               shstrtab_offset = dyn_module->shdr[i].sh_offset;
-#if LOADER_DEBUG
-               if (debugging_on)
-                  DLIF_trace("Found string table Size: [0x%x]\n", dyn_module->shstrsz);
-#endif
-            }
-            break;
-
-         /*------------------------------------------------------------------*/
-         /* Unrecognized tag, may not be illegal, but is not explicitly      */
-         /* handled by this function.  Should it be?                         */
-         /*------------------------------------------------------------------*/
-         default:
-         {
-            break;
-         }
-
-      }
-   }
-
-   /*------------------------------------------------------------------------*/
-   /* If string table offset and size were found, read string table in from  */
-   /* the ELF object file.                                                   */
+   /* Once headers have been read in, use e_machine to set virtual target.   */
+   /* This can then be used to access target specific functions.             */
    /*------------------------------------------------------------------------*/
-   if (shstrtab_offset && dyn_module->shstrsz)
+   cur_target = get_vt_obj(dyn_module->fhdr.e_machine);
+   if (!cur_target)
    {
-      DLIF_fseek(fd, shstrtab_offset, LOADER_SEEK_SET);
-      dyn_module->shstrtab = DLIF_malloc(dyn_module->shstrsz);
-      DLIF_fread(dyn_module->shstrtab, sizeof(uint8_t), dyn_module->shstrsz, fd);
-   }
-   else
-   {
-      DLIF_warning(DLWT_MISC, "Mandatory string section SHT_STRTAB not found!\n");
+      DLIF_error(DLET_FILE, "Attempt to load invalid ELF file, '%s'.\n",
+                    dyn_module->name);
       return FALSE;
    }
 
@@ -1563,9 +1635,7 @@ static BOOL find_dynamic_segment(DLIMP_Dynamic_Module *dyn_module,
    {
       DLIF_error(DLET_MISC, "Internal error: find_dynamic_segment() needs "
                             "non-NULL arguments.\n");
-#if !defined (__KERNEL__)
-      exit(1);
-#endif
+      DLIF_exit(1);
    }
 
    /*------------------------------------------------------------------------*/
@@ -1581,12 +1651,7 @@ static BOOL find_dynamic_segment(DLIMP_Dynamic_Module *dyn_module,
    /* and warn the user.                                                     */
    /*------------------------------------------------------------------------*/
    dyn_module->relocatable = FALSE;
-#if LOADER_DEBUG
-   if (debugging_on)
-      DLIF_warning("'%s' does not have a dynamic segment; assuming "
-                   "that it is a static executable and it cannot "
-                   "be relocated.\n", dyn_module->name ? : "");
-#endif
+
    return FALSE;
 }
 
@@ -1608,8 +1673,7 @@ static void copy_dynamic_table(LOADER_FILE_DESC *fd,
    /*------------------------------------------------------------------------*/
    Elf32_Word num_elem;
    dyn_module->dyntab = DLIF_malloc(dyn_module->phdr[dyn_seg_idx].p_filesz);
-   num_elem =
-        dyn_module->phdr[dyn_seg_idx].p_filesz / sizeof(struct Elf32_Dyn);
+   num_elem = dyn_module->phdr[dyn_seg_idx].p_filesz / sizeof(struct Elf32_Dyn);
    DLIF_fseek(fd, dyn_module->phdr[dyn_seg_idx].p_offset, LOADER_SEEK_SET);
    if(dyn_module->dyntab) {
       DLIF_fread(dyn_module->dyntab, sizeof(struct Elf32_Dyn), num_elem, fd);
@@ -1634,17 +1698,7 @@ static void copy_dynamic_table(LOADER_FILE_DESC *fd,
 /*****************************************************************************/
 static BOOL process_target_dynamic_tag(DLIMP_Dynamic_Module* dyn_module, int i)
 {
-#ifdef ARM_TARGET
-   if (is_arm_module(&dyn_module->fhdr))
-       return DLDYN_arm_process_dynamic_tag(dyn_module, i);
-#endif
-
-#ifdef C60_TARGET
-   if (is_c60_module(&dyn_module->fhdr))
-      return DLDYN_c60_process_dynamic_tag(dyn_module, i);
-#endif
-
-   return FALSE;
+   return cur_target->process_dynamic_tag(dyn_module, i);
 }
 
 /*****************************************************************************/
@@ -1880,8 +1934,7 @@ static BOOL process_dynamic_table(LOADER_FILE_DESC *fd,
    }
    else
    {
-      DLIF_warning(DLWT_MISC,
-                   "Mandatory dynamic tag DT_HASH is not found!\n");
+      DLIF_warning(DLWT_MISC, "Mandatory dynamic tag DT_HASH is not found!\n");
       return FALSE;
    }
 
@@ -2070,20 +2123,13 @@ static BOOL dload_dynamic_segment(DLOAD_HANDLE handle,
 /*   Copy all segments into host memory.                                     */
 /*****************************************************************************/
 static void copy_segments(DLOAD_HANDLE handle, LOADER_FILE_DESC* fp,
-                          DLIMP_Dynamic_Module* dyn_module, int* data)
+                          DLIMP_Dynamic_Module* dyn_module)
 {
-    LOADER_OBJECT *pHandle = (LOADER_OBJECT *)handle;
    DLIMP_Loaded_Segment* seg =
       (DLIMP_Loaded_Segment*)(dyn_module->loaded_module->loaded_segments.buf);
    int s, seg_size = dyn_module->loaded_module->loaded_segments.size;
-   void **va = DLIF_malloc(seg_size * sizeof(void*));
+   LOADER_OBJECT *pHandle = (LOADER_OBJECT *)handle;
 
-   if (!va) {
-      DLIF_error(DLET_MISC, "Failed to allocate va in copy_segments.\n");
-      return;
-   }
-   else
-      *data = (int)va;
 
    for (s=0; s<seg_size; s++)
    {
@@ -2100,15 +2146,8 @@ static void copy_segments(DLOAD_HANDLE handle, LOADER_FILE_DESC* fp,
       /* Copy segment data from the file into host buffer where it can       */
       /* be relocated.                                                       */
       /*---------------------------------------------------------------------*/
-        DLIF_copy(pHandle->client_handle, &targ_req);
-
-      va[s] = targ_req.host_address;
-
-      /*---------------------------------------------------------------------*/
-      /* Calculate offset for relocations.                                   */
-      /*---------------------------------------------------------------------*/
-      seg[s].reloc_offset = (int32_t)(targ_req.host_address) -
-                            (int32_t)(seg[s].obj_desc->target_address);
+      DLIF_copy(pHandle->client_handle, &targ_req);
+      seg[s].host_address = targ_req.host_address;
    }
 }
 
@@ -2117,20 +2156,14 @@ static void copy_segments(DLOAD_HANDLE handle, LOADER_FILE_DESC* fp,
 /*                                                                           */
 /*   Write all segments to target memory.                                    */
 /*****************************************************************************/
-static void write_segments(DLOAD_HANDLE handle, LOADER_FILE_DESC* fp,
-                          DLIMP_Dynamic_Module* dyn_module, int* data)
+static void write_segments(DLOAD_HANDLE handle,
+                          LOADER_FILE_DESC* fp,
+                          DLIMP_Dynamic_Module* dyn_module)
 {
-    LOADER_OBJECT *pHandle = (LOADER_OBJECT *)handle;
+   LOADER_OBJECT *pHandle = (LOADER_OBJECT *)handle;
    DLIMP_Loaded_Segment* seg =
       (DLIMP_Loaded_Segment*)(dyn_module->loaded_module->loaded_segments.buf);
    int s, seg_size = dyn_module->loaded_module->loaded_segments.size;
-   void **va = (void *)*data;
-
-   if (!va) {
-      DLIF_error(DLET_MISC, "Invalid host virtual address array passed into"
-                 "write_segments.\n");
-      return;
-   }
 
    for (s=0; s<seg_size; s++)
    {
@@ -2142,47 +2175,79 @@ static void write_segments(DLOAD_HANDLE handle, LOADER_FILE_DESC* fp,
       if (seg[s].phdr.p_flags & PF_X)
          seg[s].phdr.p_flags |= DLOAD_SF_executable;
       targ_req.align = seg[s].phdr.p_align;
-      targ_req.host_address = va[s];
+      targ_req.host_address = seg[s].host_address;
 
       /*---------------------------------------------------------------------*/
       /* Copy segment data from the file into host buffer where it can       */
       /* be relocated.                                                       */
       /*---------------------------------------------------------------------*/
-        DLIF_write(pHandle->client_handle, &targ_req);
+      DLIF_write(pHandle->client_handle, &targ_req);
    }
-
-   DLIF_free(va);
 }
 
 /*****************************************************************************/
-/* DLOAD_initialize()                                                        */
-/*                                                                           */
-/*    Construct and initialize data structures internal to the dynamic       */
-/*    loader core.                                                           */
-/*                                                                           */
-/*---------------------------------------------------------------------------*/
-/*                                                                           */
-/*    This implementation of DLOAD_initialize() will set up the list of      */
-/*    dependency modules maintained by the loader core.  This list contains  */
-/*    the names of the files that the loader is in the process of loading.   */
-/*    The list is used to keep track of what objects are waiting on their    */
-/*    dependents to be loaded so thath circular dependencies can be detected */
-/*    and reported by the core loader.                                       */
+/* SEG_HAS_SPACE_FOR_WRITE() -                                               */
 /*                                                                           */
+/*   Check if segment has enough space to recieve contents of .args section. */
 /*****************************************************************************/
-void DLOAD_initialize(DLOAD_HANDLE handle)
+static BOOL seg_has_space_for_write(DLIMP_Loaded_Module* lmodule, int sz)
 {
-     LOADER_OBJECT *pHandle = (LOADER_OBJECT *)handle;
+   DLIMP_Loaded_Segment* seg =
+                  (DLIMP_Loaded_Segment*)(lmodule->loaded_segments.buf);
+   int s, seg_size = lmodule->loaded_segments.size;
 
-   /*------------------------------------------------------------------------*/
-   /* Set up initial objects_loading queue.                                  */
-   /*------------------------------------------------------------------------*/
-    AL_initialize(&pHandle->DLIMP_module_dependency_list,
-                  sizeof (const char*), 1);
-}
+   Elf32_Addr write_address = (Elf32_Addr)lmodule->c_args;
 
+   for (s=0; s<seg_size; s++)
+   {
+      Elf32_Addr seg_boundary =
+            seg[s].phdr.p_vaddr + seg[s].obj_desc->memsz_in_bytes;
 
-/*****************************************************************************/
+      /*---------------------------------------------------------------------*/
+      /* If address to write to is greater than segment addr and less than   */
+      /* segment end, it must lie in current segment.                        */
+      /*---------------------------------------------------------------------*/
+      if ((write_address >= seg[s].phdr.p_vaddr) &&
+          (write_address < seg_boundary))
+      {
+         if ((write_address + sz) > seg_boundary)
+         {
+#if LOADER_DEBUG
+        if (debugging_on)
+        {
+           DLIF_trace("Write requires 0x%x bytes\n",write_address + sz);
+           DLIF_trace("Seg boundary at : 0x%x\n",seg_boundary);
+           DLIF_trace("WARNING - Not enough space in segment\n");
+        }
+#endif
+            return FALSE;
+         }
+         else return TRUE;
+      }
+   }
+   /*------------------------------------------------------------------------*/
+   /* Given address doesn't belong to any known segment.                     */
+   /*------------------------------------------------------------------------*/
+   return FALSE;
+}
+
+/*****************************************************************************/
+/* DLOAD_initialize()                                                        */
+/*                                                                           */
+/*    Construct and initialize data structures internal to the dynamic       */
+/*    loader core.                                                           */
+/*                                                                           */
+/*---------------------------------------------------------------------------*/
+/*                                                                           */
+/*    This function is deprecated, replaced by DLOAD_create().               */
+/*                                                                           */
+/*****************************************************************************/
+void DLOAD_initialize(DLOAD_HANDLE handle)
+{
+}
+
+
+/*****************************************************************************/
 /* DLOAD_finalize()                                                          */
 /*                                                                           */
 /*    Destroy and finalize data structures internal to the dynamic           */
@@ -2190,19 +2255,11 @@ void DLOAD_initialize(DLOAD_HANDLE handle)
 /*                                                                           */
 /*---------------------------------------------------------------------------*/
 /*                                                                           */
-/*    This implementation of DLOAD_finalize() will destroy the list of       */
-/*    dependency modules maintained by the loader core that is created       */
-/*    during DLOAD_initialize().                                             */
+/*    This function is deprecated, replaced by DLOAD_destroy().              */
 /*                                                                           */
 /*****************************************************************************/
 void DLOAD_finalize(DLOAD_HANDLE handle)
 {
-    LOADER_OBJECT *pHandle = (LOADER_OBJECT *)handle;
-
-    /*-----------------------------------------------------------------------*/
-    /* Destroy initial objects_loading queue.                                */
-    /*-----------------------------------------------------------------------*/
-    AL_destroy(&pHandle->DLIMP_module_dependency_list);
 }
 
 
@@ -2228,8 +2285,8 @@ static int32_t dload_static_executable(DLOAD_HANDLE handle,
    /* memory for the static executable.                                      */
    /*------------------------------------------------------------------------*/
    dyn_module->loaded_module->entry_point = dyn_module->fhdr.e_entry;
-    if (load_static_segment(handle, fd, dyn_module) &&
-        load_object(fd, dyn_module))
+   if (load_static_segment(handle, fd, dyn_module) &&
+       load_object(fd, dyn_module))
    {
       /*---------------------------------------------------------------------*/
       /* If successful, we'll want to detach the loaded module object from   */
@@ -2250,11 +2307,11 @@ static int32_t dload_static_executable(DLOAD_HANDLE handle,
    /* Static load failed.  Flag an error.                                    */
    /*------------------------------------------------------------------------*/
    else
-    {
-        DLIF_trace("%s:%d EMEMORY\n",__func__,__LINE__);
+   {
+      DLIF_trace("%s:%d EMEMORY\n",__func__,__LINE__);
       DLIF_error(DLET_MEMORY,
                  "Failed to allocate target memory for static executable.\n");
-    }
+   }
 
    /*------------------------------------------------------------------------*/
    /* Destruct dynamic module object.                                        */
@@ -2268,6 +2325,11 @@ static int32_t dload_static_executable(DLOAD_HANDLE handle,
    return local_file_handle;
 }
 
+#if LOADER_DEBUG && LOADER_PROFILE
+int DLREL_relocations;
+time_t DLREL_total_reloc_time;
+#endif
+
 /*****************************************************************************/
 /* process_dynamic_module_relocations()                                      */
 /*                                                                           */
@@ -2281,8 +2343,6 @@ static void process_dynamic_module_relocations(DLOAD_HANDLE handle,
                                                LOADER_FILE_DESC *fd,
                                                DLIMP_Dynamic_Module *dyn_module)
 {
-    int data = 0;
-
 #if LOADER_DEBUG && LOADER_PROFILE
    if(debugging_on || profiling_on)
    {
@@ -2294,25 +2354,17 @@ static void process_dynamic_module_relocations(DLOAD_HANDLE handle,
    /*------------------------------------------------------------------------*/
    /* Copy segments from file to host memory                                 */
    /*------------------------------------------------------------------------*/
-   copy_segments(handle, fd, dyn_module, &data);
+   copy_segments(handle, fd, dyn_module);
 
    /*------------------------------------------------------------------------*/
    /* Process dynamic relocations.                                           */
    /*------------------------------------------------------------------------*/
-#if ARM_TARGET
-   if (is_arm_module(&dyn_module->fhdr))
-      DLREL_relocate(handle, fd, dyn_module);
-#endif
-
-#if C60_TARGET
-   if (is_c60_module(&dyn_module->fhdr))
-      DLREL_relocate_c60(handle, fd, dyn_module);
-#endif
+   DLREL_relocate(handle, fd, dyn_module);
 
    /*------------------------------------------------------------------------*/
    /* Write segments from host memory to target memory                       */
    /*------------------------------------------------------------------------*/
-   write_segments(handle, fd, dyn_module, &data);
+   write_segments(handle, fd, dyn_module);
 
 #if 0
    /*------------------------------------------------------------------------*/
@@ -2336,90 +2388,63 @@ static void process_dynamic_module_relocations(DLOAD_HANDLE handle,
       if (profiling_on) profile_start_clock();
    }
 #endif
+
 }
 
 /*****************************************************************************/
-/* execute_module_pre_initialization()                                       */
+/* store_preinit_data()                                                      */
 /*                                                                           */
-/*    Given a dynamic module object, execute any pre-initialization          */
-/*    functions for the specified dynamic executable module. Such functions  */
-/*    must be provided by the user and their addresses written to the        */
-/*    .preinit_array section. These functions should be executed in the      */
-/*    order that they are specified in the array before the initialization   */
-/*    process for this dynamic executable module begins.                     */
-/*                                                                           */
-/*---------------------------------------------------------------------------*/
-/*                                                                           */
-/*    Note that dynamic shared objects (libraries) should not have a         */
-/*    .preinit_array (should be caught during static link-time if the user   */
-/*    attempts to link a .preinit_array section into a shared object.        */
+/*    Given a dynamic module object, store pre-initialization function       */
+/*    information. The user may also provide a custom iniitialization        */
+/*    function that needs to be executed before the compiler                 */
+/*    generated static initialization functions are executed.                */
+/*    The dynamic loader will now create a table TI_init_table to store      */
+/*    pre-init and init data. This is done because pre-init and              */
+/*    init functions could reference as-yet unrelocated symbols from other   */
+/*    modules. As such it is safer to store relevant function addresses and  */
+/*    execute them only after all modules are relocated (CQ34088).           */
 /*                                                                           */
 /*****************************************************************************/
-static void execute_module_pre_initialization(DLOAD_HANDLE handle, DLIMP_Dynamic_Module *dyn_module)
+static void store_preinit_data(DLIMP_Dynamic_Module *dyn_module)
 {
-   LOADER_OBJECT *pHandle = (LOADER_OBJECT *)handle;
-
+   IF_single_record *preinit_rec = NULL;
    /*------------------------------------------------------------------------*/
    /* Check for presence of DT_PREINIT_ARRAY and DT_PREINIT_ARRAYSZ          */
    /* dynamic tags associated with this module. The dyn_module object will   */
    /* hold the relevant indices into the local copy of the dynamic table.    */
    /* The value of the DT_INIT_ARRAY tag will have been updated after        */
-   /* placement of the  module was completed.                                */
+   /* placement of the  module was completed. Arrays of size 0 will be       */
+   /* ignored (CQ36935).                                                     */
    /*------------------------------------------------------------------------*/
-   if (dyn_module->preinit_arraysz != 0)
+   if (dyn_module->preinit_arraysz > 0)
    {
+      preinit_rec = (IF_single_record *)DLIF_malloc(sizeof(IF_single_record));
       /*---------------------------------------------------------------------*/
       /* Retrieve the address of the .preinit_array section from the value   */
-      /* of the DT_PREINIT_ARRAY tag.                                        */
+      /* of the DT_PREINIT_ARRAY tag, and store it in the TI_init_table.     */
       /*---------------------------------------------------------------------*/
-      TARGET_ADDRESS preinit_array_loc = (TARGET_ADDRESS)
+      preinit_rec->size = dyn_module->preinit_arraysz;
+      preinit_rec->sect_addr = (TARGET_ADDRESS)
                 (dyn_module->dyntab[dyn_module->preinit_array_idx].d_un.d_ptr);
-
-      /*---------------------------------------------------------------------*/
-      /* Now make a loader-accessible copy of the .preinit_array section.    */
-      /*---------------------------------------------------------------------*/
-      int32_t i;
-      int32_t num_preinit_fcns =
-                            dyn_module->preinit_arraysz/sizeof(TARGET_ADDRESS);
-      TARGET_ADDRESS *preinit_array_buf = (TARGET_ADDRESS *)
-                                      DLIF_malloc(dyn_module->preinit_arraysz);
-      if(preinit_array_buf) {
-         DLIF_read(pHandle->client_handle, preinit_array_buf, 1,
-                                            dyn_module->preinit_arraysz,
-                                            (TARGET_ADDRESS)preinit_array_loc);
-
-         /*------------------------------------------------------------------*/
-         /* Call each function whose address occupies an entry in the array  */
-         /* in the order that it appears in the array. The sizeof the array  */
-         /* is provided by the preinit_arraysz field in the dynamic module   */
-         /* (copied) earlier when the dynamic table was read in). We need to */
-         /* divide the sizeof value down to get the number of actual entries */
-         /* in the array.                                                    */
-         /*------------------------------------------------------------------*/
-         for (i = 0; i < num_preinit_fcns; i++)
-            DLIF_execute(pHandle->client_handle,
-                         (TARGET_ADDRESS)(preinit_array_buf[i]));
-
-         DLIF_free(preinit_array_buf);
-      }
    }
+
+   if (preinit_rec) IF_table_enqueue(&TI_init_table, preinit_rec);
 }
 
 /*****************************************************************************/
-/* execute_module_initialization()                                           */
+/* store_init_data()                                                         */
 /*                                                                           */
-/*    Given a dynamic module object, execute initialization function(s) for  */
+/*    Given a dynamic module object, save off initialization function(s) for */
 /*    all global and static data objects that are defined in the module      */
-/*    which require construction. The user may also provide a custom         */
-/*    iniitialization function that needs to be executed before the compiler */
-/*    generated static initialization functions are executed.                */
+/*    which require construction. The dynamic loader will now create a table */
+/*    TI_init_table to store pre-init and init data. This is done because    */
+/*    pre-init and init functions could reference as-yet unrelocated symbols */
+/*    from other modules. As such it is safer to store relevant function     */
+/*    addresses and execute them only after all modules are relocated.       */
 /*                                                                           */
 /*****************************************************************************/
-static void execute_module_initialization(DLOAD_HANDLE handle,
-                                          DLIMP_Dynamic_Module *dyn_module)
+static void store_init_data(DLIMP_Dynamic_Module *dyn_module)
 {
-   LOADER_OBJECT *pHandle = (LOADER_OBJECT *)handle;
-
    /*------------------------------------------------------------------------*/
    /* Check for presence of a DT_INIT dynamic tag associated with this       */
    /* module. The dynamic module will hold the index into the local copy of  */
@@ -2428,13 +2453,17 @@ static void execute_module_initialization(DLOAD_HANDLE handle,
    /*------------------------------------------------------------------------*/
    if (dyn_module->init_idx != -1)
    {
+      IF_single_record *init_rec =
+                   (IF_single_record *)DLIF_malloc(sizeof(IF_single_record));
       /*---------------------------------------------------------------------*/
       /* Retrieve the address of the initialization function from the value  */
       /* of the DT_INIT tag, and get the client to execute the function.     */
       /*---------------------------------------------------------------------*/
-      TARGET_ADDRESS init_fcn = (TARGET_ADDRESS)
+      init_rec->size = 0;
+      init_rec->sect_addr = (TARGET_ADDRESS)
                          (dyn_module->dyntab[dyn_module->init_idx].d_un.d_ptr);
-      DLIF_execute(pHandle->client_handle, init_fcn);
+
+      IF_table_enqueue(&TI_init_table, init_rec);
    }
 
    /*------------------------------------------------------------------------*/
@@ -2442,40 +2471,127 @@ static void execute_module_initialization(DLOAD_HANDLE handle,
    /* associated with this module. The dyn_module object will hold the       */
    /* relevant indices into the local copy of the dynamic table. The value   */
    /* of the DT_INIT_ARRAY tag will have been updated after placement of the */
-   /* module was completed.                                                  */
+   /* module was completed. Arraysz must be a postive number > 0, else it    */
+   /* be ignored (CQ36935).                                                  */
    /*------------------------------------------------------------------------*/
-   if (dyn_module->init_arraysz != 0)
+   if (dyn_module->init_arraysz > 0)
    {
+      IF_single_record *arr_rec =
+                   (IF_single_record *)DLIF_malloc(sizeof(IF_single_record));
       /*---------------------------------------------------------------------*/
       /* Retrieve the address of the .init_array section from the value of   */
       /* DT_INIT_ARRAY tag.                                                  */
       /*---------------------------------------------------------------------*/
-      TARGET_ADDRESS init_array_loc = (TARGET_ADDRESS)
+      arr_rec->size = dyn_module->init_arraysz;
+      arr_rec->sect_addr = (TARGET_ADDRESS)
                    (dyn_module->dyntab[dyn_module->init_array_idx].d_un.d_ptr);
 
+      IF_table_enqueue(&TI_init_table, arr_rec);
+   }
+}
+
+/*****************************************************************************/
+/* execute_module_initialization()                                           */
+/*                                                                           */
+/*    Given a dynamic module object, execute pre-initialization and          */
+/*    initialization function(s) for all global and static data objects that */
+/*    are defined in the module which require construction. The user may     */
+/*    also provide a custom iniitialization function that needs to be        */
+/*    executed before the compiler generated static initialization functions */
+/*    are executed.                                                          */
+/*    Note that the functions to be executed have already been saved off in  */
+/*    the TI_init_table, by store_preinit_data() and store_init_data().      */
+/*                                                                           */
+/*****************************************************************************/
+static void execute_module_initialization(DLOAD_HANDLE handle)
+{
+   IF_single_record *val = NULL;
+   IF_table_Queue_Node *curr_ptr = TI_init_table.front_ptr;
+   LOADER_OBJECT *pHandle = (LOADER_OBJECT *)handle;
+
+   for (; curr_ptr; curr_ptr = curr_ptr->next_ptr)
+   {
+      val = curr_ptr->value;
+
       /*---------------------------------------------------------------------*/
-      /* Now make a loader-accessible copy of the .init_array section.       */
+      /* A size of 0 indicates DT_INIT, otherwise this is an ARRAY.         */
       /*---------------------------------------------------------------------*/
-      int32_t i;
-      int32_t num_init_fcns = dyn_module->init_arraysz/sizeof(TARGET_ADDRESS);
-      TARGET_ADDRESS *init_array_buf = (TARGET_ADDRESS *)
-                                         DLIF_malloc(dyn_module->init_arraysz);
-      if(init_array_buf) {
-         DLIF_read(pHandle->client_handle, init_array_buf, 1,
-                   dyn_module->init_arraysz, (TARGET_ADDRESS)init_array_loc);
+      if (val->size != 0)
+      {
+         /*------------------------------------------------------------------*/
+         /* Now make a loader-accessible copy of the .init_array section.    */
+         /*------------------------------------------------------------------*/
+         int32_t i;
+         int32_t num_init_fcns = val->size/sizeof(TARGET_ADDRESS);
+         TARGET_ADDRESS *init_array_buf = (TARGET_ADDRESS *)
+                                            DLIF_malloc(val->size);
+
+         DLIF_read(pHandle->client_handle,
+               init_array_buf, 1, val->size,
+           (TARGET_ADDRESS)val->sect_addr);
 
          /*------------------------------------------------------------------*/
-         /* Call each function whose address occupies an entry in the array  */
-         /* in the order that they appear in the array. The size of the array*/
-         /* is provided by the init_arraysz field in the dynamic module      */
-         /* (copied earlier when the dynamic table was read in).             */
+         /* Call each function whose address occupies an entry in array in   */
+         /* the order that they appear in the array. The size of the array is*/
+         /* provided by the init_arraysz field in the dynamic module (copied */
+         /* earlier when the dynamic table was read in). Make sure that      */
+         /* function addresses are valid before execution.                   */
          /*------------------------------------------------------------------*/
          for (i = 0; i < num_init_fcns; i++)
-            DLIF_execute(pHandle->client_handle,
-                         (TARGET_ADDRESS)(init_array_buf[i]));
+            if (init_array_buf[i])
+               DLIF_execute(pHandle->client_handle,
+                        (TARGET_ADDRESS)(init_array_buf[i]));
+            else
+               DLIF_warning(DLWT_MISC,
+                  "DT_INIT_ARRAY/DT_PREINIT_ARRAY function address is NULL!");
 
          DLIF_free(init_array_buf);
       }
+      else
+      {
+         if (val->sect_addr)
+            DLIF_execute(pHandle->client_handle,
+                     (TARGET_ADDRESS)(val->sect_addr));
+         else
+            DLIF_warning(DLWT_MISC, "DT_INIT function address is NULL!");
+      }
+   }
+}
+
+/*****************************************************************************/
+/* adjust_module_init_fini()                                                 */
+/*    If the dynamic loader need not process the module initialization       */
+/*    and termination (fini section) then adjust the module info so that     */
+/*    the respective sizes become zero.                                      */
+/*****************************************************************************/
+static void adjust_module_init_fini(DLIMP_Dynamic_Module *dm)
+{
+   /*------------------------------------------------------------------------*/
+   /* The C6x RTS boot code has the function _c_int00 which performs         */
+   /* the C/C++ initialization. This function processes the .init_array      */
+   /* to perform the C/C++ initialization and handles termination through    */
+   /* the at_exit functionality. If the dynamic executable we are loading    */
+   /* includes _c_int00, the loader assumes that the application code takes  */
+   /* care of all initialization and termination. Hence the loader won't     */
+   /* perform the initialization and termination.                            */
+   /* NOTE: Use of __TI_STACK_SIZE is a hack. The _c_int00 symbol is not     */
+   /*       in the dynamic symbol table. The right fix is for the linker     */
+   /*       not to generate the init array tags if the build includes RTS    */
+   /*       boot routine.                                                    */
+   /*------------------------------------------------------------------------*/
+   if (dm->fhdr.e_type == ET_EXEC &&
+       DLSYM_lookup_local_symtab("__TI_STACK_SIZE", dm->symtab, dm->symnum,
+                                 NULL))
+   {
+      dm->init_arraysz   = 0;
+      dm->init_array_idx = -1;
+
+      dm->preinit_arraysz   = 0;
+      dm->preinit_array_idx = -1;
+
+      dm->loaded_module->fini_arraysz = 0;
+      dm->loaded_module->fini_array   = (Elf32_Addr) NULL;
+      dm->loaded_module->fini         = (Elf32_Addr) NULL;
    }
 }
 
@@ -2492,9 +2608,10 @@ static void execute_module_initialization(DLOAD_HANDLE handle,
 /*    module, the dynamic module object is destructed.                       */
 /*                                                                           */
 /*****************************************************************************/
-static int32_t relocate_dependency_graph_modules(DLOAD_HANDLE handle,
-                                                 LOADER_FILE_DESC *fd,
-                                                 DLIMP_Dynamic_Module *dyn_module)
+static
+int32_t relocate_dependency_graph_modules(DLOAD_HANDLE handle,
+                                          LOADER_FILE_DESC *fd,
+                                          DLIMP_Dynamic_Module *dyn_module)
 {
    /*------------------------------------------------------------------------*/
    /* Processing of relocations will only be triggered when this function    */
@@ -2504,19 +2621,22 @@ static int32_t relocate_dependency_graph_modules(DLOAD_HANDLE handle,
    int32_t local_file_handle = dyn_module->loaded_module->file_handle;
    LOADER_OBJECT *pHandle = (LOADER_OBJECT *)handle;
    dynamic_module_ptr_Stack_Node *ptr =
-      pHandle->DLIMP_dependency_stack.bottom_ptr;
-   if (ptr && (ptr->value != dyn_module)) {return local_file_handle;}
+                           pHandle->DLIMP_dependency_stack.bottom_ptr;
+   if (ptr && (ptr->value != dyn_module)) return local_file_handle;
 
-   /*------------------------------------------------------------------------*/
-   /* Assign DSBT indices.                                                   */
-   /*------------------------------------------------------------------------*/
-   DLIF_assign_dsbt_indices();
+   if (is_dsbt_module(dyn_module))
+   {
+       /*--------------------------------------------------------------------*/
+       /* Assign DSBT indices.                                               */
+       /*--------------------------------------------------------------------*/
+       DLIF_assign_dsbt_indices();
 
-   /*------------------------------------------------------------------------*/
-   /* Update the content of all DSBTs for any module that uses the DSBT      */
-   /* model.                                                                 */
-   /*------------------------------------------------------------------------*/
-   DLIF_update_all_dsbts();
+       /*--------------------------------------------------------------------*/
+       /* Update the content of all DSBTs for any module that uses the       */
+       /* DSBT model.                                                        */
+       /*--------------------------------------------------------------------*/
+       DLIF_update_all_dsbts();
+   }
 
    /*------------------------------------------------------------------------*/
    /* Ok, we are ready to process relocations. The relocation tables         */
@@ -2532,16 +2652,18 @@ static int32_t relocate_dependency_graph_modules(DLOAD_HANDLE handle,
       /*---------------------------------------------------------------------*/
       /* Process dynamic relocations associated with this module.            */
       /*---------------------------------------------------------------------*/
-      process_dynamic_module_relocations(handle, dyn_mod_ptr->fd,
-                                         dyn_mod_ptr);
+      process_dynamic_module_relocations(handle, dyn_mod_ptr->fd, dyn_mod_ptr);
 
       /*---------------------------------------------------------------------*/
       /* __c_args__ points to the beginning of the .args section, if there   */
       /* is one.  Record this pointer in the ELF file internal data object.  */
+      /* Also store this in the loaded module, since this will be needed to  */
+      /* write argv, argc to .args at execution time.                        */
       /*---------------------------------------------------------------------*/
       DLSYM_lookup_local_symtab("__c_args__", dyn_mod_ptr->symtab,
                                 dyn_mod_ptr->symnum,
                                 (Elf32_Addr *)&dyn_mod_ptr->c_args);
+      dyn_mod_ptr->loaded_module->c_args = dyn_mod_ptr->c_args;
 
       /*---------------------------------------------------------------------*/
       /* Pick up entry point address from ELF file header.                   */
@@ -2556,13 +2678,15 @@ static int32_t relocate_dependency_graph_modules(DLOAD_HANDLE handle,
       /*---------------------------------------------------------------------*/
       /* Copy command-line arguments into args section and deal with DSBT    */
       /* issues (copy DSBT to its run location).                             */
+      /* Note that below function is commented out because this doesn't do   */
+      /* much as of now.                                                     */
       /*---------------------------------------------------------------------*/
-      load_object(dyn_mod_ptr->fd, dyn_mod_ptr);
+      //load_object(dyn_mod_ptr->fd, dyn_mod_ptr);
 
       /*---------------------------------------------------------------------*/
       /* Perform initialization, if needed, for this module.                 */
       /*---------------------------------------------------------------------*/
-      execute_module_initialization(handle, dyn_mod_ptr);
+      store_init_data(dyn_mod_ptr);
 
       /*---------------------------------------------------------------------*/
       /* Free all dependent file pointers.                                   */
@@ -2594,9 +2718,10 @@ static int32_t relocate_dependency_graph_modules(DLOAD_HANDLE handle,
 /*    The core loader must have read access to the file pointed to by fd.    */
 /*                                                                           */
 /*****************************************************************************/
-int32_t DLOAD_load(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd, int argc,
-                   char** argv)
+int32_t DLOAD_load(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd)
 {
+    int32_t fl_handle;
+
     LOADER_OBJECT *pHandle = (LOADER_OBJECT *)handle;
     DLIMP_Dynamic_Module *dyn_module = new_DLIMP_Dynamic_Module(fd);
 
@@ -2624,7 +2749,8 @@ int32_t DLOAD_load(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd, int argc,
    /*------------------------------------------------------------------------*/
    /* Read file headers and dynamic information into dynamic module.         */
    /*------------------------------------------------------------------------*/
-   if (!dload_headers(handle, fd, dyn_module)) {
+   if (!dload_headers(fd, dyn_module))
+   {
       delete_DLIMP_Dynamic_Module(handle, &dyn_module);
       return 0;
    }
@@ -2634,25 +2760,9 @@ int32_t DLOAD_load(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd, int argc,
    /* information from the ELF object file into the dynamic module data      */
    /* structure associated with this file.                                   */
    /*------------------------------------------------------------------------*/
-   if (!dload_dynamic_segment(handle, fd, dyn_module)) {
-      delete_DLIMP_Dynamic_Module(handle, &dyn_module);
+   if (!dload_dynamic_segment(handle, fd, dyn_module))
       return 0;
-   }
 
-   /*------------------------------------------------------------------------*/
-   /* ??? We currently don't have a way of finding the .args section.  So    */
-   /*    we are hard-wiring the address of the .args section.  The proposed  */
-   /*    solution for this problem is to invent a special segment type or    */
-   /*    dynamic tag(s) that identify the location and size of the .args     */
-   /*    section for the dynamic loader.                                     */
-   /*------------------------------------------------------------------------*/
-   /*HACK ---> */dyn_module->c_args = (uint8_t*)(0x02204000); /* <--- HACK*/
-
-   /*------------------------------------------------------------------------*/
-   /* Record argc and argv pointers with the dynamic module record.          */
-   /*------------------------------------------------------------------------*/
-   dyn_module->argc = argc;
-   dyn_module->argv = argv;
    if (dyn_module->name == NULL) {
       dyn_module->name = DLIF_malloc(sizeof(char));
       if(dyn_module->name)
@@ -2670,7 +2780,6 @@ int32_t DLOAD_load(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd, int argc,
    {
       DLIF_error(DLET_FILE, "Attempt to load invalid ELF file, '%s'.\n",
                     dyn_module->name);
-      delete_DLIMP_Dynamic_Module(handle, &dyn_module);
       return 0;
    }
 
@@ -2685,16 +2794,12 @@ int32_t DLOAD_load(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd, int argc,
       if (profiling_on)
       {
          profile_stop_clock();
-         DLIF_trace("Took %d cycles.\n", (int)profile_cycle_count());
+         DLIF_trace("Took %lu cycles.\n",
+                (unsigned long) profile_cycle_count());
       }
    }
 #endif
 
-   if (!process_section_table(fd, dyn_module)) {
-      delete_DLIMP_Dynamic_Module(handle, &dyn_module);
-      return 0;
-   }
-
    /*------------------------------------------------------------------------*/
    /* Initialize internal ELF module and segment structures.  Sets           */
    /* loaded_module in *dyn_module.  This also deals with assigning a file   */
@@ -2721,18 +2826,37 @@ int32_t DLOAD_load(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd, int argc,
    /* structure.  Note that this step needs to be performed prior and in     */
    /* addition to the relocation entry processing.                           */
    /*------------------------------------------------------------------------*/
-   if (!allocate_dynamic_segments_and_relocate_symbols(handle, fd, dyn_module)) {
-      loaded_module_ptr_remove(&pHandle->DLIMP_loaded_objects,
-                               dyn_module->loaded_module);
-      delete_DLIMP_Dynamic_Module(handle, &dyn_module);
+   if (!allocate_dynamic_segments_and_relocate_symbols(handle, fd, dyn_module))
       return 0;
-   }
+
+   /*------------------------------------------------------------------------*/
+   /* __c_args__ points to the beginning of the .args section, if there is   */
+   /* one.  __TI_STATIC_BASE points to the beginning of the DP-relative data */
+   /* segment (value to initialize DP). Record these addresses in the ELF    */
+   /* file internal data object.                                             */
+   /*------------------------------------------------------------------------*/
+   DLSYM_lookup_local_symtab("__c_args__", dyn_module->symtab,
+                             dyn_module->symnum,
+                             (Elf32_Addr *)&dyn_module->c_args);
+
+   DLSYM_lookup_local_symtab("__TI_STATIC_BASE", dyn_module->symtab,
+                             dyn_module->symnum,
+                             (Elf32_Addr *)&dyn_module->static_base);
+   dyn_module->loaded_module->static_base = dyn_module->static_base;
+
+   /*------------------------------------------------------------------------*/
+   /* If the user application performs initialization and termination,       */
+   /* the dynamic loader shouldn't process the init/fini sections.           */
+   /* Check and adjust the init/fini information accordingly.                */
+   /*------------------------------------------------------------------------*/
+   adjust_module_init_fini(dyn_module);
+
    /*------------------------------------------------------------------------*/
    /* Execute any user defined pre-initialization functions that may be      */
    /* associated with a dynamic executable module.                           */
    /*------------------------------------------------------------------------*/
    if (dyn_module->fhdr.e_type == ET_EXEC)
-      execute_module_pre_initialization(handle, dyn_module);
+      store_preinit_data(dyn_module);
 
    /*------------------------------------------------------------------------*/
    /* Append current ELF file to list of objects currently loading.          */
@@ -2753,29 +2877,19 @@ int32_t DLOAD_load(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd, int argc,
    /* request with the client's DSBT support management.                     */
    /*------------------------------------------------------------------------*/
    if (is_dsbt_module(dyn_module) &&
-      !DLIF_register_dsbt_index_request(handle,
-                                        dyn_module->name,
-                                        dyn_module->loaded_module->file_handle,
-                                        dyn_module->dsbt_index)) {
-      dynamic_module_ptr_pop(&pHandle->DLIMP_dependency_stack);
-      loaded_module_ptr_remove(&pHandle->DLIMP_loaded_objects,
-                                 dyn_module->loaded_module);
-      delete_DLIMP_Dynamic_Module(handle, &dyn_module);
+       !DLIF_register_dsbt_index_request(handle,
+                                         dyn_module->name,
+                                         dyn_module->loaded_module->file_handle,
+                                         dyn_module->dsbt_index))
       return 0;
-   }
 
    /*------------------------------------------------------------------------*/
-   /* Load this ELF file's dependents (all files on its DT_NEEDED list).     */
-   /* Do not process relocation entries for anyone in the dependency graph   */
-   /* until all modules in the graph are loaded and allocated.               */
+   /* Load this ELF file's dependees (all files on its DT_NEEDED list).      */
+   /* Dependees must be loaded and relocated before processing this module's */
+   /* relocations.                                                           */
    /*------------------------------------------------------------------------*/
-   if (!dload_and_allocate_dependencies(handle, dyn_module)) {
-      dynamic_module_ptr_pop(&pHandle->DLIMP_dependency_stack);
-      loaded_module_ptr_remove(&pHandle->DLIMP_loaded_objects,
-                                 dyn_module->loaded_module);
-      delete_DLIMP_Dynamic_Module(handle, &dyn_module);
+   if (!dload_and_allocate_dependencies(handle, dyn_module))
       return 0;
-   }
 
    /*------------------------------------------------------------------------*/
    /* Remove the current ELF file from the list of files that are in the     */
@@ -2784,21 +2898,34 @@ int32_t DLOAD_load(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd, int argc,
    pHandle->DLIMP_module_dependency_list.size--;
 
    /*------------------------------------------------------------------------*/
-   /* __c_args__ points to the beginning of the .args section, if there is   */
-   /* one.  Record this pointer in the ELF file internal data object.        */
+   /* Process relocation entries.                                            */
    /*------------------------------------------------------------------------*/
-   DLSYM_lookup_local_symtab("__c_args__", dyn_module->symtab,
-                             dyn_module->symnum,
-                             (Elf32_Addr *)&dyn_module->c_args);
+   fl_handle = relocate_dependency_graph_modules(handle, fd, dyn_module);
 
+   /*------------------------------------------------------------------------*/
+   /* With initialization complete, and all relocations having been resolved */
+   /* do module initialization.                                              */
+   /*------------------------------------------------------------------------*/
+   execute_module_initialization(handle);
 
-   return relocate_dependency_graph_modules(handle, fd, dyn_module);
+   return fl_handle;
 }
 
-BOOL DLOAD_get_entry_names_info(DLOAD_HANDLE handle,
-                                uint32_t file_handle,
-                                int32_t *entry_pt_cnt,
-                                int32_t *entry_pt_max_name_len)
+/*****************************************************************************/
+/* DLOAD_get_entry_names()                                                   */
+/*                                                                           */
+/*    Build a list of entry point names for a loaded object.  Currently,     */
+/*    any global symbol in the module is considered a valid entry point      */
+/*    regardless of whether it is defined in code or associated with a       */
+/*    data object.  We would need to process the content of the symbol       */
+/*    table entry or its debug information to determine whether it is a      */
+/*    valid entry point or not.                                              */
+/*                                                                           */
+/*****************************************************************************/
+BOOL DLOAD_get_entry_names(DLOAD_HANDLE handle,
+                           uint32_t file_handle,
+                           int32_t *entry_pt_cnt,
+                           char ***entry_pt_names)
 {
    /*------------------------------------------------------------------------*/
    /* Spin through list of loaded files until we find the file handle we     */
@@ -2807,9 +2934,8 @@ BOOL DLOAD_get_entry_names_info(DLOAD_HANDLE handle,
    /*------------------------------------------------------------------------*/
    LOADER_OBJECT *pHandle = (LOADER_OBJECT *)handle;
    loaded_module_ptr_Queue_Node* ptr;
-   for (ptr = pHandle->DLIMP_loaded_objects.front_ptr;
-       ptr != NULL;
-       ptr = ptr->next_ptr)
+   for (ptr = pHandle->DLIMP_loaded_objects.front_ptr; ptr != NULL;
+                                                          ptr = ptr->next_ptr)
    {
       if (ptr->value->file_handle == file_handle)
       {
@@ -2823,13 +2949,12 @@ BOOL DLOAD_get_entry_names_info(DLOAD_HANDLE handle,
          /*------------------------------------------------------------------*/
          symtab = (struct Elf32_Sym*)module->gsymtab;
          *entry_pt_cnt = module->gsymnum;
-         *entry_pt_max_name_len = 0;
+         *entry_pt_names = DLIF_malloc(*entry_pt_cnt * sizeof(char*));
          for (i = 0; i < module->gsymnum; i++)
          {
             const char *sym_name = (const char *)symtab[i].st_name;
-
-            if ((strlen(sym_name) + 1) > *entry_pt_max_name_len)
-               *entry_pt_max_name_len = strlen(sym_name) + 1;
+            **entry_pt_names = DLIF_malloc(strlen(sym_name) + 1);
+            strcpy(**entry_pt_names,sym_name);
          }
 
          return TRUE;
@@ -2843,60 +2968,98 @@ BOOL DLOAD_get_entry_names_info(DLOAD_HANDLE handle,
 }
 
 /*****************************************************************************/
-/* DLOAD_get_entry_names()                                                   */
+/* DLOAD_prepare_for_execution()                                             */
 /*                                                                           */
-/*    Build a list of entry point names for a loaded object.  Currently,     */
-/*    any global symbol in the module is considered a valid entry point      */
-/*    regardless of whether it is defined in code or associated with a       */
-/*    data object.  We would need to process the content of the symbol       */
-/*    table entry or its debug information to determine whether it is a      */
-/*    valid entry point or not.                                              */
+/*    Given a file handle, prepare for execution :                           */
+/*     - Return entry point associated with that module in the *sym_val      */
+/*       output parameter.                                                   */
+/*     - Write out the given arguments to the .args section contained in the */
+/*       same module.                                                        */
+/*     - As a test (for the Reference implementation) read the arguments     */
+/*       using the DLIF_read_arguments() function and set global argc,argv.  */
 /*                                                                           */
 /*****************************************************************************/
-BOOL DLOAD_get_entry_names(DLOAD_HANDLE handle,
-                           uint32_t file_handle,
-                           int32_t *entry_pt_cnt,
-                           char ***entry_pt_names)
+BOOL DLOAD_prepare_for_execution(DLOAD_HANDLE handle, uint32_t file_handle,
+                           TARGET_ADDRESS *sym_val,
+                           int argc, char** argv)
 {
    /*------------------------------------------------------------------------*/
    /* Spin through list of loaded files until we find the file handle we     */
-   /* are looking for.  Then build a list of entry points from that file's   */
-   /* symbol table.                                                          */
+   /* are looking for.  Then return the entry point address associated with  */
+   /* that module.                                                           */
    /*------------------------------------------------------------------------*/
-   char **names;
-   LOADER_OBJECT *pHandle = (LOADER_OBJECT *)handle;
+   DLIMP_Loaded_Module *ep_loaded_module;
    loaded_module_ptr_Queue_Node* ptr;
-   for (ptr = pHandle->DLIMP_loaded_objects.front_ptr;
-        ptr != NULL;
-        ptr = ptr->next_ptr)
-   {
+   LOADER_OBJECT *pHandle = (LOADER_OBJECT *)handle;
+
+   for (ptr = pHandle->DLIMP_loaded_objects.front_ptr; ptr != NULL;
+                                                       ptr = ptr->next_ptr)
       if (ptr->value->file_handle == file_handle)
       {
-         DLIMP_Loaded_Module *module = ptr->value;
-         struct Elf32_Sym *symtab;
-         int i;
+         *sym_val = (TARGET_ADDRESS)(ptr->value->entry_point);
+         ep_loaded_module = ptr->value;
 
          /*------------------------------------------------------------------*/
-         /* Any symbol in our file's symbol table is considered a valid      */
-         /* entry point.                                                     */
+         /* Write argc, argv to the .args section in this module.            */
          /*------------------------------------------------------------------*/
-         symtab = (struct Elf32_Sym*)module->gsymtab;
-         if (*entry_pt_cnt < module->gsymnum) {
-            DLIF_error(DLET_MEMORY, "There are %d entry points, "
-                       "only %d spaces provided.\n",
-                       module->gsymnum,*entry_pt_cnt);
-            return FALSE;
-         }
-         names = *entry_pt_names;
-         for (i = 0; i < module->gsymnum; i++)
+         if (!write_arguments_to_args_section(handle, argc, argv,
+                                          ep_loaded_module))
          {
-            const char *sym_name = (const char *)symtab[i].st_name;
-            strcpy(names[i],sym_name);
+            DLIF_error(DLET_MISC, "Couldn't write to .args section\n");
+            return FALSE;
          }
 
+         /*------------------------------------------------------------------*/
+         /* For the Reference Implementation we simulate a "boot" (rts boot  */
+         /* routine reads argc, argv from .args), by reading argc, argv from */
+         /* .args section. Note that we just wrote these values to the .args */
+         /* so this read serves as a test for the Reference Implementation.  */
+         /*------------------------------------------------------------------*/
+         read_args_from_section(ep_loaded_module);
          return TRUE;
       }
-   }
+
+   /*------------------------------------------------------------------------*/
+   /* We didn't find the file we were looking for, return false.             */
+   /*------------------------------------------------------------------------*/
+   return FALSE;
+}
+
+/*****************************************************************************/
+/* DLOAD_load_arguments()                                                    */
+/*                                                                           */
+/*    Write out the given arguments to the .args section contained in the    */
+/*    same module.                                                           */
+/*                                                                           */
+/*****************************************************************************/
+BOOL DLOAD_load_arguments(DLOAD_HANDLE handle, uint32_t file_handle,
+                           int argc, char** argv)
+{
+   /*------------------------------------------------------------------------*/
+   /* Spin through list of loaded files until we find the file handle we     */
+   /* are looking for.  Then return the entry point address associated with  */
+   /* that module.                                                           */
+   /*------------------------------------------------------------------------*/
+   DLIMP_Loaded_Module *ep_loaded_module;
+   loaded_module_ptr_Queue_Node* ptr;
+   LOADER_OBJECT *pHandle = (LOADER_OBJECT *)handle;
+
+   for (ptr = pHandle->DLIMP_loaded_objects.front_ptr; ptr != NULL;
+                                                       ptr = ptr->next_ptr)
+      if (ptr->value->file_handle == file_handle)
+      {
+         ep_loaded_module = ptr->value;
+
+         /*------------------------------------------------------------------*/
+         /* Write argc, argv to the .args section in this module.            */
+         /*------------------------------------------------------------------*/
+         if (!write_arguments_to_args_section(handle, argc, argv,
+                                          ep_loaded_module))
+         {
+            DLIF_error(DLET_MISC, "Couldn't write to .args section\n");
+            return FALSE;
+         }
+      }
 
    /*------------------------------------------------------------------------*/
    /* We didn't find the file we were looking for, return false.             */
@@ -2982,7 +3145,7 @@ BOOL DLOAD_query_symbol(DLOAD_HANDLE handle,
    }
 
    /*------------------------------------------------------------------------*/
-   /* We didn't find the file we were looking for, return false.             */
+   /* We didn't find the symbol we were looking for, return false.           */
    /*------------------------------------------------------------------------*/
    return FALSE;
 }
@@ -3000,53 +3163,7 @@ BOOL DLOAD_get_section_info(DLOAD_HANDLE handle, uint32_t file_handle,
                             uint32_t *sect_size)
 {
    /*------------------------------------------------------------------------*/
-   /* Spin through list of loaded files until we find the file handle we     */
-   /* are looking for.  Then return the value (target address) associated    */
-   /* with the symbol we are looking for in that file.                       */
-   /*------------------------------------------------------------------------*/
-   loaded_module_ptr_Queue_Node* ptr;
-   LOADER_OBJECT *pHandle = (LOADER_OBJECT *)handle;
-   for (ptr = pHandle->DLIMP_loaded_objects.front_ptr;
-        ptr != NULL;
-        ptr = ptr->next_ptr)
-   {
-      if (ptr->value->file_handle == file_handle)
-      {
-         DLIMP_Loaded_Module *module = ptr->value;
-         DLIMP_Section_Info *sections = (DLIMP_Section_Info*)
-                                               (module->sections.buf);
-         int size = module->sections.size;
-         int i;
-
-         /*------------------------------------------------------------------*/
-         /* Search through the symbol table by name.                         */
-         /*------------------------------------------------------------------*/
-         for(i=0; i < size; i++)
-         {
-            if (!strcmp(sect_name, (const char *)sections[i].sh_name))
-            {
-               *sect_val = (TARGET_ADDRESS) sections[i].shdr.sh_addr;
-               *sect_size = sections[i].shdr.sh_size;
-#if LOADER_DEBUG
-               if (debugging_on)  {
-                  DLIF_trace(
-                  "DLOAD_get_section_info: Found section %s of size 0x%x at addr 0x%x.\n", sect_name, *sect_size, *sect_val);
-               }
-#endif
-               return TRUE;
-            }
-         }
-      }
-   }
-#if LOADER_DEBUG
-         if (debugging_on)  {
-            DLIF_trace(
-            "DLOAD_get_section_info: Section %s not found.\n", sect_name);
-         }
-#endif
-
-   /*------------------------------------------------------------------------*/
-   /* We didn't find the file we were looking for, return false.             */
+   /* Not implemented. return false.                                         */
    /*------------------------------------------------------------------------*/
    return FALSE;
 }
@@ -3335,15 +3452,9 @@ BOOL DLOAD_unload(DLOAD_HANDLE handle, uint32_t file_handle)
             remove_loaded_module(handle, lm_node);
 
             /*---------------------------------------------------------------*/
-            /* If all loaded objects have been unloaded (including the       */
-            /* base image), then reset the machine to the default target     */
-            /* machine.  This only has an effect when multiple targets are   */
-            /* supported, in which case the machine is set to EM_NONE.       */
+            /* Once unloading is done, reset virtual target to NULL.         */
             /*---------------------------------------------------------------*/
-            if (pHandle->DLIMP_loaded_objects.front_ptr == NULL)
-            {
-               pHandle->DLOAD_TARGET_MACHINE = DLOAD_DEFAULT_TARGET_MACHINE;
-            }
+            cur_target = NULL;
 
             return TRUE;
          }
@@ -3362,10 +3473,16 @@ BOOL DLOAD_unload(DLOAD_HANDLE handle, uint32_t file_handle)
 /*****************************************************************************/
 int32_t DLOAD_load_symbols(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd)
 {
-   DLIMP_Dynamic_Module *dyn_module = NULL;
+   DLIMP_Dynamic_Module *dyn_module = new_DLIMP_Dynamic_Module(fd);
    DLIMP_Loaded_Module *loaded_module = NULL;
    LOADER_OBJECT *pHandle = (LOADER_OBJECT *)handle;
 
+   /*------------------------------------------------------------------------*/
+   /* Ensure we have a valid dynamic module object from the constructor.     */
+   /*------------------------------------------------------------------------*/
+   if (!dyn_module)
+       return 0;
+
    /*------------------------------------------------------------------------*/
    /* If no access to a program was provided, there is nothing to do.        */
    /*------------------------------------------------------------------------*/
@@ -3375,14 +3492,6 @@ int32_t DLOAD_load_symbols(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd)
       return 0;
    }
 
-   dyn_module = new_DLIMP_Dynamic_Module(fd);
-
-   /*------------------------------------------------------------------------*/
-   /* Ensure we have a valid dynamic module object from the constructor.     */
-   /*------------------------------------------------------------------------*/
-   if (!dyn_module)
-      return 0;
-
    /*------------------------------------------------------------------------*/
    /* Record argc and argv pointers with the dynamic module record.          */
    /*------------------------------------------------------------------------*/
@@ -3392,7 +3501,8 @@ int32_t DLOAD_load_symbols(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd)
    /*------------------------------------------------------------------------*/
    /* Read file headers and dynamic information into dynamic module.         */
    /*------------------------------------------------------------------------*/
-   if (!dload_headers(handle, fd, dyn_module)) {
+   if (!dload_headers(fd, dyn_module))
+   {
       delete_DLIMP_Dynamic_Module(handle, &dyn_module);
       return 0;
    }
@@ -3402,7 +3512,8 @@ int32_t DLOAD_load_symbols(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd)
    /* information from the ELF object file into the dynamic module data      */
    /* structure associated with this file.                                   */
    /*------------------------------------------------------------------------*/
-   if (!dload_dynamic_segment(handle, fd, dyn_module)) {
+   if (!dload_dynamic_segment(handle, fd, dyn_module))
+   {
       delete_DLIMP_Dynamic_Module(handle, &dyn_module);
       return 0;
    }
@@ -3418,11 +3529,6 @@ int32_t DLOAD_load_symbols(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd)
       return 0;
    }
 
-   if (!process_section_table(fd, dyn_module)) {
-      delete_DLIMP_Dynamic_Module(handle, &dyn_module);
-      return 0;
-   }
-
    /*------------------------------------------------------------------------*/
    /* Initialize internal ELF module and segment structures.  Sets           */
    /* loaded_module in *dyn_module.  This also deals with assigning a file   */
@@ -3513,19 +3619,17 @@ uint32_t DLOAD_get_dsbt_size(DLOAD_HANDLE handle, int32_t file_handle)
 BOOL DLOAD_get_static_base(DLOAD_HANDLE handle, int32_t file_handle,
                            TARGET_ADDRESS *static_base)
 {
-   dynamic_module_ptr_Stack_Node *ptr;
+   loaded_module_ptr_Queue_Node* ptr;
    LOADER_OBJECT *pHandle = (LOADER_OBJECT *)handle;
-   for (ptr = pHandle->DLIMP_dependency_stack.top_ptr;
-        ptr != NULL;
-        ptr = ptr->next_ptr)
+
+   for (ptr = pHandle->DLIMP_loaded_objects.front_ptr; ptr != NULL;
+              ptr = ptr->next_ptr)
    {
-      DLIMP_Dynamic_Module *dmp = ptr->value;
-      if (dmp->loaded_module->file_handle == file_handle)
+      DLIMP_Loaded_Module *lmp = ptr->value;
+      if (lmp->file_handle == file_handle)
       {
-         BOOL stat = DLSYM_lookup_local_symtab("__TI_STATIC_BASE",
-                                               dmp->symtab, dmp->symnum,
-                                               (Elf32_Addr *)static_base);
-         return stat;
+          *static_base = (TARGET_ADDRESS)lmp->static_base;
+          return TRUE;
       }
    }
 
@@ -3538,8 +3642,7 @@ BOOL DLOAD_get_static_base(DLOAD_HANDLE handle, int32_t file_handle,
 /*    Look up address of DSBT for the specified module.                      */
 /*                                                                           */
 /*****************************************************************************/
-BOOL DLOAD_get_dsbt_base(DLOAD_HANDLE handle, int32_t file_handle,
-                         TARGET_ADDRESS *dsbt_base)
+BOOL DLOAD_get_dsbt_base(DLOAD_HANDLE handle, int32_t file_handle, TARGET_ADDRESS *dsbt_base)
 {
    dynamic_module_ptr_Stack_Node *ptr;
    LOADER_OBJECT *pHandle = (LOADER_OBJECT *)handle;
@@ -3558,3 +3661,76 @@ BOOL DLOAD_get_dsbt_base(DLOAD_HANDLE handle, int32_t file_handle,
 
    return FALSE;
 }
+
+/*****************************************************************************/
+/* RELOCATE() - Perform RELA and REL type relocations for given ELF object   */
+/*      file that we are in the process of loading and relocating.           */
+/*****************************************************************************/
+void DLREL_relocate(DLOAD_HANDLE handle, LOADER_FILE_DESC* elf_file,
+                    DLIMP_Dynamic_Module* dyn_module)
+
+{
+   cur_target->relocate(handle, elf_file, dyn_module);
+}
+
+/*****************************************************************************/
+/* GET_VT_OBJ() - Once file headers have been read, use the e_machine id to  */
+/*        figure out the virtul target, so we can access trg specific funcs. */
+/*****************************************************************************/
+static VIRTUAL_TARGET *get_vt_obj(int given_id)
+{
+   VIRTUAL_TARGET *ptr;
+
+   for(ptr = vt_arr; ptr->machine_id != EM_NONE ; ptr++)
+      if (ptr->machine_id == given_id) return ptr;
+
+   return NULL;
+}
+
+#if 0 && LOADER_DEBUG   // enable to make available in debugger
+/*****************************************************************************/
+/* DEBUG_QUEUE() - Debug function.                                           */
+/*****************************************************************************/
+static void debug_queue(LOADER_OBJECT *pHandle, char* position)
+{
+   loaded_module_ptr_Queue_Node* ptr;
+
+   if (!debugging_on) return;
+
+   DLIF_trace ("\nDEBUG QUEUE : %s, pHandle : 0x%x\n\n", position,
+           (uint32_t)pHandle);
+
+   for (ptr = pHandle->DLIMP_loaded_objects.front_ptr; ptr != NULL;
+              ptr = ptr->next_ptr)
+   {
+      DLIF_trace ("ptr->value->name : %s\n",ptr->value->name);
+   }
+   DLIF_trace ("\n");
+}
+#endif
+
+/*****************************************************************************/
+/* READ_ARGS_FROM_SECTION() - This function reads the argc, argv from the    */
+/*         .args section, and is used to test Reference implementation.      */
+/*****************************************************************************/
+static void read_args_from_section(DLIMP_Loaded_Module* ep_module)
+{
+#if 0  /* TBD: not working. c_args is target address and cannot be dereferenced. */
+   /*------------------------------------------------------------------------*/
+   /* Before this function in called, the loader has gotten argv/argc from   */
+   /* the module and written it out to the .args section. c_args points to   */
+   /* the .args section.                                                     */
+   /*------------------------------------------------------------------------*/
+   ARGS_CONTAINER *pargs = (ARGS_CONTAINER *)(ep_module->c_args);
+   if (!pargs || pargs == (ARGS_CONTAINER *)0xFFFFFFFF)
+   {
+      global_argc = 0;
+      global_argv = NULL;
+   }
+   else
+   {
+      global_argc = pargs->argc;
+      global_argv = pargs->argv;
+   }
+#endif
+}
\ No newline at end of file
index 0ca6a55e60bdb417f3a37cfff48852b483d321cc..e8463e5d4b9292cd0771a6a36b31ed42cabeb755 100644 (file)
@@ -3,7 +3,7 @@
 *
 * Define internal data structures used by core dynamic loader.
 *
-* Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
+* Copyright (C) 2009-2015 Texas Instruments Incorporated - http://www.ti.com/
 *
 *
 * Redistribution and use in source and binary forms, with or without
 #include "dload_api.h"
 #include "util.h"
 
+/*---------------------------------------------------------------------------*/
+/* Contains strings with names of files the loader is in process of loading. */
+/* This list is used to keep track of what objects are in the process of     */
+/* loading while their dependents are being loaded so that we can detect     */
+/* circular dependencies.                                                    */
+/*---------------------------------------------------------------------------*/
+extern Array_List DLIMP_module_dependency_list;
 
 /*---------------------------------------------------------------------------*/
 /* DLIMP_Loaded_Segment                                                      */
@@ -62,26 +69,10 @@ typedef struct
    struct Elf32_Phdr            phdr;
    Elf32_Addr                   input_vaddr;  /* original segment load addr  */
    BOOL                         modified;
-   int32_t                      reloc_offset; /* used by load_program        */
    struct DLOAD_MEMORY_SEGMENT *obj_desc;
+   void *                       host_address;
 } DLIMP_Loaded_Segment;
 
-/*---------------------------------------------------------------------------*/
-/* DLIMP_Section_Info                                                        */
-/*                                                                           */
-/*    This structure represents section info from ELF file.                  */
-/*                                                                           */
-/*    This data structure should be created using host memory when a module  */
-/*    is being loaded into target memory.  The data structure should persist */
-/*    as long as the module stays resident in target memory.  It should be   */
-/*    removed when the last use of the module is unloaded from the target.   */
-/*---------------------------------------------------------------------------*/
-typedef struct
-{
-   struct Elf32_Shdr            shdr;
-   char*                        sh_name;
-} DLIMP_Section_Info;
-
 /*---------------------------------------------------------------------------*/
 /* DLIMP_Loaded_Module                                                       */
 /*                                                                           */
@@ -106,13 +97,14 @@ typedef struct
    char                *gstrtab;         /* Module's global symbol names    */
    Elf32_Word           gstrsz;          /* Size of global string table     */
    Array_List           loaded_segments; /* List of DLIMP_Loaded_Segment(s) */
-   Array_List           sections;        /* List of DLIMP_Section_Info(s) */
    Array_List           dependencies;    /* List of dependent file handles  */
    BOOL                 direct_dependent_only;
 
    Elf32_Addr           fini;            /* .fini function/section address  */
    Elf32_Addr           fini_array;      /* .fini_array term fcn ary addr   */
    int32_t              fini_arraysz;    /* sizeof .fini_array              */
+   uint8_t              *c_args;         /* address of module's .args sect  */
+   uint8_t              *static_base;    /* address of module's STATIC_BASE */
 
 } DLIMP_Loaded_Module;
 
@@ -123,6 +115,7 @@ typedef struct
 /*    loader has placed into target memory.                                  */
 /*---------------------------------------------------------------------------*/
 TYPE_QUEUE_DEFINITION(DLIMP_Loaded_Module*, loaded_module_ptr)
+extern loaded_module_ptr_Queue DLIMP_loaded_objects;
 
 /*---------------------------------------------------------------------------*/
 /* DLIMP_Dynamic_Module                                                      */
@@ -154,10 +147,6 @@ typedef struct
    struct Elf32_Ehdr    fhdr;          /* ELF Object File Header             */
    struct Elf32_Phdr   *phdr;          /* ELF Program Header Table           */
    Elf32_Word           phnum;         /* # entries in program header table  */
-   struct Elf32_Shdr   *shdr;          /* ELF Section Header Table (Optional)*/
-   Elf32_Word           shnum;         /* # entries in section header table  */
-   char*                shstrtab;      /* Section String Table               */
-   Elf32_Word           shstrsz;       /* String Table size in bytes         */
    char*                strtab;        /* String Table                       */
    Elf32_Word           strsz;         /* String Table size in bytes         */
    struct Elf32_Dyn    *dyntab;        /* Elf Dynamic Table (.dynamic scn)   */
@@ -172,6 +161,7 @@ typedef struct
                                        /* global symbol names start.         */
 
    uint8_t             *c_args;
+   uint8_t             *static_base;    /* address of module's STATIC_BASE */
    int32_t              argc;
    char               **argv;
    DLIMP_Loaded_Module *loaded_module;
@@ -206,6 +196,7 @@ typedef struct
 /*    or library. When relocation is completed, this stack should be empty.  */
 /*---------------------------------------------------------------------------*/
 TYPE_STACK_DEFINITION(DLIMP_Dynamic_Module*, dynamic_module_ptr)
+extern dynamic_module_ptr_Stack DLIMP_dependency_stack;
 
 /*---------------------------------------------------------------------------*/
 /* Private Loader Object instance.                                           */
@@ -238,14 +229,15 @@ typedef struct
     /*         when the modules are unloaded. It is conceivable that a loader*/
     /*         running for a long time and loading and unloading modules     */
     /*         could wrap-around. The loader generates error in this case.   */
+    /* Presumably each loader instance has a list of file handles, one for   */
+    /* each file that it loads, and the file handle serves as an index into  */
+    /* the list. Therefore even if the same file is loaded by two loader     */
+    /* instances, both loader instances have a different file handle for the */
+    /* file - the file is mapped uniquely to it's appopriate file handle per */
+    /* loader instance.                                                      */
     /*-----------------------------------------------------------------------*/
     int32_t                  file_handle;
 
-    /*-----------------------------------------------------------------------*/
-    /* Identify target supported by this implementation of the core loader.  */
-    /*-----------------------------------------------------------------------*/
-    int                      DLOAD_TARGET_MACHINE;
-
     /*-----------------------------------------------------------------------*/
     /* Client token, passed in via DLOAD_create()                            */
     /*-----------------------------------------------------------------------*/
@@ -253,6 +245,26 @@ typedef struct
 } LOADER_OBJECT;
 
 
+/*****************************************************************************/
+/* IF data : Below are the data structures used to store init-fini data.     */
+/*****************************************************************************/
+typedef struct
+{
+  TARGET_ADDRESS sect_addr;
+  int32_t size;
+}
+IF_single_record;
+
+TYPE_QUEUE_DEFINITION(IF_single_record*, IF_table)
+extern IF_table_Queue TI_init_table;
+
+
+/*****************************************************************************/
+/* Container used to read in argc, argv from the .srgs section.              */
+/*****************************************************************************/
+typedef struct { int argc; char *argv[1]; } ARGS_CONTAINER;
+
+
 /*****************************************************************************/
 /* is_DSBT_module()                                                          */
 /*                                                                           */
@@ -283,31 +295,6 @@ static inline BOOL is_c60_module(struct Elf32_Ehdr* fhdr)
     return fhdr->e_machine == EM_TI_C6000;
 }
 
-/*---------------------------------------------------------------------------*/
-/* Identifies the current supported target.  This is reset by the default    */
-/* value when all loaded objects have been unloaded.                         */
-/*---------------------------------------------------------------------------*/
-extern int DLOAD_TARGET_MACHINE;
-
-/*---------------------------------------------------------------------------*/
-/* Identify target which is supported by the core loader.  If set to EM_NONE */
-/* the target will be determined by the first loaded module.                 */
-/*---------------------------------------------------------------------------*/
-#if defined(ARM_TARGET) && defined(C60_TARGET)
-#define DLOAD_DEFAULT_TARGET_MACHINE  (EM_NONE)
-#elif defined(ARM_TARGET)
-#define DLOAD_DEFAULT_TARGET_MACHINE  (EM_ARM)
-#elif defined(C60_TARGET)
-#define DLOAD_DEFAULT_TARGET_MACHINE  (EM_TI_C6000)
-#else
-#error "ARM_TARGET and/or C60_TARGET must be defined"
-#endif
-
-/* =============================================================================
- *  APIs
- * =============================================================================
- */
-
 /*---------------------------------------------------------------------------*/
 /* DLIMP_update_dyntag_section_address()                                     */
 /*                                                                           */
@@ -317,8 +304,7 @@ extern int DLOAD_TARGET_MACHINE;
 /*    of the section.                                                        */
 /*                                                                           */
 /*---------------------------------------------------------------------------*/
-extern BOOL DLIMP_update_dyntag_section_address(
-                                               DLIMP_Dynamic_Module *dyn_module,
+extern BOOL DLIMP_update_dyntag_section_address(DLIMP_Dynamic_Module *dyn_module,
                                                 int32_t i);
 
 extern uint32_t DLIMP_get_first_dyntag(int tag, struct Elf32_Dyn* dyn_table);
@@ -326,28 +312,14 @@ extern uint32_t DLIMP_get_first_dyntag(int tag, struct Elf32_Dyn* dyn_table);
 /*---------------------------------------------------------------------------*/
 /* Global flags to help manage internal debug and profiling efforts.         */
 /*---------------------------------------------------------------------------*/
-#ifndef __TI_COMPILER_VERSION__
-#define LOADER_DEBUG 1
-#else
-#define LOADER_DEBUG 0
-#endif
-
-#undef LOADER_DEBUG
-
-#if !defined (__KERNEL__)
-#define LOADER_DEBUG 1
+#define LOADER_DEBUG   0
 #define LOADER_PROFILE 0
-#else
-// Leave LOADER_PROFILE == 0, otherwise time.h, cstdio.h pulled into Kernel!
-#define LOADER_DEBUG 1
-#define LOADER_PROFILE 0
-#endif
 
 #if LOADER_DEBUG
 extern BOOL debugging_on;
 #endif
 
-#if LOADER_DEBUG && LOADER_PROFILE
+#if LOADER_DEBUG || LOADER_PROFILE
 extern BOOL profiling_on;
 #endif
 
index 15560a1e9a4fe65c2e6098c89d4f820acdf97ec3..217862c5b7d8cf13ca65b4d20c887efc35778645 100644 (file)
@@ -21,7 +21,7 @@
 *    http://sco.com/developers/gabi/2003-12-17/contents.html
 *
 *
-* Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
+* Copyright (C) 2009-2015 Texas Instruments Incorporated - http://www.ti.com/
 *
 *
 * Redistribution and use in source and binary forms, with or without
 #ifndef ELF32_H
 #define ELF32_H
 
-#if defined (__KERNEL__)
-#include <linux/types.h>
-#else
 #include <inttypes.h>
-#endif
 
 /*---------------------------------------------------------------------------*/
 /* 32-Bit Data Types (Figure 1-2, page 1-2)                                  */
index bae2b3b1448576b87a6f3a23910ad8ee7b8bf56c..8df468153beec8b895852fd54f73208a48f02f88 100644 (file)
@@ -4,7 +4,7 @@
 * Declare names and IDs of all C6x-specific relocation types supported
 * in the dynamic loader.
 *
-* Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
+* Copyright (C) 2009-2015 Texas Instruments Incorporated - http://www.ti.com/
 *
 *
 * Redistribution and use in source and binary forms, with or without
 #ifndef RELOCATE_H
 #define RELOCATE_H
 
-#if defined (__KERNEL__)
-#include <linux/types.h>
-#else
 #include <inttypes.h>
-#endif
 #include "elf32.h"
 #include "dload.h"
 #include "dload_api.h"
@@ -62,10 +58,7 @@ extern time_t DLREL_total_reloc_time;
 /*---------------------------------------------------------------------------*/
 /* Landing point for core loader's relocation processor.                     */
 /*---------------------------------------------------------------------------*/
-void DLREL_relocate(DLOAD_HANDLE handle, LOADER_FILE_DESC *elf_file,
-                    DLIMP_Dynamic_Module *dyn_module);
-
-void DLREL_relocate_c60(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd,
-                    DLIMP_Dynamic_Module *dyn_module);
+void DLREL_relocate(DLOAD_HANDLE handle, LOADER_FILE_DESC *fd,
+                                            DLIMP_Dynamic_Module *dyn_module);
 
 #endif
index 308796b66591b668c2e46c1a590f6293cd787a16..46273ab53376bdb689bfacc60678b067ad12d321 100644 (file)
@@ -4,7 +4,7 @@
 * Specification of functions used by the core loader to create, maintain,
 * and destroy internal symbol tables.
 *
-* Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
+* Copyright (C) 2009-2015 Texas Instruments Incorporated - http://www.ti.com/
 *
 *
 * Redistribution and use in source and binary forms, with or without
@@ -69,8 +69,4 @@ BOOL DLSYM_lookup_local_symtab(const char       *sym_name,
 
 void DLSYM_copy_globals(DLIMP_Dynamic_Module *dyn_module);
 
-
-BOOL DLSYM_lookup_global_symtab(const char *sym_name, struct Elf32_Sym *symtab,
-                                Elf32_Word symnum, Elf32_Addr *sym_value);
-
 #endif
index fc4839bfbaf0e3d688b7236164fef4a865d0bb4e..57491655bea2c8595472a86618d86dd7532e914b 100644 (file)
@@ -4,7 +4,7 @@
 * Definition of some useful string comparison routines (not
 * not provided on all platforms) and a few generic macros.
 *
-* Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
+* Copyright (C) 2009-2015 Texas Instruments Incorporated - http://www.ti.com/
 *
 *
 * Redistribution and use in source and binary forms, with or without
 #ifndef UTIL_H
 #define UTIL_H
 
-#if defined(__KERNEL__)
-#include <linux/ctype.h>
-#else
 #include <ctype.h>
-#endif
 
 #if 0
 !defined(__linux)
@@ -81,8 +77,8 @@ static int strncasecmp(const char* s1, const char* s2, size_t n)
 /*****************************************************************************/
 /* Define MIN and MAX macros.                                                */
 /*****************************************************************************/
-#define MIN(x,y)       (((x) > (y)) ? (y) : (x))
-#define MAX(x,y)       (((x) >= (y)) ? (x) : (y))
+#define MIN(x,y)    (((x) > (y)) ? (y) : (x))
+#define MAX(x,y)    (((x) >= (y)) ? (x) : (y))
 
 /*****************************************************************************/
 /* C implementation of 'bool' type.                                          */
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/virtual_targets.h b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/virtual_targets.h
new file mode 100644 (file)
index 0000000..29e40a0
--- /dev/null
@@ -0,0 +1,68 @@
+/******************************************************************************
+* Copyright (c) 2012-2015, Texas Instruments Incorporated
+* All rights reserved.
+*
+* Property of Texas Instruments Incorporated. Restricted rights to use,
+* duplicate or disclose this code are granted through contract.
+******************************************************************************/
+#include "dload.h"
+#include "elf32.h"
+
+#ifdef C60_TARGET
+#include "c60_dynamic.h"
+#include "c60_reloc.h"
+#endif
+
+#ifdef ARM_TARGET
+#include "arm_dynamic.h"
+#include "arm_reloc.h"
+#endif
+
+/*****************************************************************************/
+/* Define a virtual target class to give access to target specific functions */
+/*****************************************************************************/
+typedef struct vtarget
+{
+   int machine_id;
+
+   BOOL (*relocate_dynamic_tag_info)(DLIMP_Dynamic_Module *dyn_module, int i);
+   BOOL (*process_eiosabi)(DLIMP_Dynamic_Module* dyn_module);
+   BOOL (*process_dynamic_tag)(DLIMP_Dynamic_Module *dyn_module, int i);
+   void (*relocate)(DLOAD_HANDLE handle, LOADER_FILE_DESC *elf_file,
+                    DLIMP_Dynamic_Module *dyn_module);
+
+} VIRTUAL_TARGET;
+
+
+
+/*****************************************************************************/
+/* Populate this for each target supported.                                  */
+/*****************************************************************************/
+VIRTUAL_TARGET vt_arr[] = {
+
+#ifdef C60_TARGET
+                 {
+                    EM_TI_C6000,
+                    DLDYN_c60_relocate_dynamic_tag_info,
+                    DLDYN_c60_process_eiosabi,
+                    DLDYN_c60_process_dynamic_tag,
+                    DLREL_c60_relocate
+                 },
+#endif
+#ifdef ARM_TARGET
+                 {
+                    EM_ARM,
+                    DLDYN_arm_relocate_dynamic_tag_info,
+                    DLDYN_arm_process_eiosabi,
+                    DLDYN_arm_process_dynamic_tag,
+                    DLREL_arm_relocate
+                 },
+#endif
+                 {
+                    EM_NONE,
+                    0,
+                    0,
+                    0,
+                    0
+                 }
+};
\ No newline at end of file
index 9001f2baded9562a52da7df0966f94d1e4f08e05..65b022d98859664faba1d6d41962269a6c6ab50a 100644 (file)
@@ -26,3 +26,7 @@
 
  1.0.0 - 17 July 2009  - Initial release of dynamic loader API and loader
                           core sources.
+
+ 2.0.0 - 1 Feb 2013     - Add client handle to several DLIF functions.
+                        - Add DLIF_exit() for loader abort.
+                       - Mandate that unsuccessful call to DLIF_malloc() must not return
index f265da4e320ddaf3f09e702c6fd1fc6512290ef7..afdcc05b62bdb47b7241feabda7ebf4d085089b1 100644 (file)
@@ -10,7 +10,7 @@
 * Core Loader side of API is assumed to be platform independent, but
 * object file format dependent and target dependent.
 *
-* Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
+* Copyright (C) 2009-2015 Texas Instruments Incorporated - http://www.ti.com/
 *
 *
 * Redistribution and use in source and binary forms, with or without
 #include <ti/syslink/Std.h>
 #include <inttypes.h>
 #include <stdio.h>
+#include "util.h"
+
+/* extern int debugging_on; */
 
 /*****************************************************************************/
 /* Specification of Loader File Descriptor.  If client side of the loader    */
 /* supports virtual memory, this may need to be updated to facilitate the    */
 /* use of mmap().                                                            */
 /*****************************************************************************/
-
-#if defined (__KERNEL__)
-typedef struct file LOADER_FILE_DESC;
-#else
 typedef FILE LOADER_FILE_DESC;
-#endif
 
 static const int LOADER_SEEK_SET = SEEK_SET;
 static const int LOADER_SEEK_CUR = SEEK_CUR;
@@ -68,10 +66,10 @@ static const int LOADER_SEEK_END = SEEK_END;
 /*****************************************************************************/
 /* TARGET_ADDRESS - type suitable for storing target memory address values.  */
 /*****************************************************************************/
-typedef void* TARGET_ADDRESS;
+typedef uint32_t TARGET_ADDRESS;
 
 /*****************************************************************************/
-/* DLOAD_HANDLE - defines the DLoad object handle.                           */
+/* Define DLOAD Object Handle                                                */
 /*****************************************************************************/
 typedef void * DLOAD_HANDLE;
 
@@ -86,14 +84,13 @@ typedef void * DLOAD_HANDLE;
 /*    dynamic loader's core loader source code.                              */
 /*                                                                           */
 /*---------------------------------------------------------------------------*/
-#define VERSION 1.2
+#include "version.h"
 #define DLOAD_version() VERSION
 
 /*---------------------------------------------------------------------------*/
 /* DLOAD_create()                                                            */
 /*                                                                           */
-/*    Create an instance of the dynamic loader, passing a handle to the      */
-/*    client-specific handle for this instance.                              */
+/*    Construct and initialize the dynamic loader core's handle.             */
 /*                                                                           */
 /*---------------------------------------------------------------------------*/
 DLOAD_HANDLE  DLOAD_create(void * client_handle);
@@ -101,7 +98,7 @@ DLOAD_HANDLE  DLOAD_create(void * client_handle);
 /*---------------------------------------------------------------------------*/
 /* DLOAD_destroy()                                                           */
 /*                                                                           */
-/*    Destroy the specified dynamic loader instance.                         */
+/*    Destroy and finalize the dynamic loader core's handle.                 */
 /*                                                                           */
 /*---------------------------------------------------------------------------*/
 void     DLOAD_destroy(DLOAD_HANDLE handle);
@@ -118,7 +115,8 @@ void     DLOAD_initialize(DLOAD_HANDLE handle);
 /*---------------------------------------------------------------------------*/
 /* DLOAD_finalize()                                                          */
 /*                                                                           */
-/*    Finalize the dynamic loader core.                                      */
+/*    Destroy and finalize data structures internal to the dynamic           */
+/*    loader core.                                                           */
 /*                                                                           */
 /*---------------------------------------------------------------------------*/
 void     DLOAD_finalize(DLOAD_HANDLE handle);
@@ -143,8 +141,7 @@ int32_t  DLOAD_load_symbols(DLOAD_HANDLE handle, LOADER_FILE_DESC* fp);
 /*    The core loader must have read access to the file pointed by fp.       */
 /*                                                                           */
 /*---------------------------------------------------------------------------*/
-int      DLOAD_load(DLOAD_HANDLE handle, LOADER_FILE_DESC* fp, int argc,
-                    char** argv);
+int      DLOAD_load(DLOAD_HANDLE handle, LOADER_FILE_DESC* fp);
 
 /*---------------------------------------------------------------------------*/
 /* DLOAD_unload()                                                            */
@@ -159,12 +156,13 @@ BOOL     DLOAD_unload(DLOAD_HANDLE handle, uint32_t pseudopid);
 /*---------------------------------------------------------------------------*/
 /* DLOAD_get_entry_names_info()                                              */
 /*                                                                           */
-/*    Given a file handle, get the information needed to create an array of  */
-/*    sufficient size to call DLOAD_get_entry_names.                         */
+/*    Given a file handle, return the number entry points that are           */
+/*    available in the specified file as well as the max name length.  This  */
+/*    can then be used by the client to allocate the appropriate amount of   */
+/*    memory needed to call DLOAD_get_entry_names()                          */
 /*                                                                           */
 /*---------------------------------------------------------------------------*/
-BOOL     DLOAD_get_entry_names_info(DLOAD_HANDLE handle,
-                                    uint32_t file_handle,
+BOOL     DLOAD_get_entry_names_info(DLOAD_HANDLE handle, uint32_t file_handle,
                                     int32_t *entry_pt_cnt,
                                     int32_t *entry_pt_max_name_len);
 
@@ -226,6 +224,40 @@ BOOL     DLOAD_get_section_offset(LOADER_FILE_DESC *fd, char * sect_name,
 BOOL     DLOAD_get_entry_point(DLOAD_HANDLE handle, uint32_t file_handle,
                                TARGET_ADDRESS *sym_val);
 
+/*---------------------------------------------------------------------------*/
+/* DLOAD_load_arguments()                                                    */
+/*                                                                           */
+/*    Given a file handle, find the object file associated with that handle  */
+/*    and copy the argc/argv information from the client into that object    */
+/*    file's .args section. The return value indicates whether the operation */
+/*    was successful. If there are no loaded object files which match the    */
+/*    handle or if there is insufficient space in the .args section to hold  */
+/*    the specified argc/argv information, the function will return false.   */
+/*                                                                           */
+/*---------------------------------------------------------------------------*/
+BOOL DLOAD_load_arguments(DLOAD_HANDLE handle, uint32_t file_handle,
+                           int argc, char** argv);
+
+/*---------------------------------------------------------------------------*/
+/* DLOAD_prepare_for_execution()                                             */
+/*                                                                           */
+/*    Given a file handle, prepare for execution :                           */
+/*     - Return entry point associated with that module in the *sym_val      */
+/*       output parameter.                                                   */
+/*     - Write out the given arguments to the .args section contained in the */
+/*       same module.                                                        */
+/*     - As a test (for the Reference implementation) read the arguments     */
+/*       using the DLIF_read_arguments() function and set global argc,argv.  */
+/*                                                                           */
+/*    The return value of the function indicates whether the file with the   */
+/*    specified handle was found or not.                                     */
+/*                                                                           */
+/*---------------------------------------------------------------------------*/
+BOOL     DLOAD_prepare_for_execution(DLOAD_HANDLE handle, uint32_t file_handle,
+                               TARGET_ADDRESS *sym_val,
+                               int argc, char** argv);
+
+
 /*****************************************************************************/
 /* Client Provided API Functions                                             */
 /*****************************************************************************/
@@ -301,6 +333,8 @@ int      DLIF_fclose(LOADER_FILE_DESC *fd);
 /*    (appropriate for the loader's internal data structures) by the dynamic */
 /*    loader.                                                                */
 /*                                                                           */
+/*    If allocation fails, this function must not return.                    */
+/*                                                                           */
 /*---------------------------------------------------------------------------*/
 void*    DLIF_malloc(size_t size);
 
@@ -341,11 +375,11 @@ static const int DLOAD_SF_relocatable = 0x2; /* Segment must be relocatable  */
 /*---------------------------------------------------------------------------*/
 struct DLOAD_MEMORY_SEGMENT
 {
-   uint32_t            target_page;     /* requested/returned memory page    */
-   TARGET_ADDRESS      target_address;  /* requested/returned address        */
-   uint32_t            objsz_in_bytes;  /* size of init'd part of segment    */
-   uint32_t            memsz_in_bytes;  /* size of memory block for segment  */
-   DLOAD_SEGMENT_FLAGS flags;           /* allocation request flags    */
+   uint32_t       target_page;          /* requested/returned memory page    */
+   TARGET_ADDRESS target_address;       /* requested/returned address        */
+   uint32_t       objsz_in_bytes;       /* size of init'd part of segment    */
+   uint32_t       memsz_in_bytes;       /* size of memory block for segment  */
+//   DLOAD_SEGMENT_FLAGS flags;           /* allocation request flags          */
 };
 
 /*---------------------------------------------------------------------------*/
@@ -367,6 +401,24 @@ struct DLOAD_MEMORY_REQUEST
    uint32_t                     align;        /* align of trg memory block   */
 };
 
+/*---------------------------------------------------------------------------*/
+/* DLIF_initMem()                                                            */
+/*                                                                           */
+/*    Given an address and size, initialize the memory used to load the      */
+/*    dynamic segments.  This should be called by the client before          */
+/*    beginning dynamic loading.                                             */
+/*                                                                           */
+/*---------------------------------------------------------------------------*/
+BOOL     DLIF_initMem(void* client_handle, uint32_t dynMemAddr, uint32_t size);
+
+/*---------------------------------------------------------------------------*/
+/* DLIF_deinitMem()                                                          */
+/*                                                                           */
+/*    De-initialize the memory used to load the dynamic segments.            */
+/*                                                                           */
+/*---------------------------------------------------------------------------*/
+BOOL     DLIF_deinitMem(void* client_handle);
+
 /*---------------------------------------------------------------------------*/
 /* DLIF_allocate()                                                           */
 /*                                                                           */
@@ -442,8 +494,16 @@ BOOL     DLIF_write(void* client_handle, struct DLOAD_MEMORY_REQUEST* req);
 /*    Given a host accessible buffer, read content of indicated target       */
 /*    memory address into the buffer.                                        */
 /*---------------------------------------------------------------------------*/
-BOOL     DLIF_read(void* client_handle, void *ptr, size_t size, size_t nmemb,
-                   TARGET_ADDRESS src);
+BOOL     DLIF_read(void* client_handle,
+                   void *ptr, size_t size, size_t nmemb, TARGET_ADDRESS src);
+
+/*---------------------------------------------------------------------------*/
+/* DLIF_memcpy()                                                             */
+/*                                                                           */
+/*    Given a host accessible buffer, copy content from specified buffer     */
+/*    into target memory.                                                    */
+/*---------------------------------------------------------------------------*/
+BOOL     DLIF_memcpy(void* client_handle, void *to, void *from, size_t size);
 
 /*---------------------------------------------------------------------------*/
 /* DLIF_execute()                                                            */
@@ -500,13 +560,6 @@ void     DLIF_unload_dependent(void* client_handle, uint32_t file_handle);
 /*                                                                           */
 /*---------------------------------------------------------------------------*/
 
-/*---------------------------------------------------------------------------*/
-/* DLIF_trace()                                                              */
-/*                                                                           */
-/*    Client implementation of Trace message output, alternative to printf.  */
-/*                                                                           */
-/*---------------------------------------------------------------------------*/
-void     DLIF_trace(const char *fmt, ...);
 
 /*---------------------------------------------------------------------------*/
 /* Loader Warning Types                                                      */
@@ -547,6 +600,21 @@ typedef enum {
 /*---------------------------------------------------------------------------*/
 void     DLIF_error(LOADER_ERROR_TYPE etype, const char *fmt, ...);
 
+/*---------------------------------------------------------------------------*/
+/* DLIF_exit()                                                               */
+/*                                                                           */
+/*    Abort the loader following a fatal error.                              */
+/*                                                                           */
+/*---------------------------------------------------------------------------*/
+void     DLIF_exit(int code);
+
+/*---------------------------------------------------------------------------*/
+/* DLIF_trace()                                                              */
+/*                                                                           */
+/*    Log a message with the client's trace handling infrastructure.         */
+/*                                                                           */
+/*---------------------------------------------------------------------------*/
+void     DLIF_trace(const char *fmt, ...);
 
 /*---------------------------------------------------------------------------*/
 /* Dynamic Static Base Table (DSBT) Support Functions                        */
@@ -652,4 +720,4 @@ int32_t  DLIF_get_dsbt_index(int32_t file_handle);
 /*---------------------------------------------------------------------------*/
 BOOL     DLIF_update_all_dsbts(void);
 
-#endif
+#endif
\ No newline at end of file
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD_SYM/Makefile.inc b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD_SYM/Makefile.inc
deleted file mode 100644 (file)
index b712307..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#   ============================================================================
-#   @file   Makefile.inc
-#
-#   @brief  Makefile definitions
-#
-#
-#   @ver        02.00.00.19
-#
-#   ============================================================================
-#
-#   Copyright (c) 2008-2009, Texas Instruments Incorporated
-#   All rights reserved.
-#
-#   Redistribution and use in source and binary forms, with or without
-#   modification, are permitted provided that the following conditions
-#   are met:
-#
-#   *  Redistributions of source code must retain the above copyright
-#      notice, this list of conditions and the following disclaimer.
-#
-#   *  Redistributions in binary form must reproduce the above copyright
-#      notice, this list of conditions and the following disclaimer in the
-#      documentation and/or other materials provided with the distribution.
-#
-#   *  Neither the name of Texas Instruments Incorporated nor the names of
-#      its contributors may be used to endorse or promote products derived
-#      from this software without specific prior written permission.
-#
-#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-#   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-#   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-#   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-#   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-#   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-#   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-#   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-#   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-#   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
-#   EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#   Contact information for paper mail:
-#   Texas Instruments
-#   Post Office Box 655303
-#   Dallas, Texas 75265
-#   Contact information:
-#   http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
-#   DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
-#   ============================================================================
-
-OBJECTS := symtab.o
index 4d8f306f4eeda92be8b813c05c15dd13a3d47105..997ddbd67fd5a5ff2017c0e4a73d606a03050274 100644 (file)
@@ -7,7 +7,7 @@
 * (assumed to be DSP Bridge or Linux model, indicated by
 * direct_dependent_only flag in a given Module).
 *
-* Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
+* Copyright (C) 2009-2015 Texas Instruments Incorporated - http://www.ti.com/
 *
 *
 * Redistribution and use in source and binary forms, with or without
@@ -52,22 +52,19 @@ TYPE_QUEUE_IMPLEMENTATION(int32_t, Int32)
 
 #include "symtab.h"
 #include "dload_api.h"
-#include "dload.h"
-#if defined (__KERNEL__)
-#include <linux/string.h>
-#else
-#include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
-#endif
 
-#undef LOADER_DEBUG
-#define LOADER_DEBUG 0
 /*---------------------------------------------------------------------------*/
 /* Holds the handle of the ET_EXEC-type mmodule loaded, if any.              */
 /*---------------------------------------------------------------------------*/
 int32_t DLIMP_application_handle = 0;
 
+/*---------------------------------------------------------------------------*/
+/* Function prototypes                                                       */
+/*---------------------------------------------------------------------------*/
+BOOL DLSYM_lookup_global_symtab(const char *sym_name, struct Elf32_Sym *symtab,
+                                Elf32_Word symnum, Elf32_Addr *sym_value);
+
 /*****************************************************************************/
 /* DLSYM_COPY_GLOBALS() - Copy global symbols from the dynamic module's      */
 /*      symbol table to the loader's global symbol table.                    */
@@ -96,28 +93,39 @@ void DLSYM_copy_globals(DLIMP_Dynamic_Module *dyn_module)
    /*------------------------------------------------------------------------*/
 
    if (module->gsymtab)
+   {
        DLIF_free(module->gsymtab);
-   module->gsymtab = DLIF_malloc(sizeof(struct Elf32_Sym) * global_symnum);
-   module->gsymnum = global_symnum;
+       module->gsymtab = NULL;
+   }
+
+   if (global_symnum > 0)
+   {
+      module->gsymtab = DLIF_malloc(sizeof(struct Elf32_Sym) * global_symnum);
 
-   if (module->gsymtab)
       memcpy(module->gsymtab,
              &dyn_module->symtab[global_index],
              sizeof(struct Elf32_Sym) * global_symnum);
+   }
+   module->gsymnum = global_symnum;
 
    /*------------------------------------------------------------------------*/
    /* Copy the string table part that contains the global symbol names.      */
    /*------------------------------------------------------------------------*/
    if (module->gstrtab)
+   {
        DLIF_free(module->gstrtab);
+       module->gstrtab = NULL;
+   }
 
    module->gstrsz  = dyn_module->strsz - dyn_module->gstrtab_offset;
-   module->gstrtab = DLIF_malloc(module->gstrsz);
+   if (module->gstrsz)
+   {
+      module->gstrtab = DLIF_malloc(module->gstrsz);
 
-   if (module->gstrtab)
       memcpy(module->gstrtab,
              dyn_module->strtab + dyn_module->gstrtab_offset,
              module->gstrsz);
+   }
 
    /*------------------------------------------------------------------------*/
    /* Update the symbol names of the global symbol entries to point to       */
@@ -132,13 +140,12 @@ void DLSYM_copy_globals(DLIMP_Dynamic_Module *dyn_module)
       Elf32_Word old_offset = dyn_module->symtab[i + global_index].st_name -
                               (Elf32_Addr) dyn_module->strtab;
       Elf32_Word new_offset = old_offset - dyn_module->gstrtab_offset;
-      if(module->gsymtab) {
-         struct Elf32_Sym *sym = &((struct Elf32_Sym*)(module->gsymtab))[i];
-         sym->st_name = new_offset + (Elf32_Addr)module->gstrtab;
-      }
+      struct Elf32_Sym *sym = &((struct Elf32_Sym*)(module->gsymtab))[i];
+      sym->st_name = new_offset + (Elf32_Addr)module->gstrtab;
+
 #if LOADER_DEBUG
-      if (debugging_on) DLIF_trace("Copying symbol: %s\n", (char *)
-                                 dyn_module->symtab[i + global_index].st_name);
+      if (debugging_on) DLIF_trace("Copying symbol: %s\n",
+                          (char*)dyn_module->symtab[i + global_index].st_name);
 #endif
    }
 }
@@ -156,10 +163,9 @@ static BOOL breadth_first_lookup(DLOAD_HANDLE phandle,
    /* We start this function by putting the specified file handle on the     */
    /* file_handle_queue.                                                     */
    /*------------------------------------------------------------------------*/
-   Int32_Queue file_handle_queue;
-   Int32_initialize_queue(&file_handle_queue);
-   Int32_enqueue(&file_handle_queue, handle);
    LOADER_OBJECT *dHandle = (LOADER_OBJECT *)phandle;
+   Int32_Queue file_handle_queue = TYPE_QUEUE_INITIALIZER;
+   Int32_enqueue(&file_handle_queue, handle);
 
    /*------------------------------------------------------------------------*/
    /* While the queue is not empty, keep looking for the symbol.             */
@@ -293,19 +299,24 @@ static BOOL DLSYM_lookup_symtab(const char *sym_name, struct Elf32_Sym *symtab,
                                 BOOL require_local_binding)
 {
    Elf32_Addr sym_idx;
+
+#if LOADER_DEBUG
+      if (debugging_on)
+         DLIF_trace("DLSYM_lookup_symtab, sym to find : %s\n", sym_name);
+#endif
+
    for (sym_idx = 0; sym_idx < symnum; sym_idx++)
    {
 #if LOADER_DEBUG
       if (debugging_on)
-         DLIF_trace("DLSYM_lookup_symtab %s\n",
-                    (char *)symtab[sym_idx].st_name);
+         DLIF_trace("\tPotential symbol match : %s\n",
+                 (char*)symtab[sym_idx].st_name);
 #endif
 
-      if ((symtab[sym_idx].st_shndx != SHN_UNDEF) &&
-          ((require_local_binding &&
-            (ELF32_ST_BIND(symtab[sym_idx].st_info) == STB_LOCAL)) ||
-          (!require_local_binding &&
-           (ELF32_ST_BIND(symtab[sym_idx].st_info) != STB_LOCAL))) &&
+      if ((symtab[sym_idx].st_shndx != SHN_UNDEF) && ((require_local_binding &&
+          (ELF32_ST_BIND(symtab[sym_idx].st_info) == STB_LOCAL)) ||
+      (!require_local_binding &&
+      (ELF32_ST_BIND(symtab[sym_idx].st_info) != STB_LOCAL))) &&
           !strcmp(sym_name,(char*)(symtab[sym_idx].st_name)))
       {
          if (sym_value) *sym_value = symtab[sym_idx].st_value;
@@ -349,8 +360,7 @@ BOOL DLSYM_lookup_local_symtab(const char *sym_name, struct Elf32_Sym *symtab,
 /*                             symbol table that contains the symbol tables  */
 /*                             from all the necessary modules.               */
 /*****************************************************************************/
-BOOL DLSYM_canonical_lookup(DLOAD_HANDLE handle,
-                            int sym_index,
+BOOL DLSYM_canonical_lookup(DLOAD_HANDLE handle, int sym_index,
                             DLIMP_Dynamic_Module *dyn_module,
                             Elf32_Addr *sym_value)
 {
@@ -362,7 +372,9 @@ BOOL DLSYM_canonical_lookup(DLOAD_HANDLE handle,
    int32_t           st_vis  = ELF32_ST_VISIBILITY(sym->st_other);
    BOOL              is_def  = (sym->st_shndx != SHN_UNDEF &&
                                (sym->st_shndx < SHN_LORESERVE ||
-                               sym->st_shndx == SHN_XINDEX));
+                                sym->st_shndx == SHN_ABS ||
+                                sym->st_shndx == SHN_COMMON ||
+                                sym->st_shndx == SHN_XINDEX));
    const char *sym_name = (char *)sym->st_name;
 
 #if LOADER_DEBUG
@@ -403,4 +415,4 @@ BOOL DLSYM_canonical_lookup(DLOAD_HANDLE handle,
       return DLSYM_global_lookup(handle, sym_name, dyn_module->loaded_module,
                                  sym_value);
    }
-}
+}
\ No newline at end of file
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/Makefile.ridl b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/Makefile.ridl
deleted file mode 100644 (file)
index be27a23..0000000
+++ /dev/null
@@ -1,229 +0,0 @@
-###############################################################################
-# This is the generic Makefile for all reference implementations of the       #
-# dynamic loader. It is meant to be included by a target specific Makefile.   #
-###############################################################################
-
-###############################################################################
-# Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/      #
-#                                                                             #
-#                                                                             #
-# Redistribution and use in source and binary forms, with or without          #
-# modification, are permitted provided that the following conditions          #
-# are met:                                                                    #
-#                                                                             #
-# Redistributions of source code must retain the above copyright              #
-# notice, this list of conditions and the following disclaimer.               #
-#                                                                             #
-# Redistributions in binary form must reproduce the above copyright           #
-# notice, this list of conditions and the following disclaimer in the         #
-# documentation and/or other materials provided with the                      #
-# distribution.                                                               #
-#                                                                             #
-# Neither the name of Texas Instruments Incorporated nor the names of         #
-# its contributors may be used to endorse or promote products derived         #
-# from this software without specific prior written permission.               #
-#                                                                             #
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS         #
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT           #
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR       #
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT        #
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,       #
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT            #
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,       #
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY       #
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT         #
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE       #
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.        #
-###############################################################################
-
-###############################################################################
-# Variables and their meanings.                                               #
-#                                                                             #
-# CC                      C compiler to be used                               #
-# C++                     C++ compiler to be used (required for unit testing) #
-# C_OPTS                  Options to be passed to compiler                    #
-# LNK_OPTS                Options to be passed during linking                 #
-# OUTPUT_FILE_OPTION      Compiler specific option used to specify the        #
-#                         object file output name                             #
-# HOST_PRFX               Prefix for the object file directory                #
-# HOST_EXT                Extension for the dynamic loader executable         #
-# TARG_TOOL_NAME_PRFX     Prefix for the dynamic loader executable            #
-# TARG_TOOL_NAME          Dynamic loader name, formed from the                #
-#                         TARG_TOOL_NAME_NAME_PRFX and HOST_EXT               #
-# OBJ_DIR                 Directory where object files are stored             #
-# UNIT_OBJ_DIR            Direcotry where object files for unit testing       #
-#                         are stored                                          #
-# UNIT_TEST_FILES         Generic files related to unit testing               #
-# TARG_UNIT_TEST_FILES    Target specific unit testing files.                 #
-# VPATH                   List of module directories                          #
-# FILES                   List of files related to building the dynamic       #
-#                         loader                                              #
-# UNIT_FILES              All files required for building a unit testing      #
-#                         executable.                                         #
-# HEADERS                 List of header files extracted from FILES           #
-# UNIT_HEADERS            List of header files extracted from UNIT_FILES      #
-# INCL                    Include directories                                 #
-# OBJS                    List of object files required for linking           #
-# OBJS_UNIT               List of object files required for linking a         #
-#                         unit testing executable.                            #
-###############################################################################
-
-###############################################################################
-# Set C++ compiler to be same as C compiler.  For gcc this must be changed
-# to g++
-###############################################################################
-C++ = $(CC)
-
-###############################################################################
-# Set host specific default options
-###############################################################################
-ifeq (cl6x, $(CC))
-HOST_PRFX = C60
-HOST_EXT = 6x
-C_OPTS += -mv6400+ ## Kelvin determines HW to simulate based on base image
-C_OPTS += -o
-C_OPTS += -pds67
-C_OPTS += --abi=elfabi
-OUTPUT_FILE_OPTION = --output_file
-LNK_OPTS += -z lnk.cmd --dynamic -c
-EXPORT_OPTS = DLWRAPPER/c60_export.cmd
-
-else ifeq (cl470, $(CC))
-HOST_PRFX = TMS470
-HOST_EXT = 470
-C_OPTS = -mv5e
-C_OPTS += -pds67
-C_OPTS += --abi=eabi
-OUTPUT_FILE_OPTION = --output_file
-LNK_OPTS += -z lnk.cmd --dynamic -c
-EXPORT_OPTS = DLWRAPPER/arm_export.cmd
-
-else ifeq (gcc, $(CC))
-HOST_PRFX = GCC
-HOST_EXT = gcc
-OUTPUT_FILE_OPTION = -o
-C++ = g++
-EXPORT_OPTS =
-
-else ifeq (rv31cc, $(CC))
-HOST_PRFX = RVCT
-HOST_EXT = rvct
-OUTPUT_FILE_OPTION = -o
-EXPORT_OPTS =
-
-else
-DEFAULT:
-       @echo "Compiler '$(CC)' not supported"
-       @exit 1
-endif
-
-TARG_TOOL_NAME = $(TARG_TOOL_NAME_PRFX).$(HOST_EXT)
-
-###############################################################################
-# List of generic modules and their files
-###############################################################################
-DLOAD_FILES = \
-        Queue.h \
-        ArrayList.c \
-        ArrayList.h \
-        dload.c \
-        dload.h \
-        elf32.c \
-        elf32.h \
-        dload_endian.c \
-        dload_endian.h \
-        relocate.h \
-        symtab.h \
-        util.h
-
-DLOAD_API_FILES = \
-        dload_api.h
-
-DLWRAPPER_FILES = \
-        dlw.c \
-        Stack.h \
-        dlw_debug.c \
-        dlw_debug.h \
-        dlw_dsbt.c \
-        dlw_dsbt.h \
-        dlw_trgmem.c \
-        dlw_trgmem.h \
-        dlmodules.c \
-        dlw_client.c
-
-DLOAD_SYM_FILES = symtab.c
-
-OBJ_DIR = $(HOST_PRFX)_LNX
-UNIT_OBJ_DIR = $(HOST_PRFX)_UNIT_LNX
-
-###############################################################################
-# Add any generic unit test files here
-###############################################################################
-UNIT_TEST_FILES = \
-        $(TARG_UNIT_TEST_FILES) \
-        runner.cpp
-
-VPATH = DLOAD DLOAD_API DLWRAPPER DLOAD_SYM $(TARG_VPATH)
-
-FILES = $(DLOAD_FILES) $(DLOAD_API_FILES) $(DLWRAPPER_FILES) $(TARG_SRCFILES) \
-        $(DLOAD_SYM_FILES)
-UNIT_FILES = $(FILES) $(UNIT_TEST_FILES)
-
-HEADERS = $(filter %.h, $(FILES))
-UNIT_HEADERS = $(filter %.h, $(UNIT_TEST_FILES))
-INCL = -I. $(patsubst %,-I%,$(VPATH))
-TARGET_TEMP = $(patsubst %,-D%,$(TARGET))
-DEFINE_TARGET = $(patsubst %,%_TARGET,$(TARGET_TEMP))
-
-OBJS = $(patsubst %.c,$(OBJ_DIR)/%.obj,$(filter %.c, $(FILES)))
-OBJS_UNIT = $(patsubst %.c,$(UNIT_OBJ_DIR)/%.obj,$(filter %.c, $(UNIT_FILES)))
-OBJS_UNIT += $(patsubst %.cpp,$(UNIT_OBJ_DIR)/%.obj,$(filter %.cpp, $(UNIT_FILES)))
-
-all: $(TARG_TOOL_NAME)
-unit: unit_$(TARG_TOOL_NAME)
-
-###############################################################################
-# Normal make process
-###############################################################################
-$(TARG_TOOL_NAME): $(OBJS) lnk.cmd
-       $(CC) $(C_OPTS) $(OBJS) $(LNK_OPTS) $(EXPORT_OPTS) -o $@
-
-$(OBJ_DIR)/%.obj: %.c $(HEADERS) $(OBJ_DIR)/.created
-       $(CC) -c $(C_OPTS) $(INCL) $(DEFINE_TARGET) $< $(OUTPUT_FILE_OPTION) $@
-
-$(OBJ_DIR)/.created:
-       mkdir -p $(OBJ_DIR)
-       touch $(OBJ_DIR)/.created
-
-
-###############################################################################
-# Unit test make process
-###############################################################################
-unit_$(TARG_TOOL_NAME): $(OBJS_UNIT) lnk.cmd
-       $(C++) $(C_OPTS) $(OBJS_UNIT) -z lnk.cmd -o $@
-
-
-$(UNIT_OBJ_DIR)/%.obj: %.c $(HEADERS) $(UNIT_OBJ_DIR)/.created
-       $(CC) -c -DUNIT_TEST=1 $(C_OPTS) $(INCL) $(DEFINE_TARGET) -I /db/sds13/packages/cxxtest-3.10.1 $< $(OUTPUT_FILE_OPTION) $@
-
-$(UNIT_OBJ_DIR)/%.obj: %.cpp $(HEADERS) $(UNIT_OBJ_DIR)/.created
-       $(CC) -c -DUNIT_TEST=1 $(C_OPTS) $(INCL) $(DEFINE_TARGET) -I /db/sds13/packages/cxxtest-3.10.1 $< $(OUTPUT_FILE_OPTION) $@
-
-runner.cpp: $(UNIT_HEADERS)
-       cxxtestgen.py --error-printer -o runner.cpp $(UNIT_HEADERS)
-
-$(UNIT_OBJ_DIR)/.created:
-       mkdir -p $(UNIT_OBJ_DIR)
-       touch $(UNIT_OBJ_DIR)/.created
-
-###############################################################################
-# Cleanup
-###############################################################################
-clean:
-       -rm -rf *_LNX
-       -rm -rf *$(TARG_TOOL_NAME_PRFX).*
-       -rm -f runner.cpp
-
-clean_host:
-       -rm -rf *$(HOST_PRFX)_LNX
-       -rm -rf *$(TARG_TOOL_NAME_PRFX).$(HOST_EXT)
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/arm_export.cmd b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/arm_export.cmd
deleted file mode 100644 (file)
index a931c08..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
---export=_ctypes_
---export=clock
---export=exit
---export=fclose
---export=fopen
---export=fread
---export=free
---export=ftell
---export=fwrite
---export=getenv
---export=malloc
---export=memcpy
---export=open
---export=printf
---export=strstr
---export=strcmp
---export=ltoa
---export=strcpy
---export=export_var
---export=_DLModules
---export=__aeabi_cdcmple
---export=__aeabi_dsub
---export=__aeabi_f2d
---export=__aeabi_fsub
---export=__aeabi_uidivmod
---export=__aeabi_idivmod
---export=__aeabi_fdiv
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/c60_export.cmd b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/c60_export.cmd
deleted file mode 100644 (file)
index 45a3d27..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
---export=__cxa_atexit
---export=__cxa_finalize
---export=__c6xabi_cmpd
---export=__c6xabi_cvtfd
---export=__c6xabi_divi
---export=__c6xabi_divu
---export=__c6xabi_llshru
---export=__c6xabi_remu
---export=__c6xabi_subd
---export=__c6xabi_subf
---export=__c6xabi_remi
---export=_ctypes_
---export=clock
---export=exit
---export=fclose
---export=fopen
---export=fread
---export=free
---export=ftell
---export=fwrite
---export=getenv
---export=malloc
---export=memcpy
---export=open
---export=printf
---export=strstr
---export=export_var
---export=strcmp
---export=ltoa
---export=_DLModules
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/dlmodules.c b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/dlmodules.c
deleted file mode 100644 (file)
index 99bea4b..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-* dlmodules.c
-*
-* Define a data object that will act as the DLL debug list header.  This
-* data structure will be filled in by the dynamic loader as the DLL debug
-* list is populated.
-*
-* Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
-*
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-*
-* Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-*
-* Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the
-* distribution.
-*
-* Neither the name of Texas Instruments Incorporated nor the names of
-* its contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-
-#include "dlw_debug.h"
-
-#pragma DATA_SECTION(_DLModules, ".dllview");
-DL_Debug_List_Header _DLModules[] = {NULL, 0, 0};
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/dlw.c b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/dlw.c
deleted file mode 100644 (file)
index c02355f..0000000
+++ /dev/null
@@ -1,848 +0,0 @@
-/*
-* dlw.c
-*
-* Client-side driver of reference implementation of the dynamic loader for
-* C6x.
-*
-* Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
-*
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-*
-* Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-*
-* Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the
-* distribution.
-*
-* Neither the name of Texas Instruments Incorporated nor the names of
-* its contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "ArrayList.h"
-#include "symtab.h"
-#include "dload.h"
-#include "dload_api.h"
-#include "util.h"
-#include "dlw_debug.h"
-#include "dlw_dsbt.h"
-#include "dlw_trgmem.h"
-
-int export_var=100;
-
-/*---------------------------------------------------------------------------*/
-/* Global function pointer that will be set to point at whatever entry       */
-/* point that we want to be in effect when the "execute" command is          */
-/* specified.                                                                */
-/*---------------------------------------------------------------------------*/
-static int (*loaded_program)() = NULL;
-
-/*---------------------------------------------------------------------------*/
-/* Handle of the loaded program.                                             */
-/*---------------------------------------------------------------------------*/
-static uint32_t prog_handle;
-
-/*****************************************************************************/
-/* Loader Testing Shell Functions                                            */
-/*                                                                           */
-/* These are intended for debugging and testing the loader.                  */
-/*****************************************************************************/
-
-/*****************************************************************************/
-/* LOAD_EXECUTABLE() - Invoke the loader to create an executable image of    */
-/*      the specified program, saving the loader's return value as the       */
-/*      future entry point.                                                  */
-/*****************************************************************************/
-static void load_executable(const char* file_name, int argc, char** argv)
-{
-   /*------------------------------------------------------------------------*/
-   /* Open specified file from "load" command, load it, then close the file. */
-   /*------------------------------------------------------------------------*/
-
-   /*------------------------------------------------------------------------*/
-   /* NOTE!! We require that any shared objects that we are trying to load   */
-   /* be in the current directory.                                           */
-   /*------------------------------------------------------------------------*/
-   /*------------------------------------------------------------------------*/
-   /* If there is registry available, we'll need to look up the given        */
-   /* file_name in the registry to find the actual pathname to be used       */
-   /* while opening the file.  Otherwise, we'll just use the given file      */
-   /* name.                                                                  */
-   /*------------------------------------------------------------------------*/
-   FILE* fp = fopen(file_name, "rb");
-
-   /*------------------------------------------------------------------------*/
-   /* Were we able to open the file successfully?                            */
-   /*------------------------------------------------------------------------*/
-   if (!fp)
-   {
-      DLIF_error(DLET_FILE, "Failed to open file '%s'.\n", file_name);
-      return;
-   }
-
-   /*------------------------------------------------------------------------*/
-   /* If we have a DLModules symbol available in the base image, then we     */
-   /* need to create debug information for this file in target memory to     */
-   /* support whatever DLL View plug-in or script is implemented in the      */
-   /* debugger.                                                              */
-   /*------------------------------------------------------------------------*/
-   if (DLL_debug)
-      DLDBG_add_host_record(file_name);
-
-   /*------------------------------------------------------------------------*/
-   /* Now, we are ready to start loading the specified file onto the target. */
-   /*------------------------------------------------------------------------*/
-   prog_handle = DLOAD_load(fp, argc, argv);
-   fclose(fp);
-
-   /*------------------------------------------------------------------------*/
-   /* If the load was successful, then we'll need to write the debug         */
-   /* information for this file into target memory.                          */
-   /*------------------------------------------------------------------------*/
-   if (prog_handle)
-   {
-      if (DLL_debug)
-      {
-        /*---------------------------------------------------------------*/
-        /* Allocate target memory for the module's debug record.  Use    */
-        /* host version of the debug information to determine how much   */
-        /* target memory we need and how it is to be filled in.          */
-        /*---------------------------------------------------------------*/
-        /* Note that we don't go through the normal API functions to get */
-        /* target memory and write the debug information since we're not */
-        /* dealing with object file content here.  The DLL View debug is */
-        /* supported entirely on the client side.                        */
-        /*---------------------------------------------------------------*/
-        DLDBG_add_target_record(prog_handle);
-      }
-
-      /*---------------------------------------------------------------------*/
-      /* Find entry point associated with loaded program's handle, set up    */
-      /* entry point in "loaded_program".                                    */
-      /*---------------------------------------------------------------------*/
-      DLOAD_get_entry_point(prog_handle, (TARGET_ADDRESS)(&loaded_program));
-      printf("loaded_program: 0x%x\n", loaded_program);
-   }
-
-   /*------------------------------------------------------------------------*/
-   /* Report failure to load an object file.                                 */
-   /*------------------------------------------------------------------------*/
-   else
-      DLIF_error(DLET_MISC, "Failed load of file '%s'.\n", file_name);
-}
-
-/*****************************************************************************/
-/* EXECUTE_PROGRAM() - Execute loaded program and print return value.        */
-/*****************************************************************************/
-static void execute_program(int argc, char** argv)
-{
-   /*------------------------------------------------------------------------*/
-   /* Have we got an entry point that we begin executing at?                 */
-   /*------------------------------------------------------------------------*/
-   if (loaded_program == NULL)
-   {
-      fprintf(stderr,"<< D O L T >> ERROR: No program has been loaded.\n");
-      return;
-   }
-
-   /*------------------------------------------------------------------------*/
-   /* Call loaded program at the entry point in "loaded_program".            */
-   /*------------------------------------------------------------------------*/
-   printf("Return value: %d\n", loaded_program(argc,argv));
-}
-
-/*---------------------------------------------------------------------------*/
-/* Global flag to control debug output.                                      */
-/*---------------------------------------------------------------------------*/
-#if LOADER_DEBUG
-BOOL debugging_on = 0;
-#endif
-
-/*---------------------------------------------------------------------------*/
-/* Global flag to enable profiling.                                          */
-/*---------------------------------------------------------------------------*/
-#if LOADER_DEBUG || LOADER_PROFILE
-BOOL profiling_on = 0;
-#endif
-
-/*---------------------------------------------------------------------------*/
-/* User command data structure                                               */
-/*---------------------------------------------------------------------------*/
-enum command_id_t
-{
-    INFORMATION,
-    LOAD_EXECUTABLE,
-    CORE,
-    EXIT,
-    HELP,
-    EXECUTE_PROGRAM,
-    UNLOAD_PROGRAM,
-    BASE_IMAGE,
-    DEBUG,
-    PROFILE,
-    COMMENT,
-    DUMP_TRGMEM,
-    CORE_VERSION,
-    ERROR_ID
-};
-
-struct commands_t
-{
-    const char *command;
-    enum command_id_t id;
-};
-
-static struct commands_t commands[] = {
-    { "information", INFORMATION },
-    { "load_executable", LOAD_EXECUTABLE },
-    { "core", CORE },
-    { "exit", EXIT },
-    { "help", HELP },
-    { "execute_program", EXECUTE_PROGRAM },
-    { "unload_program", UNLOAD_PROGRAM },
-    { "base_image", BASE_IMAGE },
-    { "dump_trgmem", DUMP_TRGMEM },
-    { "version", CORE_VERSION },
-#if LOADER_DEBUG
-    { "debug", DEBUG },
-#endif
-#if LOADER_DEBUG || LOADER_PROFILE
-    { "profile", PROFILE },
-#endif
-    { "#", COMMENT },
-};
-
-/*****************************************************************************/
-/* HELP() - Print a brief summary of the available commands.                 */
-/*****************************************************************************/
-static void help(void)
-{
-    int i;
-
-    fprintf(stderr, "Commands:\n");
-
-    for (i = 0; i < sizeof(commands) / sizeof(*commands); i++)
-        printf("\t%s\n", commands[i].command);
-}
-
-/*****************************************************************************/
-/* FIND_COMMAND_ID() - Look up a command name or partial command name in the */
-/*                     commands table.  Return an enum representing command. */
-/*****************************************************************************/
-static enum command_id_t find_command_id(const char *tok)
-{
-    int i, found = -1;
-    size_t tok_len = strlen(tok);
-
-    for (i = 0; i < sizeof(commands) / sizeof(*commands); i++)
-        if (!strncasecmp(tok, commands[i].command, tok_len))
-        {
-            if (found != -1)
-            {
-                fprintf(stderr,
-                        "<< D O L T >> ERROR: Ambiguous command '%s'\n", tok);
-                return ERROR_ID;
-            }
-            found = i;
-        }
-
-    if (found != -1) return commands[found].id;
-    else
-    {
-        fprintf(stderr, "Unknown command '%s'\n", tok);
-        return ERROR_ID;
-    }
-}
-
-/*****************************************************************************/
-/* INPUT_SERVER abstracts whether the commands come from the interactive     */
-/* command line, a script file, or the --command option                             */
-/*****************************************************************************/
-typedef struct input_server_t
-{
-    enum { IST_FILE, IST_STR } type;
-    FILE         *input_file;
-    const char   *string;
-    size_t        string_pos;
-} INPUT_SERVER;
-
-static INPUT_SERVER *cmd_set_file(FILE *input_file)
-{
-    INPUT_SERVER *input_server = malloc(sizeof(INPUT_SERVER));
-    input_server->type = IST_FILE;
-    input_server->input_file = input_file;
-    return input_server;
-}
-
-static INPUT_SERVER *cmd_set_string(const char *str)
-{
-    INPUT_SERVER *input_server = malloc(sizeof(INPUT_SERVER));
-    input_server->type = IST_STR;
-    input_server->string = str;
-    input_server->string_pos = 0;
-    return input_server;
-}
-
-static int cmd_getc(INPUT_SERVER *server)
-{
-    if (server->type == IST_FILE) return fgetc(server->input_file);
-    else
-    {
-       int ch;
-       if (!server->string) return EOF;
-       ch = server->string[server->string_pos++];
-       if (!ch) return EOF;
-       return ch;
-    }
-}
-
-static int cmd_error(INPUT_SERVER *server)
-{
-    if (server->type == IST_FILE) return ferror(server->input_file);
-    else return server->string == NULL;
-}
-
-static int cmd_eof(INPUT_SERVER *server)
-{
-    if (server->type == IST_FILE) return feof(server->input_file);
-    else return !cmd_error(server) && !server->string[server->string_pos];
-}
-
-static int cmd_isstdin(INPUT_SERVER *server)
-{
-    if (server->type == IST_FILE) return server->input_file == stdin;
-    else return 0;
-}
-
-/*****************************************************************************/
-/* GET_LINE() - Read up to buf_len bytes worth of command-line input.       */
-/*****************************************************************************/
-static char *get_line(char *cmd_buffer, size_t buf_len, INPUT_SERVER *server)
-{
-    size_t pos = 0;
-    /* fgets always NUL-terminates, we'll do the same */
-
-    while (pos < (buf_len - 1))
-    {
-       int ch;
-
-       if ((ch = cmd_getc(server)) == EOF)
-       {
-           if (cmd_error(server)) return NULL;
-           else if (pos) goto done; /* EOF, but read at least 1 char */
-           else return NULL;
-       }
-       else
-       {
-           if (ch == ';' || ch == '\n')
-           {
-               /* End of command.  Discard ';' or '\n' */
-               goto done;
-           }
-           else if (ch == '#')
-           {
-               /* comment start, discard everything until end-of-line */
-               while (((ch = cmd_getc(server)) != EOF) && ch != '\n')
-                   ;
-               goto done;
-           }
-           else
-           {
-               cmd_buffer[pos++] = ch;
-           }
-       }
-    }
-
-    /* Buffer overrun */
-    fprintf(stderr, "<< D O L T >> ERROR: command buffer overrun.\n");
-    exit(1);
-
-  done:
-
-    cmd_buffer[pos] = '\0';
-    return cmd_buffer;
-}
-
-/*****************************************************************************/
-/* MAIN() - RIDL client driver.  Implements a user-interactive shell, but    */
-/*      can also take input from a script file using "--script <file>"       */
-/*      command-line option.                                                 */
-/*****************************************************************************/
-#if UNIT_TEST
-int ridl_main(int argc, char** argv)
-#else
-int ridl_main(int argc, char** argv)
-#endif
-{
-   /*------------------------------------------------------------------------*/
-   /* Current length of a RIDL command is limited to a fixed-sized buffer.   */
-   /* Exceeding this fixed buffer will result in a runtime error.            */
-   /*------------------------------------------------------------------------*/
-   char cmd_buffer[1000];
-
-   /*------------------------------------------------------------------------*/
-   /* Identify command-line input stream.  By default, this is stdin, but    */
-   /* we can take commands from a script, using the --script option.         */
-   /*------------------------------------------------------------------------*/
-   INPUT_SERVER *cmd_server = cmd_set_file(stdin);
-
-   /*------------------------------------------------------------------------*/
-   /* Process command-line arguments to RIDL executable.                     */
-   /*------------------------------------------------------------------------*/
-   int a;
-   for (a = 1; a < argc; a++)
-   {
-      /*---------------------------------------------------------------------*/
-      /* RIDL can take input from a script file.  This is useful for running */
-      /* RIDL under a test harness.  Specify the script file using --script  */
-      /* option (usage: --script <file>).                                    */
-      /*---------------------------------------------------------------------*/
-      if (!strcmp(argv[a], "--script"))
-      {
-          if (cmd_server) free(cmd_server);
-          cmd_server = cmd_set_file(fopen(argv[a+1], "r"));
-      }
-
-      /*---------------------------------------------------------------------*/
-      /* RIDL can run commands specified on the command line.  This is      */
-      /* useful for running RIDL under a test harness.  Specify the commands */
-      /* --command option (usage: --command "<cmd1>; <cmd2>").              */
-      /*---------------------------------------------------------------------*/
-      if (!strcmp(argv[a], "--command"))
-      {
-          if (cmd_server) free(cmd_server);
-          cmd_server = cmd_set_string(argv[a+1]);
-      }
-
-#if LOADER_DEBUG
-      /*---------------------------------------------------------------------*/
-      /* Internal debug.  Can specify debugging from the command-line with   */
-      /* --debug option.  User interface also supports a "debug" command.    */
-      /*---------------------------------------------------------------------*/
-      if (!strcmp(argv[a], "--debug"))
-         debugging_on = 1;
-#endif
-
-#if LOADER_DEBUG || LOADER_PROFILE
-      /*---------------------------------------------------------------------*/
-      /* Profiling.  It is important that this loader is small and fast.     */
-      /* We may need to turn on profiing via --profile option to find where  */
-      /* the loader is sluggish.                                             */
-      /*---------------------------------------------------------------------*/
-      if (!strcmp(argv[a], "--profile"))
-         profiling_on = 1;
-#endif
-   }
-
-   /*------------------------------------------------------------------------*/
-   /* Initialize the dynamic loader.                                         */
-   /*------------------------------------------------------------------------*/
-   DLOAD_initialize();
-
-   /*------------------------------------------------------------------------*/
-   /* Initialize the client's model of the master DSBT.                      */
-   /*------------------------------------------------------------------------*/
-   AL_initialize(&DSBT_master, sizeof(DSBT_Entry), 1);
-
-   /*------------------------------------------------------------------------*/
-   /* Banner for user interaction mode.                                      */
-   /*------------------------------------------------------------------------*/
-   if (cmd_isstdin(cmd_server))
-   {
-      printf("Welcome to the Reference Implementation of the Dynamic Loader (RIDL).\n");
-      printf("Using %s\n", DLOAD_version());
-   }
-
-
-   /*------------------------------------------------------------------------*/
-   /* Command processing loop.                                               */
-   /*------------------------------------------------------------------------*/
-   cmd_buffer[0]='\0';
-   while(1)
-   {
-      int32_t prog_argc,i;
-      char* pathname;
-      char* tok, *str_argc;
-      Array_List prog_argv;
-
-      /*---------------------------------------------------------------------*/
-      /* In user interactive mode, prompt user for next command.             */
-      /*---------------------------------------------------------------------*/
-      if (cmd_isstdin(cmd_server)) printf("RIDL> ");
-
-      /*---------------------------------------------------------------------*/
-      /* Read up to semicolon, newline, or comment character.                */
-      /*---------------------------------------------------------------------*/
-      if (get_line(cmd_buffer, sizeof(cmd_buffer), cmd_server) == NULL)
-      {
-         if (cmd_eof(cmd_server))
-         {
-             if (cmd_isstdin(cmd_server)) printf("exit\n");
-             exit(0);
-         }
-         else
-         {
-             fprintf(stderr,
-                     "<< D O L T >> FATAL: "
-                     "Unknown error reading commands\n");
-             exit(1);
-         }
-      }
-
-      /*---------------------------------------------------------------------*/
-      /* Scan first token, skip over any empty command lines.                */
-      /*---------------------------------------------------------------------*/
-      tok = strtok(cmd_buffer, " \n");
-      if (!tok) continue;
-
-      /*---------------------------------------------------------------------*/
-      /* We have some kind of command.  Transfer control to the right place  */
-      /* in the loader.                                                      */
-      /*---------------------------------------------------------------------*/
-      switch (find_command_id(tok))
-      {
-         /*------------------------------------------------------------------*/
-         /* "exit"                                                           */
-         /*                                                                  */
-         /* This is a safe exit out of RIDL user-interface.                  */
-         /*------------------------------------------------------------------*/
-         case EXIT:
-           exit(0);
-           break;
-
-         /*------------------------------------------------------------------*/
-         /* "help"                                                           */
-         /*                                                                  */
-         /* Display a list of commands                                       */
-         /*------------------------------------------------------------------*/
-         case HELP:
-           help();
-           break;
-
-         /*------------------------------------------------------------------*/
-         /* "information"                                                    */
-         /*                                                                  */
-         /* Some minimally useful information.  Where is dl6x's printf()     */
-         /* and where is its exit()?                                         */
-         /*------------------------------------------------------------------*/
-         case INFORMATION:
-            printf("Host printf: %x\nHost exit: %x\n",printf, exit);
-            break;
-
-         /*------------------------------------------------------------------*/
-         /* "load <program> [<argc> <argv[0]> <argv[1]> ...]"                */
-         /*                                                                  */
-         /* Load an executable program into memory with the supplied command */
-         /* line arguments.  This will load any dependent files as well.     */
-         /*------------------------------------------------------------------*/
-         case LOAD_EXECUTABLE:
-            pathname = strtok(NULL," \n");
-            str_argc = strtok(NULL," \n");
-            if (str_argc)
-               prog_argc = strtoul(str_argc, NULL, 0);
-            else
-               prog_argc = 0;
-
-            /*---------------------------------------------------------------*/
-            /* Initialize Target Memory Allocator Interface                  */
-            /*---------------------------------------------------------------*/
-            AL_initialize(&prog_argv, sizeof(char*), 1);
-
-            /*---------------------------------------------------------------*/
-            /* Allocate a private copy of each argv string specified in the  */
-            /* load command.                                                 */
-            /*---------------------------------------------------------------*/
-            for (i = 0; i < prog_argc; i++)
-            {
-               char* temp = malloc(100);
-               strcpy(temp,strtok(NULL, " \n"));
-               AL_append(&prog_argv,&temp);
-            }
-
-            /*---------------------------------------------------------------*/
-            /* Write out progress information for arguments read from load   */
-            /* command.                                                      */
-            /*---------------------------------------------------------------*/
-            for (i = 0; i < prog_argc; i++)
-               printf("Arg %d: %s\n",i,*((char**)(prog_argv.buf) + i));
-
-            /*---------------------------------------------------------------*/
-            /* Go invoke the core loader to load the specified program.      */
-            /*---------------------------------------------------------------*/
-            load_executable(pathname, prog_argc, (char**)(prog_argv.buf));
-
-            /*---------------------------------------------------------------*/
-            /* Did we get a valid program handle back from the loader?       */
-            /*---------------------------------------------------------------*/
-            if (!prog_handle && !cmd_isstdin(cmd_server))
-            {
-               fprintf(stderr,
-                       "<< D O L T >> FATAL: load_executable failed in "
-                       "script. Terminating.\n");
-               exit(1);
-            }
-
-#if LOADER_DEBUG
-            /*---------------------------------------------------------------*/
-            /* If debug mode is turned on, then the loader will dump         */
-            /* whatever is in target memory  to a "prog.dump" file.          */
-           /* This file can be processed by dis6x or ofd6x for further      */
-           /* debugging.                                                    */
-            /*---------------------------------------------------------------*/
-            if (debugging_on)
-            {
-               FILE* dumpfile = fopen("prog.dump","wb");
-               if (!dumpfile)
-                  fprintf(stderr,
-                          "<< D O L T >> ERROR: prog.dump could not be "
-                          "written.\n");
-               else
-               {
-                 DLTMM_fwrite_trg_mem(dumpfile);
-                  fclose(dumpfile);
-               }
-            }
-#endif
-            break;
-
-         /*------------------------------------------------------------------*/
-         /* "core <entry point> [<argc> <argv[0]> <argv[1]> ...]"            */
-         /*                                                                  */
-         /* Load the core image "prog.dump" into target memory, setting the  */
-         /* specified address as the entry point.  Can also provide an       */
-         /* argument list to be passed into the executable program.          */
-         /*------------------------------------------------------------------*/
-         case CORE:
-         {
-            /*---------------------------------------------------------------*/
-            /* Find and open "prog.dump" file.  This should have been        */
-            /* created by a previous "load" command under debug.             */
-            /*---------------------------------------------------------------*/
-            FILE* core = fopen("prog.dump","rb");
-            if (!core)
-            {
-               fprintf(stderr,
-                       "<< D O L T >> ERROR: prog.dump could not be read.\n");
-               continue;
-            }
-
-            /*---------------------------------------------------------------*/
-            /* Read the contents of "prog.dump" into target memory area.     */
-            /*---------------------------------------------------------------*/
-            DLTMM_fread_trg_mem(core);
-            fclose(core);
-
-            /*---------------------------------------------------------------*/
-            /* Set entry point to specified entry point value (1st argument  */
-            /* to "core" command).                                           */
-            /*---------------------------------------------------------------*/
-            loaded_program = (int(*)())(strtoul(strtok(NULL," \n"),NULL,0));
-
-            /*---------------------------------------------------------------*/
-            /* Process any argc, argv stuff that we want to use for this     */
-            /* run.                                                          */
-            /*---------------------------------------------------------------*/
-            prog_argc = strtoul(strtok(NULL," \n"), NULL, 0);
-            AL_initialize(&prog_argv,sizeof(char*), 1);
-
-            for (i = 0; i < prog_argc; i++)
-            {
-               char* temp = malloc(100);
-               strcpy(temp,strtok(NULL," \n"));
-               AL_append(&prog_argv,&temp);
-            }
-
-            for (i = 0; i < prog_argc; i++)
-               printf("Arg %d: %s\n",i,*((char**)(prog_argv.buf) + i));
-          }
-          break;
-
-         /*------------------------------------------------------------------*/
-         /* "execute"                                                        */
-         /*                                                                  */
-         /* Transfer control to the most recently loaded program.  Expect    */
-         /* "loaded_program" to be pointing at entry point that we want to   */
-         /* start with.                                                      */
-         /*------------------------------------------------------------------*/
-         case EXECUTE_PROGRAM:
-            execute_program(prog_argc, (char**)(prog_argv.buf));
-            break;
-
-         /*------------------------------------------------------------------*/
-         /* "unload"                                                         */
-         /*                                                                  */
-         /* Unload the last program that was loaded into memory.  Does this  */
-         /* include any base image symbols?                                  */
-         /*------------------------------------------------------------------*/
-         /* We'll only worry about removing debug information if the module  */
-         /* is actually unloaded from target space (DLOAD_unload() returns   */
-         /* TRUE only if module is no longer needed and has indeed been      */
-         /* unloaded from target memory).                                    */
-         /*------------------------------------------------------------------*/
-         case UNLOAD_PROGRAM:
-            if (DLOAD_unload(prog_handle))
-            {
-               DSBT_release_entry(prog_handle);
-               if (DLL_debug) DLDBG_rm_target_record(prog_handle);
-            }
-
-            loaded_program = NULL;
-
-            break;
-
-         /*------------------------------------------------------------------*/
-         /* "base_image <program>"                                           */
-         /*                                                                  */
-         /* Load the global symbols from the dynamic symbol table of the     */
-         /* specified program.  It is assumed that the specified program     */
-         /* has already been loaded into target memory and is running.       */
-         /*------------------------------------------------------------------*/
-         case BASE_IMAGE:
-         {
-            char* base_image_name = strtok(NULL, " \n");
-            FILE* image = fopen(base_image_name, "rb");
-
-            /*---------------------------------------------------------------*/
-           /* Make sure that base image file was successfully opened.       */
-            /*---------------------------------------------------------------*/
-           if (!image)
-           {
-              DLIF_error(DLET_FILE, "Failed to open base image file '%s'.\n",
-                         base_image_name);
-              break;
-           }
-
-            /*---------------------------------------------------------------*/
-           /* Base image is assumed to be already loaded and running on the */
-           /* target.  The dynamic loader still has to read all of the      */
-           /* dynamic symbols in the base image so that we can link an      */
-           /* incoming DLL against the base image.                          */
-            /*---------------------------------------------------------------*/
-           if (!(prog_handle = DLOAD_load_symbols(image)))
-            {
-               /*------------------------------------------------------------*/
-               /* If we didn't get a proper file handle back from the        */
-               /* DLOAD_load_symbols() API function, then we need to recover */
-               /* gracefully.                                                */
-               /*------------------------------------------------------------*/
-               /* If a failure occurs from a script file, then we assume a   */
-               /* catastrophic failure and terminate the session.            */
-               /*------------------------------------------------------------*/
-              if (!prog_handle && !cmd_isstdin(cmd_server))
-               {
-                  fprintf(stderr,
-                          "<< D O L T >> FATAL: base_image failed in script. "
-                          "Terminating.\n");
-                  exit(1);
-               }
-            }
-
-            if (image) fclose(image);
-
-           /*---------------------------------------------------------------*/
-           /* Query base image for DLModules symbol to determine whether    */
-           /* debug support needs to be provided by the client side of the  */
-           /* loader.                                                       */
-           /*---------------------------------------------------------------*/
-           /* Note that space for the DLL View debug list is already        */
-           /* allocated as part of the base image, the header record is     */
-           /* initialized to zero and needs to be filled in when the first  */
-           /* module record is written to target memory.                    */
-           /*---------------------------------------------------------------*/
-           DLL_debug = DLOAD_query_symbol(prog_handle,
-                                                 "_DLModules", &DLModules_loc);
-        }
-        break;
-
-         /*------------------------------------------------------------------*/
-         /* dump_trgmem <offset>, <nbytes>, <filename>                       */
-         /*                                                                  */
-         /* Dumps nbytes from the target memory starting at <offset>.        */
-         /*------------------------------------------------------------------*/
-         case DUMP_TRGMEM:
-         {
-            char* offset_str = strtok(NULL, ",");
-            char* nbytes_str = strtok(NULL, ",");
-            uint32_t offset  = strtoul(offset_str, NULL, 0);
-            uint32_t nbytes  = strtoul(nbytes_str, NULL, 0);
-            char* fn         = strtok(NULL, " \n");
-            FILE* fp         = fopen(fn, "wb");
-
-            DLTMM_dump_trg_mem(offset, nbytes, fp);
-
-            fclose(fp);
-            break;
-         }
-
-         /*------------------------------------------------------------------*/
-        /* "version"                                                        */
-        /*                                                                  */
-        /* Echo version ID string for dynamic loader core to STDOUT.        */
-         /*------------------------------------------------------------------*/
-        case CORE_VERSION:
-            printf("\n%s\n", DLOAD_version());
-           break;
-
-         /*------------------------------------------------------------------*/
-         /* "debug"                                                          */
-         /*                                                                  */
-         /* Turn on debugging.  Could also increase level of debug if        */
-         /* we wanted to go for different levels of debug detail.            */
-         /*------------------------------------------------------------------*/
-#if LOADER_DEBUG
-         case DEBUG:
-            debugging_on = 1;
-            break;
-#endif
-
-         /*------------------------------------------------------------------*/
-         /* "profile"                                                        */
-         /*                                                                  */
-         /* Turn on profiling.  Used to find inefficiencies in loader speed  */
-         /* while debugging internally.                                      */
-         /*------------------------------------------------------------------*/
-#if LOADER_DEBUG || LOADER_PROFILE
-         case PROFILE:
-            profiling_on = 1;
-            break;
-#endif
-         /*------------------------------------------------------------------*/
-         /* Unrecognized commands will be reported and ignored.  We just     */
-         /* move onto the next prompt or line in the script.                 */
-         /* Note that in a script, if a line begins with '#', it is treated  */
-         /* as a comment.  Comment delimiter tokens must be first on a line. */
-         /*------------------------------------------------------------------*/
-         case COMMENT:
-         default:
-            if (tolower(tok[0]) != '#')
-               fprintf(stderr,
-                       "<< D O L T >> ERROR: Unrecognized command ignored.\n");
-            continue;
-      }
-   }
-
-   /*NOTREACHED*/
-   return 0;
-}
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/dlw_client.c b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/dlw_client.c
deleted file mode 100644 (file)
index 75accc2..0000000
+++ /dev/null
@@ -1,419 +0,0 @@
-/*
-* dlw_client.c
-*
-* RIDL implementation of client functions required by dynamic loader API.
-* Please see list of client-required API functions in dload_api.h.
-*
-* This implementation of RIDL is expected to run on the DSP.  It uses C6x
-* RTS functions for file I/O and memory management (both host and target
-* memory).
-*
-* A loader that runs on a GPP for the purposes of loading C6x code onto a
-* DSP will likely need to re-write all of the functions contained in this
-* module.
-*
-* Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
-*
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-*
-* Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-*
-* Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the
-* distribution.
-*
-* Neither the name of Texas Instruments Incorporated nor the names of
-* its contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-
-#include "ArrayList.h"
-#include "dload_api.h"
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-#include "dlw_debug.h"
-#include "dlw_dsbt.h"
-#include "dlw_trgmem.h"
-
-#define LOADER_DEBUG 0
-/*****************************************************************************/
-/* Client Provided File I/O                                                  */
-/*****************************************************************************/
-/*****************************************************************************/
-/* DLIF_FSEEK() - Seek to a position in specified file.                      */
-/*****************************************************************************/
-int DLIF_fseek(LOADER_FILE_DESC *stream, int32_t offset, int origin)
-{
-   return fseek(stream, offset, origin);
-}
-
-/*****************************************************************************/
-/* DLIF_FTELL() - Return the current position in the given file.             */
-/*****************************************************************************/
-int32_t DLIF_ftell(LOADER_FILE_DESC *stream)
-{
-   return ftell(stream);
-}
-
-/*****************************************************************************/
-/* DLIF_FREAD() - Read data from file into a host-accessible data buffer     */
-/*      that can be accessed through "ptr".                                  */
-/*****************************************************************************/
-size_t DLIF_fread(void *ptr, size_t size, size_t nmemb,
-                  LOADER_FILE_DESC *stream)
-{
-   return fread(ptr, size, nmemb, stream);
-}
-
-/*****************************************************************************/
-/* DLIF_FCLOSE() - Close a file that was opened on behalf of the core        */
-/*      loader. Core loader has ownership of the file pointer, but client    */
-/*      has access to file system.                                           */
-/*****************************************************************************/
-int32_t DLIF_fclose(LOADER_FILE_DESC *fd)
-{
-   return fclose(fd);
-}
-
-/*****************************************************************************/
-/* Client Provided Host Memory Management                                    */
-/*****************************************************************************/
-/*****************************************************************************/
-/* DLIF_MALLOC() - Allocate host memory suitable for loader scratch space.   */
-/*****************************************************************************/
-void* DLIF_malloc(size_t size)
-{
-   return malloc(size*sizeof(uint8_t));
-}
-
-/*****************************************************************************/
-/* DLIF_FREE() - Free host memory previously allocated with DLIF_malloc().   */
-/*****************************************************************************/
-void DLIF_free(void* ptr)
-{
-   free(ptr);
-}
-
-/*****************************************************************************/
-/* Client Provided Target Memory Management                                  */
-/*****************************************************************************/
-
-/*****************************************************************************/
-/* RIDL-Specific hack to facilitate target memory allocation.                */
-/*****************************************************************************/
-/*****************************************************************************/
-/* DLIF_ALLOCATE() - Return the load address of the segment/section          */
-/*      described in its parameters and record the run address in            */
-/*      run_address field of DLOAD_MEMORY_REQUEST.                           */
-/*****************************************************************************/
-BOOL DLIF_allocate(struct DLOAD_MEMORY_REQUEST *targ_req)
-{
-   /*------------------------------------------------------------------------*/
-   /* Get pointers to API segment and file descriptors.                      */
-   /*------------------------------------------------------------------------*/
-   struct DLOAD_MEMORY_SEGMENT* obj_desc = targ_req->segment;
-   LOADER_FILE_DESC* f = targ_req->fp;
-
-   /*------------------------------------------------------------------------*/
-   /* Request target memory for this segment from the "blob".                */
-   /*------------------------------------------------------------------------*/
-   if (!DLTMM_malloc(targ_req, obj_desc))
-   {
-      DLIF_error(DLET_MEMORY, "Failed to allocate target memory for segment.\n");
-      return 0;
-   }
-
-   /*------------------------------------------------------------------------*/
-   /* As required by API, copy the described segment into memory from file.  */
-   /* We're the client, not the loader, so we can use fseek() and fread().   */
-   /*------------------------------------------------------------------------*/
-   /* ??? I don't think we want to do this if we are allocating target       */
-   /*   memory for the run only placement of this segment.  If it is the     */
-   /*   load placement or both load and run placement, then we can do the    */
-   /*   copy.                                                                */
-   /*------------------------------------------------------------------------*/
-   memset(targ_req->host_address, 0, obj_desc->memsz_in_bytes);
-   fseek(f,targ_req->offset,SEEK_SET);
-   fread(targ_req->host_address,obj_desc->objsz_in_bytes,1,f);
-
-   /*------------------------------------------------------------------------*/
-   /* Once we have target address for this allocation, add debug information */
-   /* about this segment to the debug record for the module that is          */
-   /* currently being loaded.                                                */
-   /*------------------------------------------------------------------------*/
-   if (DLL_debug)
-   {
-      /*---------------------------------------------------------------------*/
-      /* Add information about this segment's location to the segment debug  */
-      /* information associated with the module that is currently being      */
-      /* loaded.                                                             */
-      /*---------------------------------------------------------------------*/
-      /* ??? We need a way to determine whether the target address in the    */
-      /*        segment applies to the load address of the segment or the    */
-      /*        run address.  For the time being, we assume that it applies  */
-      /*        to both (that is, the dynamic loader does not support        */
-      /*        separate load and run placement for a given segment).        */
-      /*---------------------------------------------------------------------*/
-      DLDBG_add_segment_record(obj_desc);
-   }
-
-#if LOADER_DEBUG
-   if (debugging_on)
-      printf("DLIF_allocate: buffer 0x%x\n", targ_req->host_address);
-#endif
-
-   /*------------------------------------------------------------------------*/
-   /* Target memory request was successful.                                  */
-   /*------------------------------------------------------------------------*/
-   return 1;
-}
-
-/*****************************************************************************/
-/* DLIF_RELEASE() - Unmap or free target memory that was previously          */
-/*      allocated by DLIF_allocate().                                        */
-/*****************************************************************************/
-BOOL DLIF_release(struct DLOAD_MEMORY_SEGMENT* ptr)
-{
-#if LOADER_DEBUG
-   if (debugging_on)
-      printf("DLIF_free: %d bytes starting at 0x%x\n",
-                                     ptr->memsz_in_bytes, ptr->target_address);
-#endif
-
-   /*------------------------------------------------------------------------*/
-   /* Find the target memory packet associated with this address and mark it */
-   /* as available (will also merge with adjacent free packets).             */
-   /*------------------------------------------------------------------------*/
-   DLTMM_free(ptr->target_address);
-
-   return 1;
-}
-
-/*****************************************************************************/
-/* DLIF_COPY() - Copy data from file to host-accessible memory.              */
-/*      Returns a host pointer to the data in the host_address field of the  */
-/*      DLOAD_MEMORY_REQUEST object.                                         */
-/*****************************************************************************/
-BOOL DLIF_copy(struct DLOAD_MEMORY_REQUEST* targ_req)
-{
-   targ_req->host_address = (void*)(targ_req->segment->target_address);
-   return 1;
-}
-
-/*****************************************************************************/
-/* DLIF_READ() - Read content from target memory address into host-          */
-/*      accessible buffer.                                                   */
-/*****************************************************************************/
-BOOL DLIF_read(void *ptr, size_t size, size_t nmemb, TARGET_ADDRESS src)
-{
-   if (!memcpy(ptr, (const void *)src, size * nmemb))
-      return 0;
-
-   return 1;
-}
-
-/*****************************************************************************/
-/* DLIF_WRITE() - Write updated (relocated) segment contents to target       */
-/*      memory.                                                              */
-/*****************************************************************************/
-BOOL DLIF_write(struct DLOAD_MEMORY_REQUEST* req)
-{
-   /*------------------------------------------------------------------------*/
-   /* Nothing to do since we are relocating directly into target memory.     */
-   /*------------------------------------------------------------------------*/
-   return 1;
-}
-
-/*****************************************************************************/
-/* DLIF_EXECUTE() - Transfer control to specified target address.            */
-/*****************************************************************************/
-int32_t DLIF_execute(TARGET_ADDRESS exec_addr)
-{
-   /*------------------------------------------------------------------------*/
-   /* This call will only work if the host and target are the same instance. */
-   /* The compiler may warn about this conversion from an object to a        */
-   /* function pointer.                                                      */
-   /*------------------------------------------------------------------------*/
-   return ((int32_t(*)())(exec_addr))();
-}
-
-
-/*****************************************************************************/
-/* Client Provided Communication Mechanisms to assist with creation of       */
-/* DLLView debug information.  Client needs to know exactly when a segment   */
-/* is being loaded or unloaded so that it can keep its debug information     */
-/* up to date.                                                               */
-/*****************************************************************************/
-/*****************************************************************************/
-/* DLIF_LOAD_DEPENDENT() - Perform whatever maintenance is needed in the     */
-/*      client when loading of a dependent file is initiated by the core     */
-/*      loader.  Open the dependent file on behalf of the core loader,       */
-/*      then invoke the core loader to get it into target memory. The core   */
-/*      loader assumes ownership of the dependent file pointer and must ask  */
-/*      the client to close the file when it is no longer needed.            */
-/*                                                                           */
-/*      If debug support is needed under the Braveheart model, then create   */
-/*      a host version of the debug module record for this object.  This     */
-/*      version will get updated each time we allocate target memory for a   */
-/*      segment that belongs to this module.  When the load returns, the     */
-/*      client will allocate memory for the debug module from target memory  */
-/*      and write the host version of the debug module into target memory    */
-/*      at the appropriate location.  After this takes place the new debug   */
-/*      module needs to be added to the debug module list.  The client will  */
-/*      need to update the tail of the DLModules list to link the new debug  */
-/*      module onto the end of the list.                                     */
-/*                                                                           */
-/*****************************************************************************/
-int DLIF_load_dependent(const char* so_name)
-{
-   /*------------------------------------------------------------------------*/
-   /* Find the path and file name associated with the given so_name in the   */
-   /* client's file registry.                                                */
-   /*------------------------------------------------------------------------*/
-   /* If we can't find the so_name in the file registry (or if the registry  */
-   /* is not implemented yet), we'll open the file using the so_name.        */
-   /*------------------------------------------------------------------------*/
-   int to_ret = 0;
-   FILE* fp = fopen(so_name, "rb");
-
-   /*------------------------------------------------------------------------*/
-   /* We need to make sure that the file was properly opened.                */
-   /*------------------------------------------------------------------------*/
-   if (!fp)
-   {
-      DLIF_error(DLET_FILE, "Can't open dependent file '%s'.\n", so_name);
-      return 0;
-   }
-
-   /*------------------------------------------------------------------------*/
-   /* If the dynamic loader is providing debug support for a DLL View plug-  */
-   /* in or script of some sort, then we are going to create a host version  */
-   /* of the debug module record for the so_name module.                     */
-   /*------------------------------------------------------------------------*/
-   /* In the Braveheart view of the world, debug support is only to be       */
-   /* provided if the DLModules symbol is defined in the base image.         */
-   /* We will set up a DLL_debug flag when the command to load the base      */
-   /* image is issued.                                                       */
-   /*------------------------------------------------------------------------*/
-   if (DLL_debug)
-      DLDBG_add_host_record(so_name);
-
-   /*------------------------------------------------------------------------*/
-   /* Tell the core loader to proceed with loading the module.               */
-   /*------------------------------------------------------------------------*/
-   /* Note that the client is turning ownership of the file pointer over to  */
-   /* the core loader at this point. The core loader will need to ask the    */
-   /* client to close the dependent file when it is done using the dependent */
-   /* file pointer.                                                          */
-   /*------------------------------------------------------------------------*/
-   to_ret = DLOAD_load(fp, 0, NULL);
-
-   /*------------------------------------------------------------------------*/
-   /* If the dependent load was successful, update the DLModules list in     */
-   /* target memory as needed.                                               */
-   /*------------------------------------------------------------------------*/
-   if (to_ret != 0)
-   {
-      /*---------------------------------------------------------------------*/
-      /* We will need to copy the information from our host version of the   */
-      /* debug record into actual target memory.                             */
-      /*---------------------------------------------------------------------*/
-      if (DLL_debug)
-      {
-         /*---------------------------------------------------------------*/
-         /* Allocate target memory for the module's debug record.  Use    */
-         /* host version of the debug information to determine how much   */
-         /* target memory we need and how it is to be filled in.          */
-         /*---------------------------------------------------------------*/
-         /* Note that we don't go through the normal API functions to get */
-         /* target memory and write the debug information since we're not */
-         /* dealing with object file content here.  The DLL View debug is */
-         /* supported entirely on the client side.                        */
-         /*---------------------------------------------------------------*/
-         DLDBG_add_target_record(to_ret);
-      }
-   }
-
-   /*------------------------------------------------------------------------*/
-   /* Report failure to load dependent.                                      */
-   /*------------------------------------------------------------------------*/
-   else
-      DLIF_error(DLET_MISC, "Failed load of dependent file '%s'.\n", so_name);
-
-   return to_ret;
-}
-
-/*****************************************************************************/
-/* DLIF_UNLOAD_DEPENDENT() - Perform whatever maintenance is needed in the   */
-/*      client when unloading of a dependent file is initiated by the core   */
-/*      loader.  Invoke the DLOAD_unload() function to get the core loader   */
-/*      to release any target memory that is associated with the dependent   */
-/*      file's segments.                                                     */
-/*****************************************************************************/
-void DLIF_unload_dependent(uint32_t handle)
-{
-   /*------------------------------------------------------------------------*/
-   /* If the specified module is no longer needed, DLOAD_load() will spin    */
-   /* through the object descriptors associated with the module and free up  */
-   /* target memory that was allocated to any segment in the module.         */
-   /*------------------------------------------------------------------------*/
-   /* If DLL debugging is enabled, find module debug record associated with  */
-   /* this module and remove it from the DLL debug list.                     */
-   /*------------------------------------------------------------------------*/
-   if (DLOAD_unload(handle))
-   {
-      DSBT_release_entry(handle);
-      if (DLL_debug) DLDBG_rm_target_record(handle);
-   }
-}
-
-/*****************************************************************************/
-/* Client Provided API Functions to Support Logging Warnings/Errors          */
-/*****************************************************************************/
-
-/*****************************************************************************/
-/* DLIF_WARNING() - Write out a warning message from the core loader.        */
-/*****************************************************************************/
-void DLIF_warning(LOADER_WARNING_TYPE wtype, const char *fmt, ...)
-{
-   va_list ap;
-   va_start(ap,fmt);
-   printf("<< D L O A D >> WARNING: ");
-   vprintf(fmt,ap);
-   va_end(ap);
-}
-
-/*****************************************************************************/
-/* DLIF_ERROR() - Write out an error message from the core loader.           */
-/*****************************************************************************/
-void DLIF_error(LOADER_ERROR_TYPE etype, const char *fmt, ...)
-{
-   va_list ap;
-   va_start(ap,fmt);
-   printf("<< D L O A D >> ERROR: ");
-   vprintf(fmt,ap);
-   va_end(ap);
-}
-
-/*****************************************************************************
- * END API FUNCTION DEFINITIONS
- *****************************************************************************/
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/dlw_debug.c b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/dlw_debug.c
deleted file mode 100644 (file)
index 5da521a..0000000
+++ /dev/null
@@ -1,409 +0,0 @@
-/*
-* dlw_debug.c
-*
-* This source file contains the implementation of the DLL debug support.
-* The client side of the ELF dynamic loader will write to target memory a
-* list of module debug records containing the final addresses of all
-* segments that were loaded to target memory by the dynamic loader.
-*
-* Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
-*
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-*
-* Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-*
-* Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the
-* distribution.
-*
-* Neither the name of Texas Instruments Incorporated nor the names of
-* its contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-
-#include "ArrayList.h"
-#include "symtab.h"
-#include "dload.h"
-#include "dload_api.h"
-#include "util.h"
-#include "dlw_debug.h"
-
-/*****************************************************************************/
-/* dl_debug                                                                  */
-/*                                                                           */
-/* Define a LIFO linked list "class" of DL_Module_Debug_Record pointers.     */
-/*****************************************************************************/
-TYPE_STACK_IMPLEMENTATION(DL_Host_Module_Debug*, dl_debug)
-
-/*****************************************************************************/
-/* mirror_debug_ptr                                                          */
-/*                                                                           */
-/* Define a linked list "class" of DL_Host_Module_Debug pointers.            */
-/*****************************************************************************/
-TYPE_QUEUE_IMPLEMENTATION(DL_Host_Module_Debug*, mirror_debug_ptr)
-
-/*---------------------------------------------------------------------------*/
-/* DLL debug support is enabled if _DLModules symbol is found in base image. */
-/*---------------------------------------------------------------------------*/
-BOOL DLL_debug = FALSE;
-mirror_debug_ptr_Queue mirror_debug_list;
-dl_debug_Stack dl_debug_stk;
-TARGET_ADDRESS DLModules_loc = 0;
-
-/*---------------------------------------------------------------------------*/
-/* Global flag to control debug output.                                      */
-/*---------------------------------------------------------------------------*/
-#if LOADER_DEBUG
-extern int debugging_on;
-#endif
-
-/*---------------------------------------------------------------------------*/
-/* Global flag to enable profiling.                                          */
-/*---------------------------------------------------------------------------*/
-#if LOADER_DEBUG || LOADER_PROFILE
-extern int profiling_on;
-#endif
-
-/*****************************************************************************/
-/* DLDBG_ADD_HOST_RECORD() - Construct a host version of a debug record      */
-/*     that is to be associated with the specified module.  The debug       */
-/*     record is placed on the top of the "context stack" while the module  */
-/*     is being loaded so that debug information about the location of the  */
-/*     module segments can be added during the load.                        */
-/*****************************************************************************/
-void DLDBG_add_host_record(const char *module_name)
-{
-   /*------------------------------------------------------------------------*/
-   /* Allocate a new DL_Host_Module_Debug record from host memory.           */
-   /*------------------------------------------------------------------------*/
-   DL_Host_Module_Debug *host_dbg =
-                  (DL_Host_Module_Debug *)malloc(sizeof(DL_Host_Module_Debug));
-
-   /*------------------------------------------------------------------------*/
-   /* Set up initial values.  Make a copy of the module name; everything     */
-   /* else is NULL.                                                          */
-   /*------------------------------------------------------------------------*/
-   host_dbg->module_name  = (char *)malloc(strlen(module_name) + 1);
-   strncpy(host_dbg->module_name, module_name, strlen(module_name));
-   host_dbg->module_name[strlen(module_name)] = '\0';
-
-   host_dbg->num_segments = 0;
-   host_dbg->segment_list_head =
-   host_dbg->segment_list_tail = NULL;
-
-   /*------------------------------------------------------------------------*/
-   /* Push the new host version of the debug record onto the context stack.  */
-   /* This module is now currently being loaded.  When its segments are      */
-   /* allocated and written into target memory, the debug record at the top  */
-   /* of the context stack will get updated with new segment information.    */
-   /*------------------------------------------------------------------------*/
-   dl_debug_push(&dl_debug_stk, host_dbg);
-}
-
-/*****************************************************************************/
-/* DLDBG_ADD_TARGET_RECORD() - Host version of the debug record on the top   */
-/*     of the context stack is now complete and the module associated has   */
-/*     been successfully loaded.  It is now time to create a target version */
-/*     of the debug record based on the host version.  Allocate space for   */
-/*     the target record and write the information from the host version of */
-/*     record into the target memory.  The host will retain a mirror copy   */
-/*     of the target debug record list so that it can update pointers in    */
-/*     the list when debug records are added to or removed from the list.   */
-/*****************************************************************************/
-void DLDBG_add_target_record(int handle)
-{
-   int i;
-   DL_Host_Module_Debug *host_dbg = dl_debug_pop(&dl_debug_stk);
-   struct DLOAD_MEMORY_REQUEST targ_req;
-   struct DLOAD_MEMORY_SEGMENT obj_desc;
-   DL_Host_Segment *host_seg = NULL;
-   DL_Target_Module_Debug *targ_dbg = NULL;
-   char *targ_module_name = NULL;
-
-   /*------------------------------------------------------------------------*/
-   /* Assign handle after loading has been completed.                        */
-   /*------------------------------------------------------------------------*/
-   host_dbg->handle = handle;
-
-   /*------------------------------------------------------------------------*/
-   /* Figure out how much target memory we need to hold all of the debug     */
-   /* record information for the module that just finished loading and its   */
-   /* segments.                                                              */
-   /*------------------------------------------------------------------------*/
-   obj_desc.memsz_in_bytes = sizeof(DL_Target_Module_Debug) +
-                (sizeof(DL_Target_Segment) * (host_dbg->num_segments - 1)) +
-               (strlen(host_dbg->module_name) + 1);
-
-
-   /*------------------------------------------------------------------------*/
-   /* Build up request for target memory in a local data object.             */
-   /*------------------------------------------------------------------------*/
-   targ_req.fp     = NULL;
-   targ_req.align  = 4;
-   targ_req.flags |= DLOAD_SF_relocatable;
-
-   /*------------------------------------------------------------------------*/
-   /* Request the target memory for the new debug record.                    */
-   /*------------------------------------------------------------------------*/
-   if (!DLTMM_malloc(&targ_req, &obj_desc))
-   {
-      DLIF_error(DLET_MEMORY,
-                                         "Failed to allocate target memory for debug record.\n");
-      exit(1);
-   }
-
-   /*------------------------------------------------------------------------*/
-   /* Write content of host version of the debug record into the target      */
-   /* version of the debug record in target memory.                          */
-   /*------------------------------------------------------------------------*/
-   targ_dbg = (DL_Target_Module_Debug *)obj_desc.target_address;
-   targ_dbg->tool_version = INIT_VERSION;
-   targ_dbg->verification_word = VERIFICATION;
-   targ_dbg->num_segments = host_dbg->num_segments;
-
-   for (host_seg = host_dbg->segment_list_head, i = 0;
-        host_seg; host_seg = host_seg->next_segment, i++)
-   {
-      targ_dbg->segments[i].load_address = host_seg->load_address;
-      targ_dbg->segments[i].run_address  = host_seg->run_address;
-   }
-
-   if (i != host_dbg->num_segments)
-   {
-      DLIF_error(DLET_MISC, "Debug record segment list mismatch.\n");
-      exit(1);
-   }
-
-   targ_module_name = ((char *)obj_desc.target_address +
-                        sizeof(DL_Target_Module_Debug) +
-                   (sizeof(DL_Target_Segment) * (host_dbg->num_segments - 1)));
-
-   memcpy(targ_module_name, host_dbg->module_name,
-                                          strlen(host_dbg->module_name) + 1);
-
-   /*------------------------------------------------------------------------*/
-   /* The host will hold onto access info for all target debug records so    */
-   /* the debug record list can be properly managed when adding or removing  */
-   /* debug records to/from the list.                                        */
-   /*------------------------------------------------------------------------*/
-   host_dbg->target_address = obj_desc.target_address;
-   host_dbg->next_module_ptr = NULL;
-   host_dbg->next_module_size = 0;
-
-   /*------------------------------------------------------------------------*/
-   /* Link the new target debug record into the module debug list.  This     */
-   /* means updating the debug record currently at the end of the list to    */
-   /* point at and give the size of the new debug record.                    */
-   /*------------------------------------------------------------------------*/
-   if (mirror_debug_list.size == 0)
-   {
-      DL_Debug_List_Header *dbg_hdr = (DL_Debug_List_Header *)DLModules_loc;
-      dbg_hdr->first_module_ptr = (uint32_t)(obj_desc.target_address);
-      dbg_hdr->first_module_size = obj_desc.memsz_in_bytes;
-   }
-   else
-   {
-      DL_Host_Module_Debug   *tail_host_dbg = mirror_debug_list.back_ptr->value;
-      DL_Target_Module_Debug *tail_targ_dbg = tail_host_dbg->target_address;
-
-      tail_targ_dbg->next_module_ptr  =
-      tail_host_dbg->next_module_ptr  = (uint32_t)(obj_desc.target_address);
-      tail_targ_dbg->next_module_size =
-      tail_host_dbg->next_module_size = obj_desc.memsz_in_bytes;
-   }
-
-   mirror_debug_ptr_enqueue(&mirror_debug_list, host_dbg);
-
-#if LOADER_DEBUG
-   if (debugging_on) DLDBG_dump_mirror_debug_list();
-#endif
-}
-
-/*****************************************************************************/
-/* DLDBG_RM_TARGET_RECORD() - Find the host version of the module debug      */
-/*     record on the mirror DLL debug list so that we can then find the     */
-/*     target version of the module debug record.  We'll unlink the target  */
-/*     version of the record from the DLL debug list, free the target       */
-/*     memory associated with the debug record, then finally, free the      */
-/*     host version of the module debug record.                             */
-/*****************************************************************************/
-void DLDBG_rm_target_record(int handle)
-{
-   mirror_debug_ptr_Queue_Node *prev_itr = NULL;
-   mirror_debug_ptr_Queue_Node *itr = mirror_debug_list.front_ptr;
-   DL_Host_Module_Debug *prev_host_dbg = NULL;
-   DL_Host_Module_Debug *host_dbg = itr->value;
-
-   /*------------------------------------------------------------------------*/
-   /* Base Image is assumed to have handle ID == 1, it won't be on the       */
-   /* DLL Debug list, so don't bother looking for it.                        */
-   /*------------------------------------------------------------------------*/
-   if (handle <= 1) return;
-
-   /*------------------------------------------------------------------------*/
-   /* Find host version of the module debug record using the module handle.  */
-   /*------------------------------------------------------------------------*/
-   for (; itr; itr = itr->next_ptr)
-   {
-      host_dbg = itr->value;
-      if (host_dbg->handle == handle) break;
-      prev_itr = itr;
-   }
-
-   if (!itr)
-   {
-      printf("Couldn't find handle %d on debug list\n", handle);
-      return;
-   }
-
-   /*------------------------------------------------------------------------*/
-   /* Unlink the target version of the module debug record from the DLL      */
-   /* debug list in target memory.                                           */
-   /*------------------------------------------------------------------------*/
-   /* The debug record to be removed may be in the middle or at the end of   */
-   /* the DLL debug list, or ...                                             */
-   /*------------------------------------------------------------------------*/
-   if (prev_itr)
-   {
-      DL_Target_Module_Debug *prev_targ_dbg = NULL;
-
-      prev_host_dbg = prev_itr->value;
-      prev_targ_dbg = (DL_Target_Module_Debug *)prev_host_dbg->target_address;
-
-      prev_host_dbg->next_module_ptr =
-      prev_targ_dbg->next_module_ptr = host_dbg->next_module_ptr;
-      prev_host_dbg->next_module_size =
-      prev_targ_dbg->next_module_size = host_dbg->next_module_size;
-   }
-
-   /*------------------------------------------------------------------------*/
-   /* The debug record could be at the front of the DLL debug list.  If so,  */
-   /* then we'll need to update the content of the list header object.       */
-   /*------------------------------------------------------------------------*/
-   else
-   {
-      DL_Debug_List_Header *dbg_hdr = (DL_Debug_List_Header *)DLModules_loc;
-      dbg_hdr->first_module_ptr = host_dbg->next_module_ptr;
-      dbg_hdr->first_module_size = host_dbg->next_module_size;
-   }
-
-   /*------------------------------------------------------------------------*/
-   /* Free target memory associated with the target version of the module    */
-   /* debug record.                                                          */
-   /*------------------------------------------------------------------------*/
-   DLTMM_free((char *)host_dbg->target_address);
-
-   /*------------------------------------------------------------------------*/
-   /* Find and remove the host version of the module debug record from the   */
-   /* mirror version of the DLL debug list, then free the host memory        */
-   /* associated with the object.                                            */
-   /*------------------------------------------------------------------------*/
-   mirror_debug_ptr_remove(&mirror_debug_list, host_dbg);
-
-#if LOADER_DEBUG
-   if (debugging_on) DLDBG_dump_mirror_debug_list();
-#endif
-}
-
-/*****************************************************************************/
-/* DLDBG_ADD_SEGMENT_RECORD() - Add a new segment record for the debug       */
-/*     record for the module at the top of the context stack.               */
-/*****************************************************************************/
-void DLDBG_add_segment_record(struct DLOAD_MEMORY_SEGMENT *obj_desc)
-{
-   /*------------------------------------------------------------------------*/
-   /* Get access to the module debug record at the top of the context stack. */
-   /*------------------------------------------------------------------------*/
-   DL_Host_Module_Debug *host_dbg = dl_debug_stk.top_ptr->value;
-
-   /*------------------------------------------------------------------------*/
-   /* Allocate host memory for a new segment debug record.                   */
-   /*------------------------------------------------------------------------*/
-   DL_Host_Segment *host_seg = (DL_Host_Segment *)malloc(sizeof(DL_Host_Segment));
-
-   /*------------------------------------------------------------------------*/
-   /* Fill load and run address fields of new segment debug record.          */
-   /*------------------------------------------------------------------------*/
-   host_seg->load_address =
-   host_seg->run_address  = (uint32_t)obj_desc->target_address;
-   host_seg->next_segment = NULL;
-
-   /*------------------------------------------------------------------------*/
-   /* Add the new segment debug record to the end of the segment list that   */
-   /* is attached to the module debug record.                                */
-   /*------------------------------------------------------------------------*/
-   if (host_dbg->num_segments == 0)
-   {
-      host_dbg->segment_list_head =
-      host_dbg->segment_list_tail = host_seg;
-   }
-   else
-   {
-      host_dbg->segment_list_tail->next_segment = host_seg;
-      host_dbg->segment_list_tail = host_seg;
-   }
-
-   host_dbg->num_segments++;
-}
-
-/*****************************************************************************/
-/* DLDBG_DUMP_MIRROR_DEBUG_LIST() - Write out contents of mirror debug list  */
-/*     so that we can debug what is being written to target memory on       */
-/*     behalf of the DLL View support.                                      */
-/*****************************************************************************/
-void DLDBG_dump_mirror_debug_list(void)
-{
-   mirror_debug_ptr_Queue_Node *itr = mirror_debug_list.front_ptr;
-
-   DL_Debug_List_Header *dbg_hdr = (DL_Debug_List_Header *)DLModules_loc;
-   printf("DLL View Debug List Header at 0x%lx\n", (unsigned long)dbg_hdr);
-   printf("   first module debug record at: 0x%lx\n",
-          (unsigned long)dbg_hdr->first_module_ptr);
-   printf("   first module debug record size: %d\n",
-          (int)dbg_hdr->first_module_size);
-
-   while (itr)
-   {
-      int i;
-      DL_Host_Module_Debug *host_dbg = itr->value;
-      DL_Host_Segment *host_seg = NULL;
-
-      printf("Module Debug Record for %s at 0x%lx\n",
-             host_dbg->module_name, (unsigned long)host_dbg->target_address);
-      printf("   next module debug record at: 0x%lx\n",
-             (unsigned long)host_dbg->next_module_ptr);
-      printf("   next module debug record size: %d\n",
-             (int)host_dbg->next_module_size);
-
-      printf("   handle for %s is %d\n", host_dbg->module_name, host_dbg->handle);
-      printf("   segment list for %s:\n", host_dbg->module_name);
-      for (i = 0, host_seg = host_dbg->segment_list_head;
-           host_seg; i++, host_seg = host_seg->next_segment)
-      {
-         printf("      segment [%d] load address: 0x%lx\n",
-               i, (unsigned long)host_seg->load_address);
-         printf("      segment [%d] run  address: 0x%lx\n",
-               i, (unsigned long)host_seg->run_address);
-      }
-
-      itr = itr->next_ptr;
-   }
-}
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/dlw_debug.h b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/dlw_debug.h
deleted file mode 100644 (file)
index 009f913..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
-* dlw_debug.h
-*
-* Define internal data structures used by RIDL client side for DLL debug.
-*
-* Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
-*
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-*
-* Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-*
-* Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the
-* distribution.
-*
-* Neither the name of Texas Instruments Incorporated nor the names of
-* its contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-
-#ifndef DLW_DEBUG_H
-#define DLW_DEBUG_H
-
-#include "dload_api.h"
-#include "Queue.h"
-#include "Stack.h"
-
-/*---------------------------------------------------------------------------*/
-/* DLL Debug Support                                                         */
-/*                                                                           */
-/* A host copy of the DLL View debug support data structure that will be     */
-/* written into target memory to assist the debugger with mapping symbol     */
-/* definitions to their dynamically loaded location in target memory.        */
-/*---------------------------------------------------------------------------*/
-#define INIT_VERSION   2
-#define VERIFICATION   0x79
-
-/*---------------------------------------------------------------------------*/
-/* DL_Debug_List_Header - Address of this structure in target memory is      */
-/*     recorded in DLModules symbol.  Provides directions to first          */
-/*     DL_Module_Record in the list.                                        */
-/*---------------------------------------------------------------------------*/
-typedef struct {
-   uint32_t    first_module_ptr;
-   uint16_t    first_module_size;
-   uint16_t    update_flag;
-} DL_Debug_List_Header;
-
-/*---------------------------------------------------------------------------*/
-/* DL_Segment - Debug information recorded about each segment in a module.   */
-/*---------------------------------------------------------------------------*/
-typedef struct {
-