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: [PATCH 3/6] gold: Take addend into account for calculating value of the local symbol for GOT.


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


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