diff leo-obj/tool/richsym.c @ 155:15743b40e03a

tiobjd ctypes: print more useful hex byte offsets for struct fields
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Fri, 02 May 2014 23:41:44 +0000
parents 6fe08feee018
children f7943bdbb3ea
line wrap: on
line diff
--- a/leo-obj/tool/richsym.c	Fri May 02 06:20:26 2014 +0000
+++ b/leo-obj/tool/richsym.c	Fri May 02 23:41:44 2014 +0000
@@ -323,12 +323,16 @@
 	int c;
 	unsigned n;
 	struct internal_syment *sym;
+	int print_offsets = 0;
 
-	while ((c = getopt(argc, argv, "b")) != EOF)
+	while ((c = getopt(argc, argv, "bo")) != EOF)
 		switch (c) {
 		case 'b':
 			richsym_print_bitsize++;
 			continue;
+		case 'o':
+			print_offsets++;
+			continue;
 		default:
 			/* error msg already printed */
 			exit(1);
@@ -386,7 +390,10 @@
 		case C_MOU:
 			if (sym->scnum != -1)
 				printf("\t/* MOS/MOU section != ABS! */\n");
-			else if (richsym_print_bitsize >= 2)
+			else if (print_offsets && !(sym->value & 7))
+				printf("\t/* offset: 0x%x */\n",
+					sym->value >> 3);
+			else if (print_offsets || richsym_print_bitsize >= 2)
 				printf("\t/* offset: %u bits */\n", sym->value);
 			richsym_print_in_c("\t", sym, 0);
 			continue;