mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-05 23:23:09 +00:00
Fix bug when applying R_SPARC_GOTDATA_OP* relocations to local symbols.
When applying a GOTDATA_OP* relocation to a local symbol, the addend is being applied after getting the value of the symbol. When the relocation refers to a merge section, however, the addend must be provided when computing the symbol value, since the contents of the section may have been rearranged. gold/ PR gold/18855 * sparc.cc (Sparc_relocate_functions::gdop_hix22): Remove addend parameter. (Sparc_relocate_functions::gdop_lox10): Likewise. (Target_sparc::Relocate::relocate): Use addend when computing symbol value for R_SPARC_GOTDATA_OP*.
This commit is contained in:
@@ -1,3 +1,12 @@
|
|||||||
|
2015-10-06 Cary Coutant <ccoutant@gmail.com>
|
||||||
|
|
||||||
|
PR gold/18855
|
||||||
|
* sparc.cc (Sparc_relocate_functions::gdop_hix22): Remove addend
|
||||||
|
parameter.
|
||||||
|
(Sparc_relocate_functions::gdop_lox10): Likewise.
|
||||||
|
(Target_sparc::Relocate::relocate): Use addend when computing
|
||||||
|
symbol value for R_SPARC_GOTDATA_OP*.
|
||||||
|
|
||||||
2015-09-07 Cary Coutant <ccoutant@gmail.com>
|
2015-09-07 Cary Coutant <ccoutant@gmail.com>
|
||||||
|
|
||||||
PR gold/18930
|
PR gold/18930
|
||||||
|
|||||||
@@ -1107,13 +1107,12 @@ public:
|
|||||||
// R_SPARC_GOTDATA_OP_HIX22: @gdopoff(Symbol + Addend) >> 10
|
// R_SPARC_GOTDATA_OP_HIX22: @gdopoff(Symbol + Addend) >> 10
|
||||||
static inline void
|
static inline void
|
||||||
gdop_hix22(unsigned char* view,
|
gdop_hix22(unsigned char* view,
|
||||||
typename elfcpp::Elf_types<size>::Elf_Addr value,
|
typename elfcpp::Elf_types<size>::Elf_Addr value)
|
||||||
typename elfcpp::Elf_types<size>::Elf_Addr addend)
|
|
||||||
{
|
{
|
||||||
typedef typename elfcpp::Swap<32, true>::Valtype Valtype;
|
typedef typename elfcpp::Swap<32, true>::Valtype Valtype;
|
||||||
Valtype* wv = reinterpret_cast<Valtype*>(view);
|
Valtype* wv = reinterpret_cast<Valtype*>(view);
|
||||||
Valtype val = elfcpp::Swap<32, true>::readval(wv);
|
Valtype val = elfcpp::Swap<32, true>::readval(wv);
|
||||||
int32_t reloc = static_cast<int32_t>(value + addend);
|
int32_t reloc = static_cast<int32_t>(value);
|
||||||
|
|
||||||
val &= ~0x3fffff;
|
val &= ~0x3fffff;
|
||||||
|
|
||||||
@@ -1170,13 +1169,12 @@ public:
|
|||||||
// R_SPARC_GOTDATA_OP_LOX10: (@gdopoff(Symbol + Addend) & 0x3ff) | 0x1c00
|
// R_SPARC_GOTDATA_OP_LOX10: (@gdopoff(Symbol + Addend) & 0x3ff) | 0x1c00
|
||||||
static inline void
|
static inline void
|
||||||
gdop_lox10(unsigned char* view,
|
gdop_lox10(unsigned char* view,
|
||||||
typename elfcpp::Elf_types<size>::Elf_Addr value,
|
typename elfcpp::Elf_types<size>::Elf_Addr value)
|
||||||
typename elfcpp::Elf_types<size>::Elf_Addr addend)
|
|
||||||
{
|
{
|
||||||
typedef typename elfcpp::Swap<32, true>::Valtype Valtype;
|
typedef typename elfcpp::Swap<32, true>::Valtype Valtype;
|
||||||
Valtype* wv = reinterpret_cast<Valtype*>(view);
|
Valtype* wv = reinterpret_cast<Valtype*>(view);
|
||||||
Valtype val = elfcpp::Swap<32, true>::readval(wv);
|
Valtype val = elfcpp::Swap<32, true>::readval(wv);
|
||||||
int32_t reloc = static_cast<int32_t>(value + addend);
|
int32_t reloc = static_cast<int32_t>(value);
|
||||||
|
|
||||||
if (reloc < 0)
|
if (reloc < 0)
|
||||||
reloc = (reloc & 0x3ff) | 0x1c00;
|
reloc = (reloc & 0x3ff) | 0x1c00;
|
||||||
@@ -3244,7 +3242,7 @@ Target_sparc<size, big_endian>::Relocate::relocate(
|
|||||||
&& !gsym->is_preemptible()
|
&& !gsym->is_preemptible()
|
||||||
&& !orig_is_ifunc))
|
&& !orig_is_ifunc))
|
||||||
{
|
{
|
||||||
got_offset = psymval->value(object, 0) - target->got_address();
|
got_offset = psymval->value(object, addend) - target->got_address();
|
||||||
gdop_valid = true;
|
gdop_valid = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -3384,7 +3382,7 @@ Target_sparc<size, big_endian>::Relocate::relocate(
|
|||||||
case elfcpp::R_SPARC_GOTDATA_OP_LOX10:
|
case elfcpp::R_SPARC_GOTDATA_OP_LOX10:
|
||||||
if (gdop_valid)
|
if (gdop_valid)
|
||||||
{
|
{
|
||||||
Reloc::gdop_lox10(view, got_offset, addend);
|
Reloc::gdop_lox10(view, got_offset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Fall through. */
|
/* Fall through. */
|
||||||
@@ -3395,7 +3393,7 @@ Target_sparc<size, big_endian>::Relocate::relocate(
|
|||||||
case elfcpp::R_SPARC_GOTDATA_OP_HIX22:
|
case elfcpp::R_SPARC_GOTDATA_OP_HIX22:
|
||||||
if (gdop_valid)
|
if (gdop_valid)
|
||||||
{
|
{
|
||||||
Reloc::gdop_hix22(view, got_offset, addend);
|
Reloc::gdop_hix22(view, got_offset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Fall through. */
|
/* Fall through. */
|
||||||
|
|||||||
Reference in New Issue
Block a user