Re: Module sections Query

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Asim <linkasim@...>
Cc: kernelnewbies@nl.linux.org <kernelnewbies@...>
Date: Monday, August 18, 2008 - 3:39 am

Looking at kernel/module.c:load_module():

To know that u can see how load_module() identify each section by name:

        exportindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab");
        gplindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab_gpl");
        gplfutureindex = find_sec(hdr, sechdrs, secstrings,
"__ksymtab_gpl_future");
        unusedindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab_unused");
        unusedgplindex = find_sec(hdr, sechdrs, secstrings,
"__ksymtab_unused_gpl");


What u said is correct.   U can see how load_module() load each
section into memory (from file image) in the following extraction
(look at the memcp() statement - both the start of memory, and size is
indicated).


        /* Transfer each section which specifies SHF_ALLOC */
        DEBUGP("final section addresses:\n");
        for (i = 0; i < hdr->e_shnum; i++) {
                void *dest;

                if (!(sechdrs[i].sh_flags & SHF_ALLOC))
                        continue;

                if (sechdrs[i].sh_entsize & INIT_OFFSET_MASK)
                        dest = mod->module_init
                                + (sechdrs[i].sh_entsize & ~INIT_OFFSET_MASK);
                else
                        dest = mod->module_core + sechdrs[i].sh_entsize;

                if (sechdrs[i].sh_type != SHT_NOBITS)
                        memcpy(dest, (void *)sechdrs[i].sh_addr,

sechdrs[i].sh_size);==============>>>>this is the heart of section
loading.
                /* Update sh_addr to point to copy in image. */
                sechdrs[i].sh_addr = (unsigned long)dest;
                DEBUGP("\t0x%lx %s\n", sechdrs[i].sh_addr, secstrings
+ sechdrs[i].sh_name);
        }





-- 
Regards,
Peter Teoh

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Module sections Query, Asim, (Fri Aug 1, 3:24 pm)
Re: Module sections Query, Peter Teoh, (Fri Aug 1, 8:58 pm)
Re: Module sections Query, Asim, (Sun Aug 17, 11:46 am)
Re: Module sections Query, Peter Teoh, (Mon Aug 18, 3:39 am)
Re: Module sections Query, Asim, (Mon Aug 18, 11:41 am)
Re: Module sections Query, Sandeep K Sinha, (Fri Aug 1, 4:00 pm)
Re: Module sections Query, Asim, (Fri Aug 1, 4:32 pm)
Re: Module sections Query, Sandeep K Sinha, (Fri Aug 1, 5:43 pm)