view ticoff/reloc.c @ 82:c20dc315a9d4

tiobjd: beginning of reloc handling
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Wed, 26 Mar 2014 06:00:07 +0000
parents
children e650fdc743fe
line wrap: on
line source

/*
 * Handling of relocation records
 */

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include "filestruct.h"
#include "intstruct.h"
#include "globals.h"

extern unsigned get_u16(), get_u32();

cmd_rawrel()
{
	unsigned n, m;
	struct internal_scnhdr *sec;
	struct external_reloc *rel;

	get_int_section_table();
	for (n = 0; n < nsections; n++) {
		sec = sections + n;
		if (!sec->nreloc)
			continue;
		printf("%s:\n\n", sec->name);
		rel = (struct external_reloc *)(filemap + sec->reloc_offset);
		printf("Location  SymIndex  Rsvd  Type\n");
		for (m = 0; m < sec->nreloc; m++, rel++)
			printf("%08X  %08X  %04X  %04X\n",
				get_u32(rel->r_vaddr), get_u32(rel->r_symndx),
				get_u16(rel->r_reserved), get_u16(rel->r_type));
		putchar('\n');
	}
	exit(0);
}