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.
/* shell process begin here */
int main()
{
char *promt = "sh:#";
int i;
write("\x1B[2J", strlen("\x1B[2J"));
while(1)
{
/*strcpy(text,"hallo ^1");*/
write(promt, strlen(promt));
readline(command);
if(execve(command, 0) < 0)
write(command, strlen(command));
for(i=0; i< 100; i++)
command[i] = '\0';
}
return 0;
}
this a part from small shell whish OS execute it (loaded from floppy). with this shell I can run programs. until now I have test small program and executed the shell it self.
now see the problem. when I have change the Message of promt to (Enter Your Name), it crash with page fault.
look only the message has been change my OS crash.
Have you some suggestion about how to improve my OS Code?
how exactly do you 'change' the prompt ? you know that as you programmed it, prompt is pointing towards a supposed-constant string within the .text (or .data) section ...
can you find the message in the final binary image (e.g. does the linker include *all* what it should) ? did you made sure the loader loaded the *whole* file into memory ?
If both answer are positive, i fear you'll have to search for uninitialized pointers or things like that somewhere in your code. If possible, use BOCHS to locate the faulty instruction ...
Before touching anything in the source, take a snapshot of your working directory to make sure you can understand how the bug disappeared if you make it disappear "magically".
can you find the message in the final binary image (e.g. does the linker include *all* what it should) ? did you made sure the loader loaded the *whole* file into memory ?
your are correct about that. my linker did not copy all things, the code which indicate page fault, is not a part of the real code of the program. it's address is inside the code segment but the instruction is not like which one in the program code. I have notice that with the bochsdbg. Code Segment did not copyed correctly.
but the question why only this prgramm case problem?. I could load the first prgramm 10 times without problem.
there may be various reasons, all coming from a hackish-way to write the linker script. Under linux/ELF for instance, small strings and long strings do not go to the same .rodata section. If you didn't include .rodata*, it may play tricks on you...
the program has 2 program header, the first PH include text and rodata. the rodata size is exactly the size of string.
the second PH is the BSS. and my linker see those 2 PH and give the correct size, address equal with which I have readed from command "readelf".
as I said before, the Code segment are not equal with the real code of my program ( when diassembled it). as I use bochsdbg and I run the program step by step. As I reached the point of calling strlen and jump to the address of strlen, there the instruction is not correct. it seems that code for strlen does not exist!!!!
note that I do not use any library, the strlen is build in the program as function.
could it be that the loader missed parts of your code ? that's unlikely if you use something like GRUB, but damn common with MyOwnBootLoader, unfortunately ... make sure everything is in place (using a checksum could be nice)