-/*** copy.c -- copy object file from input to output, optionally massaging it */
-#include "sysdep.h"
+/*** copy.c -- copy object file from input to output, optionally
+ massaging it */
+
#include "bfd.h"
+
asymbol **sympp;
char *input_target = NULL;
char *output_target = NULL;
arelent **relpp;
int relcount;
sec_ptr osection;
- unsigned long size;
+ bfd_size_type size;
osection = bfd_get_section_by_name(obfd,
bfd_section_name(ibfd, isection));
- size = bfd_section_size(ibfd, isection);
+ size = isection->size;
if (size == 0)
return;
if (bfd_get_section_flags(ibfd, isection) & SEC_HAS_CONTENTS)
{
- unsigned char *memhunk = (unsigned char *) xmalloc(size);
+ PTR memhunk = (PTR) xmalloc((unsigned)size);
- if (!bfd_get_section_contents(ibfd, isection, memhunk, 0, size))
+ if (!bfd_get_section_contents(ibfd, isection, memhunk, (file_ptr) 0, size))
bfd_fatal(bfd_get_filename(ibfd));
- if (!bfd_set_section_contents(obfd, osection, memhunk, 0, size))
+ if (!bfd_set_section_contents(obfd, osection, memhunk, (file_ptr)0, size))
bfd_fatal(bfd_get_filename(obfd));
free(memhunk);
}
{"print-armap", 0, &print_armap, 1},
{"print-file-name", 0, &file_on_each_line, 1},
{"reverse-sort", 0, &reverse_sort, 1},
- {"target", 2, NULL, NULL},
+ {"target", 2, (int *)NULL, 0},
{"undefined-only", 0, &undefined_only, 1},
{0, 0, 0, 0}
};
char *x;
char *y;
{
- char *xn = (*(asymbol **) x)->name;
- char *yn = (*(asymbol **) y)->name;
+ CONST char *xn = (*(asymbol **) x)->name;
+ CONST char *yn = (*(asymbol **) y)->name;
return ((xn == NULL) ? ((yn == NULL) ? 0 : -1) :
((yn == NULL) ? 1 : strcmp (xn, yn)));
if (p->flags & BSF_GLOBAL)
class = toupper (class);
- if (p->value || ((p->flags & BSF_UNDEFINED) != BSF_UNDEFINED))
- printf ("%08lx ", (p->section ? p->value + p->section->vma : p->value));
- else fputs (" ", stdout);
+ if (p->value || ((p->flags & BSF_UNDEFINED) != BSF_UNDEFINED))
+ printf_vma( (p->section ? p->value + p->section->vma : p->value));
+ else fputs (" ", stdout);
- printf ("%c %s\n", class, p->name);
+ printf (" %c %s\n", class, p->name);
}
}
}
section->index,
section->name,
(unsigned) section->size);
- printf(" vma %08lx align 2**%2u\n ",
- section->vma,
+ printf(" vma ");
+printf_vma(section->vma);
+printf(" align 2**%2u\n ",
section->alignment_power);
PF(SEC_ALLOC,"ALLOC");
PF(SEC_LOAD,"LOAD");
unsigned int oldthisplace ;
int vardiff;
- if (symcount == 0)
- fprintf(stream,"%08lx", vma);
+ if (symcount == 0) {
+ fprintf_vma(stream, vma);
+ }
else {
while (true) {
oldthisplace = thisplace;
thisplace = (max + min )/2 ;
if (thisplace == oldthisplace) break;
-
-
vardiff = syms[thisplace]->value - vma;
if (vardiff) {
}
}
else {
+ /* Totally awesome! the exact right symbol */
+ char *match_name = syms[thisplace]->name;
+ int sym_len = strlen(match_name);
+ /* Avoid "filename.o" as a match */
+ if (sym_len > 2
+ && match_name[sym_len - 2] == '.'
+ && match_name[sym_len - 1] == 'o'
+ && thisplace + 1 < symcount
+ && syms[thisplace+1]->value == vma)
+ match_name = syms[thisplace+1]->name;
/* Totally awesome! the exact right symbol */
- fprintf(stream,"%08lx (%s)", vma, syms[thisplace]->name);
+ fprintf_vma(stream, vma);
+ fprintf(stream," (%s)", syms[thisplace]->name);
return;
}
}
}
}
-
+ fprintf_vma(stream, vma);
if (syms[thisplace]->value > vma) {
- fprintf(stream,"%08lx (%s-%lx)", vma, syms[thisplace]->name,
- syms[thisplace]->value - vma);
+ fprintf(stream," (%s-)", syms[thisplace]->name);
+ fprintf_vma(stream, syms[thisplace]->value - vma);
}
else {
- fprintf(stream,"%08lx (%s+%lx)", vma,
- syms[thisplace]->name,
- vma - syms[thisplace]->value);
+ fprintf(stream," (%s+)", syms[thisplace]->name);
+ fprintf_vma(stream, vma - syms[thisplace]->value);
+
+
}
}
}
bfd *abfd;
{
bfd_byte *data = NULL;
- unsigned int datasize = 0;
- unsigned int i;
+ bfd_size_type datasize = 0;
+ bfd_size_type i;
int (*print)() ;
int print_insn_m68k();
int print_insn_i960();
(void) qsort(syms, symcount, sizeof(asymbol *), comp);
/* Find the first useless symbol */
- { unsigned int i;
- for (i =0; i < symcount; i++) {
- if (syms[i]->the_bfd == 0) {
- symcount =i;
- break;
+ { unsigned int i;
+ for (i =0; i < symcount; i++) {
+ if (syms[i]->the_bfd == 0) {
+ symcount =i;
+ break;
+ }
}
}
- }
if (machine!= (char *)NULL) {
bfd_get_section_contents (abfd, section, data, 0, section->size);
i = 0;
- while ((size_t)i <section->size) {
+ while (i <section->size) {
if (with_line_numbers) {
static prevline;
- char *filename;
- char *functionname;
- int line;
+ CONST char *filename;
+ CONST char *functionname;
+ unsigned int line;
bfd_find_nearest_line(abfd,
section,
syms,
&line);
if (filename && functionname && line && line != prevline) {
- printf("%s:%d\n", filename, line);
+ printf("%s:%u\n", filename, line);
prevline = line;
}
}
PF(DYNAMIC, "DYNAMIC");
PF(WP_TEXT, "WP_TEXT");
PF(D_PAGED, "D_PAGED");
- printf("\nstart address 0x%08lx", abfd->start_address);
+ printf("\nstart address 0x");
+ printf_vma(abfd->start_address);
}
printf("\n");
{
asection *section;
bfd_byte *data ;
- unsigned int datasize = 0;
- size_t i;
+ bfd_size_type datasize = 0;
+ bfd_size_type i;
for (section = abfd->sections; section != NULL; section =
section->next) {
datasize = section->size;
- bfd_get_section_contents (abfd, section, data, 0, section->size);
+ bfd_get_section_contents (abfd, section, (PTR)data, 0, section->size);
for (i= 0; i < section->size; i += onaline) {
- size_t j;
- printf(" %04lx ", i + section->vma);
+ bfd_size_type j;
+ printf(" %04lx ", (unsigned long int)(i + section->vma));
for (j = i; j < i+ onaline; j++) {
if (j < section->size)
printf("%02x", (unsigned)(data[j]));
printf("\n");
printf("OFFSET TYPE VALUE \n");
- for (p =relpp; *p != (arelent *)NULL; p++) {
+ for (p =relpp; relcount && *p != (arelent *)NULL; p++,
+ relcount --) {
arelent *q = *p;
CONST char *sym_name;
CONST char *section_name = q->section == (asection *)NULL ? "*abs" :
sym_name = 0;
}
if (sym_name) {
- printf("%08lx %-8s %s",
- q->address,
+ printf_vma(q->address);
+ printf(" %-8s %s",
q->howto->name,
sym_name);
}
else {
- printf("%08lx %-8s [%s]",
- q->address,
+ printf_vma(q->address);
+ printf(" %-8s [%s]",
q->howto->name,
section_name);
}
if (q->addend) {
- printf("+0x%lx(%ld)", q->addend, (long) q->addend);
+ printf("+0x");
+ printf_vma(q->addend);
}
printf("\n");
}
p->byteorder_big_p ? "big endian" : "little endian" );
{
enum bfd_architecture j;
- for (j = bfd_arch_obscure +1; j < bfd_arch_last; j++)
+ for (j = (int)bfd_arch_obscure +1; j <(int) bfd_arch_last; j++)
{
if (bfd_set_arch_mach(abfd, j, 0))
{
printf("%s ",target_vector[i]->name);
}
printf("\n");
- for (j = bfd_arch_obscure +1; j < bfd_arch_last; j++) {
+ for (j = (int)bfd_arch_obscure +1; (int)j <(int) bfd_arch_last; j++) {
printf("%11s ", bfd_printable_arch_mach(j,0));
for (i = 0; target_vector[i]; i++) {
{