Messages in this thread | | | Date | Tue, 9 Nov 1999 09:07:06 +0000 (GMT) | From | Tigran Aivazian <> | Subject | Re: [patch-2.3.27-pre2] /proc/kcore with segment per module. |
| |
actually, there is one mistake there - the loop walking through module list should be isnide #ifdef CONFIG_MODULES.
On Tue, 9 Nov 1999, Tigran Aivazian wrote:
> Hi David, > > Today I have implemented your idea of having > per-module segment in the ELF /proc/kcore file. Here is the patch for > yours and everyone else's review. > If you are happy with it, I will send it to Linus. Tested on i386 > architecture both with and without modules. I retained the > get_kcore_size() thing as it is a nice indication of the file size. > > http://www.ocston.org/~tigran/patches/kcore-2.3.27a.patch > > regards, > ------ > Tigran A. Aivazian | http://www.sco.com > Escalations Research Group | tel: +44-(0)1923-813796 > Santa Cruz Operation Ltd | http://www.ocston.org/~tigran > > PS. Some idiot (probably commercial spam) tried to send a fax to my phone > at 2am so that woke me up and I couldn't sleep so I had to hack the kernel > a little bit :) > > diff -urN -X dontdiff linux/fs/proc/kcore.c 2327-p2-kcore/fs/proc/kcore.c > --- linux/fs/proc/kcore.c Tue Nov 9 08:34:43 1999 > +++ 2327-p2-kcore/fs/proc/kcore.c Tue Nov 9 09:32:14 1999 > @@ -143,7 +143,7 @@ > * store an ELF coredump header in the supplied buffer > * - assume the memory image is the size specified > */ > -static void elf_kcore_store_hdr(char *bufp, size_t size, off_t dataoff) > +static void elf_kcore_store_hdr(char *bufp) > { > struct elf_prstatus prstatus; /* NT_PRSTATUS */ > struct elf_prpsinfo psinfo; /* NT_PRPSINFO */ > @@ -151,68 +151,85 @@ > struct elfhdr *elf; > struct memelfnote notes[3]; > off_t offset = 0; > + struct module *m; > > /* acquire an ELF header block from the buffer */ > elf = (struct elfhdr *) bufp; > - bufp += sizeof(*elf); > - offset += sizeof(*elf); > + bufp += sizeof(struct elfhdr); > + offset += sizeof(struct elfhdr); > > /* set up header */ > memcpy(elf->e_ident,ELFMAG,SELFMAG); > elf->e_ident[EI_CLASS] = ELF_CLASS; > elf->e_ident[EI_DATA] = ELF_DATA; > elf->e_ident[EI_VERSION]= EV_CURRENT; > - memset(elf->e_ident+EI_PAD,0,EI_NIDENT-EI_PAD); > + memset(elf->e_ident+EI_PAD, 0, EI_NIDENT-EI_PAD); > > elf->e_type = ET_CORE; > elf->e_machine = ELF_ARCH; > elf->e_version = EV_CURRENT; > elf->e_entry = 0; > - elf->e_phoff = sizeof(*elf); > + elf->e_phoff = sizeof(struct elfhdr); > elf->e_shoff = 0; > elf->e_flags = 0; > - elf->e_ehsize = sizeof(*elf); > + elf->e_ehsize = sizeof(struct elfhdr); > elf->e_phentsize= sizeof(struct elf_phdr); > - elf->e_phnum = 2; /* no. of segments */ > + elf->e_phnum = 1; /* no. of segments = 1 + Nmodules */ > elf->e_shentsize= 0; > elf->e_shnum = 0; > elf->e_shstrndx = 0; > > /* acquire an ELF program header blocks from the buffer for notes */ > nhdr = (struct elf_phdr *) bufp; > - bufp += sizeof(*nhdr); > - offset += sizeof(*nhdr); > + bufp += sizeof(struct elf_phdr); > + offset += sizeof(struct elf_phdr); > > /* store program headers for notes dump */ > nhdr->p_type = PT_NOTE; > nhdr->p_offset = 0; > nhdr->p_vaddr = 0; > nhdr->p_paddr = 0; > + nhdr->p_filesz = 0; > nhdr->p_memsz = 0; > nhdr->p_flags = 0; > nhdr->p_align = 0; > > /* acquire an ELF program header blocks from the buffer for data */ > dhdr = (struct elf_phdr *) bufp; > - bufp += sizeof(*dhdr); > - offset += sizeof(*dhdr); > + bufp += sizeof(struct elf_phdr); > + offset += sizeof(struct elf_phdr); > > /* store program headers for data dump */ > dhdr->p_type = PT_LOAD; > dhdr->p_flags = PF_R|PF_W|PF_X; > - dhdr->p_offset = dataoff; > + dhdr->p_offset = PAGE_SIZE; > dhdr->p_vaddr = PAGE_OFFSET; > dhdr->p_paddr = __pa(PAGE_OFFSET); > - dhdr->p_filesz = size; > - dhdr->p_memsz = size; > + dhdr->p_filesz = ((unsigned long)high_memory - PAGE_OFFSET + PAGE_SIZE); > + dhdr->p_memsz = ((unsigned long)high_memory - PAGE_OFFSET + PAGE_SIZE); > dhdr->p_align = PAGE_SIZE; > > + for (m=module_list; m; m=m->next) { > + dhdr = (struct elf_phdr *) bufp; > + bufp += sizeof(struct elf_phdr); > + offset += sizeof(struct elf_phdr); > + > + dhdr->p_type = PT_LOAD; > + dhdr->p_flags = PF_R|PF_W|PF_X; > + dhdr->p_offset = (unsigned long)m - PAGE_OFFSET + PAGE_SIZE; > + dhdr->p_vaddr = (unsigned long)m; > + dhdr->p_paddr = __pa(m); > + dhdr->p_filesz = m->size; > + dhdr->p_memsz = m->size; > + dhdr->p_align = 0; > + elf->e_phnum++; > + } > + > /* > * Set up the notes in similar form to SVR4 core dumps made > * with info from their /proc. > */ > nhdr->p_offset = offset; > - nhdr->p_filesz = 0; > > /* set up the process status */ > notes[0].name = "CORE"; > @@ -289,7 +306,7 @@ > > /* create a header */ > memset(page,0,PAGE_SIZE); > - elf_kcore_store_hdr(page,size-PAGE_SIZE,PAGE_SIZE); > + elf_kcore_store_hdr(page); > > /* copy data to the users buffer */ > copy_to_user(buffer,page,tsz); > > >
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |