This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] Add support for sparc GOTDATA optimizations in Gold.
- From: Ian Lance Taylor <iant at google dot com>
- To: David Miller <davem at davemloft dot net>
- Cc: binutils at sourceware dot org
- Date: Mon, 16 Apr 2012 17:15:35 -0700
- Subject: Re: [PATCH] Add support for sparc GOTDATA optimizations in Gold.
- References: <20120411.182636.58388483759233355.davem@davemloft.net>
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