changeset 120:4d8dfdbd2ea1

tiobjd: auto-translation of section-relative relocs made more conservative
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Fri, 04 Apr 2014 05:45:22 +0000
parents fb1e47bebe00
children d88f2f40e3ae
files ticoff/disasm.c
diffstat 1 files changed, 11 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/ticoff/disasm.c	Fri Apr 04 05:11:32 2014 +0000
+++ b/ticoff/disasm.c	Fri Apr 04 05:45:22 2014 +0000
@@ -19,23 +19,24 @@
 	unsigned *addp;
 {
 	struct internal_scnhdr *sec;
-	unsigned addr;
-	struct internal_syment *sym, *symsel;
+	unsigned addr, delta;
+	struct internal_syment *sym;
 	unsigned n;
 
 	sec = (*symp)->section;
 	addr = *addp;
-	symsel = 0;
 	for (n = 0; n < sec->nsymbols; n++) {
 		sym = sec->sorted_symbols[n];
 		if (sym->value > addr)
-			break;
-		if (sym->class == C_EXT || sym->class == C_STAT)
-			symsel = sym;
-	}
-	if (symsel) {
-		*symp = symsel;
-		*addp = addr - symsel->value;
+			return;
+		if (sym->class != C_EXT && sym->class != C_STAT)
+			continue;
+		delta = addr - sym->value;
+		if (sym->name[0] == '_' && !delta ||
+		    sym->name[0] == '$' && delta <= 1) {
+			*symp = sym;
+			*addp = delta;
+		}
 	}
 }