Help with confusing C code in loader?

Matthew Dillon dillon at apollo.backplane.com
Sun Jul 29 17:43:26 PDT 2007


:I'm trying to debug a problem in /boot/loader but I'm stumped by
:this line in sys/boot/common/module.c:
:
:error = (file_formats[i]->l_load)(filename, loadaddr, &fp);
:
:This seems to refer to a line in common/bootstrap.h:
:
:int (* l_load)(char *filename, u_int64_t dest, struct preloaded_file **result);
:
:And that's where I lose the thread.  I can't figure out what the
:(* l_load) means because 'l_load' doesn't seem to be defined in
:any obvious place.
:
:Any clues most welcome.

     extern struct file_format   *file_formats[];

     file_formats[] is an array of pointers to a structure.  Each supported
     file format has its own structure.

     The file_format structure is defined somewhere, not sure.  But the
     jist is that each individual format supported creates a file_format
     structure, e.g. /usr/src/sys/boot/pc32/libi386/elf32_freebsd.c line
     44.  A pointer to the structure is installed in the file_formats[]
     array so the loader can iterate through the various load formats
     supported.

     The actual function being called is supplied by the individual 
     loaders (see same file above, a pointer to elf32_loadfile() is
     loaded into the file_format structure).  The code you are
     referencing is what calls through to that function.

     The l_load declration you found is not specifically related.

					-Matt
					Matthew Dillon 
					<dillon at backplane.com>





More information about the Users mailing list