This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH 3/6] gold: Take addend into account for calculating value of the local symbol for GOT.
- From: Cary Coutant <ccoutant at gmail dot com>
- To: Vladimir Radosavljevic <Vladimir dot Radosavljevic at imgtec dot com>
- Cc: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Mon, 9 Nov 2015 12:00:48 -0800
- Subject: Re: [PATCH 3/6] gold: Take addend into account for calculating value of the local symbol for GOT.
- Authentication-results: sourceware.org; auth=none
- References: <3060420525346945A0ADBD567348A91723734F13 at BADAG02 dot ba dot imgtec dot org>
When posting patches, please post them either as plain text or as
attachments -- your patches were encoded as quoted-printable, which
makes them a bit harder to process.
> @@ -1113,6 +1113,13 @@ class Relobj : public Object
> local_has_got_offset(unsigned int symndx, unsigned int got_type) const
> { return this->do_local_has_got_offset(symndx, got_type); }
>
> + // Return whether the local symbol SYMNDX with ADDEND has a GOT offset
> + // of type GOT_TYPE.
> + bool
> + local_has_got_offset(unsigned int symndx, unsigned int got_type,
> + uint64_t addend) const
> + { return this->do_local_has_got_offset(symndx, got_type, addend); }
> +
Rather than overloading the private virtual method, let's just change
its signature to include the addend, and pass a 0 explicitly from the
original version of the public method.
> // Return the GOT offset of type GOT_TYPE of the local symbol
> // SYMNDX. It is an error to call this if the symbol does not have
> // a GOT offset of the specified type.
> @@ -1120,6 +1127,14 @@ class Relobj : public Object
> local_got_offset(unsigned int symndx, unsigned int got_type) const
> { return this->do_local_got_offset(symndx, got_type); }
>
> + // Return the GOT offset of type GOT_TYPE of the local symbol
> + // SYMNDX with ADDEND. It is an error to call this if the symbol
> + // does not have a GOT offset of the specified type.
> + unsigned int
> + local_got_offset(unsigned int symndx, unsigned int got_type,
> + uint64_t addend) const
> + { return this->do_local_got_offset(symndx, got_type, addend); }
> +
> // Set the GOT offset with type GOT_TYPE of the local symbol SYMNDX
> // to GOT_OFFSET.
> void
> @@ -1127,6 +1142,13 @@ class Relobj : public Object
> unsigned int got_offset)
> { this->do_set_local_got_offset(symndx, got_type, got_offset); }
>
> + // Set the GOT offset with type GOT_TYPE of the local symbol SYMNDX
> + // with ADDEND to GOT_OFFSET.
> + void
> + set_local_got_offset(unsigned int symndx, unsigned int got_type,
> + unsigned int got_offset, uint64_t addend)
> + { this->do_set_local_got_offset(symndx, got_type, got_offset, addend); }
> +
Likewise for these.
> // Return whether the local symbol SYMNDX is a TLS symbol.
> bool
> local_is_tls(unsigned int symndx) const
> @@ -1323,15 +1345,31 @@ class Relobj : public Object
> do_local_has_got_offset(unsigned int symndx,
> unsigned int got_type) const = 0;
>
> + // Return whether a local symbol with addend has a GOT offset
> + // of a given type.
> + virtual bool
> + do_local_has_got_offset(unsigned int symndx,
> + unsigned int got_type, uint64_t addend) const = 0;
> +
> // Return the GOT offset of a given type of a local symbol.
> virtual unsigned int
> do_local_got_offset(unsigned int symndx, unsigned int got_type) const = 0;
>
> + // Return the GOT offset of a given type of a local symbol with addend.
> + virtual unsigned int
> + do_local_got_offset(unsigned int symndx, unsigned int got_type,
> + uint64_t addend) const = 0;
> +
> // Set the GOT offset with a given type for a local symbol.
> virtual void
> do_set_local_got_offset(unsigned int symndx, unsigned int got_type,
> unsigned int got_offset) = 0;
>
> + // Set the GOT offset with a given type for a local symbol with addend.
> + virtual void
> + do_set_local_got_offset(unsigned int symndx, unsigned int got_type,
> + unsigned int got_offset, uint64_t addend) = 0;
> +
Here we can just replace the first version of each with the new one;
no overload necessary.
> // Return whether local symbol SYMNDX is a TLS symbol.
> virtual bool
> do_local_is_tls(unsigned int symndx) const = 0;
> @@ -2004,6 +2042,12 @@ class Sized_relobj : public Relobj
> && p->second->get_offset(got_type) != -1U);
> }
>
> + // Return whether the local symbol SYMNDX with ADDEND has a GOT offset
> + // of type GOT_TYPE.
> + bool
> + do_local_has_got_offset(unsigned int, unsigned int, uint64_t) const
> + { gold_unreachable(); }
> +
> // Return the GOT offset of type GOT_TYPE of the local symbol
> // SYMNDX.
> unsigned int
> @@ -2017,6 +2061,12 @@ class Sized_relobj : public Relobj
> return off;
> }
>
> + // Return the GOT offset of type GOT_TYPE of the local symbol
> + // SYMNDX with ADDEND.
> + unsigned int
> + do_local_got_offset(unsigned int, unsigned int, uint64_t) const
> + { gold_unreachable(); }
> +
> // Set the GOT offset with type GOT_TYPE of the local symbol SYMNDX
> // to GOT_OFFSET.
> void
> @@ -2036,6 +2086,13 @@ class Sized_relobj : public Relobj
> }
> }
>
> + // Set the GOT offset with type GOT_TYPE of the local symbol SYMNDX
> + // with ADDEND to GOT_OFFSET.
> + void
> + do_set_local_got_offset(unsigned int, unsigned int,
> + unsigned int, uint64_t)
> + { gold_unreachable(); }
> +
And here, rather than implementing these only for Mips_relobj, let's
just pull your implementations from patch #5 into here, replacing the
ones without addend.
I think there are other platforms that may also need to track (symbol
+ addend) for GOT entries, so it makes sense to support it in
target-independent code. (PA-RISC comes to mind.)
Thanks!
-cary