"walt" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 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.

l_load is a function pointer, and a member of struct file_formats, which is
declared "extern struct file_format *file_formats[]" in common/bootstrap.h.
The comments say that this structure is provided by the consumer, so more
digging is required.

sys/boot/ARCH/loader/conf.c appears to be the "consumer", as each defines
*file_formats[].

In the ARCH=pc32 case, the array contains pointers to two file formats:
i386_elf and amd64_elf.  These are declared extern, so their definitions
reside somewhere else.  Yet more digging.

These two are defined in sys/boot/pc32/libi3864/elf32_freebsd.c and
elf64_freebsd.c.

>From these structure defs, they are implicitly initialized, so the l_load
function pointer (which isn't explicitly mentioned!) is either
elf32_loadfile or elf64_loadfile, depending on whether you're looking at
i386_elf or amd64_elf.

So where is *_loadfile implemented?  I don't know. This is where I lost the
thread.

HTH,
--
Matt Emmerton


Reply via email to