]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/ibl.git/blob - src/interp/coff/cload.h
.gitignore: update to ignore all make created files
[keystone-rtos/ibl.git] / src / interp / coff / cload.h
1 /*
2  *
3  * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ 
4  * 
5  * 
6  *  Redistribution and use in source and binary forms, with or without 
7  *  modification, are permitted provided that the following conditions 
8  *  are met:
9  *
10  *    Redistributions of source code must retain the above copyright 
11  *    notice, this list of conditions and the following disclaimer.
12  *
13  *    Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the 
15  *    documentation and/or other materials provided with the   
16  *    distribution.
17  *
18  *    Neither the name of Texas Instruments Incorporated nor the names of
19  *    its contributors may be used to endorse or promote products derived
20  *    from this software without specific prior written permission.
21  *
22  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
23  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
24  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
26  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
27  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
28  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
31  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
32  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34 */
38 /***************************************************************************
39 * FILENAME: cload.h
40 * VERSION:  2.4  5/2/96  13:12:48
41 * SCCS ID:  "@(#)cload.h        2.4  5/2/96"
42 ***************************************************************************/
43 /*****************************************************************************/
44 /* CLOAD.H - Header file for Generic COFF Loader     Version 4.00 9/92       */
45 /*****************************************************************************/
46 #ifndef _CLOAD_H_
47 #define _CLOAD_H_
49 /*---------------------------------------------------------------------------*/
50 /* THIS MACRO IS USED TO FACILIATE ACCESS TO THE SECTION HEADERS             */
51 /*---------------------------------------------------------------------------*/
52 #define SECT_HDR(i) ((SCNHDR *)(sect_hdrs + (i) * SCNHSZ))
54 /*---------------------------------------------------------------------------*/
55 /* THIS MACRO IS USED TO FACILITATE BACKWARDS COMPATIBILITY FOR COFF-        */
56 /* DEPENDENT TOOLS THAT SUPPORT COFF VERSION 2.                              */
57 /*---------------------------------------------------------------------------*/
58 #define O_SECT_HDR(i) ((O_SCNHDR *)(o_sect_hdrs + (i)*SCNHSZ_IN(coff_version)))
60 /*----------------------------------------------------------------------------*/
61 /* STATIC COPY OF 8 CHARACTER SECTION NAME, GUARANTEED NULL TERMINATION WHEN  */
62 /* USED AS A STRING.                                                          */
63 /*----------------------------------------------------------------------------*/
64 static char stat_nm[SYMNMLEN+1]={'\0','\0','\0','\0','\0','\0','\0','\0','\0'};
65 #define SNAMECPY(s)     (strn_copy(stat_nm, (s), SYMNMLEN))
67 /*---------------------------------------------------------------------------*/
68 /* THESE MACROS ARE USED TO FIND CINIT AND BSS SECTIONS                      */
69 /*---------------------------------------------------------------------------*/
70 #define IS_BSS(sptr)    (!str_comp(sptr->s_name, ".bss"))
71 #define IS_CINIT(sptr)  ((sptr->s_flags & STYP_COPY) &&         \
72                         !str_comp(sptr->s_name, CINIT) )
74 /*---------------------------------------------------------------------------*/
75 /* VARIABLES SET BY THE APPLICATION.                                         */
76 /*---------------------------------------------------------------------------*/
77 /* #define FILE_BASED 0   - moved to osal.h */
78 #define STRIP_RELOC 1
79 #define REMOVE_MALLOC 0
81 #if (FILE_BASED)
82 extern FILE   *fin;                                             /* INPUT FILE                         */
83 #else
84 extern unsigned char gRxBuffer[0x400040];
85 #endif
87 extern int     need_data;            /* READ IN RAW DATA                     */
88 extern int     need_symbols;         /* READ IN SYMBOL TABLE                 */
89 extern int     clear_bss;            /* CLEAR BSS SECTION                    */
90 extern int     big_e_config;         /* ENDIANNESS CONFIGURATION OF TARGET   */
91 #if TMS320C60 || RTC
92 extern int    fill_bss_value;       /* NUMBER FOR FILL VALUE                */
93 #endif
95 /*---------------------------------------------------------------------------*/
96 /* VARIABLES SET BY THE LOADER.                                              */
97 /*---------------------------------------------------------------------------*/
98 extern FILHDR  file_hdr;             /* FILE HEADER STRUCTURE                */
99 extern int     coff_version;         /* VERSION OF COFF USED BY FILE         */
100 extern AOUTHDR o_filehdr;            /* OPTIONAL (A.OUT) FILE HEADER         */
101 extern T_ADDR  entry_point;          /* ENTRY POINT OF MODULE                */
102 extern T_ADDR *reloc_amount;         /* AMOUNT OF RELOCATION PER SECTION     */
103 extern char   *sect_hdrs;            /* ARRAY OF SECTION HEADERS             */
104 extern char   *o_sect_hdrs;          /* ARRAY OF OLD COFF SECTION HEADERS    */
105 extern int     n_sections;           /* NUMBER OF SECTIONS IN THE FILE       */
106 extern int     big_e_target;         /* OBJECT DATA IS STORED MSB FIRST      */
107 extern int     byte_swapped;         /* BYTE ORDERING OPPOSITE OF HOST       */
108 extern int     curr_sect;            /* INDEX OF SECTION CURRENTLY LOADING   */
109 extern int     load_err;             /* ERROR CODE RETURNED IF LOADER FAILS  */
110 extern struct strtab *str_head;      /* HEAD OF STRING BUFFER LIST           */
112 /*--------------------------------------------------------------------------*/
113 /*                        CLOAD.C PROTOTYPES                                */
114 /*--------------------------------------------------------------------------*/
115 extern int      cload (void);
116 extern int      cload_headers (void);
117 extern int      cload_data (void);
118 extern int      cload_sect_data (struct scnhdr *);
119 extern int      cload_cinit (unsigned char *, int *, int *);
120 extern int      cload_symbols (void);
121 extern int      cload_strings (void);
122 extern void     str_free (struct strtab *);
123 extern int      sym_read (int, struct syment *, union auxent *);
124 extern char    *sym_name (struct syment *);
125 extern char    *sym_add_name (struct syment *);
126 extern int      reloc_add (int, struct syment *);
127 extern int      relocate (RELOC *, unsigned char *, int);
128 extern int      reloc_size (int);
129 extern int      reloc_offset (int);
130 extern int      reloc_stop (int);
131 extern int      sym_reloc_amount (RELOC *);
132 extern unsigned int unpack (unsigned char *, int, int, int);
133 extern void     repack (unsigned int, unsigned char *, int,int,int);
134 extern int      cload_lineno (int, int, struct lineno *, int);
135 extern void     swap4byte (void *);
136 extern void     swap2byte (void *);
138 #if FILE_BASED
139 int reloc_read(RELOC *rptr);
140 #else
141 int reloc_read(RELOC *rptr, unsigned int offset);
142 #endif
144 /*--------------------------------------------------------------------------*/
145 /*             PROTOTYPES FOR FUNCTIONS REQUIRED BY CLOAD.C                 */
146 /*--------------------------------------------------------------------------*/
147 extern void     lookup_sym(int indx, SYMENT *sym, AUXENT *aux);
148 /* extern int           mem_write(unsigned char *, unsigned int, T_ADDR, unsigned char); - moved to osal.h */
149 extern void     load_msg(const char *);
150 extern int      set_reloc_amount(void);
151 extern int      load_syms(int);
153 /*---------------------------------------------------------------------------*/
154 /* VALUE OF big_e_config IF THERE IS NO TARGET AND SO IT'S A DON'T CARE.     */
155 /*---------------------------------------------------------------------------*/
156 #define DONTCARE    -1
158 /*---------------------------------------------------------------------------*/
159 /* ERROR CODES                                                               */
160 /*---------------------------------------------------------------------------*/
161 #define E_FILE      1                /* ERROR READING COFF FILE              */
162 #define E_MAGIC     2                /* WRONG MAGIC NUMBER                   */
163 #define E_RELOC     3                /* FILE IS NOT RELOCATABLE              */
164 #define E_SYM       4                /* LOAD_SYM RETURNED FALSE              */
165 #define E_ALLOC     5                /* MYALLOC OR MRALLOC RETURNED FALSE    */
166 #define E_SETRELOC  6                /* SET_RELOC_AMOUNT RETURNED FALSE      */
167 #define E_MEMWRITE  7                /* MEM_WRITE RETURNED FALSE             */
168 #define E_RELOCENT  8                /* RELOC ENTRY RULES VIOLATED           */
169 #define E_ENDIAN    9                /* OBJ ENDIANESS CONFLICTS WITH TARGET  */
171 #endif /* _CLOAD_H_  */