Skip to contentSkip to conversation

Thumb symbol lookup

PATCH New Paul Brook 1 participant 1 message Oct 22, 2005

lore
Share & tools
lore

Paul Brook

author
#0 lore raw

PATCH 1/1 Thumb symbol lookup

Some Arm ABIs use the low bit of a symbol address to mark thumb function symbols (instruction are always halfword aligned). The patch below makes lookup_symbol ignore this bit when comparing addresses.

Paul

Index: disas.c
===================================================================
RCS file: /cvsroot/qemu/qemu/disas.c,v
retrieving revision 1.25

disas.c +8 -2
diff -u -p -r1.25 disas.c
@@ -279,6 +279,7 @@ const char *lookup_symbol(target_ulong o
     /* Hack, because we know this is x86. */
     Elf32_Sym *sym;
     struct syminfo *s;
+    target_ulong addr;
     
     for (s = syminfos; s; s = s->next) {
 	sym = s->disas_symtab;
@@ -290,8 +291,13 @@ const char *lookup_symbol(target_ulong o
 	    if (ELF_ST_TYPE(sym[i].st_info) != STT_FUNC)
 		continue;
 
-	    if (orig_addr >= sym[i].st_value
-		&& orig_addr < sym[i].st_value + sym[i].st_size)
+	    addr = sym[i].st_value;
+#ifdef TARGET_ARM
+            /* The bottom address bit marks a Thumb symbol.  */
+            addr &= ~(target_ulong)1;
+#endif
+	    if (orig_addr >= addr
+		&& orig_addr < addr + sym[i].st_size)
 		return s->disas_strtab + sym[i].st_name;
 	}
     }