Reuse of reloc_howto_type depending on section

Martin Walter martin.walter@gmail.com
Thu Jul 30 14:48:00 GMT 2009


2009/7/28 Martin Walter <martin.walter@gmail.com>:
> 2009/7/28 Nick Clifton <nickc@redhat.com>:
>> Hi Martin,
>>
>>>    case SPEAR32_OPERAND_SIMM8:
>>>      fixP->fx_pcrel = 0;
>>>
>>>      if (fixP->fx_cgen.opinfo != 0)
>>>        type = fixP->fx_cgen.opinfo;
>>
>> But at this point you also have access to fixP->fx_add_symbol.  So you can
>> transform the basic relocation type that you are extracting from
>> fixP->fx_cgen.opinfo.  eg:
>>
>>     if (fixP->fx_cgen.opinfo != 0)
>>       {
>>         type = fixP->fx_cgen.opinfo;
>>         if (S_GET_SEGMENT (fixp->fx_addsy)->flags & SEC_CODE)
>>           type += 1;
>>       }
>>
>> (I have assumed here that you have arranged for the ..._TEXT versions of the
>> relocs to have a numerical value of 1 more than their corresponding data
>> address space versions).
>
> Hi Nick,
>
> I just tried your idea, however I experienced the following problem:
> undefined symbols, such, as an example, 'main' in crt0 cannot be
> covered by this approach, since they are not within the scope of the
> assembler. Can you think of some way to get this done by the linker?
>
> Cheers,
> Martin
>

Now, please let me refine my problem: what I would actually need is to
divide any symbols that point to an address in the .text section by a
factor of 2 in a final relocation.

My idea: instead of returning types BFD_RELOC_X and BFD_RELOC_X_CODE
in spear32_cgen_lookup_reloc() I would stick to returning
BFD_RELOC_Xs, since this approach does not cover undefined symbols in
the assembler suitably. I would then like to implement the division by
2 in spear32_final_link_relocate() just before calling
bfd_final_link_relocate(). However, I am unsure how to determine the
section of the symbol in spear32_final_link_relocate().

Any ideas? Thank you!
Martin



More information about the Binutils mailing list