compile programs in standalone mode

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <misc@...>
Date: Wednesday, October 1, 2008 - 7:25 am

Hi,

int main()
{
int i;
short int *screen = (short int *) 0xB8000;
char msg[]="Hello World";

for(i=0; msg[i] != '\0'; *(screen++) = 0x1F00 | msg[i], ++i);
for(;;);
return 0;
}

When i compiled i got a very big main.bin file more then 960MByte, so i
tried to change the char vector with only a char and it works fine. I
think the problem was the buffer overflow protector system that take the
.nodata segment in other address, or something like that... (readelf -S
main)

So how can i use the char vector in my programs and build them in standalone
mode?

int main()
{
int i;
short int *screen = (short int *) 0xB8000;
char msg = 'H';

*screen = 0x1F00 | msg;
for(;;);
return 0;
}

gcc -c main.c -o main.o -fno-stack-protector -ffreestand
ld main.o -e main -Ttext 0x1000 -o main
objcopy -R .comment -R .note -S -O binary main main.bin

Regards

-Alex-

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
compile programs in standalone mode, amm, (Wed Oct 1, 7:25 am)