[PATCH] Add support for sparc GOTDATA optimizations in Gold.
Ian Lance Taylor
iant@google.com
Tue Apr 17 00:16:00 GMT 2012
David Miller <davem@davemloft.net> writes:
> gold/
>
> * sparc.cc (Target_sparc::got_address): New function.
> (Sparc_relocate_functions::gdop_hix22): New function.
> (Sparc_relocate_functions::gdop_lox10): New function.
> (Target_sparc::Scan::local): Do not emit a GOT entry for GOTDATA
> relocs.
> (Target_sparc::Scan::local): Likewise if the global symbol is not
> preemptible and is not IFUNC.
> (Target_sparc::Relocate::relocate): Perform GOTDATA code
> transformations for local and non-preemptible non-IFUNC global
> symbols.
> + // R_SPARC_GOTDATA_OP_HIX22: @gdopoff(Symbol + Addend) >> 10
> + static inline void
> + gdop_hix22(unsigned char* view,
> + typename elfcpp::Elf_types<size>::Elf_Addr value,
> + typename elfcpp::Elf_types<size>::Elf_Addr addend)
> + {
> + typedef typename elfcpp::Swap<32, true>::Valtype Valtype;
> + Valtype* wv = reinterpret_cast<Valtype*>(view);
> + Valtype val = elfcpp::Swap<32, true>::readval(wv);
> + int32_t reloc = (value + addend);
> +
> + val &= ~0x3fffff;
> +
> + if (reloc < 0)
> + reloc ^= ~(Valtype)0;
> + reloc >>= 10;
> +
> + reloc &= 0x3fffff;
> +
> + elfcpp::Swap<32, true>::writeval(wv, val | reloc);
> + }
I think I would change the line setting reloc to
int32_t reloc = static_cast<int32_t>(value + addend);
to make clear that you are intentionally dropping some bits for the
64-bit target.
The line
reloc ^= ~(Valtype)0;
should probably be
reloc ^= ~static_cast<int32_t>(0);
or perhaps even, for extreme clarity,
reloc = static_cast<int32_t>(static_cast<uint32_t>(reloc)
^ static_cast<uint32_t>(0));
to avoid bit operations on signed types.
This is OK with changes along those lines.
Thanks.
Ian
More information about the Binutils
mailing list