Hi Sami, really forgot these two FIXMEs should be probably dealt with. On Tue, 23 Nov 2010 17:27:36 +0100, sami wagiaalla wrote: > +/* Locate NT_GNU_BUILD_ID and return its matching debug filename. > + FIXME: NOTE decoding should be unified with the BFD core notes decoding. */ [...] > +static void > +elf_swap_ehdr_in (bfd *abfd, > + const Elf64_External_Ehdr *src64, > + Elf_Internal_Ehdr *dst) > +{ > + int is64 = bfd_get_arch_size (abfd) == 64; > +#define SRC(field) (is64 ? src64->field \ > + : ((const Elf32_External_Ehdr *) src64)->field) > + > + int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma; > + memcpy (dst->e_ident, SRC (e_ident), EI_NIDENT); > + dst->e_type = H_GET_16 (abfd, SRC (e_type)); > + dst->e_machine = H_GET_16 (abfd, SRC (e_machine)); > + dst->e_version = H_GET_32 (abfd, SRC (e_version)); > + if (signed_vma) > + dst->e_entry = H_GET_SIGNED_WORD (abfd, SRC (e_entry)); > + else > + dst->e_entry = H_GET_WORD (abfd, SRC (e_entry)); > + dst->e_phoff = H_GET_WORD (abfd, SRC (e_phoff)); > + dst->e_shoff = H_GET_WORD (abfd, SRC (e_shoff)); > + dst->e_flags = H_GET_32 (abfd, SRC (e_flags)); > + dst->e_ehsize = H_GET_16 (abfd, SRC (e_ehsize)); > + dst->e_phentsize = H_GET_16 (abfd, SRC (e_phentsize)); > + dst->e_phnum = H_GET_16 (abfd, SRC (e_phnum)); > + dst->e_shentsize = H_GET_16 (abfd, SRC (e_shentsize)); > + dst->e_shnum = H_GET_16 (abfd, SRC (e_shnum)); > + dst->e_shstrndx = H_GET_16 (abfd, SRC (e_shstrndx)); > + > +#undef SRC > +} The code like this one is copy-pasted from bfd/elfcode.h . This is apparently wrong and the FIXME tries to address this. OTOH I had a first version [attached] which was really trying to apply bfd/ to any functionality and it was probably also wrong. ELF is not so complicated it would always make sense to bend over backwards any piece of bfd/ for any ELF functionality GDB needs. I cannot say offhand how much it should be merged with bfd/ but it seems to me it should be merged a bit more, the copy-pasting is too obvious now. > +/* BUILD_ID_ADDR_GET gets ADDR located somewhere in the object. > + Find the first section before ADDR containing an ELF header. > + We rely on the fact the sections from multiple files do not mix. > + FIXME: We should check ADDR is contained _inside_ the section with possibly > + missing content (P_FILESZ < P_MEMSZ). These omitted sections are currently > + hidden by _BFD_ELF_MAKE_SECTION_FROM_PHDR. */ When you dump a core each segment can have now three kinds of dump: /usr/share/doc/kernel-doc-*/Documentation/filesystems/proc.txt - (bit 3) file-backed shared memory - (bit 4) ELF header pages in file-backed private memory areas (it is effective only if the bit 2 is cleared) echo 0x7f >/proc/self/coredump_filter Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x001000 0x0000000000400000 0x0000000000000000 0x0d5000 0x0d5000 R E 0x1000 ^^^^^^^^ echo 0x00 >/proc/self/coredump_filter Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x001000 0x0000000000400000 0x0000000000000000 0x000000 0x0d5000 R E 0x1000 ^^^^^^^^ echo 0x33 >/proc/self/coredump_filter # default Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x001000 0x0000000000400000 0x0000000000000000 0x001000 0x0d5000 R E 0x1000 ^^^^^^^^ bfd/ generates virtual sections (asection) from these segments, for some (or only the last? _bfd_elf_make_section_from_phdr ) cases two sections are generated. If the code chooses the wrong of two sections covering that same memory range it may miss the build-id content as it may be in the other section. Also it may check even < and not just the >= condition to avoid possibly false build-ids (it may not be needed, but not sure why it is not now). Thanks, Jan