summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (from parent 1: 437426c)
raw | patch | inline | side by side (from parent 1: 437426c)
author | vwan@ti.com <vwan@ti.com> | |
Wed, 21 Jan 2015 19:37:27 +0000 (11:37 -0800) | ||
committer | Robert 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>
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:
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
--- a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_DYN/Makefile.inc
+++ /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
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_DYN/c60_dynamic.c b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_DYN/c60_dynamic.c
index 92633cb5799a09a7ae503ee0a6c0972a5ca520e5..467c92097a5373e0b94f568e545c96c6f84f1231 100644 (file)
--- a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_DYN/c60_dynamic.c
+++ b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_DYN/c60_dynamic.c
*
* 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"
/*****************************************************************************/
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_DYN/c60_dynamic.h b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_DYN/c60_dynamic.h
index 185855e73071d0e7e2536fbdc3a750dab4abf588..a0cee7dcaa7cb3910b034e46d7bfefc71063f386 100644 (file)
--- a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_DYN/c60_dynamic.h
+++ b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_DYN/c60_dynamic.h
*
* 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
--- a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_REL/Makefile.inc
+++ /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
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_REL/c60_reloc.c b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/C60_DLOAD_REL/c60_reloc.c
index 7a67d121bf4afe4975836b98452a676a648b9290..a99f91383aa2a256dfebc88fb68abc6fff8ef594 100644 (file)
*
* 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)
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
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,
/* 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++;
/* 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;
}
/*------------------------------------------------------------------*/
/* 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;
}
/* 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
/*------------------------------------------------------------------------*/
if (debugging_on)
DLIF_trace("reloc_value = 0x%x\n", reloc_value);
#endif
-
}
/*****************************************************************************/
/*****************************************************************************/
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 */
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);
}
/*****************************************************************************/
/*****************************************************************************/
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");
/* 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;
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,
/*****************************************************************************/
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");
/* 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;
/* 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,
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);
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);
}
}
/* 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);
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;
}
/* 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 */
/* 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),
/*------------------------------------------------------------------------*/
/* 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),
/*------------------------------------------------------------------------*/
/* 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);
}
/*****************************************************************************/
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
--- /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
--- /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
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/ArrayList.c b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/ArrayList.c
index 53a096e88a3517015dc4b5d1a71e13992d29c50a..bcb6e9cc0ca1f4ae2ad3d433efc8853b7200e7a5 100644 (file)
* 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"
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/ArrayList.h b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/ArrayList.h
index 5807fdf68fbbaa2a68cd315b9f7071ba0f6dfd0f..76c67f30cd4eabe5172d5a341afd237287a9edc9 100644 (file)
*
* 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
+++ /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
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/Queue.h b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/Queue.h
index 3e9eaadf2057308abd6f5a00bcac5fd9c2083762..59b28d9593f1efd33e0e2719bb8bab8c1f56a95f 100644 (file)
* 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"
/*****************************************************************************/
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 */
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--; \
\
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
--- /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
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/dload.c b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/dload.c
index 45ea19b1e5568483de76e62724c0eafed6a23222..c341c9abfc5f505ec1294f6f7ecb15f0f219b34e 100644 (file)
* 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 */
/* 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. */
#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. */
/* */
/* 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;
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;
}
return((DLOAD_HANDLE)pLoaderObject);
}
-/*---------------------------------------------------------------------------*/
+/*****************************************************************************/
/* DLOAD_destroy() */
/* */
/* Remove an instance of the dynamic loader core, and free all resources */
/* Preconditions: 1) handle must be valid. */
/* 2) Loader instance must be in "UNLOADED" state. */
/* */
-/*---------------------------------------------------------------------------*/
+/*****************************************************************************/
void DLOAD_destroy(DLOAD_HANDLE handle)
{
LOADER_OBJECT * pLoaderObject;
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() */
/* */
}
#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");
/*------------------------------------------------------------------------*/
}
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), §);
- }
-
/*------------------------------------------------------------------------*/
/* Initialize the DSO termination information for this module. */
/* It will be copied over from the enclosing dyn_module object when */
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
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);
}
/*****************************************************************************/
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) &&
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
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");
/*--------------------------------------------------------------------*/
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)
#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
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));
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;
/* 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)
{
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;
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 */
/* 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;
+ }
}
/*****************************************************************************/
/*****************************************************************************/
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() */
/* 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)
{
/*------------------------------------------------------------------------*/
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
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;
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();
}
}
}
}
-/*****************************************************************************/
-/* 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() */
/* 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
/* 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;
/*------------------------------------------------------------------------*/
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;
}
{
DLIF_error(DLET_MISC, "Internal error: find_dynamic_segment() needs "
"non-NULL arguments.\n");
-#if !defined (__KERNEL__)
- exit(1);
-#endif
+ DLIF_exit(1);
}
/*------------------------------------------------------------------------*/
/* 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;
}
/*------------------------------------------------------------------------*/
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);
/*****************************************************************************/
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);
}
/*****************************************************************************/
}
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;
}
/* 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++)
{
/* 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;
}
}
/* */
/* 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++)
{
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 */
/* */
/*---------------------------------------------------------------------------*/
/* */
-/* 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);
}
/* 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 */
/* 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. */
return local_file_handle;
}
+#if LOADER_DEBUG && LOADER_PROFILE
+int DLREL_relocations;
+time_t DLREL_total_reloc_time;
+#endif
+
/*****************************************************************************/
/* process_dynamic_module_relocations() */
/* */
LOADER_FILE_DESC *fd,
DLIMP_Dynamic_Module *dyn_module)
{
- int data = 0;
-
#if LOADER_DEBUG && LOADER_PROFILE
if(debugging_on || profiling_on)
{
/*------------------------------------------------------------------------*/
/* 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
/*------------------------------------------------------------------------*/
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 */
/*------------------------------------------------------------------------*/
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);
}
/*------------------------------------------------------------------------*/
/* 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;
}
}
/* 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 */
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 */
/*---------------------------------------------------------------------*/
/* 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. */
/*---------------------------------------------------------------------*/
/* 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. */
/* 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);
/*------------------------------------------------------------------------*/
/* 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;
}
/* 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)
{
DLIF_error(DLET_FILE, "Attempt to load invalid ELF file, '%s'.\n",
dyn_module->name);
- delete_DLIMP_Dynamic_Module(handle, &dyn_module);
return 0;
}
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 */
/* 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. */
/* 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 */
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 */
/*------------------------------------------------------------------------*/
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)
{
/*------------------------------------------------------------------*/
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;
}
/*****************************************************************************/
-/* 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. */
}
/*------------------------------------------------------------------------*/
- /* 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;
}
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;
}
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;
}
/*****************************************************************************/
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. */
/*------------------------------------------------------------------------*/
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. */
/*------------------------------------------------------------------------*/
/*------------------------------------------------------------------------*/
/* 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;
}
/* 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;
}
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 */
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;
}
}
/* 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;
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
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/dload.h b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/dload.h
index 0ca6a55e60bdb417f3a37cfff48852b483d321cc..e8463e5d4b9292cd0771a6a36b31ed42cabeb755 100644 (file)
*
* 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 */
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 */
/* */
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;
/* 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 */
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) */
/* 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;
/* 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. */
/* 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() */
/*-----------------------------------------------------------------------*/
} 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() */
/* */
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() */
/* */
/* 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);
/*---------------------------------------------------------------------------*/
/* 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
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/elf32.h b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/elf32.h
index 15560a1e9a4fe65c2e6098c89d4f820acdf97ec3..217862c5b7d8cf13ca65b4d20c887efc35778645 100644 (file)
* 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) */
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/relocate.h b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/relocate.h
index bae2b3b1448576b87a6f3a23910ad8ee7b8bf56c..8df468153beec8b895852fd54f73208a48f02f88 100644 (file)
* 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"
/*---------------------------------------------------------------------------*/
/* 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
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/symtab.h b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/symtab.h
index 308796b66591b668c2e46c1a590f6293cd787a16..46273ab53376bdb689bfacc60678b067ad12d321 100644 (file)
* 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
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
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/util.h b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD/util.h
index fc4839bfbaf0e3d688b7236164fef4a865d0bb4e..57491655bea2c8595472a86618d86dd7532e914b 100644 (file)
* 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)
/*****************************************************************************/
/* 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
--- /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
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD_API/api_version_change.log b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD_API/api_version_change.log
index 9001f2baded9562a52da7df0966f94d1e4f08e05..65b022d98859664faba1d6d41962269a6c6ab50a 100644 (file)
--- a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD_API/api_version_change.log
+++ b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD_API/api_version_change.log
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
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD_API/dload_api.h b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD_API/dload_api.h
index f265da4e320ddaf3f09e702c6fd1fc6512290ef7..afdcc05b62bdb47b7241feabda7ebf4d085089b1 100644 (file)
* 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;
/*****************************************************************************/
/* 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;
/* 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);
/*---------------------------------------------------------------------------*/
/* DLOAD_destroy() */
/* */
-/* Destroy the specified dynamic loader instance. */
+/* Destroy and finalize the dynamic loader core's handle. */
/* */
/*---------------------------------------------------------------------------*/
void DLOAD_destroy(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);
/* 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() */
/*---------------------------------------------------------------------------*/
/* 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);
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 */
/*****************************************************************************/
/* (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 */
};
/*---------------------------------------------------------------------------*/
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() */
/* */
/* 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() */
/* */
/*---------------------------------------------------------------------------*/
-/*---------------------------------------------------------------------------*/
-/* DLIF_trace() */
-/* */
-/* Client implementation of Trace message output, alternative to printf. */
-/* */
-/*---------------------------------------------------------------------------*/
-void DLIF_trace(const char *fmt, ...);
/*---------------------------------------------------------------------------*/
/* Loader Warning Types */
/*---------------------------------------------------------------------------*/
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 */
/*---------------------------------------------------------------------------*/
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
+++ /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
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD_SYM/symtab.c b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLOAD_SYM/symtab.c
index 4d8f306f4eeda92be8b813c05c15dd13a3d47105..997ddbd67fd5a5ff2017c0e4a73d606a03050274 100644 (file)
* (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
#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. */
/*------------------------------------------------------------------------*/
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 */
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
}
}
/* 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;
/* 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)
{
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
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
+++ /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
+++ /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
+++ /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
+++ /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
+++ /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
+++ /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
+++ /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
+++ /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 {
- uint32_t load_address;
- uint32_t run_address;
-} DL_Target_Segment;
-
-typedef struct _DL_Host_Segment {
- uint32_t load_address;
- uint32_t run_address;
- struct _DL_Host_Segment *next_segment;
-} DL_Host_Segment;
-
-/*---------------------------------------------------------------------------*/
-/* DL_Module_Debug_Record - Debug information about each module that has */
-/* been loaded. */
-/*---------------------------------------------------------------------------*/
-/* We have a host version of the debug record which is built up while the */
-/* module is being loaded, and a target version of the debug record which */
-/* is built after the load has completed and we know all of the information */
-/* that needs to be written to target memory for this module. */
-/*---------------------------------------------------------------------------*/
-typedef struct {
- int handle;
- char *module_name;
- TARGET_ADDRESS target_address;
- uint32_t next_module_ptr;
- uint16_t next_module_size;
- int num_segments;
- DL_Host_Segment *segment_list_head;
- DL_Host_Segment *segment_list_tail;
-} DL_Host_Module_Debug;
-
-typedef struct {
- uint32_t next_module_ptr;
- uint16_t next_module_size;
- uint16_t tool_version;
- uint16_t verification_word;
- uint16_t num_segments;
- uint32_t timestamp;
- DL_Target_Segment segments[1];
-} DL_Target_Module_Debug;
-
-/*---------------------------------------------------------------------------*/
-/* DLL Debug Support - context stack of module records. We need to maintain */
-/* a stack of modules while creating the DLL module record list for */
-/* debug support. While we are building up a module record for one */
-/* module, the loader may be asked to load dependent modules. Note */
-/* that we cannot emit a module record to target memory until loading */
-/* of the module has been completed (need to know how many segments */
-/* are in the module before we can allocate target memory for the */
-/* module record). */
-/*---------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------*/
-/* dl_debug */
-/* */
-/* Define a LIFO linked list "class" of DL_Module_Debug_Record pointers. */
-/*---------------------------------------------------------------------------*/
-TYPE_STACK_DEFINITION(DL_Host_Module_Debug*, dl_debug)
-
-/*---------------------------------------------------------------------------*/
-/* mirror_debug_ptr */
-/* */
-/* Define a linked list "class" of DL_Host_Module_Debug pointers. */
-/*---------------------------------------------------------------------------*/
-TYPE_QUEUE_DEFINITION(DL_Host_Module_Debug*, mirror_debug_ptr)
-
-/*---------------------------------------------------------------------------*/
-/* Management functions for DLL debug support data structures. */
-/*---------------------------------------------------------------------------*/
-extern void DLDBG_add_host_record(void* client_handle,
- const char *module_name);
-extern void DLDBG_add_target_record(void* client_handle,
- int handle);
-extern void DLDBG_rm_target_record(void* client_handle,
- int handle);
-extern void DLDBG_add_segment_record(void* client_handle,
- struct DLOAD_MEMORY_SEGMENT *obj_desc);
-extern void DLDBG_dump_mirror_debug_list(void* client_handle);
-#endif
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/dlw_trgmem.c b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/dlw_trgmem.c
+++ /dev/null
@@ -1,503 +0,0 @@
-/*
-* dlw_trgmem.c
-*
-* This source file contains the implementation of the client side's target
-* memory allocator. The RIDL version of the dynamic loader will manage
-* target memory from a massive data object called "trg_mem_pool". This
-* memory manager is derived from the RTS version of malloc()/free().
-*
-*---------------------------------------------------------------------------
-* This module contains the functions which implement the dynamic memory
-* management routines. The following assumptions/rules apply:
-*
-* 1) Packets are allocated from host memory so they have no impact on
-* the target memory heap.
-* 2) The size of the heap is assumed to be 0x02000000 (the size of the
-* .blob section in the ELF dynamic loader executable file).
-* 3) The heap can be reset at any time by calling trg_minit()
-*
-*---------------------------------------------------------------------------
-* These functions constitute the target memory manager interface with the
-* rest of the dynamic loader:
-*
-* DLTMM_malloc() : Allocate a chunk of target memory per request.
-* DLTMM_free() : Release target memory allocated to specified address.
-* DLTMM_fwrite() : Write content of target memory to dump file.
-* DLTMM_fread() : Read core file into target memory area.
-*
-*---------------------------------------------------------------------------
-* These functions manage the target memory packet list and help the
-* interface functions carry out a target memory allocation:
-*
-* trg_minit() : Initialize target memory packet list.
-* trg_align() : Find next address within packet that is aligned.
-* trg_free_pkt() : Free a used packet and merge it with free neighbors.
-* trg_alloc_pkt() : Allocate chunk of free packet and split packet into
-* used and available pieces.
-* trg_malloc() : Serve DLTMM_malloc(), set actual request size to
-* multiple of MIN_BLOCK and find a free packet to
-* allocate from.
-*
-*---------------------------------------------------------------------------
-*
-* 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_trgmem.h"
-
-/*---------------------------------------------------------------------------*/
-/* Definition and placement of target memory pool (defined in ".blob" */
-/* section of ELF dynamic loader executable object file). */
-/*---------------------------------------------------------------------------*/
-#define trg_mem_pool_sz 0x02000000
-
-#pragma DATA_SECTION(trg_mem_pool,".blob");
-#pragma DATA_ALIGN(trg_mem_pool, 8)
-uint8_t trg_mem_pool[trg_mem_pool_sz];
-const uint32_t trg_mem_pool_addr = (uint32_t)trg_mem_pool;
-static BOOL need_trg_minit = TRUE;
-
-/*---------------------------------------------------------------------------*/
-/* Target Memory Manager - is allocated from host memory to manage available */
-/* target memory space. trg_memory is the first, and initially the */
-/* only, element on the target memory list. */
-/*---------------------------------------------------------------------------*/
-static TRG_PACKET *trg_mem_head = NULL;
-
-/*---------------------------------------------------------------------------*/
-/* Function declarations */
-/*---------------------------------------------------------------------------*/
-static void trg_minit(void);
-static uint32_t trg_align(uint32_t orig_addr, int alignment);
-static void trg_free_pkt(TRG_PACKET *);
-static uint32_t trg_alloc_pkt(TRG_PACKET *, size_t, int, uint32_t);
-static BOOL trg_malloc(uint32_t *req_addr, size_t size, int alignment);
-
-/*****************************************************************************/
-/* TRG_MINIT() - Initialize target memory management data structures. */
-/* Set up initial free list. */
-/*****************************************************************************/
-static void trg_minit(void)
-{
- trg_mem_head = (TRG_PACKET *)malloc(sizeof(TRG_PACKET));
-
- trg_mem_head->packet_addr = trg_mem_pool_addr;
- trg_mem_head->packet_size = trg_mem_pool_sz;
- trg_mem_head->prev_packet = NULL;
- trg_mem_head->next_packet = NULL;
- trg_mem_head->used_packet = FALSE;
-}
-
-/*****************************************************************************/
-/* TRG_ALIGN() - If given origin address is aligned, return it. Otherwise, */
-/* find next aligned address and return it. */
-/*****************************************************************************/
-static uint32_t trg_align(uint32_t orig_addr, int alignment)
-{
- if (alignment <= 1) return orig_addr;
- return ((orig_addr + (alignment - 1)) & ~(alignment - 1));
-}
-
-/*****************************************************************************/
-/* TRG_FREE_PKT() - Move packet from used state to free state and merge it */
-/* with any free neighbors on the target memory packet list. */
-/*****************************************************************************/
-static void trg_free_pkt(TRG_PACKET *ptr)
-{
- if (ptr)
- {
- TRG_PACKET *prev_pkt = ptr->prev_packet;
- TRG_PACKET *next_pkt = ptr->next_packet;
-
- if (prev_pkt && !prev_pkt->used_packet)
- {
- ptr->packet_addr = prev_pkt->packet_addr;
- ptr->packet_size += prev_pkt->packet_size;
- ptr->prev_packet = prev_pkt->prev_packet;
- if (prev_pkt->prev_packet)
- prev_pkt->prev_packet->next_packet = ptr;
- free(prev_pkt);
- }
-
- if (next_pkt && !next_pkt->used_packet)
- {
- ptr->packet_size += next_pkt->packet_size;
- ptr->next_packet = next_pkt->next_packet;
- if (next_pkt->next_packet)
- next_pkt->next_packet->prev_packet = ptr;
- free(next_pkt);
- }
-
- if (!ptr->prev_packet) trg_mem_head = ptr;
-
- ptr->used_packet = FALSE;
- }
-}
-
-/*****************************************************************************/
-/* TRG_ALLOC_PKT() - Allocate size bytes into given free packet at next */
-/* aligned address in the packet. Split packet into used and free */
-/* pieces, updating the target memory list along the way. */
-/*****************************************************************************/
-static uint32_t trg_alloc_pkt(TRG_PACKET *ptr, size_t size, int alignment,
- uint32_t req_addr)
-{
- uint32_t align_addr;
- uint32_t align_pad;
-
- /*------------------------------------------------------------------------*/
- /* Split given packet into used and unused pieces. */
- /*------------------------------------------------------------------------*/
- TRG_PACKET *used_pkt = ptr;
- size_t orig_sz = 0;
- TRG_PACKET *free_pkt = NULL;
-
- /*------------------------------------------------------------------------*/
- /* If the requested address is not equal to the packet address, we need */
- /* to break the packet in two by inserting a free packet before the */
- /* the used packet. This assumes that the requested address has already */
- /* been verified to lie within the packet. */
- /*------------------------------------------------------------------------*/
- if (req_addr > used_pkt->packet_addr)
- {
- free_pkt = (TRG_PACKET *)malloc(sizeof(TRG_PACKET));
- free_pkt->next_packet = used_pkt;
- free_pkt->prev_packet = used_pkt->prev_packet;
- used_pkt->prev_packet = free_pkt;
-
- free_pkt->packet_size = req_addr - used_pkt->packet_addr;
- free_pkt->packet_addr = used_pkt->packet_addr;
- free_pkt->used_packet = FALSE;
-
- used_pkt->packet_addr = req_addr;
- }
-
- /*------------------------------------------------------------------------*/
- /* Compute aligned address within given free packet where we want to */
- /* allocate. Any alignment padding at the front will become a separate */
- /* free packet on the target memory list. */
- /*------------------------------------------------------------------------*/
- align_addr = trg_align(used_pkt->packet_addr, alignment);
- align_pad = align_addr - used_pkt->packet_addr;
-
- /*------------------------------------------------------------------------*/
- /* If there is any padding at the front of the packet, then we'll build */
- /* a new packet to represent our allocated space. */
- /*------------------------------------------------------------------------*/
- if (align_pad)
- {
- /*---------------------------------------------------------------------*/
- /* If free_pkt is NULL, then we did not split ptr into two packets. */
- /* If this is the case we need to allocate a new packet for the */
- /* padding. If we did split ptr into two packets, just merge the */
- /* padding into the free packet. */
- /*---------------------------------------------------------------------*/
- if (!free_pkt)
- {
- free_pkt = (TRG_PACKET *)malloc(sizeof(TRG_PACKET));
- free_pkt->next_packet = used_pkt;
- free_pkt->prev_packet = used_pkt->prev_packet;
- used_pkt->prev_packet = free_pkt;
- free_pkt->packet_addr = used_pkt->packet_addr;
- free_pkt->packet_size = 0;
- }
-
- free_pkt->packet_size += align_pad;
- used_pkt->packet_size -= align_pad;
- used_pkt->packet_addr = align_addr;
-
- }
-
- /*------------------------------------------------------------------------*/
- /* Preserve original size of used packet so that we can compute size of */
- /* unused space when we split the used packet. Then set size of used */
- /* packet. */
- /*------------------------------------------------------------------------*/
- orig_sz = used_pkt->packet_size;
- used_pkt->packet_size = size;
- used_pkt->used_packet = TRUE;
-
- /*------------------------------------------------------------------------*/
- /* If there is unused space at the end of our allocated packet, then */
- /* we'll build up a new packet to represent this free space and at it */
- /* into the target memory list. */
- /*------------------------------------------------------------------------*/
- if (orig_sz > size)
- {
- free_pkt = (TRG_PACKET *)malloc(sizeof(TRG_PACKET));
- free_pkt->next_packet = used_pkt->next_packet;
- free_pkt->prev_packet = used_pkt;
- used_pkt->next_packet = free_pkt;
-
- free_pkt->packet_size = orig_sz - size;
-
- free_pkt->packet_addr = used_pkt->packet_addr + size;
-
- free_pkt->used_packet = FALSE;
- }
-
- return (used_pkt->packet_addr);
-}
-
-/*****************************************************************************/
-/* TRG_MALLOC() - Allocate target memory from the free list (which manages */
-/* available target memory in .blob section). The free list keeps */
-/* track of available and used target memory. */
-/*****************************************************************************/
-static BOOL trg_malloc(uint32_t *req_addr, size_t size, int alignment)
-{
- TRG_PACKET *current = NULL;
- TRG_PACKET *best_fit = NULL;
-
- if (size <= 0) return FALSE;
-
- if (need_trg_minit)
- {
- trg_minit();
- need_trg_minit = FALSE;
- }
-
- /*------------------------------------------------------------------------*/
- /* If we did not get a request for a specific target address from the */
- /* client, then find the best fit available packet, incorporating any */
- /* alignment constraints imposed by the client. */
- /*------------------------------------------------------------------------*/
- if (*req_addr == (uint32_t)-1)
- {
- /*---------------------------------------------------------------------*/
- /* Find best free packet on the target memory list. */
- /*---------------------------------------------------------------------*/
- for (current = trg_mem_head; current; current = current->next_packet)
- {
- /*------------------------------------------------------------------*/
- /* Account for alignment constraint on current packet. */
- /*------------------------------------------------------------------*/
- uint32_t align_addr = trg_align(current->packet_addr, alignment);
- uint32_t align_pad = align_addr - current->packet_addr;
-
- /*------------------------------------------------------------------*/
- /* Skip over any packets that are already allocated. */
- /*------------------------------------------------------------------*/
- if (current->used_packet) continue;
-
- /*------------------------------------------------------------------*/
- /* Best fit will be smallest free packet that is >= size. */
- /*------------------------------------------------------------------*/
- if ((current->packet_size > align_pad) &&
- ((current->packet_size - align_pad) >= size))
- {
- if (best_fit && (current->packet_size >= best_fit->packet_size))
- continue;
- best_fit = current;
- }
- }
-
- if (!best_fit) return FALSE;
-
- *req_addr = trg_alloc_pkt(best_fit, size, alignment,
- best_fit->packet_addr);
-
- return TRUE;
- }
-
- /*------------------------------------------------------------------------*/
- /* Otherwise, we do have a request for a specific target address from the */
- /* client. So we need to find the free packet that contains that target */
- /* address. */
- /*------------------------------------------------------------------------*/
- else
- {
- /*---------------------------------------------------------------------*/
- /* Find the free packet that contains the requested address. */
- /*---------------------------------------------------------------------*/
- for (current = trg_mem_head; current; current = current->next_packet)
- {
- /*------------------------------------------------------------------*/
- /* If we have a requested address, we must make sure that the */
- /* requested address falls on an alignment boundary, if it does not */
- /* report an error. */
- /* -----------------------------------------------------------------*/
- uint32_t align_addr = trg_align(*req_addr, alignment);
- if (align_addr != *req_addr)
- {
- DLIF_error(DLET_TRGMEM, "requested address is not aligned\n");
- return FALSE;
- }
-
- /*------------------------------------------------------------------*/
- /* Does the requested address fall inside the packet? */
- /*------------------------------------------------------------------*/
- if (*req_addr < current->packet_addr ||
- ((current->packet_addr + current->packet_size) <= *req_addr))
- continue;
-
- /*------------------------------------------------------------------*/
- /* Is the current packet big enough for the request? */
- /*------------------------------------------------------------------*/
- if ((current->packet_size) >= size)
- {
- uint32_t alloc_addr = trg_alloc_pkt(current, size, alignment,
- *req_addr);
- if (alloc_addr != *req_addr)
- {
- DLIF_error(DLET_TRGMEM, "Problem with trg_alloc_pkt\n");
- exit(1);
- }
-
- return TRUE;
- }
-
- break;
- }
- }
-
- return FALSE;
-}
-
-/*****************************************************************************/
-/* DLTMM_MALLOC() - Externally accessible interface into target memory */
-/* allocator. This function will use the core target memory manager */
-/* to find available space per requested and update target memory list */
-/* to reflect new status of used and free target memory. */
-/*****************************************************************************/
-BOOL DLTMM_malloc(struct DLOAD_MEMORY_REQUEST *targ_req,
- struct DLOAD_MEMORY_SEGMENT *obj_desc)
-{
- /*------------------------------------------------------------------------*/
- /* Set up alignment constraint and request for specific address, if */
- /* there is one. */
- /*------------------------------------------------------------------------*/
- int alignment = (targ_req->align) ? targ_req->align : 1;
- uint32_t req_addr = (targ_req->flags & DLOAD_SF_relocatable) ?
- (uint32_t)-1 : (uint32_t)obj_desc->target_address;
-
- /*------------------------------------------------------------------------*/
- /* Ask for free space from the target memory allocator. */
- /*------------------------------------------------------------------------*/
- if (trg_malloc(&req_addr, obj_desc->memsz_in_bytes, alignment))
- {
- obj_desc->target_address = targ_req->host_address = (void *)req_addr;
- return TRUE;
- }
-
- /*------------------------------------------------------------------------*/
- /* Something went wrong. Target memory allocation failed. */
- /*------------------------------------------------------------------------*/
- return FALSE;
-}
-
-/*****************************************************************************/
-/* DLTMM_FREE() - Find packet in target memory list associated with given */
-/* target address and change its state from used to free. */
-/*****************************************************************************/
-void DLTMM_free(TARGET_ADDRESS ptr)
-{
- uint32_t pkt_addr = (uint32_t)ptr;
- TRG_PACKET *prev = NULL;
- TRG_PACKET *current = NULL;
-
- /*------------------------------------------------------------------------*/
- /* Find free packet on the target memory list that contains the specified */
- /* address that we are trying to free. */
- /*------------------------------------------------------------------------*/
- for (current = trg_mem_head; current; current = current->next_packet)
- {
- /*---------------------------------------------------------------------*/
- /* Skip over any packets that are already free. */
- /*---------------------------------------------------------------------*/
- if (!current->used_packet) continue;
-
- /*---------------------------------------------------------------------*/
- /* Find used packet associated with given address. */
- /*---------------------------------------------------------------------*/
- if (current->packet_addr <= pkt_addr) prev = current;
- else break;
- }
-
- if (prev) trg_free_pkt(prev);
-
- else
- {
- DLIF_error(DLET_TRGMEM,
- "Did not find free packet associated with given target "
- "address, 0x%lx\n", pkt_addr);
- exit(1);
- }
-}
-
-/*****************************************************************************/
-/* DLTMM_FWRITE_TRG_MEM() - Write content of target memory area to a file. */
-/*****************************************************************************/
-void DLTMM_fwrite_trg_mem(FILE *fp)
-{
- if (fp) fwrite(trg_mem_pool, trg_mem_pool_sz, 1, fp);
-}
-
-/*****************************************************************************/
-/* DLTMM_FREAD_TRG_MEM() - Read file content into target memory area. */
-/*****************************************************************************/
-void DLTMM_fread_trg_mem(FILE *fp)
-{
- if (fp) fread(trg_mem_pool, trg_mem_pool_sz, 1, fp);
-}
-
-/*****************************************************************************/
-/* DLTMM_DUMP_TRG_MEM() - Dump the contents of target memory into a file. */
-/*****************************************************************************/
-void DLTMM_dump_trg_mem(uint32_t offset, uint32_t nbytes,
- FILE* fp)
-{
- uint8_t* ptr = trg_mem_pool + offset;
-
- if (!fp)
- {
- DLIF_error(DLET_TRGMEM, "NULL file pointer given to dump_trgmem\n");
- return;
- }
-
- /*-----------------------------------------------------------------------*/
- /* Make sure the request is in range. */
- /*-----------------------------------------------------------------------*/
- if ((ptr + nbytes) > (trg_mem_pool + trg_mem_pool_sz ))
- {
- DLIF_error(DLET_TRGMEM, "Invalid range given to dump_trgmem\n");
- return;
- }
-
- fwrite(ptr, 1, nbytes, fp);
-}
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/dlw_trgmem.h b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/dlw_trgmem.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
-* dlw_trgmem.h
-*
-* Define internal data structures used by RIDL client side for target
-* memory management.
-*
-* 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_TRGMEM_H
-#define DLW_TRGMEM_H
-
-#include "dload_api.h"
-
-/*---------------------------------------------------------------------------*/
-/* MIN_BLOCK is the minimum size of a packet. */
-/*---------------------------------------------------------------------------*/
-#define MIN_BLOCK 4
-
-/*---------------------------------------------------------------------------*/
-/* TRG_PACKET is the template for a data packet. Packet size contains the */
-/* number of bytes allocated for the user. Packets are always allocated */
-/* memory in MIN_BLOCK byte chunks. The list is ordered by packet address */
-/* which refers to the target address associated with the first byte of the */
-/* packet. The list itself is allocated out of host memory and is a doubly */
-/* linked list to help with easy splitting and merging of elements. */
-/*---------------------------------------------------------------------------*/
-typedef struct _trg_packet
-{
- /* Need to change this to TARGET_ADDRESS packet_addr */
- uint32_t packet_addr; /* target address of packet */
- uint32_t packet_size; /* number of bytes in this packet */
- struct _trg_packet *prev_packet; /* prev packet in trg mem list */
- struct _trg_packet *next_packet; /* next packet in trg mem list */
- BOOL used_packet; /* has packet been allocated? */
-} TRG_PACKET;
-
-/*---------------------------------------------------------------------------*/
-/* Interface into client's target memory manager. */
-/*---------------------------------------------------------------------------*/
-extern BOOL DLTMM_init(void* client_handle, uint32_t dynMemAddr, uint32_t size);
-extern BOOL DLTMM_deinit(void* client_handle);
-extern BOOL DLTMM_malloc(void* client_handle,
- struct DLOAD_MEMORY_REQUEST *targ_req,
- struct DLOAD_MEMORY_SEGMENT *obj_desc);
-extern void DLTMM_free(void* client_handle, TARGET_ADDRESS ptr);
-
-extern void DLTMM_fwrite_trg_mem(FILE *fp);
-extern void DLTMM_fread_trg_mem(FILE *fp);
-extern void DLTMM_dump_trg_mem(uint32_t offset, uint32_t nbytes,
- FILE* fp);
-
-#endif /* DLW_TRGMEM_H */
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/read_me_dlwrapper.txt b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/read_me_dlwrapper.txt
--- a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/DLWRAPPER/read_me_dlwrapper.txt
+++ /dev/null
@@ -1,77 +0,0 @@
-Read Me -- RIDL
----------------
-
-Unless otherwise noted, a command can be replaced with any word
-starting with the same character. Commands are case-insensitive. The
-size of the buffer for the RIDL prompt is one hundred characters, and
-input is read with gets(). So, if you type more than 100 characters
-at any one RIDL prompt, it is likely bad things will happen.
-
-information - gives the memory addresses of printf and exit.
-
-load <executable_name> <number_of_arguments> <argv[0]> <argv[1]> ...
-
-Loads the executable <executable_name> into memory with the supplied
-command-line arguments. This will result in any DT_NEEDED entries for
-that executable being loaded into memory as well.
-
-core <entry_point> <number_of_arguments> <argv[0]> <argv[1]>
-
-Loads the core image prog.dump into memory with the specified memory
-address as the entry point and the supplied arguments as command-line
-parameters.
-
-exit
-
-Exit RIDL and return to the execution environment.
-
-help
-
-Display a list of commands.
-
-execute
-
-Transfers control to the loaded program. If you're lucky, eventually
-the loaded program will transfer control back to RIDL.
-
-unload
-
-Unloads the last program that was loaded into memory. Doesn't
-actually free any memory -- this command is just here for testing.
-
-base_image <executable_name>
-
-Load the specified executable's symbols into the symbol table for the
-base image.
-
-symbol <symname> <symval>
-
-Manually insert the specified symbol into the symbol table for the
-base image. This command is currently disabled.
-
-debug
-
-Turns on debugging support. You can also do this with the "--debug"
-command-line parameter to RIDL. The executable must have been built
-with debugging support for this command to work. When debugging is
-enabled, the core loader will chat endlessly about its various
-activities while it loads a file. It will also produce a file named
-"prog.dump" at the end of loading, which is a core dump of the loaded
-executable. You can load this file back into RIDL later with the
-"core" command. Besides this file, the loader will also write files
-suffixed ".elfdbg" for each ELF executable loaded. These .elfdbg
-files will have all relocations performed and can be viewed with
-"dis6x", so they are very useful in hunting down relocation bugs.
-Turning debugging on will also enable profiling.
-
-profile
-
-Turns on profiling support. This will provide cycle counts for each
-stage of the loading process.
-
-Command-line parameter: --script file
-
-If this argument is given to RIDL at the command line, it will read
-its input from the file "file", rather than from standard input.
-Comments may be added to the script by starting the line with the '#'
-character.
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/Makefile b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/Makefile
+++ /dev/null
@@ -1,60 +0,0 @@
-##############################################################################
-# C6x Dynamic Loader Reference Implementation Makefile Settings
-##############################################################################
-
-###############################################################################
-# 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.
-###############################################################################
-
-###############################################################################
-# The following variables must be set for the tool makefile to work correctly
-# (although they can be set to nothing):
-#
-# TARG_VPATH - Modules/subdirectories specific to target
-# TARG_SRCFILES - Additional files used by this target (.c .h)
-# TARG_TOOL_NAME_PRFX - Prefix for the tool name
-# TARG_UNIT_TEST_FILES - Additional files used for unit testing by this
-# target
-#
-##############################################################################
-
-TARG_TOOL_NAME_PRFX = dl6x
-TARG_VPATH = C60_DLOAD_REL C60_DLOAD_DYN
-TARG_SRCFILES = c60_reloc.c c60_elf32.h \
- c60_dynamic.h c60_dynamic.c
-TARG_UNIT_TEST_FILES = test_c60_reloc.h test_c60_reloc.cpp
-CC = cl6x
-TARGET = C60
-##############################################################################
-# Generic Shared Makefile
-##############################################################################
-include ./Makefile.ridl
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/README.txt b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/README.txt
--- /dev/null
@@ -0,0 +1,423 @@
+
+ TMS320C6000 C/C++ CODE GENERATION TOOLS
+ 0.4 ELF Dynamic Loader Release Notes
+ August 2011
+ updated February 2013
+
+
+===============================================================================
+Contents
+===============================================================================
+1. The ELF Dynamic Loader
+ 1.1 Alpha Package Manifest
+ 1.2 Building the Dynamic Loader Tester (dlti.gen)
+ 1.3 User-Interaction Mode Commands
+
+2. Getting Started
+ 2.1 Building a Dynamic Executable
+ 2.2 Building a Dynamic Library
+ 2.3 "Hello World" Example
+ 2.4 Known Issues
+
+3. Relevant Documents
+
+
+-------------------------------------------------------------------------------
+1. The ELF Dynamic Loader
+-------------------------------------------------------------------------------
+
+This alpha package contains a reference implementation of an ELF dynamic
+loader. This implementation is intended to be loaded and run on a C6x/TMS470
+architecture. Once up and running, it provides a user-interaction mode
+in which you can load and execute dynamic libraries that are linked
+against the base image (the loader itself).
+
+1.1 Alpha Package Manifest
+--------------------------
+
+Top Level:
+
+ Makefile
+ Makefile.gen
+ lnkc60.cmd
+ lnk470.cmd
+ README.txt
+
+Dynamic Loader API Specification (DLOAD_API):
+
+ dload_api.h
+ api_version_change.log
+
+C60-Specific Relocation Processing (C60_DLOAD_REL):
+
+ c60_reloc.c
+ c60_reloc.h
+ test_c60_reloc.cpp
+ test_c60_reloc.h
+
+C60-Specific Dynamic Loading Functions (C60_DLOAD_DYN):
+
+ c60_dynamic.c
+ c60_dynamic.h
+ c60_elf32.h
+
+TMS470-Specific Relocation Processing (TMS470_DLOAD_REL):
+
+ arm_reloc.c
+ arm_reloc.h
+ test_arm_reloc.cpp
+ test_arm_reloc.h
+
+TMS470-Specific Dynamic Loading Functions (TMS470_DLOAD_DYN):
+
+ arm_dynamic.c
+ arm_dynamic.h
+ arm_elf32.h
+
+Symbol Table Management (DLOAD_SYM)
+
+ symtab.c
+
+Core Dynamic Loader (DLOAD):
+
+ ArrayList.c
+ ArrayList.h
+ Queue.h
+ dload.c
+ dload.h
+ dload_endian.c
+ dload_endian.h
+ elf32.c
+ elf32.h
+ relocate.h
+ symtab.h
+ util.h
+ version.h
+ virtual_targets.h
+
+Dynamic Loader Tester Client-Provided Functions (DLWRAPPER):
+
+ Stack.h
+ arm_export.cmd
+ c60_export.cmd
+ dlmodules.c
+ dlw.c
+ dlw_client.c
+ dlw_debug.c
+ dlw_debug.h
+ dlw_dsbt.c
+ dlw_dsbt.h
+ dlw_trgmem.c
+ dlw_trgmem.h
+ read_me_dlwrapper.txt
+ ridl_client.c
+ ridl_client.h
+ Makefile.ridl
+
+1.2 Building the Dynamic Loader Tester (dlti.gen)
+-------------------------------------------------------
+
+Included in the alpha package is a Makefile which can be used to build
+the Dynamic Loader Tester (dlti.gen). As mentioned above, this
+reference implementation of the ELF dynamic loader is intended to be
+loaded and run on the C6x or TMS470 as a base image executable file.The
+extension of the loader is the host platform on which it is to run.
+
+With the latest alpha C6x/TMS470 tools in your path and your C_DIR
+and C6X_C_DIR/TMS470_C_DIR environment variables set up to provide
+access to the RTS header files and libraries, you can then build
+dlti.gen using gmake:
+
+ %> gmake TARGET_CC=ARM
+
+ or
+
+ %> gmake TARGET_CC=C60
+
+This will build an executable, dlti.gen, which you can load and
+start running with a version of CCS that supports loading a C6x/ARM ELF
+executable object file (or your favorite standalone simulator tool).
+(Although, the dlti.gen can be built for either C6000 or TMS470,
+the documentation and examples below use C6000 for illustration
+purposes.)
+
+For example, we use a tool called "kelvin" which is a standalone
+C6x simulator that supports loading ELF executable object files.
+We start by loading and starting the run of dlti.gen as follows:
+
+ %> kelvin -q dlti.gen
+
+When the dynamic loader starts running it places itself into a user-
+interactive mode in which it can receive commands from the user.
+Section 1.3 reviews the list of commands that are available in this
+user-interactive mode.
+
+Alternatively, you can write user-interaction mode commands into a text
+file, one command per file. This file can then used with the --script
+command-line option when invoking the dynamic loader.
+
+An example:
+
+ dl_cmds.txt contains:
+
+ base_image dlti.gen
+ load hello.dll
+ execute
+ exit
+
+ invoke dynamic loader:
+
+ %> kelvin_elf dlti.gen --script dl_cmds.txt
+
+The dynamic loader will be loaded and started running, then it will
+process each command from the script file in the sequence that it
+appears in the text file.
+
+
+1.3 User-Interaction Mode Commands
+----------------------------------
+
+When dlti.gen is set running on the C6x, it enters a user-interactive
+mode, displaying a prompt for the user as follows:
+
+ RIDL>
+
+At this point the dynamic loader is waiting for a command from the user.
+The available user-interaction mode commands are as follows:
+
+ "information"
+
+ - Provide information about location of loader's copy of
+ printf() and exit() functions.
+
+ "load_executable <program> [<argc> <argv[0]> <argv[1]> ...]"
+
+ - Load an executable program into target memory with
+ optional command-line arguments.
+
+ "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.
+
+ "execute"
+
+ - Transfer control to the most recently loaded program.
+
+ "unload"
+
+ - Unload the last program that was loaded into memory.
+
+ "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.
+
+ "debug"
+
+ - Turn on internal debugging.
+
+ "profile"
+
+ - Turn on internal profiling.
+
+ "exit"
+
+ - Terminate execution of the dynamic loader executable.
+
+ "help"
+
+ - Display list of available user-interaction mode
+ commands.
+
+You can also terminate execution of the dynamic loader with "control-D".
+
+
+-------------------------------------------------------------------------------
+2. Getting Started
+-------------------------------------------------------------------------------
+
+The dynamic loader included in this alpha release supports basic dynamic
+linking functionalities.
+
+The sample dynamic linking model described here is similar to a system where
+a Real Time OS (RTOS) running on the DSP. The RTOS is assumed to be loaded by
+traditional means (bootstrap) and shall be running on the DSP. The DLLs loaded
+by the dynamic loader in this system is expected to call RTOS functions. Hence
+the RTOS shall 'export' functions that a DLL is expected to call. Any module
+(usually RTOS) that is boot loaded in a dynamic linking system and 'exports'
+a set of functions to be called by dynamically loaded library is called a
+base image in this document.
+
+The dynamic loader has the flexibility of running on the DSP to load the DLLs
+on the DSP or in an ARM+DSP system, the dynamic loader can run on the ARM side
+and still load the DLLs on the DSP side.
+
+In the sample dynamic linking model, the dynamic loader + some RTS functions
+are built as the base image (dlti.gen). This base image is first loader on the
+simulator. Then the dynamic loader in the base image can load any DLLs.
+
+In order for the dynamic loader to resolve DLL references to the functions in
+the base image, it needs to know the symbols exported from the base image and
+their addresses. Hence, the dynamic loader should read the base image and load
+its dynamic symbols. In the system described here, this means the dlti.gen is
+reading itself.
+
+2.1 Building a Dynamic Executable
+---------------------------------
+
+A dynamic executable is essentially a statically linked executable file
+that contains extra information in the form of a dynamic segment that
+can be used when a dynamic library is loaded and needs symbols that are
+defined in the dynamic executable.
+
+In the sample system described here, the reference implementation of the
+dynamic loader (RIDL) is built as a base image. This base image also contains
+the basic IO functions and some runtime support (RTS) function . The
+base image should export these IO and RTS functions. These symbols will then
+become available to a dynamic library when it is dynamically loaded and linked
+against the dynamic executable.
+
+To accomplish exporting of symbols, there are two methods available:
+
+ 1. Declare exported symbols explicitly in the source of the
+ dynamic executable using "__declspec(dllexport)".
+
+ For example, if I want to export "exp_func" from the dynamic
+ executable, I can declare it in my source as follows;
+
+ __declspec(dllexport) int exp_func();
+
+ 2. Use --export option at link time. You can specify one or
+ more symbols to be exported with "--export=<symbol" on the
+ linker command line or in a linker command file.
+
+ For example, you could export exp_func() at link time
+ with:
+
+ %> cl6x --abi=elfabi ... -z --dynamic=exe --export=exp_func ...
+
+In general, to build a dynamic executable, you must specify
+--dynamic=exe or --dynamic on the linker command line or in a
+linker_command file.
+
+Consider the build of the dlti.gen file described above as an
+example of how to build a dynamic executable or "base image":
+
+ %> cl6x --abi=elfabi ... -z *.obj ... --dynamic --export=printf ...
+
+
+
+2.2 Building a Dynamic Library
+------------------------------
+
+A dynamic library is a shared object that contains dynamic information
+in the form of a dynamic segment. It is relocatable and can import
+symbols from other ELF dynamic objects that it links against and it can
+export symbols that it defines itself.
+
+Importing and exporting of symbols can be accomplished in two ways,
+similarly to how it can be done in dynamic executables:
+
+ 1. Declare exported and/or imported symbols explicitly in
+ the source code of the dynamic library using
+ "__declspec(dllexport)" for exported symbols and
+ "__declspec(dllimport)" for imported symbols.
+
+ For example, if I want to export a function, red_fish(),
+ and import another function, blue_fish(), I could specify
+ this in a source file as follows:
+
+ __declspec(dllexport) long red_fish();
+ __declspec(dllimport) int blue_fish();
+
+ 2. You can also specify symbols to be imported or exported on
+ the linker command line (or in a linker command file) using
+ "--import=<symbol>" or "--export=<symbol>".
+
+ So at link time, you might say:
+
+ %> cl6x --abi=elfabi ... -z --dynamic=lib --export=red_fish --import=blue_fish blue.dll -o red.dll
+
+ This informs the linker that the definition of red_fish()
+ will be in the red.dll dynamic library and that we can find
+ and use the definition of blue_fish() in blue.dll.
+
+In general, to build a dynamic library, you must specify --dynamic=lib
+on the linker command line or in a linker_command file. In addition,
+if any symbols are imported from other dynamic objects, then those
+dynamic objects must be specified on the linker command line when the
+dynamic library is built. This is sometimes referred to as static
+binding.
+
+
+2.3 "Hello World" Example
+-------------------------
+
+First compile this simple "Hello World" source (hello.c):
+
+ #include <stdio.h>
+ __declspec(dllexport) int start();
+ int start()
+ {
+ printf("Hello World\n");
+ return 0;
+ }
+
+Then build a dynamic library called "hello.dll":
+
+ %> cl6x -mv6400+ --abi=elfabi hello.c -z --import=printf --dynamic=lib -o hello.dll dlti.gen -e start
+
+Now, load the dynamic loader using a loader that supports C6x ELF
+executable object files. Then start the dynamic loader running.
+You will see the "RIDL" prompt come up and then you need to issue
+the following commands:
+
+ RIDL> base_image dlti.gen
+ RIDL> load hello.dll
+ RIDL> execute
+
+You should see the "Hello World" message displayed and then control
+will return to the "RIDL" prompt.
+
+
+2.4 Known Issues
+----------------
+
+- By default, the linker will use the output file name as the DT_SONAME
+ in the dynamic segment, but the linker supports a --soname option
+ that allows you to specify a custom name for a dynamic object. The
+ CORE dynamic loader asks the client to find the physical file that
+ matches the SONAME and load it. However the RIDL client code does not
+ implement any mechanism to find the physical file. It simply tries to
+ open a file with the SONAME in the current directory. Hence the dependent
+ library loading in the RIDL client code will work only if the SONAME
+ is the same as the dynamic library name and also the file is in the
+ current directory.
+
+ A system shall implement a proper mechanism (registry for example) to
+ find the file given the SONAME.
+
+ We do not plan to add such support in this reference implementation.
+
+-------------------------------------------------------------------------------
+3. Relevant Documents
+-------------------------------------------------------------------------------
+
+Please see the Texas Instruments Embedded Porcessor Wiki for more information
+about the architecture, specifications, and use cases for the dynamic loader.
+The specific URL is:
+
+http://processors.wiki.ti.com/index.php/C6000_EABI:Dynamic_Loader
+
+
+Also refer to the C6000 Embedded Application binary Interface (EABI)
+specification, available from:
+
+http://www.ti.com/lit/an/sprab89/sprab89.pdf
+
+(The above links are current as of Feb 2013.)
\ No newline at end of file
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/TMS470_DLOAD_DYN/arm_dynamic.c b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/TMS470_DLOAD_DYN/arm_dynamic.c
index 1b2deb8a0fb9a07c7bfb6fa11e63786adbfcf803..7c21a05b181bd2c704a562dfcdff2594a01a07c7 100644 (file)
--- a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/TMS470_DLOAD_DYN/arm_dynamic.c
+++ b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/TMS470_DLOAD_DYN/arm_dynamic.c
*
* ARM-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 ARM_TARGET
#include "arm_elf32.h"
-#if defined (__KERNEL__)
-#include <linux/types.h>
-#else
-#include <inttypes.h>
-#include <stdlib.h>
-#endif
#include "dload.h"
/*****************************************************************************/
case DT_ARM_SYMTABSZ:
{
dyn_module->symnum = dyn_module->dyntab[i].d_un.d_val;
-#if 0
+#if LOADER_DEBUG
if (debugging_on)
- DLIF_trace("Found global string table: %d\n",
- dyn_module->gstrtab_offset);
+ DLIF_trace("Found symbol table size: %d\n",
+ dyn_module->symnum);
#endif
return TRUE;
}
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/TMS470_DLOAD_DYN/arm_dynamic.h b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/TMS470_DLOAD_DYN/arm_dynamic.h
index bc42cae934f7eb59e1bb878221022bfbe6b3007d..5657e1376ce3a62faeae0d2acc5b398de2ea53d2 100644 (file)
--- a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/TMS470_DLOAD_DYN/arm_dynamic.h
+++ b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/TMS470_DLOAD_DYN/arm_dynamic.h
*
* Interface into ARM-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
int32_t i);
BOOL DLDYN_arm_process_eiosabi(DLIMP_Dynamic_Module* dyn_module);
+#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/TMS470_DLOAD_REL/Makefile.inc b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/TMS470_DLOAD_REL/Makefile.inc
--- a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/TMS470_DLOAD_REL/Makefile.inc
+++ /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 := arm_reloc.o
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/TMS470_DLOAD_REL/arm_reloc.c b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/TMS470_DLOAD_REL/arm_reloc.c
index be2dff51d0d58354b9cca06250fee799f28df38b..3123c6910745dbb876517decf30d8e739e46c8e5 100644 (file)
--- a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/TMS470_DLOAD_REL/arm_reloc.c
+++ b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/TMS470_DLOAD_REL/arm_reloc.c
*
* Process ARM-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 "dload_api.h"
#include "util.h"
#include "dload_endian.h"
#include "symtab.h"
#include "arm_elf32.h"
+#include "dload.h"
+#include "arm_reloc.h"
#define EXTRACT(field, lsb_offset, field_size) \
( (field >> lsb_offset) & ((1U << field_size) - 1) )
default:
return FALSE;
}
-
- return FALSE;
}
/*****************************************************************************/
default:
return FALSE;
}
- return FALSE;
}
/*****************************************************************************/
default:
return 0;
}
-
- return 0;
}
/*****************************************************************************/
if (bit_align == 0) bit_align = 1;
- if ((mask_offset & bit_align) !=0)
+ if (mask_offset % bit_align != 0)
mask_offset += (bit_align - (mask_offset % bit_align));
return mask_offset;
default:
return FALSE;
}
- return FALSE;
}
+#if LOADER_DEBUG && LOADER_PROFILE
+extern int DLREL_relocations;
+extern time_t DLREL_total_reloc_time;
+#endif
+
/*****************************************************************************/
/* RELOC_DO() - Process a single relocation entry. */
/*****************************************************************************/
/* 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++;
for ( ; rid < relnum; rid++)
{
+ int32_t r_symid = ELF32_R_SYM(rel_table[rid].r_info);
+
/*---------------------------------------------------------------*/
/* If the relocation offset falls within the segment, process it */
/*---------------------------------------------------------------*/
rel_table[rid].r_offset < seg_end_addr)
{
Elf32_Addr r_symval;
- ARM_RELOC_TYPE r_type = ELF32_R_TYPE(rel_table[rid].r_info);
+ ARM_RELOC_TYPE r_type =
+ (ARM_RELOC_TYPE) ELF32_R_TYPE(rel_table[rid].r_info);
int32_t r_symid = ELF32_R_SYM(rel_table[rid].r_info);
uint8_t* reloc_address;
+ uint32_t offset;
uint32_t pc;
uint32_t addend = 0;
BOOL change_endian;
if (!DLSYM_canonical_lookup(handle, r_symid, dyn_module, &r_symval))
continue;
- reloc_address =
- (((uint8_t*)(seg->phdr.p_vaddr) + seg->reloc_offset) +
- rel_table[rid].r_offset - seg->input_vaddr);
- pc = (uint32_t) reloc_address;
+ offset = rel_table[rid].r_offset - seg->input_vaddr;
+ pc = seg->phdr.p_vaddr + offset;
+ reloc_address = (uint8_t*)seg->host_address + offset;
+
change_endian = rel_swap_endian(dyn_module, r_type);
if (change_endian)
rel_change_endian(r_type, reloc_address);
- rel_unpack_addend(ELF32_R_TYPE(rel_table[rid].r_info),
- reloc_address,
- &addend);
+ rel_unpack_addend(r_type, reloc_address, &addend);
#if LOADER_DEBUG && LOADER_PROFILE
if (debugging_on)
return found;
}
+/*****************************************************************************/
+/* PROCESS_RELA_TABLE() */
+/* */
+/* Process a table of Elf32_Rela type relocations. */
+/* */
+/*****************************************************************************/
static BOOL process_rela_table(DLOAD_HANDLE handle,
DLIMP_Loaded_Segment* seg,
struct Elf32_Rela* rela_table,
rela_table[rid].r_offset < seg_end_addr)
{
Elf32_Addr r_symval;
- ARM_RELOC_TYPE r_type = ELF32_R_TYPE(rela_table[rid].r_info);
+ ARM_RELOC_TYPE r_type =
+ (ARM_RELOC_TYPE)ELF32_R_TYPE(rela_table[rid].r_info);
int32_t r_symid = ELF32_R_SYM(rela_table[rid].r_info);
uint8_t* reloc_address;
+ uint32_t offset;
uint32_t pc;
uint32_t addend;
BOOL change_endian;
if (!DLSYM_canonical_lookup(handle, r_symid, dyn_module, &r_symval))
continue;
- reloc_address = (((uint8_t*)(seg->phdr.p_vaddr) + seg->reloc_offset) +
- rela_table[rid].r_offset - seg->input_vaddr);
- pc = (uint32_t) reloc_address;
+ offset = rela_table[rid].r_offset - seg->input_vaddr;
+ pc = seg->phdr.p_vaddr + offset;
+ reloc_address = (uint8_t*)seg->host_address + offset;
addend = rela_table[rid].r_addend;
change_endian = rel_swap_endian(dyn_module, r_type);
/* function interface and could do with some encapsulation. */
/*----------------------------------------------------------*/
- reloc_do(ELF32_R_TYPE(rela_table[rid].r_info),
+ reloc_do((ARM_RELOC_TYPE)ELF32_R_TYPE(rela_table[rid].r_info),
reloc_address,
addend,
r_symval,
BOOL wrong_endian)
{
int i;
+
+ if (relnum == 0) { *rel_table = NULL; return; }
+
*rel_table = (struct Elf32_Rel*) DLIF_malloc(relnum*relent);
- if (NULL == *rel_table) {
+ if (NULL == *rel_table) {
DLIF_error(DLET_MEMORY,"Failed to Allocate read_rel_table\n");
return;
- }
+ }
DLIF_fseek(elf_file, table_offset, LOADER_SEEK_SET);
DLIF_fread(*rel_table, relnum, relent, elf_file);
BOOL wrong_endian)
{
int i;
+
+ if (relanum == 0) { *rela_table = NULL; return; }
+
*rela_table = DLIF_malloc(relanum*relaent);
- if (NULL == *rela_table) {
+ if (NULL == *rela_table) {
DLIF_error(DLET_MEMORY,"Failed to Allocate read_rela_table\n");
return;
- }
+ }
DLIF_fseek(elf_file, table_offset, LOADER_SEEK_SET);
DLIF_fread(*rela_table, relanum, relaent, elf_file);
if (debugging_on)
{
DLIF_trace("Reloc segment %d:\n", s);
- DLIF_trace("addr=0x%x, old_addr=0x%x, r_offset=0x%x\n",
- seg[s].phdr.p_vaddr, seg[s].input_vaddr, seg[s].reloc_offset);
+ DLIF_trace("addr=0x%x, old_addr=0x%x, host=0x%x\n",
+ seg[s].phdr.p_vaddr, seg[s].input_vaddr, seg[s].host_address);
}
#endif
if (rela_table)
- process_rela_table(handle, (seg + s), rela_table, relanum,
- &rela_rid, dyn_module);
+ process_rela_table(handle, (seg + s), rela_table, relanum, &rela_rid,
+ dyn_module);
if (rel_table)
process_rel_table(handle, (seg + s), rel_table, relnum, &rel_rid,
/* 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,
+void DLREL_arm_relocate(DLOAD_HANDLE handle,
LOADER_FILE_DESC* elf_file,
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 */
/* 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 (pltreltype == DT_REL)
{
pltnum = pltrelsz/relent;
relsz -= pltrelsz;
- read_rel_table(((struct Elf32_Rel**) &plt_table),
+ read_rel_table(&rel_plt_table,
DLIMP_get_first_dyntag(DT_JMPREL, dyn_nugget),
pltnum, relent, elf_file,
dyn_module->wrong_endian);
{
pltnum = pltrelsz/relaent;
relasz -= pltrelsz;
- read_rela_table(((struct Elf32_Rela**) &plt_table),
+ read_rela_table(&rela_plt_table,
DLIMP_get_first_dyntag(DT_JMPREL, dyn_nugget),
pltnum, relaent, elf_file,
dyn_module->wrong_endian);
/*------------------------------------------------------------------------*/
/* 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),
/*------------------------------------------------------------------------*/
/* 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),
/*------------------------------------------------------------------------*/
/* Process the PLTGOT relocations */
/*------------------------------------------------------------------------*/
- if (plt_table)
- process_pltgot_relocs(handle, plt_table, pltreltype, pltnum, dyn_module);
+ if (rela_plt_table)
+ process_pltgot_relocs(handle, rela_plt_table, pltreltype, pltnum,
+ dyn_module);
+
+ if (rel_plt_table)
+ process_pltgot_relocs(handle, rel_plt_table, pltreltype, pltnum,
+ dyn_module);
/*------------------------------------------------------------------------*/
/* Process the GOT relocations */
/*-------------------------------------------------------------------------*/
if (rela_table) DLIF_free(rela_table);
if (rel_table) DLIF_free(rel_table);
- if (plt_table) DLIF_free(plt_table);
+ if (rel_plt_table) DLIF_free(rel_plt_table);
+ if (rela_plt_table) DLIF_free(rela_plt_table);
}
/*****************************************************************************/
{
rel_mask_for_group(r_type, reloc_val);
}
-#endif
+#endif
\ No newline at end of file
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/TMS470_DLOAD_REL/arm_reloc.h b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/TMS470_DLOAD_REL/arm_reloc.h
--- /dev/null
+++ b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/TMS470_DLOAD_REL/arm_reloc.h
@@ -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_arm_relocate(DLOAD_HANDLE handle, LOADER_FILE_DESC* elf_file,
+ DLIMP_Dynamic_Module* dyn_module);
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/TMS470_DLOAD_SYM/README b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/TMS470_DLOAD_SYM/README
--- /dev/null
@@ -0,0 +1,4 @@
+TMS470_DLOAD_SYM:
+
+This module is for ARM specific symbol table features. Currently there are
+no target specific features in the symbol table implementation.
\ No newline at end of file
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/lnk.cmd b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/DLOAD/lnk.cmd
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
-* lnk.cmd
-*
-* C6x dynamic loader linker command file.
-*
-* 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.
-*
-*/
--c
--heap 0x10000000
--stack 0x200000
---args 0x200
-
-MEMORY
-{
- PMEM: o = 00000020h l = 01000000h
- BLOB: o = 02000000h l = 02000000h
- BMEM: o = 80000000h l = 20000000h
-}
-
-SECTIONS
-{
- .text > PMEM
- .stack > BMEM
- .args > BMEM
-
- GROUP
- {
- .dsbt
- .got
- .bss
- .neardata
- .rodata
- }>BMEM
-
- .cinit > BMEM
- .cio > BMEM
- .const > BMEM
- .data > BMEM
- .blob > BLOB
- .switch > BMEM
- .sysmem > BMEM
- .far > BMEM
- .ppinfo > BMEM
- .ppdata > BMEM, palign(32) /* Work-around kelvin bug */
-}
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/ElfLoader.c b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/ElfLoader.c
index ac18eea295c83e9ee8e11039c4fa48b8a2e1e3e4..c5cfd29fbf91ef5a8eea36b4e9017b1518301e66 100644 (file)
* @endcode
*
*
- * @ver 02.00.00.46_alpha1
- *
* ============================================================================
*
- * Copyright (c) 2008-2009, Texas Instruments Incorporated
+ * Copyright (c) 2008-2015, Texas Instruments Incorporated
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
ElfLoader_Object * elfLoaderObj;
DLOAD_HANDLE elfObj;
_ElfLoader_Object * _elfLoaderObj;
+ TARGET_ADDRESS ep;
+ Int argStatus;
GT_5trace (curTrace, GT_ENTER, "ElfLoader_load",
handle, imagePath, argc, argv, params);
* This cast to (LOADER_FILE_DESC *) is not ideal, but appears safe
* as DLOAD_load does not look into fileDesc.
*/
- *fileId = DLOAD_load(elfObj, (LOADER_FILE_DESC *)fileDesc, argc,
- argv);
+ *fileId = DLOAD_load(elfObj, (LOADER_FILE_DESC *)fileDesc);
if (*fileId == 0) {
status = LOADER_E_FAIL;
}
- //status = ElfLoader_getEntryPt(handle, *fileId, (UInt32*)params);
-
#if !defined(SYSLINK_BUILD_OPTIMIZE)
if (status < 0) {
GT_setFailureReason (curTrace,
}
else {
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
+ argStatus = DLOAD_prepare_for_execution(elfObj,
+ *fileId, &ep, argc, argv);
+
+#if !defined(SYSLINK_BUILD_OPTIMIZE)
+ if (argStatus == FALSE) {
+ GT_setFailureReason (curTrace,
+ GT_4CLASS,
+ "ElfLoader_load",
+ argStatus,
+ "Failed to write args!"
+ " (ensure .args section is big enough)");
+ }
+#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
+
/* Set the state of the Processor to loaded. */
Processor_setState (_elfLoaderObj->procHandle,
ProcMgr_State_Loaded);
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/dlw_client/Makefile.inc b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/dlw_client/Makefile.inc
+++ /dev/null
@@ -1,51 +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 := dlw_dsbt.o dlw_client.o
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/dlw_client/dlw_client.c b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/dlw_client/dlw_client.c
index efaa9e76b2c4693569edde9f92a04aa8be25f696..6897482a0d22bb98df39b3b485da525583e18d52 100644 (file)
/* */
/*****************************************************************************/
/*
-* Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
+* Copyright (C) 2012-2015 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
#define LOADER_DEBUG 1
#if LOADER_DEBUG
BOOL debugging_on = 1;
+#if LOADER_PROFILE
+BOOL profiling_on = 1;
+#else
+BOOL profiling_on = 0;
+#endif
#endif
-
/*****************************************************************************/
/* Client Provided File I/O */
return ElfLoaderFile_close(NULL, fd);
}
+/*****************************************************************************/
+/* DLIF_EXIT() - Abort the loader after a fatal error. */
+/*****************************************************************************/
+void DLIF_exit(int code)
+{
+ exit(code);
+}
+
/*****************************************************************************/
/* Client Provided Host Memory Management */
/*****************************************************************************/
return retval;
}
+/*****************************************************************************/
+/* DLIF_MEMCPY() - Write updated (relocated) segment contents to target */
+/* memory. */
+/*****************************************************************************/
+BOOL DLIF_memcpy(void* client_handle, void *to, void *from, size_t size)
+{
+ BOOL retval = TRUE;
+
+ struct DLOAD_MEMORY_REQUEST memReq;
+ struct DLOAD_MEMORY_SEGMENT memSeg;
+
+ /*
+ * Fake up a memReq record, setting only those fields used by ElfLoaderTrgWrite_write()
+ */
+ memReq.is_loaded = FALSE;
+ memReq.segment = &memSeg;
+ memReq.host_address = from;
+ memSeg.target_address = (TARGET_ADDRESS)to;
+ memSeg.objsz_in_bytes = size;
+
+ if (ElfLoaderTrgWrite_write (client_handle, &memReq) < 0) {
+ retval = FALSE;
+ }
+
+ return retval;
+}
+
/*****************************************************************************/
/* DLIF_EXECUTE() - Transfer control to specified target address. */
/*****************************************************************************/
diff --git a/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/dlw_client/dlw_dsbt.c b/qnx/src/ipc3x_dev/ti/syslink/procMgr/hlos/knl/loaders/Elf/Qnx/dlw_client/dlw_dsbt.c
index cc13b58edccd364a014f5a082ece2fdcdd63a6c5..48e0266e04623b685df954dc4f2f377dae68f66a 100644 (file)
* 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/
+* Copyright (C) 2009-2015 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
#include "dload.h" // Needed for LOADER_DEBUG def.
#include <string.h>
#include "dlw_dsbt.h"
-#undef LOADER_DEBUG
-#define LOADER_DEBUG 1
/*****************************************************************************/
/* DSBT_index_request_queue - This is a holding area for DSBT index requests */
/* DLIF_assign_dsbt_indices(). */
/*****************************************************************************/
TYPE_QUEUE_IMPLEMENTATION(DSBT_Index_Request*, dsbt_index_request_ptr)
-dsbt_index_request_ptr_Queue DSBT_index_request_queue;
+dsbt_index_request_ptr_Queue DSBT_index_request_queue = TYPE_QUEUE_INITIALIZER;
/*****************************************************************************/
/* DSBT_Master - This is the master copy of the DSBT created by the client */
DSBT_Index_Request *existing_request = ptr->value;
/*------------------------------------------------------------------*/
- /* Have we seen a request for this file already? That would be a */
- /* problem (likely internal). */
+ /* Have we seen a request for this file already? That would be a */
+ /* problem (likely internal). */
/*------------------------------------------------------------------*/
- if (requestor_file_handle == existing_request->file_handle)
- {
- DLIF_error(DLET_MISC,
- "A DSBT index has already been requested on behalf "
- "of %s; cannot make a second DSBT index request for "
- "the same module", existing_request->name);
- return FALSE;
- }
+ if (requestor_file_handle == existing_request->file_handle)
+ {
+ DLIF_error(DLET_MISC,
+ "A DSBT index has already been requested on behalf "
+ "of %s; cannot make a second DSBT index request for "
+ "the same module", existing_request->name);
+ return FALSE;
+ }
/*------------------------------------------------------------------*/
- /* Have we seen a specific request for this DSBT index already? */
- /* Report a conflict among specific requests in the same load. */
+ /* Have we seen a specific request for this DSBT index already? */
+ /* Report a conflict among specific requests in the same load. */
/*------------------------------------------------------------------*/
- if (requested_dsbt_index == existing_request->requested_index)
- {
- DLIF_error(DLET_MISC,
- "Requested DSBT index, %d, requested by %s has "
- "already been requested by %s; load aborted",
- requested_dsbt_index,
- requestor_name,
- existing_request->name);
- return FALSE;
- }
+ if (requested_dsbt_index == existing_request->requested_index)
+ {
+ DLIF_error(DLET_MISC,
+ "Requested DSBT index, %d, requested by %s has "
+ "already been requested by %s; load aborted",
+ requested_dsbt_index,
+ requestor_name,
+ existing_request->name);
+ return FALSE;
+ }
}
}
{
DLIF_error(DLET_MISC,
"Could not resolve DSBT base value for %s",
- requestor_name);
+ requestor_name);
DLIF_free(new_request->name);
new_request->name = NULL;
DLIF_free(new_request);
}
if (i == AL_size(&DSBT_master))
- add_dsbt_entry(request);
+ add_dsbt_entry(request);
request->assigned_index = i;
}
if (curr_req == NULL) continue;
if (curr_req->file_handle == file_handle)
- return curr_req->assigned_index;
+ return curr_req->assigned_index;
}
/*------------------------------------------------------------------------*/
if (curr_dsbt_size < master_dsbt_size)
{
DLIF_error(DLET_MISC,
- "DSBT allocated for %s is not large enough to hold "
- "entire DSBT", curr_req->name);
+ "DSBT allocated for %s is not large enough to hold "
+ "entire DSBT", curr_req->name);
return FALSE;
}
}
#endif
for (j = 0; j < master_dsbt_size; j++)
- {
+ {
DSBT_Index_Request *j_req = client_dsbt[j].index_request;
if (j_req != NULL)
*((TARGET_ADDRESS *)(curr_req->dsbt_base) + j) =
(j_req != NULL) ? j_req->static_base : 0;
- }
+ }
}
}