summaryrefslogtreecommitdiff
path: root/gold/object.h
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2021-08-28 14:45:53 +0930
committerAlan Modra <amodra@gmail.com>2021-09-18 08:20:11 +0930
commit54721a930e80a635d3cb47c0ad3899ed9680bd78 (patch)
tree88b5cd53e547a5a37273303eabeac5bbcc868499 /gold/object.h
parent973b2b402ebf660e2bbbac60e85469164d76ecfc (diff)
downloadbinutils-gdb-54721a930e80a635d3cb47c0ad3899ed9680bd78.tar.gz
[GOLD] Output_data_got tidy
Some Output_data_got methods already have support for addends, but were implemented as separate methods. This removes unnecessary code duplication. Relobj::local_has_got_offset and others there get a similar treatment. Comments are removed since it should be obvious without a comment, and the existing comments are not precisely what the code does. For example, a local_has_got_offset call without an addend does not return whether the local symbol has *a* GOT offset of type GOT_TYPE, it returns whether there is a GOT entry of type GOT_TYPE for the symbol with addend of zero. PR 28192 * output.h (Output_data_got::add_local): Make addend optional. (Output_data_got::add_local_with_rel): Likewise. (Output_data_got::add_local_pair_with_rel): Likewise. * output.cc (Output_data_got::add_local): Delete overload without addend. (Output_data_got::add_local_with_rel): Likewise. (Output_data_got::add_local_pair_with_rel): Likewise. * object.h (Relobj::local_has_got_offset): Make addend optional. Delete overload without addend later. Update comment. (Relobj::local_got_offset): Likewise. (Relobj::set_local_got_offset): Likewise.
Diffstat (limited to 'gold/object.h')
-rw-r--r--gold/object.h41
1 files changed, 11 insertions, 30 deletions
diff --git a/gold/object.h b/gold/object.h
index 2dbe4b3e1be..dc089f5a417 100644
--- a/gold/object.h
+++ b/gold/object.h
@@ -1216,46 +1216,27 @@ class Relobj : public Object
local_plt_offset(unsigned int symndx) const
{ return this->do_local_plt_offset(symndx); }
- // Return whether the local symbol SYMNDX has a GOT offset of type
- // GOT_TYPE.
- bool
- local_has_got_offset(unsigned int symndx, unsigned int got_type) const
- { return this->do_local_has_got_offset(symndx, got_type, 0); }
-
- // Return whether the local symbol SYMNDX plus ADDEND has a GOT offset
- // of type GOT_TYPE.
+ // Return whether there is a GOT entry of type GOT_TYPE for the
+ // local symbol SYMNDX with given ADDEND.
bool
local_has_got_offset(unsigned int symndx, unsigned int got_type,
- uint64_t addend) const
+ uint64_t addend = 0) const
{ return this->do_local_has_got_offset(symndx, got_type, addend); }
- // 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.
- unsigned int
- local_got_offset(unsigned int symndx, unsigned int got_type) const
- { return this->do_local_got_offset(symndx, got_type, 0); }
-
- // Return the GOT offset of type GOT_TYPE of the local symbol
- // SYMNDX plus ADDEND. It is an error to call this if the symbol
- // does not have a GOT offset of the specified type.
+ // Return the GOT offset of the GOT entry with type GOT_TYPE for the
+ // local symbol SYMNDX with given ADDEND. It is an error to call
+ // this function if the symbol does not have such a GOT entry.
unsigned int
local_got_offset(unsigned int symndx, unsigned int got_type,
- uint64_t addend) const
+ uint64_t addend = 0) 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
- set_local_got_offset(unsigned int symndx, unsigned int got_type,
- unsigned int got_offset)
- { this->do_set_local_got_offset(symndx, got_type, got_offset, 0); }
-
- // Set the GOT offset with type GOT_TYPE of the local symbol SYMNDX
- // plus ADDEND to GOT_OFFSET.
+ // Set the GOT offset for a GOT entry with type GOT_TYPE for the
+ // local symbol SYMNDX with ADDEND to GOT_OFFSET. Create such an
+ // entry if none exists.
void
set_local_got_offset(unsigned int symndx, unsigned int got_type,
- unsigned int got_offset, uint64_t addend)
+ unsigned int got_offset, uint64_t addend = 0)
{ this->do_set_local_got_offset(symndx, got_type, got_offset, addend); }
// Return whether the local symbol SYMNDX is a TLS symbol.