Move bitfield overflow checks to after the md_apply_fix call in
fixup_segment so that md_apply_fix has a chance to modify value.
Handle 8 and 16-bit pcrel relocs for i386.
Prototypes and other minor code cleanups.
This commit is contained in:
Alan Modra 1999-05-17 03:21:50 +00:00
parent ec0f0840fc
commit 93382f6dd7
1 changed files with 48 additions and 27 deletions

View File

@ -3906,15 +3906,31 @@ md_apply_fix3 (fixP, valp, seg)
register char *p = fixP->fx_where + fixP->fx_frag->fr_literal; register char *p = fixP->fx_where + fixP->fx_frag->fr_literal;
valueT value = *valp; valueT value = *valp;
if (fixP->fx_r_type == BFD_RELOC_32 && fixP->fx_pcrel) if (fixP->fx_pcrel)
fixP->fx_r_type = BFD_RELOC_32_PCREL; {
switch (fixP->fx_r_type)
{
case BFD_RELOC_32:
fixP->fx_r_type = BFD_RELOC_32_PCREL;
break;
case BFD_RELOC_16:
fixP->fx_r_type = BFD_RELOC_16_PCREL;
break;
case BFD_RELOC_8:
fixP->fx_r_type = BFD_RELOC_8_PCREL;
break;
}
}
#if defined (BFD_ASSEMBLER) && !defined (TE_Mach) #if defined (BFD_ASSEMBLER) && !defined (TE_Mach)
/* /*
* This is a hack. There should be a better way to * This is a hack. There should be a better way to
* handle this. * handle this.
*/ */
if (fixP->fx_r_type == BFD_RELOC_32_PCREL && fixP->fx_addsy) if ((fixP->fx_r_type == BFD_RELOC_32_PCREL
|| fixP->fx_r_type == BFD_RELOC_16_PCREL
|| fixP->fx_r_type == BFD_RELOC_8_PCREL)
&& fixP->fx_addsy)
{ {
#ifndef OBJ_AOUT #ifndef OBJ_AOUT
if (OUTPUT_FLAVOR == bfd_target_elf_flavour if (OUTPUT_FLAVOR == bfd_target_elf_flavour
@ -4014,9 +4030,9 @@ md_apply_fix3 (fixP, valp, seg)
default: default:
break; break;
} }
#endif #endif /* defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) */
*valp = value;
#endif #endif /* defined (BFD_ASSEMBLER) && !defined (TE_Mach) */
md_number_to_chars (p, value, fixP->fx_size); md_number_to_chars (p, value, fixP->fx_size);
return 1; return 1;
@ -4315,9 +4331,6 @@ i386_validate_fix (fixp)
} }
} }
#define F(SZ,PCREL) (((SZ) << 1) + (PCREL))
#define MAP(SZ,PCREL,TYPE) case F(SZ,PCREL): code = (TYPE); break
arelent * arelent *
tc_gen_reloc (section, fixp) tc_gen_reloc (section, fixp)
asection *section; asection *section;
@ -4338,27 +4351,35 @@ tc_gen_reloc (section, fixp)
code = fixp->fx_r_type; code = fixp->fx_r_type;
break; break;
default: default:
switch (F (fixp->fx_size, fixp->fx_pcrel)) if (fixp->fx_pcrel)
{ {
MAP (1, 0, BFD_RELOC_8); switch (fixp->fx_size)
MAP (2, 0, BFD_RELOC_16); {
MAP (4, 0, BFD_RELOC_32); default:
MAP (1, 1, BFD_RELOC_8_PCREL); as_bad (_("Can not do %d byte pc-relative relocation"),
MAP (2, 1, BFD_RELOC_16_PCREL); fixp->fx_size);
MAP (4, 1, BFD_RELOC_32_PCREL); code = BFD_RELOC_32_PCREL;
default: break;
if (fixp->fx_pcrel) case 1: code = BFD_RELOC_8_PCREL; break;
as_bad (_("Can not do %d byte pc-relative relocation"), case 2: code = BFD_RELOC_16_PCREL; break;
fixp->fx_size); case 4: code = BFD_RELOC_32_PCREL; break;
else }
as_bad (_("Can not do %d byte relocation"), fixp->fx_size); }
code = BFD_RELOC_32; else
break; {
switch (fixp->fx_size)
{
default:
as_bad (_("Can not do %d byte relocation"), fixp->fx_size);
code = BFD_RELOC_32;
break;
case 1: code = BFD_RELOC_8; break;
case 2: code = BFD_RELOC_16; break;
case 4: code = BFD_RELOC_32; break;
}
} }
break; break;
} }
#undef MAP
#undef F
if (code == BFD_RELOC_32 if (code == BFD_RELOC_32
&& GOT_symbol && GOT_symbol
@ -4461,6 +4482,6 @@ tc_coff_sizemachdep (frag)
#endif /* I386COFF */ #endif /* I386COFF */
#endif /* BFD_ASSEMBLER? */ #endif /* ! BFD_ASSEMBLER */
/* end of tc-i386.c */ /* end of tc-i386.c */