changeset 112:61a58677dc68

tiobjd disasm: beginning of reloc handling
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Thu, 03 Apr 2014 05:54:59 +0000
parents 0f94d17899b3
children d97fbe98600b
files ticoff/disasm.c
diffstat 1 files changed, 40 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ticoff/disasm.c	Thu Apr 03 05:14:15 2014 +0000
+++ b/ticoff/disasm.c	Thu Apr 03 05:54:59 2014 +0000
@@ -14,6 +14,36 @@
 extern unsigned get_u16(), get_u32();
 
 void
+disasm_reloc_target(sec, rel, addend)
+	struct internal_scnhdr *sec;
+	struct internal_reloc *rel;
+	unsigned addend;
+{
+	struct internal_syment *sym = rel->sym;
+
+	addend -= sym->value;
+	if (addend >= 10)
+		printf("%s+0x%x", sym->name, addend);
+	else if (addend)
+		printf("%s+%u", sym->name, addend);
+	else
+		fputs(sym->name, stdout);
+}
+
+void
+disasm_word32_reloc(sec, rel)
+	struct internal_scnhdr *sec;
+	struct internal_reloc *rel;
+{
+	unsigned word;
+
+	word = get_u32(filemap + sec->data_offset + rel->location);
+	printf("%08x R\t.word\t", word);
+	disasm_reloc_target(sec, rel, word);
+	putchar('\n');
+}
+
+void
 disasm_text_section(sec)
 	struct internal_scnhdr *sec;
 {
@@ -76,6 +106,15 @@
 		} else
 			rel = 0;
 		printf("%8x:\t", pos);
+		if (rel && rel->type == RTYPE_LONG) {
+			if (pos & 3) {
+			  printf("MISALIGNED pos for word32 reloc, aborting\n");
+				return;
+			}
+			disasm_word32_reloc(sec, rel);
+			incr = 4;
+			goto next;
+		}
 		switch (state) {
 		case 0:		/* ARM */
 			if (pos & 3) {
@@ -103,7 +142,7 @@
 			printf("UNKNOWN T state, aborting\n");
 			return;
 		}
-		linebrk = 0;
+next:		linebrk = 0;
 		if (incr > headroom) {
 			printf("error: increment %u > headroom %u, aborting\n",
 				incr, headroom);