kallsyms.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  1. /* Generate assembler source containing symbol information
  2. *
  3. * Copyright 2002 by Kai Germaschewski
  4. *
  5. * This software may be used and distributed according to the terms
  6. * of the GNU General Public License, incorporated herein by reference.
  7. *
  8. * Usage: nm -n vmlinux | scripts/kallsyms [--all-symbols] > symbols.S
  9. *
  10. * ChangeLog:
  11. *
  12. * (25/Aug/2004) Paulo Marques <pmarques@grupopie.com>
  13. * Changed the compression method from stem compression to "table lookup"
  14. * compression
  15. *
  16. * Table compression uses all the unused char codes on the symbols and
  17. * maps these to the most used substrings (tokens). For instance, it might
  18. * map char code 0xF7 to represent "write_" and then in every symbol where
  19. * "write_" appears it can be replaced by 0xF7, saving 5 bytes.
  20. * The used codes themselves are also placed in the table so that the
  21. * decompresion can work without "special cases".
  22. * Applied to kernel symbols, this usually produces a compression ratio
  23. * of about 50%.
  24. *
  25. */
  26. #include <stdio.h>
  27. #include <stdlib.h>
  28. #include <string.h>
  29. #include <ctype.h>
  30. /* maximum token length used. It doesn't pay to increase it a lot, because
  31. * very long substrings probably don't repeat themselves too often. */
  32. #define MAX_TOK_SIZE 11
  33. #define KSYM_NAME_LEN 127
  34. /* we use only a subset of the complete symbol table to gather the token count,
  35. * to speed up compression, at the expense of a little compression ratio */
  36. #define WORKING_SET 1024
  37. /* first find the best token only on the list of tokens that would profit more
  38. * than GOOD_BAD_THRESHOLD. Only if this list is empty go to the "bad" list.
  39. * Increasing this value will put less tokens on the "good" list, so the search
  40. * is faster. However, if the good list runs out of tokens, we must painfully
  41. * search the bad list. */
  42. #define GOOD_BAD_THRESHOLD 10
  43. /* token hash parameters */
  44. #define HASH_BITS 18
  45. #define HASH_TABLE_SIZE (1 << HASH_BITS)
  46. #define HASH_MASK (HASH_TABLE_SIZE - 1)
  47. #define HASH_BASE_OFFSET 2166136261U
  48. #define HASH_FOLD(a) ((a)&(HASH_MASK))
  49. /* flags to mark symbols */
  50. #define SYM_FLAG_VALID 1
  51. #define SYM_FLAG_SAMPLED 2
  52. struct sym_entry {
  53. unsigned long long addr;
  54. char type;
  55. unsigned char flags;
  56. unsigned char len;
  57. unsigned char *sym;
  58. };
  59. static struct sym_entry *table;
  60. static int size, cnt;
  61. static unsigned long long _stext, _etext, _sinittext, _einittext, _sextratext, _eextratext;
  62. static int all_symbols = 0;
  63. static char symbol_prefix_char = '\0';
  64. struct token {
  65. unsigned char data[MAX_TOK_SIZE];
  66. unsigned char len;
  67. /* profit: the number of bytes that could be saved by inserting this
  68. * token into the table */
  69. int profit;
  70. struct token *next; /* next token on the hash list */
  71. struct token *right; /* next token on the good/bad list */
  72. struct token *left; /* previous token on the good/bad list */
  73. struct token *smaller; /* token that is less one letter than this one */
  74. };
  75. struct token bad_head, good_head;
  76. struct token *hash_table[HASH_TABLE_SIZE];
  77. /* the table that holds the result of the compression */
  78. unsigned char best_table[256][MAX_TOK_SIZE+1];
  79. unsigned char best_table_len[256];
  80. static void
  81. usage(void)
  82. {
  83. fprintf(stderr, "Usage: kallsyms [--all-symbols] [--symbol-prefix=<prefix char>] < in.map > out.S\n");
  84. exit(1);
  85. }
  86. /*
  87. * This ignores the intensely annoying "mapping symbols" found
  88. * in ARM ELF files: $a, $t and $d.
  89. */
  90. static inline int
  91. is_arm_mapping_symbol(const char *str)
  92. {
  93. return str[0] == '$' && strchr("atd", str[1])
  94. && (str[2] == '\0' || str[2] == '.');
  95. }
  96. static int
  97. read_symbol(FILE *in, struct sym_entry *s)
  98. {
  99. char str[500];
  100. char *sym;
  101. int rc;
  102. rc = fscanf(in, "%llx %c %499s\n", &s->addr, &s->type, str);
  103. if (rc != 3) {
  104. if (rc != EOF) {
  105. /* skip line */
  106. fgets(str, 500, in);
  107. }
  108. return -1;
  109. }
  110. sym = str;
  111. /* skip prefix char */
  112. if (symbol_prefix_char && str[0] == symbol_prefix_char)
  113. sym++;
  114. /* Ignore most absolute/undefined (?) symbols. */
  115. if (strcmp(sym, "_stext") == 0)
  116. _stext = s->addr;
  117. else if (strcmp(sym, "_etext") == 0)
  118. _etext = s->addr;
  119. else if (strcmp(sym, "_sinittext") == 0)
  120. _sinittext = s->addr;
  121. else if (strcmp(sym, "_einittext") == 0)
  122. _einittext = s->addr;
  123. else if (strcmp(sym, "_sextratext") == 0)
  124. _sextratext = s->addr;
  125. else if (strcmp(sym, "_eextratext") == 0)
  126. _eextratext = s->addr;
  127. else if (toupper(s->type) == 'A')
  128. {
  129. /* Keep these useful absolute symbols */
  130. if (strcmp(sym, "__kernel_syscall_via_break") &&
  131. strcmp(sym, "__kernel_syscall_via_epc") &&
  132. strcmp(sym, "__kernel_sigtramp") &&
  133. strcmp(sym, "__gp"))
  134. return -1;
  135. }
  136. else if (toupper(s->type) == 'U' ||
  137. is_arm_mapping_symbol(sym))
  138. return -1;
  139. /* include the type field in the symbol name, so that it gets
  140. * compressed together */
  141. s->len = strlen(str) + 1;
  142. s->sym = (char *) malloc(s->len + 1);
  143. strcpy(s->sym + 1, str);
  144. s->sym[0] = s->type;
  145. return 0;
  146. }
  147. static int
  148. symbol_valid(struct sym_entry *s)
  149. {
  150. /* Symbols which vary between passes. Passes 1 and 2 must have
  151. * identical symbol lists. The kallsyms_* symbols below are only added
  152. * after pass 1, they would be included in pass 2 when --all-symbols is
  153. * specified so exclude them to get a stable symbol list.
  154. */
  155. static char *special_symbols[] = {
  156. "kallsyms_addresses",
  157. "kallsyms_num_syms",
  158. "kallsyms_names",
  159. "kallsyms_markers",
  160. "kallsyms_token_table",
  161. "kallsyms_token_index",
  162. /* Exclude linker generated symbols which vary between passes */
  163. "_SDA_BASE_", /* ppc */
  164. "_SDA2_BASE_", /* ppc */
  165. NULL };
  166. int i;
  167. int offset = 1;
  168. /* skip prefix char */
  169. if (symbol_prefix_char && *(s->sym + 1) == symbol_prefix_char)
  170. offset++;
  171. /* if --all-symbols is not specified, then symbols outside the text
  172. * and inittext sections are discarded */
  173. if (!all_symbols) {
  174. if ((s->addr < _stext || s->addr > _etext)
  175. && (s->addr < _sinittext || s->addr > _einittext)
  176. && (s->addr < _sextratext || s->addr > _eextratext))
  177. return 0;
  178. /* Corner case. Discard any symbols with the same value as
  179. * _etext _einittext or _eextratext; they can move between pass
  180. * 1 and 2 when the kallsyms data are added. If these symbols
  181. * move then they may get dropped in pass 2, which breaks the
  182. * kallsyms rules.
  183. */
  184. if ((s->addr == _etext && strcmp(s->sym + offset, "_etext")) ||
  185. (s->addr == _einittext && strcmp(s->sym + offset, "_einittext")) ||
  186. (s->addr == _eextratext && strcmp(s->sym + offset, "_eextratext")))
  187. return 0;
  188. }
  189. /* Exclude symbols which vary between passes. */
  190. if (strstr(s->sym + offset, "_compiled."))
  191. return 0;
  192. for (i = 0; special_symbols[i]; i++)
  193. if( strcmp(s->sym + offset, special_symbols[i]) == 0 )
  194. return 0;
  195. return 1;
  196. }
  197. static void
  198. read_map(FILE *in)
  199. {
  200. while (!feof(in)) {
  201. if (cnt >= size) {
  202. size += 10000;
  203. table = realloc(table, sizeof(*table) * size);
  204. if (!table) {
  205. fprintf(stderr, "out of memory\n");
  206. exit (1);
  207. }
  208. }
  209. if (read_symbol(in, &table[cnt]) == 0)
  210. cnt++;
  211. }
  212. }
  213. static void output_label(char *label)
  214. {
  215. if (symbol_prefix_char)
  216. printf(".globl %c%s\n", symbol_prefix_char, label);
  217. else
  218. printf(".globl %s\n", label);
  219. printf("\tALGN\n");
  220. if (symbol_prefix_char)
  221. printf("%c%s:\n", symbol_prefix_char, label);
  222. else
  223. printf("%s:\n", label);
  224. }
  225. /* uncompress a compressed symbol. When this function is called, the best table
  226. * might still be compressed itself, so the function needs to be recursive */
  227. static int expand_symbol(unsigned char *data, int len, char *result)
  228. {
  229. int c, rlen, total=0;
  230. while (len) {
  231. c = *data;
  232. /* if the table holds a single char that is the same as the one
  233. * we are looking for, then end the search */
  234. if (best_table[c][0]==c && best_table_len[c]==1) {
  235. *result++ = c;
  236. total++;
  237. } else {
  238. /* if not, recurse and expand */
  239. rlen = expand_symbol(best_table[c], best_table_len[c], result);
  240. total += rlen;
  241. result += rlen;
  242. }
  243. data++;
  244. len--;
  245. }
  246. *result=0;
  247. return total;
  248. }
  249. static void
  250. write_src(void)
  251. {
  252. int i, k, off, valid;
  253. unsigned int best_idx[256];
  254. unsigned int *markers;
  255. char buf[KSYM_NAME_LEN+1];
  256. printf("#include <asm/types.h>\n");
  257. printf("#if BITS_PER_LONG == 64\n");
  258. printf("#define PTR .quad\n");
  259. printf("#define ALGN .align 8\n");
  260. printf("#else\n");
  261. printf("#define PTR .long\n");
  262. printf("#define ALGN .align 4\n");
  263. printf("#endif\n");
  264. printf(".data\n");
  265. output_label("kallsyms_addresses");
  266. valid = 0;
  267. for (i = 0; i < cnt; i++) {
  268. if (table[i].flags & SYM_FLAG_VALID) {
  269. printf("\tPTR\t%#llx\n", table[i].addr);
  270. valid++;
  271. }
  272. }
  273. printf("\n");
  274. output_label("kallsyms_num_syms");
  275. printf("\tPTR\t%d\n", valid);
  276. printf("\n");
  277. /* table of offset markers, that give the offset in the compressed stream
  278. * every 256 symbols */
  279. markers = (unsigned int *) malloc(sizeof(unsigned int)*((valid + 255) / 256));
  280. output_label("kallsyms_names");
  281. valid = 0;
  282. off = 0;
  283. for (i = 0; i < cnt; i++) {
  284. if (!table[i].flags & SYM_FLAG_VALID)
  285. continue;
  286. if ((valid & 0xFF) == 0)
  287. markers[valid >> 8] = off;
  288. printf("\t.byte 0x%02x", table[i].len);
  289. for (k = 0; k < table[i].len; k++)
  290. printf(", 0x%02x", table[i].sym[k]);
  291. printf("\n");
  292. off += table[i].len + 1;
  293. valid++;
  294. }
  295. printf("\n");
  296. output_label("kallsyms_markers");
  297. for (i = 0; i < ((valid + 255) >> 8); i++)
  298. printf("\tPTR\t%d\n", markers[i]);
  299. printf("\n");
  300. free(markers);
  301. output_label("kallsyms_token_table");
  302. off = 0;
  303. for (i = 0; i < 256; i++) {
  304. best_idx[i] = off;
  305. expand_symbol(best_table[i],best_table_len[i],buf);
  306. printf("\t.asciz\t\"%s\"\n", buf);
  307. off += strlen(buf) + 1;
  308. }
  309. printf("\n");
  310. output_label("kallsyms_token_index");
  311. for (i = 0; i < 256; i++)
  312. printf("\t.short\t%d\n", best_idx[i]);
  313. printf("\n");
  314. }
  315. /* table lookup compression functions */
  316. static inline unsigned int rehash_token(unsigned int hash, unsigned char data)
  317. {
  318. return ((hash * 16777619) ^ data);
  319. }
  320. static unsigned int hash_token(unsigned char *data, int len)
  321. {
  322. unsigned int hash=HASH_BASE_OFFSET;
  323. int i;
  324. for (i = 0; i < len; i++)
  325. hash = rehash_token(hash, data[i]);
  326. return HASH_FOLD(hash);
  327. }
  328. /* find a token given its data and hash value */
  329. static struct token *find_token_hash(unsigned char *data, int len, unsigned int hash)
  330. {
  331. struct token *ptr;
  332. ptr = hash_table[hash];
  333. while (ptr) {
  334. if ((ptr->len == len) && (memcmp(ptr->data, data, len) == 0))
  335. return ptr;
  336. ptr=ptr->next;
  337. }
  338. return NULL;
  339. }
  340. static inline void insert_token_in_group(struct token *head, struct token *ptr)
  341. {
  342. ptr->right = head->right;
  343. ptr->right->left = ptr;
  344. head->right = ptr;
  345. ptr->left = head;
  346. }
  347. static inline void remove_token_from_group(struct token *ptr)
  348. {
  349. ptr->left->right = ptr->right;
  350. ptr->right->left = ptr->left;
  351. }
  352. /* build the counts for all the tokens that start with "data", and have lenghts
  353. * from 2 to "len" */
  354. static void learn_token(unsigned char *data, int len)
  355. {
  356. struct token *ptr,*last_ptr;
  357. int i, newprofit;
  358. unsigned int hash = HASH_BASE_OFFSET;
  359. unsigned int hashes[MAX_TOK_SIZE + 1];
  360. if (len > MAX_TOK_SIZE)
  361. len = MAX_TOK_SIZE;
  362. /* calculate and store the hash values for all the sub-tokens */
  363. hash = rehash_token(hash, data[0]);
  364. for (i = 2; i <= len; i++) {
  365. hash = rehash_token(hash, data[i-1]);
  366. hashes[i] = HASH_FOLD(hash);
  367. }
  368. last_ptr = NULL;
  369. ptr = NULL;
  370. for (i = len; i >= 2; i--) {
  371. hash = hashes[i];
  372. if (!ptr) ptr = find_token_hash(data, i, hash);
  373. if (!ptr) {
  374. /* create a new token entry */
  375. ptr = (struct token *) malloc(sizeof(*ptr));
  376. memcpy(ptr->data, data, i);
  377. ptr->len = i;
  378. /* when we create an entry, it's profit is 0 because
  379. * we also take into account the size of the token on
  380. * the compressed table. We then subtract GOOD_BAD_THRESHOLD
  381. * so that the test to see if this token belongs to
  382. * the good or bad list, is a comparison to zero */
  383. ptr->profit = -GOOD_BAD_THRESHOLD;
  384. ptr->next = hash_table[hash];
  385. hash_table[hash] = ptr;
  386. insert_token_in_group(&bad_head, ptr);
  387. ptr->smaller = NULL;
  388. } else {
  389. newprofit = ptr->profit + (ptr->len - 1);
  390. /* check to see if this token needs to be moved to a
  391. * different list */
  392. if((ptr->profit < 0) && (newprofit >= 0)) {
  393. remove_token_from_group(ptr);
  394. insert_token_in_group(&good_head,ptr);
  395. }
  396. ptr->profit = newprofit;
  397. }
  398. if (last_ptr) last_ptr->smaller = ptr;
  399. last_ptr = ptr;
  400. ptr = ptr->smaller;
  401. }
  402. }
  403. /* decrease the counts for all the tokens that start with "data", and have lenghts
  404. * from 2 to "len". This function is much simpler than learn_token because we have
  405. * more guarantees (tho tokens exist, the ->smaller pointer is set, etc.)
  406. * The two separate functions exist only because of compression performance */
  407. static void forget_token(unsigned char *data, int len)
  408. {
  409. struct token *ptr;
  410. int i, newprofit;
  411. unsigned int hash=0;
  412. if (len > MAX_TOK_SIZE) len = MAX_TOK_SIZE;
  413. hash = hash_token(data, len);
  414. ptr = find_token_hash(data, len, hash);
  415. for (i = len; i >= 2; i--) {
  416. newprofit = ptr->profit - (ptr->len - 1);
  417. if ((ptr->profit >= 0) && (newprofit < 0)) {
  418. remove_token_from_group(ptr);
  419. insert_token_in_group(&bad_head, ptr);
  420. }
  421. ptr->profit=newprofit;
  422. ptr=ptr->smaller;
  423. }
  424. }
  425. /* count all the possible tokens in a symbol */
  426. static void learn_symbol(unsigned char *symbol, int len)
  427. {
  428. int i;
  429. for (i = 0; i < len - 1; i++)
  430. learn_token(symbol + i, len - i);
  431. }
  432. /* decrease the count for all the possible tokens in a symbol */
  433. static void forget_symbol(unsigned char *symbol, int len)
  434. {
  435. int i;
  436. for (i = 0; i < len - 1; i++)
  437. forget_token(symbol + i, len - i);
  438. }
  439. /* set all the symbol flags and do the initial token count */
  440. static void build_initial_tok_table(void)
  441. {
  442. int i, use_it, valid;
  443. valid = 0;
  444. for (i = 0; i < cnt; i++) {
  445. table[i].flags = 0;
  446. if ( symbol_valid(&table[i]) ) {
  447. table[i].flags |= SYM_FLAG_VALID;
  448. valid++;
  449. }
  450. }
  451. use_it = 0;
  452. for (i = 0; i < cnt; i++) {
  453. /* subsample the available symbols. This method is almost like
  454. * a Bresenham's algorithm to get uniformly distributed samples
  455. * across the symbol table */
  456. if (table[i].flags & SYM_FLAG_VALID) {
  457. use_it += WORKING_SET;
  458. if (use_it >= valid) {
  459. table[i].flags |= SYM_FLAG_SAMPLED;
  460. use_it -= valid;
  461. }
  462. }
  463. if (table[i].flags & SYM_FLAG_SAMPLED)
  464. learn_symbol(table[i].sym, table[i].len);
  465. }
  466. }
  467. /* replace a given token in all the valid symbols. Use the sampled symbols
  468. * to update the counts */
  469. static void compress_symbols(unsigned char *str, int tlen, int idx)
  470. {
  471. int i, len, learn, size;
  472. unsigned char *p;
  473. for (i = 0; i < cnt; i++) {
  474. if (!(table[i].flags & SYM_FLAG_VALID)) continue;
  475. len = table[i].len;
  476. learn = 0;
  477. p = table[i].sym;
  478. do {
  479. /* find the token on the symbol */
  480. p = (unsigned char *) strstr((char *) p, (char *) str);
  481. if (!p) break;
  482. if (!learn) {
  483. /* if this symbol was used to count, decrease it */
  484. if (table[i].flags & SYM_FLAG_SAMPLED)
  485. forget_symbol(table[i].sym, len);
  486. learn = 1;
  487. }
  488. *p = idx;
  489. size = (len - (p - table[i].sym)) - tlen + 1;
  490. memmove(p + 1, p + tlen, size);
  491. p++;
  492. len -= tlen - 1;
  493. } while (size >= tlen);
  494. if(learn) {
  495. table[i].len = len;
  496. /* if this symbol was used to count, learn it again */
  497. if(table[i].flags & SYM_FLAG_SAMPLED)
  498. learn_symbol(table[i].sym, len);
  499. }
  500. }
  501. }
  502. /* search the token with the maximum profit */
  503. static struct token *find_best_token(void)
  504. {
  505. struct token *ptr,*best,*head;
  506. int bestprofit;
  507. bestprofit=-10000;
  508. /* failsafe: if the "good" list is empty search from the "bad" list */
  509. if(good_head.right == &good_head) head = &bad_head;
  510. else head = &good_head;
  511. ptr = head->right;
  512. best = NULL;
  513. while (ptr != head) {
  514. if (ptr->profit > bestprofit) {
  515. bestprofit = ptr->profit;
  516. best = ptr;
  517. }
  518. ptr = ptr->right;
  519. }
  520. return best;
  521. }
  522. /* this is the core of the algorithm: calculate the "best" table */
  523. static void optimize_result(void)
  524. {
  525. struct token *best;
  526. int i;
  527. /* using the '\0' symbol last allows compress_symbols to use standard
  528. * fast string functions */
  529. for (i = 255; i >= 0; i--) {
  530. /* if this table slot is empty (it is not used by an actual
  531. * original char code */
  532. if (!best_table_len[i]) {
  533. /* find the token with the breates profit value */
  534. best = find_best_token();
  535. /* place it in the "best" table */
  536. best_table_len[i] = best->len;
  537. memcpy(best_table[i], best->data, best_table_len[i]);
  538. /* zero terminate the token so that we can use strstr
  539. in compress_symbols */
  540. best_table[i][best_table_len[i]]='\0';
  541. /* replace this token in all the valid symbols */
  542. compress_symbols(best_table[i], best_table_len[i], i);
  543. }
  544. }
  545. }
  546. /* start by placing the symbols that are actually used on the table */
  547. static void insert_real_symbols_in_table(void)
  548. {
  549. int i, j, c;
  550. memset(best_table, 0, sizeof(best_table));
  551. memset(best_table_len, 0, sizeof(best_table_len));
  552. for (i = 0; i < cnt; i++) {
  553. if (table[i].flags & SYM_FLAG_VALID) {
  554. for (j = 0; j < table[i].len; j++) {
  555. c = table[i].sym[j];
  556. best_table[c][0]=c;
  557. best_table_len[c]=1;
  558. }
  559. }
  560. }
  561. }
  562. static void optimize_token_table(void)
  563. {
  564. memset(hash_table, 0, sizeof(hash_table));
  565. good_head.left = &good_head;
  566. good_head.right = &good_head;
  567. bad_head.left = &bad_head;
  568. bad_head.right = &bad_head;
  569. build_initial_tok_table();
  570. insert_real_symbols_in_table();
  571. /* When valid symbol is not registered, exit to error */
  572. if (good_head.left == good_head.right &&
  573. bad_head.left == bad_head.right) {
  574. fprintf(stderr, "No valid symbol.\n");
  575. exit(1);
  576. }
  577. optimize_result();
  578. }
  579. int
  580. main(int argc, char **argv)
  581. {
  582. if (argc >= 2) {
  583. int i;
  584. for (i = 1; i < argc; i++) {
  585. if(strcmp(argv[i], "--all-symbols") == 0)
  586. all_symbols = 1;
  587. else if (strncmp(argv[i], "--symbol-prefix=", 16) == 0) {
  588. char *p = &argv[i][16];
  589. /* skip quote */
  590. if ((*p == '"' && *(p+2) == '"') || (*p == '\'' && *(p+2) == '\''))
  591. p++;
  592. symbol_prefix_char = *p;
  593. } else
  594. usage();
  595. }
  596. } else if (argc != 1)
  597. usage();
  598. read_map(stdin);
  599. optimize_token_table();
  600. write_src();
  601. return 0;
  602. }