loaders: Record CU's endianness in dwarf/btf/ctf loaders
This patch records for each CU whether it's in little-endian or big-endian data format. This flag will be used in subsequent commits to adjust bit offsets where necessary, to make them uniform across endianness. This patch doesn't have any effect on pahole's output. Signed-off-by: Andrii Nakryiko <andriin@fb.com> Cc: Alexei Starovoitov <ast@fb.com> Cc: Mark Wielaard <mark@klomp.org> Cc: Martin KaFai Lau <kafai@fb.com> Cc: Yonghong Song <yhs@fb.com> Cc: dwarves@vger.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
975757bc88
commit
5104d1bef3
|
@ -538,6 +538,7 @@ int btf_elf__load_file(struct cus *cus, struct conf_load *conf, const char *file
|
|||
|
||||
cu->language = LANG_C;
|
||||
cu->uses_global_strings = false;
|
||||
cu->little_endian = !btfe->is_big_endian;
|
||||
cu->dfops = &btf_elf__ops;
|
||||
cu->priv = btfe;
|
||||
btfe->priv = cu;
|
||||
|
|
|
@ -734,6 +734,7 @@ int ctf__load_file(struct cus *cus, struct conf_load *conf,
|
|||
|
||||
cu->language = LANG_C;
|
||||
cu->uses_global_strings = false;
|
||||
cu->little_endian = state->ehdr.e_ident[EI_DATA] == ELFDATA2LSB;
|
||||
cu->dfops = &ctf__ops;
|
||||
cu->priv = state;
|
||||
state->priv = cu;
|
||||
|
|
|
@ -2243,6 +2243,12 @@ static int cus__load_debug_types(struct cus *cus, struct conf_load *conf,
|
|||
cu->extra_dbg_info = conf ? conf->extra_dbg_info : 0;
|
||||
cu->has_addr_info = conf ? conf->get_addr_info : 0;
|
||||
|
||||
GElf_Ehdr ehdr;
|
||||
if (gelf_getehdr(elf, &ehdr) == NULL) {
|
||||
return DWARF_CB_ABORT;
|
||||
}
|
||||
cu->little_endian = ehdr.e_ident[EI_DATA] == ELFDATA2LSB;
|
||||
|
||||
dwarf_cu__init(dcup);
|
||||
dcup->cu = cu;
|
||||
/* Funny hack. */
|
||||
|
@ -2324,6 +2330,12 @@ static int cus__load_module(struct cus *cus, struct conf_load *conf,
|
|||
cu->extra_dbg_info = conf ? conf->extra_dbg_info : 0;
|
||||
cu->has_addr_info = conf ? conf->get_addr_info : 0;
|
||||
|
||||
GElf_Ehdr ehdr;
|
||||
if (gelf_getehdr(elf, &ehdr) == NULL) {
|
||||
return DWARF_CB_ABORT;
|
||||
}
|
||||
cu->little_endian = ehdr.e_ident[EI_DATA] == ELFDATA2LSB;
|
||||
|
||||
struct dwarf_cu dcu;
|
||||
|
||||
dwarf_cu__init(&dcu);
|
||||
|
|
Loading…
Reference in New Issue