Mon May 20 16:14:07 1991 Steve Chamberlain (steve at cygint.cygnus.com)

* Changed some types to work with 64 bit object files
This commit is contained in:
Steve Chamberlain 1991-05-20 23:15:15 +00:00
parent bce4bf525f
commit fc5d607456
3 changed files with 71 additions and 54 deletions

View File

@ -1,7 +1,9 @@
/*** copy.c -- copy object file from input to output, optionally massaging it */ /*** copy.c -- copy object file from input to output, optionally
#include "sysdep.h" massaging it */
#include "bfd.h" #include "bfd.h"
asymbol **sympp; asymbol **sympp;
char *input_target = NULL; char *input_target = NULL;
char *output_target = NULL; char *output_target = NULL;
@ -311,11 +313,11 @@ copy_sections(ibfd, isection, obfd)
arelent **relpp; arelent **relpp;
int relcount; int relcount;
sec_ptr osection; sec_ptr osection;
unsigned long size; bfd_size_type size;
osection = bfd_get_section_by_name(obfd, osection = bfd_get_section_by_name(obfd,
bfd_section_name(ibfd, isection)); bfd_section_name(ibfd, isection));
size = bfd_section_size(ibfd, isection); size = isection->size;
if (size == 0) if (size == 0)
return; return;
@ -334,12 +336,12 @@ copy_sections(ibfd, isection, obfd)
if (bfd_get_section_flags(ibfd, isection) & SEC_HAS_CONTENTS) 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)); 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)); bfd_fatal(bfd_get_filename(obfd));
free(memhunk); free(memhunk);
} }

View File

@ -43,7 +43,7 @@ struct option long_options[] = {
{"print-armap", 0, &print_armap, 1}, {"print-armap", 0, &print_armap, 1},
{"print-file-name", 0, &file_on_each_line, 1}, {"print-file-name", 0, &file_on_each_line, 1},
{"reverse-sort", 0, &reverse_sort, 1}, {"reverse-sort", 0, &reverse_sort, 1},
{"target", 2, NULL, NULL}, {"target", 2, (int *)NULL, 0},
{"undefined-only", 0, &undefined_only, 1}, {"undefined-only", 0, &undefined_only, 1},
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
@ -230,8 +230,8 @@ non_numeric_forward (x, y)
char *x; char *x;
char *y; char *y;
{ {
char *xn = (*(asymbol **) x)->name; CONST char *xn = (*(asymbol **) x)->name;
char *yn = (*(asymbol **) y)->name; CONST char *yn = (*(asymbol **) y)->name;
return ((xn == NULL) ? ((yn == NULL) ? 0 : -1) : return ((xn == NULL) ? ((yn == NULL) ? 0 : -1) :
((yn == NULL) ? 1 : strcmp (xn, yn))); ((yn == NULL) ? 1 : strcmp (xn, yn)));
@ -353,11 +353,11 @@ print_symbols (abfd, syms, symcount)
if (p->flags & BSF_GLOBAL) if (p->flags & BSF_GLOBAL)
class = toupper (class); class = toupper (class);
if (p->value || ((p->flags & BSF_UNDEFINED) != BSF_UNDEFINED)) if (p->value || ((p->flags & BSF_UNDEFINED) != BSF_UNDEFINED))
printf ("%08lx ", (p->section ? p->value + p->section->vma : p->value)); printf_vma( (p->section ? p->value + p->section->vma : p->value));
else fputs (" ", stdout); else fputs (" ", stdout);
printf ("%c %s\n", class, p->name); printf (" %c %s\n", class, p->name);
} }
} }
} }

View File

@ -106,8 +106,9 @@ bfd *abfd;
section->index, section->index,
section->name, section->name,
(unsigned) section->size); (unsigned) section->size);
printf(" vma %08lx align 2**%2u\n ", printf(" vma ");
section->vma, printf_vma(section->vma);
printf(" align 2**%2u\n ",
section->alignment_power); section->alignment_power);
PF(SEC_ALLOC,"ALLOC"); PF(SEC_ALLOC,"ALLOC");
PF(SEC_LOAD,"LOAD"); PF(SEC_LOAD,"LOAD");
@ -184,15 +185,14 @@ FILE *stream;
unsigned int oldthisplace ; unsigned int oldthisplace ;
int vardiff; int vardiff;
if (symcount == 0) if (symcount == 0) {
fprintf(stream,"%08lx", vma); fprintf_vma(stream, vma);
}
else { else {
while (true) { while (true) {
oldthisplace = thisplace; oldthisplace = thisplace;
thisplace = (max + min )/2 ; thisplace = (max + min )/2 ;
if (thisplace == oldthisplace) break; if (thisplace == oldthisplace) break;
vardiff = syms[thisplace]->value - vma; vardiff = syms[thisplace]->value - vma;
if (vardiff) { if (vardiff) {
@ -204,8 +204,19 @@ FILE *stream;
} }
} }
else { 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 */ /* 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; return;
} }
} }
@ -220,16 +231,17 @@ FILE *stream;
} }
} }
fprintf_vma(stream, vma);
if (syms[thisplace]->value > vma) { if (syms[thisplace]->value > vma) {
fprintf(stream,"%08lx (%s-%lx)", vma, syms[thisplace]->name, fprintf(stream," (%s-)", syms[thisplace]->name);
syms[thisplace]->value - vma); fprintf_vma(stream, syms[thisplace]->value - vma);
} }
else { else {
fprintf(stream,"%08lx (%s+%lx)", vma, fprintf(stream," (%s+)", syms[thisplace]->name);
syms[thisplace]->name, fprintf_vma(stream, vma - syms[thisplace]->value);
vma - syms[thisplace]->value);
} }
} }
} }
@ -239,8 +251,8 @@ disassemble_data(abfd)
bfd *abfd; bfd *abfd;
{ {
bfd_byte *data = NULL; bfd_byte *data = NULL;
unsigned int datasize = 0; bfd_size_type datasize = 0;
unsigned int i; bfd_size_type i;
int (*print)() ; int (*print)() ;
int print_insn_m68k(); int print_insn_m68k();
int print_insn_i960(); int print_insn_i960();
@ -264,14 +276,14 @@ bfd *abfd;
(void) qsort(syms, symcount, sizeof(asymbol *), comp); (void) qsort(syms, symcount, sizeof(asymbol *), comp);
/* Find the first useless symbol */ /* Find the first useless symbol */
{ unsigned int i; { unsigned int i;
for (i =0; i < symcount; i++) { for (i =0; i < symcount; i++) {
if (syms[i]->the_bfd == 0) { if (syms[i]->the_bfd == 0) {
symcount =i; symcount =i;
break; break;
}
} }
} }
}
if (machine!= (char *)NULL) { if (machine!= (char *)NULL) {
@ -325,12 +337,12 @@ bfd *abfd;
bfd_get_section_contents (abfd, section, data, 0, section->size); bfd_get_section_contents (abfd, section, data, 0, section->size);
i = 0; i = 0;
while ((size_t)i <section->size) { while (i <section->size) {
if (with_line_numbers) { if (with_line_numbers) {
static prevline; static prevline;
char *filename; CONST char *filename;
char *functionname; CONST char *functionname;
int line; unsigned int line;
bfd_find_nearest_line(abfd, bfd_find_nearest_line(abfd,
section, section,
syms, syms,
@ -340,7 +352,7 @@ bfd *abfd;
&line); &line);
if (filename && functionname && line && line != prevline) { if (filename && functionname && line && line != prevline) {
printf("%s:%d\n", filename, line); printf("%s:%u\n", filename, line);
prevline = line; prevline = line;
} }
} }
@ -392,7 +404,8 @@ display_bfd (abfd)
PF(DYNAMIC, "DYNAMIC"); PF(DYNAMIC, "DYNAMIC");
PF(WP_TEXT, "WP_TEXT"); PF(WP_TEXT, "WP_TEXT");
PF(D_PAGED, "D_PAGED"); PF(D_PAGED, "D_PAGED");
printf("\nstart address 0x%08lx", abfd->start_address); printf("\nstart address 0x");
printf_vma(abfd->start_address);
} }
printf("\n"); printf("\n");
@ -459,8 +472,8 @@ dump_data (abfd)
{ {
asection *section; asection *section;
bfd_byte *data ; bfd_byte *data ;
unsigned int datasize = 0; bfd_size_type datasize = 0;
size_t i; bfd_size_type i;
for (section = abfd->sections; section != NULL; section = for (section = abfd->sections; section != NULL; section =
section->next) { section->next) {
@ -482,11 +495,11 @@ dump_data (abfd)
datasize = section->size; 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) { for (i= 0; i < section->size; i += onaline) {
size_t j; bfd_size_type j;
printf(" %04lx ", i + section->vma); printf(" %04lx ", (unsigned long int)(i + section->vma));
for (j = i; j < i+ onaline; j++) { for (j = i; j < i+ onaline; j++) {
if (j < section->size) if (j < section->size)
printf("%02x", (unsigned)(data[j])); printf("%02x", (unsigned)(data[j]));
@ -562,7 +575,8 @@ bfd *abfd;
printf("\n"); printf("\n");
printf("OFFSET TYPE VALUE \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; arelent *q = *p;
CONST char *sym_name; CONST char *sym_name;
CONST char *section_name = q->section == (asection *)NULL ? "*abs" : CONST char *section_name = q->section == (asection *)NULL ? "*abs" :
@ -574,19 +588,20 @@ bfd *abfd;
sym_name = 0; sym_name = 0;
} }
if (sym_name) { if (sym_name) {
printf("%08lx %-8s %s", printf_vma(q->address);
q->address, printf(" %-8s %s",
q->howto->name, q->howto->name,
sym_name); sym_name);
} }
else { else {
printf("%08lx %-8s [%s]", printf_vma(q->address);
q->address, printf(" %-8s [%s]",
q->howto->name, q->howto->name,
section_name); section_name);
} }
if (q->addend) { if (q->addend) {
printf("+0x%lx(%ld)", q->addend, (long) q->addend); printf("+0x");
printf_vma(q->addend);
} }
printf("\n"); printf("\n");
} }
@ -616,7 +631,7 @@ DEFUN_VOID(display_info)
p->byteorder_big_p ? "big endian" : "little endian" ); p->byteorder_big_p ? "big endian" : "little endian" );
{ {
enum bfd_architecture j; 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)) if (bfd_set_arch_mach(abfd, j, 0))
{ {
@ -633,7 +648,7 @@ DEFUN_VOID(display_info)
printf("%s ",target_vector[i]->name); printf("%s ",target_vector[i]->name);
} }
printf("\n"); 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)); printf("%11s ", bfd_printable_arch_mach(j,0));
for (i = 0; target_vector[i]; i++) { for (i = 0; target_vector[i]; i++) {
{ {