changeset 75:1a23ff9a81de

tiobjd: dumpsym implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Tue, 25 Mar 2014 20:38:31 +0000
parents 2eef88395908
children 7a0559016b68
files ticoff/basics.c ticoff/main.c ticoff/tables.c
diffstat 3 files changed, 30 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ticoff/basics.c	Tue Mar 25 18:55:36 2014 +0000
+++ b/ticoff/basics.c	Tue Mar 25 20:38:31 2014 +0000
@@ -42,3 +42,30 @@
 	}
 	exit(0);
 }
+
+cmd_dumpsym()
+{
+	unsigned n;
+	struct internal_syment *sym;
+	char *sec, secstr[8];
+
+	get_int_section_table();
+	get_int_symbol_table();
+	printf("%-5s %-24s %-4s %-5s %-12s %-8s\n",
+		"Num", "Name", "Type", "Class", "Section", "Value");
+	for (n = 0; n < nsymtab; n++) {
+		sym = symtab[n];
+		if (!sym)
+			continue;
+		if (sym->scnum >= 1 && (unsigned)sym->scnum <= nsections)
+			sec = sections[sym->scnum - 1].name;
+		else {
+			sprintf(secstr, "%d", sym->scnum);
+			sec = secstr;
+		}
+		printf("%-5u %-24s %04X %-5d %-12s %08X%s\n",
+			n, sym->name, sym->type, sym->class,
+			sec, sym->value, sym->aux ? " Aux" : "");
+	}
+	exit(0);
+}
--- a/ticoff/main.c	Tue Mar 25 18:55:36 2014 +0000
+++ b/ticoff/main.c	Tue Mar 25 20:38:31 2014 +0000
@@ -9,6 +9,7 @@
 #include <strings.h>
 #include "globals.h"
 
+extern int cmd_dumpsym();
 extern int cmd_sechdr();
 extern int dump_filehdr_info();
 
@@ -16,6 +17,7 @@
 	char	*cmd;
 	int	(*func)();
 } cmdtab[] = {
+	{"dumpsym", cmd_dumpsym},
 	{"hdr", dump_filehdr_info},
 	{"sechdr", cmd_sechdr},
 	{0, 0}
--- a/ticoff/tables.c	Tue Mar 25 18:55:36 2014 +0000
+++ b/ticoff/tables.c	Tue Mar 25 20:38:31 2014 +0000
@@ -98,7 +98,7 @@
 		in->name = get_secorsym_name(symtab_raw[n].e_name);
 		in->value = get_u32(symtab_raw[n].e_value);
 		in->scnum = get_s16(symtab_raw[n].e_scnum);
-		if (in->scnum < -2 || in->scnum > nsections) {
+		if (in->scnum < -2 || in->scnum > (int)nsections) {
 			fprintf(stderr,
 				"symtab entry #%u: scnum out of range\n", n);
 			exit(1);