* copy.c, nm.c, objdump.c, size.c : changed to use the

new reloc scheme.
This commit is contained in:
Steve Chamberlain 1992-01-24 22:49:24 +00:00
parent e98e6ec111
commit d20f480f8a
4 changed files with 119 additions and 100 deletions

View file

@ -1,3 +1,15 @@
Fri Jan 24 14:47:53 1992 Steve Chamberlain (sac at rtl.cygnus.com)
* copy.c, nm.c, objdump.c, size.c : changed to use the
new reloc scheme.
Mon Dec 30 18:34:41 1991 Per Bothner (bothner at cygnus.com)
* bucomm.c (print_arelt_descr): Tweek the output format
so that 'ar tv' output follows Posix 1003.2/D11.
Output is now also identical to Sun's (except __.SYMDEF).
Mon Dec 30 06:09:53 1991 John Gilmore (gnu at cygnus.com) Mon Dec 30 06:09:53 1991 John Gilmore (gnu at cygnus.com)
* Makefile.in: Make `make' output more readable. * Makefile.in: Make `make' output more readable.

View file

@ -344,7 +344,7 @@ copy_sections(ibfd, isection, obfd)
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 = isection->size; size = bfd_get_section_size_before_reloc(isection);
if (size == 0) if (size == 0)
return; return;
@ -360,6 +360,9 @@ copy_sections(ibfd, isection, obfd)
bfd_set_reloc(obfd, osection, relpp, relcount); bfd_set_reloc(obfd, osection, relpp, relcount);
} }
isection->_cooked_size = isection->_raw_size;
isection->reloc_done =true;
if (bfd_get_section_flags(ibfd, isection) & SEC_HAS_CONTENTS) if (bfd_get_section_flags(ibfd, isection) & SEC_HAS_CONTENTS)
{ {

View file

@ -19,9 +19,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "bfd.h" #include "bfd.h"
#include "sysdep.h" #include "sysdep.h"
#include "bucomm.h"
#include "getopt.h" #include "getopt.h"
#include "aout/stab_gnu.h" #include "aout/stab_gnu.h"
#include <ranlib.h> #include "aout/ranlib.h"
@ -247,7 +248,7 @@ do_one_rel_file (abfd)
} }
/* Symbol-sorting predicates */ /* Symbol-sorting predicates */
#define valueof(x) ((x)->section ? (x)->section->vma + (x)->value : (x)->value) #define valueof(x) (x)->section->vma + (x)->value
int int
numeric_forward (x, y) numeric_forward (x, y)
char *x; char *x;
@ -336,7 +337,6 @@ print_symbols (abfd, syms, symcount)
unsigned long symcount; unsigned long symcount;
{ {
asymbol **sym = syms, **end = syms + symcount; asymbol **sym = syms, **end = syms + symcount;
char class;
for (; sym < end; ++sym) { for (; sym < end; ++sym) {
if (file_on_each_line) printf("%s:", bfd_get_filename(abfd)); if (file_on_each_line) printf("%s:", bfd_get_filename(abfd));

View file

@ -1,12 +1,11 @@
/*** objdump.c -- dump information about an object file. */ /* objdump.c -- dump information about an object file.
Copyright (C) 1990, 1991 Free Software Foundation, Inc.
/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Diddler. This file is part of BFD, the Binary File Diddler.
BFD is free software; you can redistribute it and/or modify BFD is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
BFD is distributed in the hope that it will be useful, BFD is distributed in the hope that it will be useful,
@ -26,8 +25,8 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
* the system 5 program's reference manual * the system 5 program's reference manual
*/ */
#include "sysdep.h"
#include "bfd.h" #include "bfd.h"
#include "sysdep.h"
#include "getopt.h" #include "getopt.h"
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
@ -106,7 +105,7 @@ bfd *abfd;
printf("SECTION %d [%s]\t: size %08x", printf("SECTION %d [%s]\t: size %08x",
section->index, section->index,
section->name, section->name,
(unsigned) section->size); (unsigned) bfd_get_section_size_before_reloc(section));
printf(" vma "); printf(" vma ");
printf_vma(section->vma); printf_vma(section->vma);
printf(" align 2**%u\n ", printf(" align 2**%u\n ",
@ -129,25 +128,26 @@ bfd *abfd;
} }
static asymbol ** static asymbol **
slurp_symtab(abfd) DEFUN(slurp_symtab,(abfd),
bfd *abfd; bfd *abfd)
{ {
asymbol **sy; asymbol **sy = (asymbol **)NULL;
if (!(bfd_get_file_flags (abfd) & HAS_SYMS)) {
(void) printf ("No symbols in \"%s\".\n", bfd_get_filename (abfd));
return(NULL);
}
storage = get_symtab_upper_bound (abfd); if (!(bfd_get_file_flags (abfd) & HAS_SYMS)) {
if (storage) { (void) printf ("No symbols in \"%s\".\n", bfd_get_filename (abfd));
sy = (asymbol **) malloc (storage); return(NULL);
if (sy == NULL) { }
fprintf (stderr, "%s: out of memory.\n", program_name);
exit (1); storage = get_symtab_upper_bound (abfd);
} if (storage) {
} sy = (asymbol **) malloc (storage);
symcount = bfd_canonicalize_symtab (abfd, sy); if (sy == NULL) {
return sy; fprintf (stderr, "%s: out of memory.\n", program_name);
exit (1);
}
}
symcount = bfd_canonicalize_symtab (abfd, sy);
return sy;
} }
/* Sort symbols into value order */ /* Sort symbols into value order */
static int comp(ap,bp) static int comp(ap,bp)
@ -221,12 +221,12 @@ FILE *stream;
match_name = syms[thisplace+1]->name; match_name = syms[thisplace+1]->name;
/* Totally awesome! the exact right symbol */ /* Totally awesome! the exact right symbol */
fprintf_vma(stream, vma); fprintf_vma(stream, vma);
fprintf(stream," (%s)", syms[thisplace]->name); fprintf(stream," (%s+)0000", syms[thisplace]->name);
return; return;
} }
} }
/* We've run out of places to look, print the symbol before this one */ /* We've run out of places to look, print the symbol before this one
/* see if this or the symbol before describes this location the best */ see if this or the symbol before describes this location the best */
if (thisplace != 0) { if (thisplace != 0) {
if (syms[thisplace-1]->value - vma > if (syms[thisplace-1]->value - vma >
@ -239,12 +239,12 @@ FILE *stream;
fprintf_vma(stream, vma); fprintf_vma(stream, vma);
if (syms[thisplace]->value > vma) { if (syms[thisplace]->value > vma) {
fprintf(stream," (%s-)", syms[thisplace]->name); fprintf(stream," (%s-)", syms[thisplace]->name);
fprintf_vma(stream, syms[thisplace]->value - vma); fprintf(stream,"%04x", syms[thisplace]->value - vma);
} }
else { else {
fprintf(stream," (%s+)", syms[thisplace]->name); fprintf(stream," (%s+)", syms[thisplace]->name);
fprintf_vma(stream, vma - syms[thisplace]->value); fprintf(stream, "%04x", vma - syms[thisplace]->value);
} }
@ -259,22 +259,20 @@ bfd *abfd;
bfd_arch_info_type *info ; bfd_arch_info_type *info ;
bfd_size_type datasize = 0; bfd_size_type datasize = 0;
bfd_size_type i; bfd_size_type i;
unsigned int (*print)() ; unsigned int (*print)() =0;
unsigned int print_insn_m68k(); unsigned int print_insn_m68k();
unsigned int print_insn_a29k(); unsigned int print_insn_a29k();
unsigned int print_insn_i960(); unsigned int print_insn_i960();
unsigned int print_insn_sparc(); unsigned int print_insn_sparc();
unsigned int print_insn_h8300(); unsigned int print_insn_h8300();
enum bfd_architecture a; enum bfd_architecture a;
unsigned long m;
asection *section; asection *section;
/* Replace symbol section relative values with abs values */ /* Replace symbol section relative values with abs values */
boolean done_dot = false; boolean done_dot = false;
for (i = 0; i < symcount; i++) { for (i = 0; i < symcount; i++) {
if (syms[i]->section != (asection *)NULL) {
syms[i]->value += syms[i]->section->vma; syms[i]->value += syms[i]->section->vma;
}
} }
/* We keep a copy of the symbols in the original order */ /* We keep a copy of the symbols in the original order */
@ -343,21 +341,21 @@ bfd *abfd;
if (only == (char *)NULL || strcmp(only,section->name) == 0){ if (only == (char *)NULL || strcmp(only,section->name) == 0){
printf("Disassembly of section %s:\n", section->name); printf("Disassembly of section %s:\n", section->name);
if (section->size == 0) continue; if (bfd_get_section_size_before_reloc(section) == 0) continue;
data = (bfd_byte *)malloc(section->size); data = (bfd_byte *)malloc(bfd_get_section_size_before_reloc(section));
if (data == (bfd_byte *)NULL) { if (data == (bfd_byte *)NULL) {
fprintf (stderr, "%s: memory exhausted.\n", program_name); fprintf (stderr, "%s: memory exhausted.\n", program_name);
exit (1); exit (1);
} }
datasize = section->size; datasize = bfd_get_section_size_before_reloc(section);
bfd_get_section_contents (abfd, section, data, 0, section->size); bfd_get_section_contents (abfd, section, data, 0, bfd_get_section_size_before_reloc(section));
i = 0; i = 0;
while (i <section->size) { while (i <bfd_get_section_size_before_reloc(section)) {
if (data[i] ==0 && data[i+1] == 0 && data[i+2] == 0 && if (data[i] ==0 && data[i+1] == 0 && data[i+2] == 0 &&
data[i+3] == 0) { data[i+3] == 0) {
if (done_dot == false) { if (done_dot == false) {
@ -501,7 +499,7 @@ dump_data (abfd)
bfd *abfd; bfd *abfd;
{ {
asection *section; asection *section;
bfd_byte *data ; bfd_byte *data = 0;
bfd_size_type datasize = 0; bfd_size_type datasize = 0;
bfd_size_type i; bfd_size_type i;
@ -516,22 +514,22 @@ dump_data (abfd)
printf("Contents of section %s:\n", section->name); printf("Contents of section %s:\n", section->name);
if (section->size == 0) continue; if (bfd_get_section_size_before_reloc(section) == 0) continue;
data = (bfd_byte *)malloc(section->size); data = (bfd_byte *)malloc(bfd_get_section_size_before_reloc(section));
if (data == (bfd_byte *)NULL) { if (data == (bfd_byte *)NULL) {
fprintf (stderr, "%s: memory exhausted.\n", program_name); fprintf (stderr, "%s: memory exhausted.\n", program_name);
exit (1); exit (1);
} }
datasize = section->size; datasize = bfd_get_section_size_before_reloc(section);
bfd_get_section_contents (abfd, section, (PTR)data, 0, section->size); bfd_get_section_contents (abfd, section, (PTR)data, 0, bfd_get_section_size_before_reloc(section));
for (i= 0; i < section->size; i += onaline) { for (i= 0; i < bfd_get_section_size_before_reloc(section); i += onaline) {
bfd_size_type j; bfd_size_type j;
printf(" %04lx ", (unsigned long int)(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 < bfd_get_section_size_before_reloc(section))
printf("%02x", (unsigned)(data[j])); printf("%02x", (unsigned)(data[j]));
else else
printf(" "); printf(" ");
@ -540,7 +538,7 @@ dump_data (abfd)
printf(" "); printf(" ");
for (j = i; j < i+onaline ; j++) { for (j = i; j < i+onaline ; j++) {
if (j >= section->size) if (j >= bfd_get_section_size_before_reloc(section))
printf(" "); printf(" ");
else else
printf("%c", isprint(data[j]) ?data[j] : '.'); printf("%c", isprint(data[j]) ?data[j] : '.');
@ -590,59 +588,65 @@ bfd *abfd;
unsigned int relcount; unsigned int relcount;
asection *a; asection *a;
for (a = abfd->sections; a != (asection *)NULL; a = a->next) { for (a = abfd->sections; a != (asection *)NULL; a = a->next) {
printf("RELOCATION RECORDS FOR [%s]:",a->name); if (a == &bfd_abs_section) continue;
if (a == &bfd_und_section) continue;
if (a == &bfd_com_section) continue;
if (get_reloc_upper_bound(abfd, a) == 0) { printf("RELOCATION RECORDS FOR [%s]:",a->name);
printf(" (none)\n\n");
}
else {
arelent **p;
relpp = (arelent **) xmalloc( get_reloc_upper_bound(abfd,a) ); if (bfd_get_reloc_upper_bound(abfd, a) == 0) {
relcount = bfd_canonicalize_reloc(abfd,a,relpp, syms); printf(" (none)\n\n");
if (relcount == 0) {
printf(" (none)\n\n");
}
else {
printf("\n");
printf("OFFSET TYPE VALUE \n");
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" :
q->section->name;
if (q->sym_ptr_ptr && *q->sym_ptr_ptr) {
sym_name = (*(q->sym_ptr_ptr))->name ;
}
else {
sym_name = 0;
}
if (sym_name) {
printf_vma(q->address);
printf(" %-8s %s",
q->howto->name,
sym_name);
}
else {
printf_vma(q->address);
printf(" %-8s [%s]",
q->howto->name,
section_name);
}
if (q->addend) {
printf("+0x");
printf_vma(q->addend);
}
printf("\n");
} }
printf("\n\n"); else {
free(relpp); arelent **p;
}
}
} relpp = (arelent **) xmalloc( bfd_get_reloc_upper_bound(abfd,a) );
relcount = bfd_canonicalize_reloc(abfd,a,relpp, syms);
if (relcount == 0) {
printf(" (none)\n\n");
}
else {
printf("\n");
printf("OFFSET TYPE VALUE \n");
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" :*/
/* q->section->name;*/
CONST char *section_name = (*( q->sym_ptr_ptr))->section->name;
if (q->sym_ptr_ptr && *q->sym_ptr_ptr) {
sym_name = (*(q->sym_ptr_ptr))->name ;
}
else {
sym_name = 0;
}
if (sym_name) {
printf_vma(q->address);
printf(" %-8s %s",
q->howto->name,
sym_name);
}
else {
printf_vma(q->address);
printf(" %-8s [%s]",
q->howto->name,
section_name);
}
if (q->addend) {
printf("+0x");
printf_vma(q->addend);
}
printf("\n");
}
printf("\n\n");
free(relpp);
}
}
}
} }
static void static void