[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Fix reading of relocation sections when endianness mismatches



Hello,

When the endianness of the ELF binary differs from the endianness of
the host, some byte swapping needs to happen when we read the reloc
section to either determine the format of the kernel symbol table or
to get the set of symbols referenced by the kernel symbol table.

So we need to use elf_getdata rather than elf_rawdata to read the data
from the reloc section, because the former handles the proper byte
swapping for us.

This patch does just that and thus fixes the build breakage that is
occuring when running the testreaddwarf test on s390x (big endian),
especially when trying to read the AARCH64 little endian binary
data/test-read-dwarf/PR25007-sdhci.ko.

The patch fixes the build breakage on s390x.

Applied to master.

	* src/abg-dwarf-reader.cc
	(read_context::{get_ksymtab_format_module,
	populate_symbol_map_from_ksymtab_reloc}): Use elf_getdata rather
	than elf_rawdata.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
---
 src/abg-dwarf-reader.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
index dbac01b..1e6d801 100644
--- a/src/abg-dwarf-reader.cc
+++ b/src/abg-dwarf-reader.cc
@@ -7676,8 +7676,8 @@ public:
     // what format the ksymtab is in depending on what types of relocs it
     // contains.
 
-    int type;
-    Elf_Data *section_data = elf_rawdata(section, 0);
+    uint64_t type;
+    Elf_Data *section_data = elf_getdata(section, 0);
     if (is_relasec)
       {
 	GElf_Rela rela;
@@ -7977,7 +7977,7 @@ public:
     size_t reloc_count =
       reloc_section_shdr->sh_size / reloc_section_shdr->sh_entsize;
 
-    Elf_Data *reloc_section_data = elf_rawdata(reloc_section, 0);
+    Elf_Data *reloc_section_data = elf_getdata(reloc_section, 0);
 
     bool is_relasec = (reloc_section_shdr->sh_type == SHT_RELA);
     elf_symbol_sptr symbol;
-- 
1.8.3.1


-- 
		Dodji