<*>= [D->] #include <stdio.h> #include "sparcdis.h"
We do nothing at all clever about disassembling relocatable addresses. A real function would keep track of labels and show these things more symbolically.
<*>+= [<-D->] static char *dis_rel (void *unused, unsigned addr) { static char buf[80]; sprintf(buf, "0x%08x", addr); return buf; }
Definesdis_rel
(links are to index).
We fetch by casting pointers and integers.
<*>+= [<-D->] static unsigned fetch_word(void *unused, unsigned lc) { return *(unsigned *)lc; }
Definesfetch_word
(links are to index).
The main program disassembles from main
through empty
<*>+= [<-D] static void empty(void); main() { unsigned start = (unsigned)main; for (start = (unsigned)main; start < (unsigned)empty; start += 4) { sparc_disassemble(start, (Printer) fprintf, stdout, dis_rel, NULL, fetch_word, NULL); printf("\n"); } } static void empty() {}
Definesempty
,main
(links are to index).