FreeCalypso > hg > freecalypso-reveng
diff leo-obj/tool/ln.c @ 152:fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Thu, 01 May 2014 01:01:58 +0000 |
parents | fbdb7686a9e9 |
children | 71e25510f5af |
line wrap: on
line diff
--- a/leo-obj/tool/ln.c Thu May 01 00:23:18 2014 +0000 +++ b/leo-obj/tool/ln.c Thu May 01 01:01:58 2014 +0000 @@ -31,3 +31,39 @@ } exit(0); } + +get_lineno_addrs(sec, arr_rtn, count_rtn) + struct internal_scnhdr *sec; + unsigned **arr_rtn, *count_rtn; +{ + unsigned *array, cur, last; + unsigned n, m; + u_char *rec; + + array = malloc(sizeof(unsigned) * sec->nlineent); + if (!array) { + perror("malloc"); + exit(1); + } + m = 0; + rec = filemap + sec->line_offset; + for (n = 0; n < sec->nlineent; n++, rec += 6) { + if (!get_u16(rec + 4)) + continue; + cur = get_u32(rec); + if (m) { + if (cur < last) { + fprintf(stderr, + "error: line # addresses in section %s going backward\n", + sec->name); + exit(1); + } + if (cur == last) + continue; + } + array[m++] = cur; + last = cur; + } + *arr_rtn = array; + *count_rtn = m; +}