Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
I have implement my bootloader and then decide to implement a simple kernel just writes classical world message on screen. But I havent implement my memory manager functions such as malloc.., yet.
But, although Im sure that my print function works well, it prints nonsense characters on screen. May I have to implement my memory allocation functions and use pointers and allocate memory for them? (Im using gcc)
how does the declaration of your print-function look like?
Are you sure you pass the correct parameters to your print-function? Usually, printf (as I know it), expects one string literal and a parameterlist of variable length. (p.ex. printf("amount: %d, lot: %d, dest: %s",amount,lot,dest);)
i would suggest you to get a look at your binary file and make sure the "Hello World" string hasn't been dropped due to a bad link script (i.e. strings kernel.bin if you're under linux)
It's very likely that you're missing .rodata or something alike when creating your final kernel binary. Omitting character attributes may lead to no display (if the older attribute was 00 (black on black)), but not in garbage display.
.rodata?? I used to use tcc,tlink,tasm before. Im new to gcc, ld and nasm. If someone help if it is a parameter(.rodata), Ill be happy.(ld dont have help)
Zottur Zibop wrote:
ables I use your script. But it gives an error:
target elf32-i386 not found
so your compiler don't support for ELF, which makes the link script unappropriated as COFF doesn't support .rodata and put strings in .text section.
i don't know how you get your kernel loaded, but one thing is sure : if you just assume it starts at address 0 (**hack**), having the string first will make the string executed, which is unlikely to work well ...
"but what ? i said entry = _main" will you say.
true. Which makes the COFF file store this information, but if you don't use it to jump to CODESELECTOR:_main rather than CODESELECTOR:<start_of_kernel_image>, it's pretty useless ...
Pype, Im using last version of Nasm.doesnt it support elf format??(I dont know)
And you are right. I start at addr 0 of my kernel and as I thought and you said, it execute the string first. What Im trying to do is to prevent this.
By the way, I think the problem is not using an asm entry for my kernel. (My kernel is completely written in C). And if I dont remember wrong, I read an article which advises to code an asm-kernel first and than jmp to c kernel. I think I can overcome my problem by an asm-kernel jmping to c-kernel...Ill try....
NASM supports for ELF since a long time ago ... i dunno why you talk about nasm, anyway. You're facing a *linking* problem: the linker doesn't recognize ELF output format. nasm has nothing to do with this ...
there's no "absolute best format". Both have pros and cons, but as ELF is now supported by DJGPP and CYGWIN (through optionnal binaries or objcopy) while there's no COFF support for Linux (afaik), using ELF is probably more portable, and will open you the gates of GRUB.
The only thing i would not recommend is A.OUT -- iirc, it has no dynamic shared libraries support -- except for very early stages (for instance, your kernel would nicely fit an a.out that could easily be loaded by a small bootloader