[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 4/4] Bug 24431 Treat __ksymtab as int32_t for v4.19+ kernels
Calculating the relocation for values in __ksymtab with GElf_Addr (i.e.
uint64_t), makes the calculation rely on overflows for negative offsets.
Address that by treating these as 32bit signed values for the v4.19+
__ksymtabs and calculate the offset with them. This also allows, similar
an earlier commit, to drop the distinction between 64bit and 32bit
kernels.
* src/abg-dwarf-reader.cc (maybe_adjust_sym_address_from_v4_19_ksymtab):
treat passed addr as 32bit signed offset in case of v4.19+ __ksymtabs
Signed-off-by: Matthias Maennich <maennich@google.com>
---
src/abg-dwarf-reader.cc | 18 ++----------------
1 file changed, 2 insertions(+), 16 deletions(-)
diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
index 107cd6d90008..08840b577d65 100644
--- a/src/abg-dwarf-reader.cc
+++ b/src/abg-dwarf-reader.cc
@@ -7671,24 +7671,10 @@ public:
if (get_ksymtab_format() == V4_19_KSYMTAB_FORMAT)
{
+ int32_t offset = addr;
GElf_Shdr mem;
GElf_Shdr *section_header = gelf_getshdr(ksymtab_section, &mem);
- if (architecture_word_size() == 4)
- result = (uint32_t)(addr + section_header->sh_addr + addr_offset);
- else if (architecture_word_size() == 8)
- {
- result = addr + section_header->sh_addr + addr_offset;
- if (result < ((uint64_t)1 << 32))
- // The symbol address is expressed in 32 bits. So let's
- // convert it to a 64 bits address with the 4 most
- // significant bytes set to ff each. This is how 64
- // bits addresses of symbols are in the .symbol section,
- // so we need this address to be consistent with that
- // format.
- result = ((uint64_t)0xffffffff << 32) | result;
- }
- else
- ABG_ASSERT_NOT_REACHED;
+ result = offset + section_header->sh_addr + addr_offset;
}
return result;
--
2.21.0.1020.gf2820cf01a-goog