diff options
author | Alan Modra <amodra@gmail.com> | 2021-08-25 20:24:18 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2021-09-18 08:20:11 +0930 |
commit | 2cc9ed14fae1b288bbdbd9b102b2cbc9a29bf348 (patch) | |
tree | ecfc23a51fb6bdf6f6e894f391b4f6d26a3a03e9 /gold/output.cc | |
parent | 54721a930e80a635d3cb47c0ad3899ed9680bd78 (diff) | |
download | gdb-2cc9ed14fae1b288bbdbd9b102b2cbc9a29bf348.zip gdb-2cc9ed14fae1b288bbdbd9b102b2cbc9a29bf348.tar.gz gdb-2cc9ed14fae1b288bbdbd9b102b2cbc9a29bf348.tar.bz2 |
[GOLD] Output_data_got create entry method addends
This patch makes all the Output_data_got methods that create new
entries accept an optional addend.
PR 28192
* output.h (Output_data_got::add_global): Add optional addend
parameter. Update comment. Delete overload without addend.
(Output_data_got::add_global_plt): Likewise.
(Output_data_got::add_global_tls): Likewise.
(Output_data_got::add_global_with_rel): Likewise.
(Output_data_got::add_global_pair_with_rel): Likewise.
(Output_data_got::add_local_plt): Likewise.
(Output_data_got::add_local_tls): Likewise.
(Output_data_got::add_local_tls_pair): Likewise.
(Output_data_got::reserve_local): Likewise.
(Output_data_got::reserve_global): Likewise.
(Output_data_got::Got_entry): Include addend in global sym
constructor. Delete local sym constructor without addend.
* output.cc (Output_data_got::add_global): Add addend param,
pass to got handling methods.
(Output_data_got::add_global_plt): Likewise.
(Output_data_got::add_global_with_rel): Likewise.
(Output_data_got::add_global_pair_with_rel): Likewise.
(Output_data_got::add_local_plt): Likewise.
(Output_data_got::add_local_tls_pair): Likewise.
(Output_data_got::reserve_local): Likewise.
(Output_data_got::reserve_global): Likewise.
Diffstat (limited to 'gold/output.cc')
-rw-r--r-- | gold/output.cc | 77 |
1 files changed, 43 insertions, 34 deletions
diff --git a/gold/output.cc b/gold/output.cc index 75f54f0..c5f7eef 100644 --- a/gold/output.cc +++ b/gold/output.cc @@ -1461,15 +1461,15 @@ Output_data_got<got_size, big_endian>::Got_entry::write( template<int got_size, bool big_endian> bool -Output_data_got<got_size, big_endian>::add_global( - Symbol* gsym, - unsigned int got_type) +Output_data_got<got_size, big_endian>::add_global(Symbol* gsym, + unsigned int got_type, + uint64_t addend) { - if (gsym->has_got_offset(got_type)) + if (gsym->has_got_offset(got_type, addend)) return false; - unsigned int got_offset = this->add_got_entry(Got_entry(gsym, false)); - gsym->set_got_offset(got_type, got_offset); + unsigned int got_offset = this->add_got_entry(Got_entry(gsym, false, addend)); + gsym->set_got_offset(got_type, got_offset, addend); return true; } @@ -1478,13 +1478,14 @@ Output_data_got<got_size, big_endian>::add_global( template<int got_size, bool big_endian> bool Output_data_got<got_size, big_endian>::add_global_plt(Symbol* gsym, - unsigned int got_type) + unsigned int got_type, + uint64_t addend) { - if (gsym->has_got_offset(got_type)) + if (gsym->has_got_offset(got_type, addend)) return false; - unsigned int got_offset = this->add_got_entry(Got_entry(gsym, true)); - gsym->set_got_offset(got_type, got_offset); + unsigned int got_offset = this->add_got_entry(Got_entry(gsym, true, addend)); + gsym->set_got_offset(got_type, got_offset, addend); return true; } @@ -1497,14 +1498,15 @@ Output_data_got<got_size, big_endian>::add_global_with_rel( Symbol* gsym, unsigned int got_type, Output_data_reloc_generic* rel_dyn, - unsigned int r_type) + unsigned int r_type, + uint64_t addend) { - if (gsym->has_got_offset(got_type)) + if (gsym->has_got_offset(got_type, addend)) return; unsigned int got_offset = this->add_got_entry(Got_entry()); - gsym->set_got_offset(got_type, got_offset); - rel_dyn->add_global_generic(gsym, r_type, this, got_offset, 0); + gsym->set_got_offset(got_type, got_offset, addend); + rel_dyn->add_global_generic(gsym, r_type, this, got_offset, addend); } // Add a pair of entries for a global symbol to the GOT, and add @@ -1517,18 +1519,19 @@ Output_data_got<got_size, big_endian>::add_global_pair_with_rel( unsigned int got_type, Output_data_reloc_generic* rel_dyn, unsigned int r_type_1, - unsigned int r_type_2) + unsigned int r_type_2, + uint64_t addend) { - if (gsym->has_got_offset(got_type)) + if (gsym->has_got_offset(got_type, addend)) return; unsigned int got_offset = this->add_got_entry_pair(Got_entry(), Got_entry()); - gsym->set_got_offset(got_type, got_offset); - rel_dyn->add_global_generic(gsym, r_type_1, this, got_offset, 0); + gsym->set_got_offset(got_type, got_offset, addend); + rel_dyn->add_global_generic(gsym, r_type_1, this, got_offset, addend); if (r_type_2 != 0) rel_dyn->add_global_generic(gsym, r_type_2, this, - got_offset + got_size / 8, 0); + got_offset + got_size / 8, addend); } // Add an entry for a local symbol plus ADDEND to the GOT. This returns @@ -1559,14 +1562,15 @@ bool Output_data_got<got_size, big_endian>::add_local_plt( Relobj* object, unsigned int symndx, - unsigned int got_type) + unsigned int got_type, + uint64_t addend) { - if (object->local_has_got_offset(symndx, got_type)) + if (object->local_has_got_offset(symndx, got_type, addend)) return false; unsigned int got_offset = this->add_got_entry(Got_entry(object, symndx, - true)); - object->set_local_got_offset(symndx, got_type, got_offset); + true, addend)); + object->set_local_got_offset(symndx, got_type, got_offset, addend); return true; } @@ -1580,7 +1584,8 @@ Output_data_got<got_size, big_endian>::add_local_with_rel( unsigned int symndx, unsigned int got_type, Output_data_reloc_generic* rel_dyn, - unsigned int r_type, uint64_t addend) + unsigned int r_type, + uint64_t addend) { if (object->local_has_got_offset(symndx, got_type, addend)) return; @@ -1604,7 +1609,8 @@ Output_data_got<got_size, big_endian>::add_local_pair_with_rel( unsigned int shndx, unsigned int got_type, Output_data_reloc_generic* rel_dyn, - unsigned int r_type, uint64_t addend) + unsigned int r_type, + uint64_t addend) { if (object->local_has_got_offset(symndx, got_type, addend)) return; @@ -1628,16 +1634,17 @@ Output_data_got<got_size, big_endian>::add_local_tls_pair( unsigned int symndx, unsigned int got_type, Output_data_reloc_generic* rel_dyn, - unsigned int r_type) + unsigned int r_type, + uint64_t addend) { - if (object->local_has_got_offset(symndx, got_type)) + if (object->local_has_got_offset(symndx, got_type, addend)) return; unsigned int got_offset = this->add_got_entry_pair(Got_entry(), - Got_entry(object, symndx, true)); - object->set_local_got_offset(symndx, got_type, got_offset); - rel_dyn->add_local_generic(object, 0, r_type, this, got_offset, 0); + Got_entry(object, symndx, true, addend)); + object->set_local_got_offset(symndx, got_type, got_offset, addend); + rel_dyn->add_local_generic(object, 0, r_type, this, got_offset, addend); } // Reserve a slot in the GOT for a local symbol or the second slot of a pair. @@ -1648,10 +1655,11 @@ Output_data_got<got_size, big_endian>::reserve_local( unsigned int i, Relobj* object, unsigned int sym_index, - unsigned int got_type) + unsigned int got_type, + uint64_t addend) { this->do_reserve_slot(i); - object->set_local_got_offset(sym_index, got_type, this->got_offset(i)); + object->set_local_got_offset(sym_index, got_type, this->got_offset(i), addend); } // Reserve a slot in the GOT for a global symbol. @@ -1661,10 +1669,11 @@ void Output_data_got<got_size, big_endian>::reserve_global( unsigned int i, Symbol* gsym, - unsigned int got_type) + unsigned int got_type, + uint64_t addend) { this->do_reserve_slot(i); - gsym->set_got_offset(got_type, this->got_offset(i)); + gsym->set_got_offset(got_type, this->got_offset(i), addend); } // Write out the GOT. |