compile programs in standalone mode

Previous thread: Re: Weird pkg_info behavior? by Stuart Henderson on Wednesday, October 1, 2008 - 5:25 am. (3 messages)

Next thread: New tcp stack attack by Leon Dippenaar on Wednesday, October 1, 2008 - 8:52 am. (18 messages)
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 thread: Re: Weird pkg_info behavior? by Stuart Henderson on Wednesday, October 1, 2008 - 5:25 am. (3 messages)

Next thread: New tcp stack attack by Leon Dippenaar on Wednesday, October 1, 2008 - 8:52 am. (18 messages)