the famous 'disasm' bug fix.

This commit is contained in:
Steve Chamberlain 1991-04-03 22:05:58 +00:00
parent 9d5ee7e282
commit 8daa713142

View file

@ -125,7 +125,7 @@ swap_name(abfd, ptr)
}
}
void
static void
bfd_coff_swap_sym(abfd, se)
bfd *abfd;
SYMENT *se;
@ -138,7 +138,7 @@ bfd_coff_swap_sym(abfd, se)
bfd_h_put_x(abfd, se->n_numaux, &se->n_numaux);
}
void
static void
bfd_coff_swap_aux(abfd, au, type, class)
bfd *abfd;
AUXENT *au;
@ -164,7 +164,7 @@ bfd_coff_swap_aux(abfd, au, type, class)
sp(au->x_sym.x_tagndx);
sp(au->x_sym.x_tvndx);
if (ISARY(type) || class == C_BLOCK) {
if (ISARY(type)) {
sp(au->x_sym.x_fcnary.x_ary.x_dimen[0]);
sp(au->x_sym.x_fcnary.x_ary.x_dimen[1]);
sp(au->x_sym.x_fcnary.x_ary.x_dimen[2]);
@ -184,7 +184,7 @@ bfd_coff_swap_aux(abfd, au, type, class)
}
}
void
static void
bfd_coff_swap_lineno(abfd, lineno)
bfd *abfd;
LINENO *lineno;
@ -361,7 +361,9 @@ coff_real_object_p(abfd, nscns, opthdr)
case I960ROMAGIC:
case I960RWMAGIC:
abfd->obj_arch = bfd_arch_i960;
switch (F_I960TYPE & filehdr->f_flags) {
switch (F_I960TYPE & filehdr->f_flags)
{
default:
case F_I960CORE:
abfd->obj_machine = bfd_mach_i960_core;
break;
@ -380,11 +382,7 @@ coff_real_object_p(abfd, nscns, opthdr)
case F_I960KA:
abfd->obj_machine = bfd_mach_i960_ka_sa;
break;
/*
Doomed to fail but sneak out a bit of info in the process.
*/
default:
abfd->obj_machine = filehdr->f_flags & F_I960TYPE;
}
break;
#endif
@ -478,11 +476,10 @@ coff_mkobject(abfd)
{
char *rawptr;
bfd_error = system_call_error;
/* Use an intermediate variable for clarity */
rawptr = malloc(sizeof(struct icofdata) + sizeof(AOUTHDR));
rawptr = zalloc(sizeof(struct icofdata) + sizeof(AOUTHDR));
if (rawptr == NULL) {
bfd_error = no_memory;
return false;
@ -532,35 +529,6 @@ coff_count_linenumbers(abfd)
}
}
/*
This function returns true if the supplied SYMENT has an auxent with
and endndx field which should be relocated as the symbol moves
within the file.
*/
static
boolean
uses_x_sym_x_fcnary_x_fcn_x_endndx_p(native)
SYMENT *native;
{
if (ISFCN(native->n_type))
return true;
if (native->n_sclass == C_BLOCK)
return true;
if (native->n_sclass == C_STRTAG)
return true;
if (native->n_sclass == C_ENTAG)
return true;
if (native->n_sclass == C_UNTAG)
return true;
if (native->n_sclass == C_MOS)
return true;
if(native->n_sclass == C_EOS)
return true;
if(native->n_sclass == C_MOE)
return true;
return false;
}
/*
This function returns true if the supplied SYMENT has an AUXENT with
a tagndx field which should be relocated.
@ -581,62 +549,8 @@ SYMENT *native;
}
/*
Return the canonical symbol we work out how far it has moved since it
started life. This is done by finding the base of the raw syments as
read in when a file was slurped, which discovers the original offset
into the file. Then we return the value which we've saved in the
n_offset field of that name - and voila.
*/
static
unsigned int
new_idx(symbol, original_offset)
coff_symbol_type *symbol;
unsigned int original_offset;
{
struct icofdata *coff = obj_icof(symbol->symbol.the_bfd);
/* Point to the native we used to point to */
SYMENT *native = coff->raw_syments + original_offset;
/* We keep the native's new index in it's string space */
return native->n_offset;
}
/* Function to run through the raw parts of a coff symbol table and
loads each SYMENT's n_offset with its output index. If a symbol has
been deleted or moved to the end, still mark the offset of the one
following it. This makes refs to symbols which have moved point to
the symbol which now sits in the spot vacated.
*/
static
void
preload_n_offset(abfd)
bfd *abfd;
{
unsigned int limit = bfd_get_symcount(abfd);
asymbol **p = abfd->outsymbols;
bfd *thebfd = (bfd *)NULL;
unsigned int native_index;
native_index = 0;
/* First phase, mark each SYMENT with final position */
while (limit --) {
coff_symbol_type *q = coff_symbol_from(abfd, *p);
if (q != (coff_symbol_type *)NULL && q->native) {
q->native->n_offset = native_index;
native_index += 1 + q->native->n_numaux;
}
else {
native_index++;
}
p++;
}
}
/*
@ -743,8 +657,11 @@ bfd *bfd_ptr;
}
else if ((syment->n_sclass == C_EXT
|| syment->n_sclass == C_STAT
#ifdef C_LEAFEXT
|| syment->n_sclass == C_LEAFEXT
|| syment->n_sclass == C_LEAFSTAT)
|| syment->n_sclass == C_LEAFSTAT
#endif
)
&& last_fcn != (SYMENT *)NULL)
{
AUXENT *auxent = (AUXENT *)(last_fcn+1);
@ -783,6 +700,7 @@ bfd *bfd_ptr;
last_file->n_value = native_index;
first_time = false;
}
#ifdef C_LEAFPROC
if (syment->n_sclass == C_LEAFPROC && syment->n_numaux == 2) {
AUXENT *auxent = (AUXENT *)(syment+2);
/* This is the definition of a leaf proc, we'll relocate the
@ -792,6 +710,7 @@ bfd *bfd_ptr;
coff_symbol_ptr->symbol.section->output_offset +
coff_symbol_ptr->symbol.section->output_section->vma ;
}
#endif
/* If this symbol needs to be tied up then remember some facts */
if (syment->n_sclass == C_FILE)
{
@ -1050,7 +969,7 @@ coff_write_relocs(abfd)
for (i = 0; i < s->reloc_count; i++) {
struct reloc n;
arelent *q = p[i];
memset(&n, 0, sizeof(n));
memset((PTR)&n, 0, sizeof(n));
n.r_vaddr = q->address + s->vma;
n.r_symndx = get_index((*(q->sym_ptr_ptr)));
n.r_type = q->howto->type;
@ -1075,12 +994,9 @@ coff_write_linenumbers(abfd)
if (l) {
/* Found a linenumber entry, output */
struct lineno out;
bzero( &out, sizeof(out));
out.l_lnno = 0;
out.l_addr.l_symndx = l->u.offset;
#ifdef LINENO_PADDING
out.padding[0] = 0;
out.padding[1] = 0;
#endif
bfd_coff_swap_lineno(abfd, &out);
bfd_write((void *) &out, 1, LINESZ, abfd);
l++;