aicasm_symbol.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. /*
  2. * Aic7xxx SCSI host adapter firmware assembler symbol table implementation
  3. *
  4. * Copyright (c) 1997 Justin T. Gibbs.
  5. * Copyright (c) 2002 Adaptec Inc.
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions, and the following disclaimer,
  13. * without modification.
  14. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  15. * substantially similar to the "NO WARRANTY" disclaimer below
  16. * ("Disclaimer") and any redistribution must be conditioned upon
  17. * including a substantially similar Disclaimer requirement for further
  18. * binary redistribution.
  19. * 3. Neither the names of the above-listed copyright holders nor the names
  20. * of any contributors may be used to endorse or promote products derived
  21. * from this software without specific prior written permission.
  22. *
  23. * Alternatively, this software may be distributed under the terms of the
  24. * GNU General Public License ("GPL") version 2 as published by the Free
  25. * Software Foundation.
  26. *
  27. * NO WARRANTY
  28. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  29. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  30. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  31. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  32. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  33. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  34. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  36. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  37. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  38. * POSSIBILITY OF SUCH DAMAGES.
  39. *
  40. * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.c#24 $
  41. *
  42. * $FreeBSD$
  43. */
  44. #include <sys/types.h>
  45. #include "aicdb.h"
  46. #include <fcntl.h>
  47. #include <inttypes.h>
  48. #include <regex.h>
  49. #include <stdio.h>
  50. #include <stdlib.h>
  51. #include <string.h>
  52. #include <sysexits.h>
  53. #include "aicasm_symbol.h"
  54. #include "aicasm.h"
  55. static DB *symtable;
  56. symbol_t *
  57. symbol_create(char *name)
  58. {
  59. symbol_t *new_symbol;
  60. new_symbol = (symbol_t *)malloc(sizeof(symbol_t));
  61. if (new_symbol == NULL) {
  62. perror("Unable to create new symbol");
  63. exit(EX_SOFTWARE);
  64. }
  65. memset(new_symbol, 0, sizeof(*new_symbol));
  66. new_symbol->name = strdup(name);
  67. if (new_symbol->name == NULL)
  68. stop("Unable to strdup symbol name", EX_SOFTWARE);
  69. new_symbol->type = UNINITIALIZED;
  70. new_symbol->count = 1;
  71. return (new_symbol);
  72. }
  73. void
  74. symbol_delete(symbol_t *symbol)
  75. {
  76. if (symtable != NULL) {
  77. DBT key;
  78. key.data = symbol->name;
  79. key.size = strlen(symbol->name);
  80. symtable->del(symtable, &key, /*flags*/0);
  81. }
  82. switch(symbol->type) {
  83. case SCBLOC:
  84. case SRAMLOC:
  85. case REGISTER:
  86. if (symbol->info.rinfo != NULL)
  87. free(symbol->info.rinfo);
  88. break;
  89. case ALIAS:
  90. if (symbol->info.ainfo != NULL)
  91. free(symbol->info.ainfo);
  92. break;
  93. case MASK:
  94. case FIELD:
  95. case ENUM:
  96. case ENUM_ENTRY:
  97. if (symbol->info.finfo != NULL) {
  98. symlist_free(&symbol->info.finfo->symrefs);
  99. free(symbol->info.finfo);
  100. }
  101. break;
  102. case DOWNLOAD_CONST:
  103. case CONST:
  104. if (symbol->info.cinfo != NULL)
  105. free(symbol->info.cinfo);
  106. break;
  107. case LABEL:
  108. if (symbol->info.linfo != NULL)
  109. free(symbol->info.linfo);
  110. break;
  111. case UNINITIALIZED:
  112. default:
  113. break;
  114. }
  115. free(symbol->name);
  116. free(symbol);
  117. }
  118. void
  119. symtable_open()
  120. {
  121. symtable = dbopen(/*filename*/NULL,
  122. O_CREAT | O_NONBLOCK | O_RDWR, /*mode*/0, DB_HASH,
  123. /*openinfo*/NULL);
  124. if (symtable == NULL) {
  125. perror("Symbol table creation failed");
  126. exit(EX_SOFTWARE);
  127. /* NOTREACHED */
  128. }
  129. }
  130. void
  131. symtable_close()
  132. {
  133. if (symtable != NULL) {
  134. DBT key;
  135. DBT data;
  136. while (symtable->seq(symtable, &key, &data, R_FIRST) == 0) {
  137. symbol_t *stored_ptr;
  138. memcpy(&stored_ptr, data.data, sizeof(stored_ptr));
  139. symbol_delete(stored_ptr);
  140. }
  141. symtable->close(symtable);
  142. }
  143. }
  144. /*
  145. * The semantics of get is to return an uninitialized symbol entry
  146. * if a lookup fails.
  147. */
  148. symbol_t *
  149. symtable_get(char *name)
  150. {
  151. symbol_t *stored_ptr;
  152. DBT key;
  153. DBT data;
  154. int retval;
  155. key.data = (void *)name;
  156. key.size = strlen(name);
  157. if ((retval = symtable->get(symtable, &key, &data, /*flags*/0)) != 0) {
  158. if (retval == -1) {
  159. perror("Symbol table get operation failed");
  160. exit(EX_SOFTWARE);
  161. /* NOTREACHED */
  162. } else if (retval == 1) {
  163. /* Symbol wasn't found, so create a new one */
  164. symbol_t *new_symbol;
  165. new_symbol = symbol_create(name);
  166. data.data = &new_symbol;
  167. data.size = sizeof(new_symbol);
  168. if (symtable->put(symtable, &key, &data,
  169. /*flags*/0) !=0) {
  170. perror("Symtable put failed");
  171. exit(EX_SOFTWARE);
  172. }
  173. return (new_symbol);
  174. } else {
  175. perror("Unexpected return value from db get routine");
  176. exit(EX_SOFTWARE);
  177. /* NOTREACHED */
  178. }
  179. }
  180. memcpy(&stored_ptr, data.data, sizeof(stored_ptr));
  181. stored_ptr->count++;
  182. data.data = &stored_ptr;
  183. if (symtable->put(symtable, &key, &data, /*flags*/0) !=0) {
  184. perror("Symtable put failed");
  185. exit(EX_SOFTWARE);
  186. }
  187. return (stored_ptr);
  188. }
  189. symbol_node_t *
  190. symlist_search(symlist_t *symlist, char *symname)
  191. {
  192. symbol_node_t *curnode;
  193. curnode = SLIST_FIRST(symlist);
  194. while(curnode != NULL) {
  195. if (strcmp(symname, curnode->symbol->name) == 0)
  196. break;
  197. curnode = SLIST_NEXT(curnode, links);
  198. }
  199. return (curnode);
  200. }
  201. void
  202. symlist_add(symlist_t *symlist, symbol_t *symbol, int how)
  203. {
  204. symbol_node_t *newnode;
  205. newnode = (symbol_node_t *)malloc(sizeof(symbol_node_t));
  206. if (newnode == NULL) {
  207. stop("symlist_add: Unable to malloc symbol_node", EX_SOFTWARE);
  208. /* NOTREACHED */
  209. }
  210. newnode->symbol = symbol;
  211. if (how == SYMLIST_SORT) {
  212. symbol_node_t *curnode;
  213. int field;
  214. field = FALSE;
  215. switch(symbol->type) {
  216. case REGISTER:
  217. case SCBLOC:
  218. case SRAMLOC:
  219. break;
  220. case FIELD:
  221. case MASK:
  222. case ENUM:
  223. case ENUM_ENTRY:
  224. field = TRUE;
  225. break;
  226. default:
  227. stop("symlist_add: Invalid symbol type for sorting",
  228. EX_SOFTWARE);
  229. /* NOTREACHED */
  230. }
  231. curnode = SLIST_FIRST(symlist);
  232. if (curnode == NULL
  233. || (field
  234. && (curnode->symbol->type > newnode->symbol->type
  235. || (curnode->symbol->type == newnode->symbol->type
  236. && (curnode->symbol->info.finfo->value >
  237. newnode->symbol->info.finfo->value))))
  238. || (!field && (curnode->symbol->info.rinfo->address >
  239. newnode->symbol->info.rinfo->address))) {
  240. SLIST_INSERT_HEAD(symlist, newnode, links);
  241. return;
  242. }
  243. while (1) {
  244. if (SLIST_NEXT(curnode, links) == NULL) {
  245. SLIST_INSERT_AFTER(curnode, newnode,
  246. links);
  247. break;
  248. } else {
  249. symbol_t *cursymbol;
  250. cursymbol = SLIST_NEXT(curnode, links)->symbol;
  251. if ((field
  252. && (cursymbol->type > symbol->type
  253. || (cursymbol->type == symbol->type
  254. && (cursymbol->info.finfo->value >
  255. symbol->info.finfo->value))))
  256. || (!field
  257. && (cursymbol->info.rinfo->address >
  258. symbol->info.rinfo->address))) {
  259. SLIST_INSERT_AFTER(curnode, newnode,
  260. links);
  261. break;
  262. }
  263. }
  264. curnode = SLIST_NEXT(curnode, links);
  265. }
  266. } else {
  267. SLIST_INSERT_HEAD(symlist, newnode, links);
  268. }
  269. }
  270. void
  271. symlist_free(symlist_t *symlist)
  272. {
  273. symbol_node_t *node1, *node2;
  274. node1 = SLIST_FIRST(symlist);
  275. while (node1 != NULL) {
  276. node2 = SLIST_NEXT(node1, links);
  277. free(node1);
  278. node1 = node2;
  279. }
  280. SLIST_INIT(symlist);
  281. }
  282. void
  283. symlist_merge(symlist_t *symlist_dest, symlist_t *symlist_src1,
  284. symlist_t *symlist_src2)
  285. {
  286. symbol_node_t *node;
  287. *symlist_dest = *symlist_src1;
  288. while((node = SLIST_FIRST(symlist_src2)) != NULL) {
  289. SLIST_REMOVE_HEAD(symlist_src2, links);
  290. SLIST_INSERT_HEAD(symlist_dest, node, links);
  291. }
  292. /* These are now empty */
  293. SLIST_INIT(symlist_src1);
  294. SLIST_INIT(symlist_src2);
  295. }
  296. void
  297. aic_print_file_prologue(FILE *ofile)
  298. {
  299. if (ofile == NULL)
  300. return;
  301. fprintf(ofile,
  302. "/*\n"
  303. " * DO NOT EDIT - This file is automatically generated\n"
  304. " * from the following source files:\n"
  305. " *\n"
  306. "%s */\n",
  307. versions);
  308. }
  309. void
  310. aic_print_include(FILE *dfile, char *include_file)
  311. {
  312. if (dfile == NULL)
  313. return;
  314. fprintf(dfile, "\n#include \"%s\"\n\n", include_file);
  315. }
  316. void
  317. aic_print_reg_dump_types(FILE *ofile)
  318. {
  319. if (ofile == NULL)
  320. return;
  321. fprintf(ofile,
  322. "typedef int (%sreg_print_t)(u_int, u_int *, u_int);\n"
  323. "typedef struct %sreg_parse_entry {\n"
  324. " char *name;\n"
  325. " uint8_t value;\n"
  326. " uint8_t mask;\n"
  327. "} %sreg_parse_entry_t;\n"
  328. "\n",
  329. prefix, prefix, prefix);
  330. }
  331. static void
  332. aic_print_reg_dump_start(FILE *dfile, symbol_node_t *regnode)
  333. {
  334. if (dfile == NULL)
  335. return;
  336. fprintf(dfile,
  337. "static const %sreg_parse_entry_t %s_parse_table[] = {\n",
  338. prefix,
  339. regnode->symbol->name);
  340. }
  341. static void
  342. aic_print_reg_dump_end(FILE *ofile, FILE *dfile,
  343. symbol_node_t *regnode, u_int num_entries)
  344. {
  345. char *lower_name;
  346. char *letter;
  347. lower_name = strdup(regnode->symbol->name);
  348. if (lower_name == NULL)
  349. stop("Unable to strdup symbol name", EX_SOFTWARE);
  350. for (letter = lower_name; *letter != '\0'; letter++)
  351. *letter = tolower(*letter);
  352. if (dfile != NULL) {
  353. if (num_entries != 0)
  354. fprintf(dfile,
  355. "\n"
  356. "};\n"
  357. "\n");
  358. fprintf(dfile,
  359. "int\n"
  360. "%s%s_print(u_int regvalue, u_int *cur_col, u_int wrap)\n"
  361. "{\n"
  362. " return (%sprint_register(%s%s, %d, \"%s\",\n"
  363. " 0x%02x, regvalue, cur_col, wrap));\n"
  364. "}\n"
  365. "\n",
  366. prefix,
  367. lower_name,
  368. prefix,
  369. num_entries != 0 ? regnode->symbol->name : "NULL",
  370. num_entries != 0 ? "_parse_table" : "",
  371. num_entries,
  372. regnode->symbol->name,
  373. regnode->symbol->info.rinfo->address);
  374. }
  375. fprintf(ofile,
  376. "#if AIC_DEBUG_REGISTERS\n"
  377. "%sreg_print_t %s%s_print;\n"
  378. "#else\n"
  379. "#define %s%s_print(regvalue, cur_col, wrap) \\\n"
  380. " %sprint_register(NULL, 0, \"%s\", 0x%02x, regvalue, cur_col, wrap)\n"
  381. "#endif\n"
  382. "\n",
  383. prefix,
  384. prefix,
  385. lower_name,
  386. prefix,
  387. lower_name,
  388. prefix,
  389. regnode->symbol->name,
  390. regnode->symbol->info.rinfo->address);
  391. }
  392. static void
  393. aic_print_reg_dump_entry(FILE *dfile, symbol_node_t *curnode)
  394. {
  395. int num_tabs;
  396. if (dfile == NULL)
  397. return;
  398. fprintf(dfile,
  399. " { \"%s\",",
  400. curnode->symbol->name);
  401. num_tabs = 3 - (strlen(curnode->symbol->name) + 5) / 8;
  402. while (num_tabs-- > 0)
  403. fputc('\t', dfile);
  404. fprintf(dfile, "0x%02x, 0x%02x }",
  405. curnode->symbol->info.finfo->value,
  406. curnode->symbol->info.finfo->mask);
  407. }
  408. void
  409. symtable_dump(FILE *ofile, FILE *dfile)
  410. {
  411. /*
  412. * Sort the registers by address with a simple insertion sort.
  413. * Put bitmasks next to the first register that defines them.
  414. * Put constants at the end.
  415. */
  416. symlist_t registers;
  417. symlist_t masks;
  418. symlist_t constants;
  419. symlist_t download_constants;
  420. symlist_t aliases;
  421. symlist_t exported_labels;
  422. symbol_node_t *curnode;
  423. symbol_node_t *regnode;
  424. DBT key;
  425. DBT data;
  426. int flag;
  427. int reg_count = 0, reg_used = 0;
  428. u_int i;
  429. if (symtable == NULL)
  430. return;
  431. SLIST_INIT(&registers);
  432. SLIST_INIT(&masks);
  433. SLIST_INIT(&constants);
  434. SLIST_INIT(&download_constants);
  435. SLIST_INIT(&aliases);
  436. SLIST_INIT(&exported_labels);
  437. flag = R_FIRST;
  438. while (symtable->seq(symtable, &key, &data, flag) == 0) {
  439. symbol_t *cursym;
  440. memcpy(&cursym, data.data, sizeof(cursym));
  441. switch(cursym->type) {
  442. case REGISTER:
  443. case SCBLOC:
  444. case SRAMLOC:
  445. symlist_add(&registers, cursym, SYMLIST_SORT);
  446. break;
  447. case MASK:
  448. case FIELD:
  449. case ENUM:
  450. case ENUM_ENTRY:
  451. symlist_add(&masks, cursym, SYMLIST_SORT);
  452. break;
  453. case CONST:
  454. symlist_add(&constants, cursym,
  455. SYMLIST_INSERT_HEAD);
  456. break;
  457. case DOWNLOAD_CONST:
  458. symlist_add(&download_constants, cursym,
  459. SYMLIST_INSERT_HEAD);
  460. break;
  461. case ALIAS:
  462. symlist_add(&aliases, cursym,
  463. SYMLIST_INSERT_HEAD);
  464. break;
  465. case LABEL:
  466. if (cursym->info.linfo->exported == 0)
  467. break;
  468. symlist_add(&exported_labels, cursym,
  469. SYMLIST_INSERT_HEAD);
  470. break;
  471. default:
  472. break;
  473. }
  474. flag = R_NEXT;
  475. }
  476. /* Register dianostic functions/declarations first. */
  477. aic_print_file_prologue(ofile);
  478. aic_print_reg_dump_types(ofile);
  479. aic_print_file_prologue(dfile);
  480. aic_print_include(dfile, stock_include_file);
  481. SLIST_FOREACH(curnode, &registers, links) {
  482. if (curnode->symbol->dont_generate_debug_code)
  483. continue;
  484. switch(curnode->symbol->type) {
  485. case REGISTER:
  486. case SCBLOC:
  487. case SRAMLOC:
  488. {
  489. symlist_t *fields;
  490. symbol_node_t *fieldnode;
  491. int num_entries;
  492. num_entries = 0;
  493. reg_count++;
  494. if (curnode->symbol->count == 1)
  495. break;
  496. fields = &curnode->symbol->info.rinfo->fields;
  497. SLIST_FOREACH(fieldnode, fields, links) {
  498. if (num_entries == 0)
  499. aic_print_reg_dump_start(dfile,
  500. curnode);
  501. else if (dfile != NULL)
  502. fputs(",\n", dfile);
  503. num_entries++;
  504. aic_print_reg_dump_entry(dfile, fieldnode);
  505. }
  506. aic_print_reg_dump_end(ofile, dfile,
  507. curnode, num_entries);
  508. reg_used++;
  509. }
  510. default:
  511. break;
  512. }
  513. }
  514. fprintf(stderr, "%s: %d of %d register definitions used\n", appname,
  515. reg_used, reg_count);
  516. /* Fold in the masks and bits */
  517. while (SLIST_FIRST(&masks) != NULL) {
  518. char *regname;
  519. curnode = SLIST_FIRST(&masks);
  520. SLIST_REMOVE_HEAD(&masks, links);
  521. regnode = SLIST_FIRST(&curnode->symbol->info.finfo->symrefs);
  522. regname = regnode->symbol->name;
  523. regnode = symlist_search(&registers, regname);
  524. SLIST_INSERT_AFTER(regnode, curnode, links);
  525. }
  526. /* Add the aliases */
  527. while (SLIST_FIRST(&aliases) != NULL) {
  528. char *regname;
  529. curnode = SLIST_FIRST(&aliases);
  530. SLIST_REMOVE_HEAD(&aliases, links);
  531. regname = curnode->symbol->info.ainfo->parent->name;
  532. regnode = symlist_search(&registers, regname);
  533. SLIST_INSERT_AFTER(regnode, curnode, links);
  534. }
  535. /* Output generated #defines. */
  536. while (SLIST_FIRST(&registers) != NULL) {
  537. symbol_node_t *curnode;
  538. u_int value;
  539. char *tab_str;
  540. char *tab_str2;
  541. curnode = SLIST_FIRST(&registers);
  542. SLIST_REMOVE_HEAD(&registers, links);
  543. switch(curnode->symbol->type) {
  544. case REGISTER:
  545. case SCBLOC:
  546. case SRAMLOC:
  547. fprintf(ofile, "\n");
  548. value = curnode->symbol->info.rinfo->address;
  549. tab_str = "\t";
  550. tab_str2 = "\t\t";
  551. break;
  552. case ALIAS:
  553. {
  554. symbol_t *parent;
  555. parent = curnode->symbol->info.ainfo->parent;
  556. value = parent->info.rinfo->address;
  557. tab_str = "\t";
  558. tab_str2 = "\t\t";
  559. break;
  560. }
  561. case MASK:
  562. case FIELD:
  563. case ENUM:
  564. case ENUM_ENTRY:
  565. value = curnode->symbol->info.finfo->value;
  566. tab_str = "\t\t";
  567. tab_str2 = "\t";
  568. break;
  569. default:
  570. value = 0; /* Quiet compiler */
  571. tab_str = NULL;
  572. tab_str2 = NULL;
  573. stop("symtable_dump: Invalid symbol type "
  574. "encountered", EX_SOFTWARE);
  575. break;
  576. }
  577. fprintf(ofile, "#define%s%-16s%s0x%02x\n",
  578. tab_str, curnode->symbol->name, tab_str2,
  579. value);
  580. free(curnode);
  581. }
  582. fprintf(ofile, "\n\n");
  583. while (SLIST_FIRST(&constants) != NULL) {
  584. symbol_node_t *curnode;
  585. curnode = SLIST_FIRST(&constants);
  586. SLIST_REMOVE_HEAD(&constants, links);
  587. fprintf(ofile, "#define\t%-8s\t0x%02x\n",
  588. curnode->symbol->name,
  589. curnode->symbol->info.cinfo->value);
  590. free(curnode);
  591. }
  592. fprintf(ofile, "\n\n/* Downloaded Constant Definitions */\n");
  593. for (i = 0; SLIST_FIRST(&download_constants) != NULL; i++) {
  594. symbol_node_t *curnode;
  595. curnode = SLIST_FIRST(&download_constants);
  596. SLIST_REMOVE_HEAD(&download_constants, links);
  597. fprintf(ofile, "#define\t%-8s\t0x%02x\n",
  598. curnode->symbol->name,
  599. curnode->symbol->info.cinfo->value);
  600. free(curnode);
  601. }
  602. fprintf(ofile, "#define\tDOWNLOAD_CONST_COUNT\t0x%02x\n", i);
  603. fprintf(ofile, "\n\n/* Exported Labels */\n");
  604. while (SLIST_FIRST(&exported_labels) != NULL) {
  605. symbol_node_t *curnode;
  606. curnode = SLIST_FIRST(&exported_labels);
  607. SLIST_REMOVE_HEAD(&exported_labels, links);
  608. fprintf(ofile, "#define\tLABEL_%-8s\t0x%02x\n",
  609. curnode->symbol->name,
  610. curnode->symbol->info.linfo->address);
  611. free(curnode);
  612. }
  613. }