[PATCH] fix PR gold/13320, inline thumb stubs in PLT entries

Doug Kwan (關振德) dougkwan@google.com
Mon Apr 9 15:20:00 GMT 2012


Patch?

On Mon, Apr 9, 2012 at 7:59 AM, Nathan Froyd <froydnj@mozilla.com> wrote:
> ----- Original Message -----
>>    Your patch causes a failure.
>>
>> You can reproduce it even in the cross compilation mode:
>
> Thanks for pointing this out.  The problem here is that prior to this patch, Target_arm::make_plt_entry set the PLT offset for the symbol.  The patch now defers computation of the PLT offsets until later, when we have seen all relocations and know which PLT entries need Thumb stubs.  However, some places were using Symbol::has_plt_offset as a substitute for Symbol::needs_plt_entry; those calls to Symbol::has_plt_offset were returning incorrect results, causing problems.
>
> This issue is fixed in the attached patch, which makes Symbol::needs_dynamic_reloc use Symbol::needs_plt_entry.
>
> Tested with cross to arm-none-linux-gnueabi; all applicable tests pass.  Would you be so kind as to run any necessary tests natively?
>
> OK to commit?
>
> -Nathan
>
>        PR gold/13320
>        * symtab.h (Symbol::needs_dynamic_reloc): Use needs_plt_entry
>        rather than has_plt_offset.
>        * arm.cc (Output_data_plt_arm): Move backwards in the file.
>        (Output_data_plt_arm::calculate_offsets): New function.
>        (Output_data_plt_arm::thumb_plt_entry_stub): New member.
>        (Output_data_plt_arm::thumb_stub_size): New function.
>        (Output_data_plt_arm::plt_reference): New struct.
>        (Output_data_plt_arm::stub_map_): New member.
>        (Output_data_plt_arm::stub_list_): New member.
>        (Output_data_plt_arm::entry_count): Query this->stub_list_.
>        (Output_data_plt_arm::count_): Delete.
>        (Output_data_plt_arm::Output_data_plt_arm): Don't initialize count_.
>        (Output_data_plt_arm::add_entry): Add boolean parameters indicating
>        the source of the jump.  Record the target for later use.
>        (Output_data_plt_arm::do_write): Iterate over this->stub_list_ for
>        writing.
>        (Reloc_stub::stub_type_for_reloc): Adjust the branch target if
>        necessary.  Add gsym argument.
>        (Arm_relocate_functions::arm_branch_common): Update call to it.
>        (Target_arm::scan_reloc_for_stub): Likewise.
>        (Arm_relocate_functions::thumb_branch_common): Likewise.
>        Adjust the branch target if we are using an inline thumb stub.
>        (Target_arm::make_plt_entry): Add boolean parameters indicating the
>        source of the jump.  Pass them to add_entry.
>        (Target_arm::Scan::global): Adjust calls to make_plt_entry.
>        (Target_arm::do_finalize_sections): Call calculate_offsets if
>        necessary.



More information about the Binutils mailing list