problem to compile with -fno-stack-protector

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

problem to compile with -fno-stack-protector

alemus
Hi,

I tried to compile a simple program written in C with -fno-stack-protector
option and i have some troubles...

this is my simple file main.c:

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;
}

and these are my commands:

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

I have gcc #version# default in OpenBSD 4.3

After compiled i got a very big main.bin about 10MByte... and this is very
strange

I don't know how to solve this problem.

Regards

-- Alex --

Reply | Threaded
Open this post in threaded view
|

Re: problem to compile with -fno-stack-protector

David Higgs
On Wed, Sep 24, 2008 at 8:59 AM, alemus <[hidden email]> wrote:

> Hi,
>
> I tried to compile a simple program written in C with -fno-stack-protector
> option and i have some troubles...
>
> this is my simple file main.c:
>
> 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;
> }
>
> and these are my commands:
>
> gcc -c main.c -o main.o -fno-stack-protector
> ld main.o -e main -Ttext 0x1000 -o main
> objcopy -R .comment -R .note -S -O binary main main.bin
>
> I have gcc #version# default in OpenBSD 4.3
>
> After compiled i got a very big main.bin about 10MByte... and this is very
> strange
>
> I don't know how to solve this problem.
>
> Regards
>
> -- Alex --

The programs you ran did everything you asked without error.  Your
main.bin is probably more like 960MB, since the many sections are
still located at 0x3c000000.

readelf -S main

Good luck.

--david