Bug 24431 Treat __ksymtab as int32_t for v4.19+ kernels
authormaennich@google.com <maennich@google.com>
Fri, 10 May 2019 01:00:41 +0000 (02:00 +0100)
committerDodji Seketeli <dodji@redhat.com>
Fri, 10 May 2019 05:34:45 +0000 (07:34 +0200)
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

index 5396c9b6f5154f46653524da9385cd5b6abd3e2e..cd39fc391849871672257b3e18bf508d4d00b8eb 100644 (file)
@@ -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;