Hello, I was browsing the code for memdisk (I want to adjust it to my hardware) and noticed a couple of things that I am struggling to understand. I would appreciate if someone could clarify the following mysteries to me: 1) _binary_memdisk_bin_start[], _binary_memdisk_bin_end[] and _binary_memdisk_bin_size[]; These variables are declared (as extern const chat in 'setup.c') but never defined in the code. Yet, it seems that somehow they are initialized with the size and start address of memdisk. How can it be? 2) What is driverptr (declared in setup())? It is defined as driverptr = driverseg << 16; Why is it shifted by 16-bits? Thanks. Best regards, Alex
Hallo, some wild guesses which may help you right now and may be clarified by hpa later on: * Loginov Alexander <aloginov at asmpt.com> [20080618 08:11]:> 1) _binary_memdisk_bin_start[], _binary_memdisk_bin_end[] and > _binary_memdisk_bin_size[]; These variables are declared (as extern > const chat in 'setup.c') but never defined in the code. Yet, it seems > that somehow they are initialized with the size and start address of > memdisk. How can it be?most likely, the linker does that ... have a look at the linker script and what happens in that area :)> 2) What is driverptr (declared in setup())? It is defined as > driverptr = driverseg << 16; Why is it shifted by 16-bits?no idea what it is, but name and shifting seem to be related to http://en.wikipedia.org/wiki/X86_memory_segmentation Hope that helps you for the moment ... Andreas -- flatline IT services - A.Kotes - IT-consulting for ISPs & Internet services
Loginov Alexander wrote:> > 1) _binary_memdisk_bin_start[], _binary_memdisk_bin_end[] and > _binary_memdisk_bin_size[]; These variables are declared (as extern > const chat in 'setup.c') but never defined in the code. Yet, it seems > that somehow they are initialized with the size and start address of > memdisk. How can it be? >GNU ld can convert a binary file to an object file (.o), and then it automatically create those symbols assuming that the original file was named memdisk.bin. -hpa