From acfcea3ef28b412636eb2a89237daeb831c27834 Mon Sep 17 00:00:00 2001 From: Matthias Maennich Date: Wed, 13 Nov 2019 15:09:17 +0000 Subject: [PATCH] dwarf-reader: relax restriction about relocation sections in try_reading_first_ksymtab_entry Commit 43679a610316 ("dwarf-reader: refactor try_reading_first_ksymtab_entry_using{pre,}_v4_19_format") introduced an assertion to ensure the absence of ksymtab relocation sections as they are an unhandled case for try_reading_first_ksymtab_entry. This assertion turns out to be too strict as relocation sections might be present (e.g. on x86_64), but not affecting the functionality of this function (i.e. helping to detect the ksymtab format). Hence, remove the assertion and document that case. * src/abg-dwarf-reader.cc (try_reading_first_ksymtab_entry): remove assertion and update documentation Fixes: 43679a610316 ("dwarf-reader: refactor try_reading_first_ksymtab_entry_using{pre,}_v4_19_format") Reviewed-by: Dodji Seketeli Signed-off-by: Matthias Maennich --- src/abg-dwarf-reader.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index bb1ffc1c..d3efb02a 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -7632,10 +7632,15 @@ public: /// the section designated by @p section contains position-relative /// relocated symbol addresses. /// - ///@param symbol_offset if different from zero + /// @param symbol_offset if different from zero /// If symbol_offset is != 0, adjust the position we consider the section /// start. That is useful to read the ksymtab with a slight offset. /// + /// Note, this function does not support relocatable ksymtab entries (as for + /// example in kernel modules). Using this function for ksymtabs where + /// relocations need to be applied for the entries we are reading here, will + /// yield wrong results. + /// /// @return the symbol resulting from the lookup of the symbol address we /// got from reading the first entry of the ksymtab or null if no such entry /// could be found. @@ -7644,12 +7649,6 @@ public: bool position_relative_relocations, int symbol_offset = 0) const { - // this function does not support relocatable ksymtab entries (as for - // example in kernel modules). Hence assert here on not having any - // relocation sections around. We can consider this a TODO that we have to - // work around in the rest of the code. - ABG_ASSERT(!find_any_ksymtab_reloc_section()); - Elf_Data* elf_data = elf_rawdata(section, 0); uint8_t* bytes = reinterpret_cast(elf_data->d_buf); bool is_big_endian = elf_architecture_is_big_endian(); -- 2.34.1