SPRUIG8J January 2018 – March 2024
To use a copy table generated by the linker, you must know the contents of the copy table. This information is included in a run-time-support library header file, cpy_tbl.h, which contains a C source representation of the copy table data structure generated by the linker.
/*****************************************************************************/
/* cpy_tbl.h */
/* */
/* Copyright (c) 2003 Texas Instruments Incorporated http://www.ti.com/ */
/* */
/* Specification of copy table data structures which can be automatically */
/* generated by the linker (using the table() operator in the LCF). */
/*****************************************************************************/
#ifndef _CPY_TBL
#define _CPY_TBL
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*****************************************************************************/
/* Copy Record Data Structure */
/*****************************************************************************/
typedef struct copy_record
{
uint64_t load_addr;
uint64_t run_addr;
uint32_t size;
} __attribute((__packed__)) COPY_RECORD;
/*****************************************************************************/
/* Copy Table Data Structure */
/*****************************************************************************/
typedef struct copy_table
{
uint16_t rec_size;
uint16_t num_recs;
COPY_RECORD recs[1];
} COPY_TABLE;
/*****************************************************************************/
/* Prototype for general purpose copy routine. */
/*****************************************************************************/
extern void copy_in(COPY_TABLE *tp);
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
#endif /* !_CPY_TBL */
For each object component that is marked for a copy, the linker creates a COPY_RECORD object for it. Each COPY_RECORD contains at least the following information for the object component:
The linker collects all COPY_RECORDs that are associated with the same copy table into a COPY_TABLE object. The COPY_TABLE object contains the size of a given COPY_RECORD, the number of COPY_RECORDs in the table, and the array of COPY_RECORDs in the table. For instance, in the BINIT example in Section 12.8.4.2, the .first and .extra output sections will each have their own COPY_RECORD entries in the BINIT copy table. The BINIT copy table will then look like this:
COPY_TABLE __binit__ = { 12, 2,
{ <load address of .first>,
<run address of .first>,
<size of .first> },
{ <load address of .extra>,
<run address of .extra>,
<size of .extra> } };