From: Peng F. <van...@gm...> - 2013-07-01 02:42:00
|
Hi, I am trying to use elftoolchain to handle arm elf object files. But I always get error when handling ".ARM.attributes, .ARM.exidx , .ARM.extab " sections. I traced the source code and found that it fails at elf_data.c line 93. The following is a piece of code. if ((elftype = _libelf_xlate_shtype(sh_type)) < ELF_T_FIRST || elftype > ELF_T_LAST || (sh_type != SHT_NOBITS && sh_offset + sh_size > (uint64_t) e->e_rawsize)) { LIBELF_SET_ERROR(SECTION, 0); return (NULL); } The .ARM.* sections are specific to ARM and the _libelf_xlate_shtype function does not handle such arch specific sections. I have a question about how to add support for arch specific sections, not only to arm, but also other archs. I added the following code before invoke _libelf_xlate_shtype to handle arm specific sections, but I am not sure whether this is the right way. * if (s->s_elf->e_u.e_elf.e_ehdr.e_ehdr32->e_machine == EM_ARM) {* * if ((sh_type == 0x70000003) || (sh_type == 0x70000001)) {* * if ((d = _libelf_allocate_data(s)) == NULL) * * return (NULL);* * d->d_buf = 0;* * d->d_size = 0;* * return (d);* * }* * }* if ((elftype = _libelf_xlate_shtype(sh_type)) < ELF_T_FIRST || Thanks very much. Regards, Peng |