This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH v2 2/4] gold: Correctly get and put r_info for Mips64el.
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Cary Coutant <ccoutant at gmail dot com>
- Cc: Vladimir Radosavljevic <Vladimir dot Radosavljevic at imgtec dot com>, "binutils at sourceware dot org" <binutils at sourceware dot org>, Petar Jovanovic <Petar dot Jovanovic at imgtec dot com>
- Date: Tue, 12 Jan 2016 10:20:59 -0800
- Subject: Re: [PATCH v2 2/4] gold: Correctly get and put r_info for Mips64el.
- Authentication-results: sourceware.org; auth=none
- References: <3060420525346945A0ADBD567348A91723737257 at BADAG02 dot ba dot imgtec dot org> <CAJimCsFogsVm1t6zjzsP_Es4vjnXHMzjG3RnGZ_zy7VtDLk+qQ at mail dot gmail dot com>
On Mon, Jan 11, 2016 at 7:01 PM, Cary Coutant <ccoutant@gmail.com> wrote:
>> elfcpp/
>> * elfcpp.h (class Rel): Add new constructor.
>> (class Rel_write): Likewise.
>> (class Rela): Likewise.
>> (class Rela_write): Likewise.
>> (Rela::get_r_info): Correctly get r_info for Mips64 little endian.
>> (Rela_write::put_r_info): Correctly put r_info for Mips64 little endian.
>>
>> gold/
>> * gc.h (gc_process_relocs): Call new constructor for Reltype.
>> * target-reloc.h (scan_relocs): Likewise.
>> (relocate_section): Likewise.
>> (scan_relocatable_relocs): Likewise.
>> (relocate_relocs): Call new constructor for Reltype and for Reltype_write.
>> * target.h (Target::is_mips64el): New virtual function.
>
> I've taken a different approach. Rather than store a flag in the
> elfcpp accessor class, which will have to be tested every time the
> r_info field is accessed, I've extended the Classify_reloc interface
> to provide methods for reading the r_sym and r_type fields. For the
> templated routines in gc.h and target-reloc.h that use Classify_reloc
> or Default_scan_relocatable_relocs, this allows us to provide the MIPS
> accessor functions without a runtime check.
>
> The commit description and ChangeLog entry are copied below. The patch
> is attached.
>
> -cary
>
>
> For MIPS-64, the r_info field in the relocation format is
> replaced by several individual fields, including r_sym and
> r_type. To enable support for this format, I've refactored
> target-independent code to remove almost all uses of the r_info
> field. (I've left alone a couple of routines used only for
> incremental linking, which I can update if/when the MIPS target
> adds support for incremental linking.)
>
> For routines that are already templated on a Classify_reloc class
> (namely, gc_process_relocs, relocate_section, and
> relocate_relocs), I've extended the Classify_reloc interface to
> include sh_type (which no longer needs to be a separate template
> parameter) as well as get_r_sym() and get_r_type() methods for
> extracting the r_sym and r_type fields. For
> scan_relocatable_relocs, I've extended the
> Default_scan_relocatable_relocs class by converting it to a class
> template with Classify_reloc as a template parameter. For the
> remaining routines that need to access r_sym, I've added a
> virtual Target::get_r_sym() method with an override for the MIPS
> target.
>
> In elfcpp, I've added Mips64_rel, etc., accessor classes and
> corresponding internal data structures. The MIPS target uses
> these new classes within its own Mips_classify_reloc class.
> The Mips64_ accessor classes also expose the r_ssym, r_type2,
> and r_type3 fields from the relocation.
>
> These changes should be functionally the same for all but the
> MIPS target.
>
>
> 2016-01-11 Cary Coutant <ccoutant@gmail.com>
>
> elfcpp/
> * elfcpp.h (Mips64_rel, Mips64_rel_write): New classes.
> (Mips64_rela, Mips64_rela_write): New classes.
> * elfcpp_internal.h (Mips64_rel_data, Mips64_rela_data): New structs.
>
> gold/
> * gc.h (get_embedded_addend_size): Remove sh_type parameter.
> (gc_process_relocs): Remove sh_type template parameter.
> Use Classify_reloc to access r_sym, r_type, and r_addend fields.
> * object.h (Sized_relobj_file::split_stack_adjust): Add target
> parameter.
> (Sized_relobj_file::split_stack_adjust_reltype): Likewise.
> * reloc-types.h (Reloc_types::copy_reloc_addend): (SHT_REL and SHT_RELA
> specializations) Remove.
> * reloc.cc (Emit_relocs_strategy): Rename and move to target-reloc.h.
> (Sized_relobj_file::emit_relocs_scan): Call Target::emit_relocs_scan().
> (Sized_relobj_file::emit_relocs_scan_reltype): Remove.
> (Sized_relobj_file::split_stack_adjust): Add target parameter.
> Adjust all callers.
> (Sized_relobj_file::split_stack_adjust_reltype): Likewise. Call
> Target::get_r_sym() to get r_sym field from relocations.
> (Track_relocs::next_symndx): Call Target::get_r_sym().
> * target-reloc.h (scan_relocs): Remove sh_type template parameter;
> add Classify_reloc template parameter. Use for accessing r_sym and
> r_type.
> (relocate_section): Likewise.
> (Default_classify_reloc): New class (renamed and moved from reloc.cc).
> (Default_scan_relocatable_relocs): Remove sh_type template parameter.
> (Default_scan_relocatable_relocs::Reltype): New typedef.
> (Default_scan_relocatable_relocs::reloc_size): New const.
> (Default_scan_relocatable_relocs::sh_type): New const.
> (Default_scan_relocatable_relocs::get_r_sym): New method.
> (Default_scan_relocatable_relocs::get_r_type): New method.
> (Default_emit_relocs_strategy): New class.
> (scan_relocatable_relocs): Replace sh_type template parameter with
> Scan_relocatable_relocs class. Use it to access r_sym and r_type
> fields.
> (relocate_relocs): Replace sh_type template parameter with
> Classify_reloc class. Use it to access r_sym and r_type fields.
> * target.h (Target::is_call_to_non_split): Replace r_type parameter
> with pointer to relocation. Adjust all callers.
> (Target::do_is_call_to_non_split): Likewise.
> (Target::emit_relocs_scan): New virtual method.
> (Sized_target::get_r_sym): New virtual method.
> * target.cc (Target::do_is_call_to_non_split): Replace r_type parameter
> with pointer to relocation.
>
>
It breaks i686 gold:
gcctestdir/ld: internal error in get_reloc_addend, at
/export/gnu/import/git/sources/binutils-gdb/gold/reloc-types.h:49
collect2: error: ld returned 1 exit status
Makefile:5149: recipe for target 'icf_virtual_function_folding_test' failed
make[7]: *** [icf_virtual_function_folding_test] Error 1
--
H.J.