4 * Copyright (C) 2001-2009 Alan R. Baldwin
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31 * The module lkcdb.c contains the functions
32 * required to create a SDCDB debug file.
34 * lksdcdb.c contains the following functions:
40 /*)Function VOID SDCDBfopen()
42 * The function SDCDBfopen() opens the SDCDB output file
43 * and sets the map flag, mflag, to create a map file.
44 * SDCDB processing is performed during map generation.
50 * int yflag SDCDB Debug flag
51 * FILE * yfp SDCDB Debug File handle
52 * struct lfile *linkp Pointer to the Linker output file name
53 * int mflag Map output flag
56 * FILE * afile() lkmain.c
57 * VOID lkexit() lkmain.c
60 * The SDCDB output file is opened.
61 * Failure to open the file will
62 * terminate the linker.
68 SaveLinkedFilePath(linkp
->f_idp
); //Must be the first one...
69 yfp
= afile(linkp
->f_idp
, "cdb", 1);
78 /*)Function VOID SDCDBcopy()
80 * char * str pointer to the file spec
82 * The function SDCDBcopy() copies an existing adb file
83 * into the linker cdb file.
85 * The function is called from lklex.c and lklibr.c
88 * FILE * xfp file handle
89 * char line[] line from file
92 * int yflag SDCDB Debug flag
93 * FILE * yfp SDCDB Debug File handle
96 * FILE * afile() lkmain.c
97 * int fgets() c_library
98 * int fprintf() c_library
99 * int fclose() c_library
102 * SDCDB cdb file is copied into
103 * the linker cdb output file.
106 VOID
SDCDBcopy(char * str
)
111 * Copy .adb file if present and requested.
114 xfp
= afile(str
, "adb", 0); //JCF: Nov 30, 2002
123 /*)Function VOID DefineSDCDB()
125 * char * name pointer to the symbol string
126 * a_uint value value of symbol
128 * The function DefineSDCDB() processes the symbols into
129 * SDCDB commands for inclusion in the SDCDB output file.
131 * The function is called from lstarea in lklist.c
135 * int j argument count
136 * char * p1 temporary string pointer
139 * FILE * yfp SDCDB Debug File handle
142 * int fprintf() c_library
143 * int strchr() c_library
146 * SDCDB debug symbols are placed
147 * into the output file.
150 VOID
DefineSDCDB(char *name
, a_uint value
)
155 /* no output if file is not open */
156 if (yfp
== NULL
) return;
159 * SDCC symbols have 2 or more $ characters
160 * with the shortest being the Linker ASM Record
161 * eg L:A$TinyBuffer$2320:A13
165 while ((p1
= strchr(p1
, '$')) != NULL
) {
172 fprintf(yfp
, "L:%s:%lX\n", name
,value
);
174 fprintf(yfp
, "L:%s:%X\n", name
,value
);