Help with confusing C code in loader?

Matt Emmerton matt at gsicomp.on.ca
Sun Jul 29 19:23:24 PDT 2007


"walt" <wa1ter at myrealbox.com> wrote in message
Pine.NEB.4.64.0707291702560.890 at x9.ybpnyarg">news:Pine.NEB.4.64.0707291702560.890 at x9.ybpnyarg...
> 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.





More information about the Users mailing list