This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GOLD handling of weak symbols (including x86 vs. ARM)


Richard Sandiford <richard.sandiford@linaro.org> writes:

> gold/
> 	* symtab.h (Symbol::NON_PIC_REF): Remove.
> 	(Symbol::RELATIVE_REF, Symbol::TLS_REF): New Reference_flags.
> 	(Symbol::FUNCTION_CALL): Renumber.  Reword comment.
> 	(Symbol::needs_dynamic_reloc): Don't check NON_PIC_REF.
> 	(Symbol::use_plt_offset): Take a flags argument and pass it
> 	directly to needs_dynamic_reloc.  Restrict check for undefined
> 	weak symbols to function calls.
> 	* arm.cc (Target_arm::Scan::get_reference_flags): New function.
> 	(Target_arm::Scan::global): Use it.
> 	(Target_arm::Scan::scan_reloc_for_stub): Likewise.
> 	(Target_arm::Relocate::relocate): Likewise.
> 	(Target_arm::Relocate::should_apply_static_reloc): Replace flags
> 	parameter with an r_type parameter.  Use get_reference_flags
> 	to get the flags.
> 	(Target_arm::Relocate::relocate): Update accordingly.
> 	* i386.cc (Target_i386::Scan::get_reference_flags): New function.
> 	(Target_i386::Scan::reloc_needs_plt_for_ifunc): Use it.
> 	(Target_i386::Scan::global): Likewise.
> 	(Target_i386::Relocate::relocate): Likewise.
> 	(Target_i386::Relocate::should_apply_static_reloc): Replace flags
> 	parameter with an r_type parameter.  Use get_reference_flags
> 	to get the flags.
> 	(Target_i386::Relocate::relocate): Update accordingly.
> 	* powerpc.cc (Target_powerpc::Scan::get_reference_flags): New function.
> 	(Target_powerpc::Scan::global): Use it.
> 	(Target_powerpc::Scan::scan_reloc_for_stub): Likewise.
> 	(Target_powerpc::Relocate::relocate): Likewise.
> 	* sparc.cc (Target_sparc::Scan::get_reference_flags): New function.
> 	(Target_sparc::Scan::global): Use it.
> 	(Target_sparc::Scan::scan_reloc_for_stub): Likewise.
> 	(Target_sparc::Relocate::relocate): Likewise.
> 	* x86_64.cc (Target_x86_64::Scan::get_reference_flags): New function.
> 	(Target_x86_64::Scan::reloc_needs_plt_for_ifunc): Use it.
> 	(Target_x86_64::Scan::global): Likewise.
> 	(Target_x86_64::Relocate::relocate): Likewise.


> @@ -7993,7 +8115,7 @@ Target_arm<big_endian>::Scan::global(Sym
>                gsym->set_needs_dynsym_value();
>            }
>          // Make a dynamic relocation if necessary.
> -        if (gsym->needs_dynamic_reloc(Symbol::ABSOLUTE_REF))
> +        if (gsym->needs_dynamic_reloc(get_reference_flags(r_type)))

Write Scan::get_reference_flags(r_type) (add "Scan::").  It's not
necessary but it helps clarify where the symbol is coming from.

> @@ -8074,8 +8196,7 @@ Target_arm<big_endian>::Scan::global(Sym
>        // Relative addressing relocations.
>        {
>  	// Make a dynamic relocation if necessary.
> -	int flags = Symbol::NON_PIC_REF;
> -	if (gsym->needs_dynamic_reloc(flags))
> +	if (gsym->needs_dynamic_reloc(get_reference_flags(r_type)))

Here too.

> +bool
> +Target_i386::Scan::reloc_needs_plt_for_ifunc(Sized_relobj<32, false>* object,
> +					     unsigned int r_type)
> +{
> +  int flags = get_reference_flags(r_type);

Here too.

> @@ -1676,7 +1694,7 @@ Target_i386::Scan::global(Symbol_table* 
>                gsym->set_needs_dynsym_value();
>            }
>          // Make a dynamic relocation if necessary.
> -        if (gsym->needs_dynamic_reloc(Symbol::ABSOLUTE_REF))
> +        if (gsym->needs_dynamic_reloc(get_reference_flags(r_type)))

Here too.

> @@ -1737,10 +1755,7 @@ Target_i386::Scan::global(Symbol_table* 
>                target->make_plt_entry(symtab, layout, gsym);
>            }
>          // Make a dynamic relocation if necessary.
> -        int flags = Symbol::NON_PIC_REF;
> -        if (gsym->is_func())
> -          flags |= Symbol::FUNCTION_CALL;
> -        if (gsym->needs_dynamic_reloc(flags))
> +        if (gsym->needs_dynamic_reloc(get_reference_flags(r_type)))

Here too.

> @@ -1400,7 +1466,7 @@ Target_powerpc<size, big_endian>::Scan::
>                gsym->set_needs_dynsym_value();
>            }
>          // Make a dynamic relocation if necessary.
> -        if (gsym->needs_dynamic_reloc(Symbol::ABSOLUTE_REF))
> +        if (gsym->needs_dynamic_reloc(get_reference_flags(r_type)))

Here too.

> @@ -2068,10 +2184,7 @@ Target_sparc<size, big_endian>::Scan::gl
>  	if (gsym->needs_plt_entry())
>  	  target->make_plt_entry(symtab, layout, gsym);
>  	// Make a dynamic relocation if necessary.
> -	int flags = Symbol::NON_PIC_REF;
> -	if (gsym->type() == elfcpp::STT_FUNC)
> -	  flags |= Symbol::FUNCTION_CALL;
> -	if (gsym->needs_dynamic_reloc(flags))
> +	if (gsym->needs_dynamic_reloc(get_reference_flags(r_type)))

Here too.

> @@ -2127,7 +2240,7 @@ Target_sparc<size, big_endian>::Scan::gl
>                gsym->set_needs_dynsym_value();
>            }
>          // Make a dynamic relocation if necessary.
> -        if (gsym->needs_dynamic_reloc(Symbol::ABSOLUTE_REF))
> +        if (gsym->needs_dynamic_reloc(get_reference_flags(r_type)))

Here too.

> @@ -1779,7 +1797,7 @@ Target_x86_64::Scan::global(Symbol_table
>                gsym->set_needs_dynsym_value();
>            }
>          // Make a dynamic relocation if necessary.
> -        if (gsym->needs_dynamic_reloc(Symbol::ABSOLUTE_REF))
> +        if (gsym->needs_dynamic_reloc(get_reference_flags(r_type)))

Here too.

> @@ -1836,10 +1854,7 @@ Target_x86_64::Scan::global(Symbol_table
>          if (gsym->needs_plt_entry())
>            target->make_plt_entry(symtab, layout, gsym);
>          // Make a dynamic relocation if necessary.
> -        int flags = Symbol::NON_PIC_REF;
> -        if (gsym->is_func())
> -          flags |= Symbol::FUNCTION_CALL;
> -        if (gsym->needs_dynamic_reloc(flags))
> +        if (gsym->needs_dynamic_reloc(get_reference_flags(r_type)))

Here too.


This is OK with those changes.

Thanks very much for tackling this.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]