public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* how to set some value at a memory location in stack
@ 2010-04-13  6:20 Vaibhav Shrimali
  2010-04-14  0:21 ` Ian Lance Taylor
  0 siblings, 1 reply; 16+ messages in thread
From: Vaibhav Shrimali @ 2010-04-13  6:20 UTC (permalink / raw)
  To: gcc-help

I wanted to know : how to set some value at a particular memory
location on the stack.
Suppose I want to set a value stored in a rtx type variable to a
memory location.
Is the following code correct?
I need to read a particular memory location, then XOR it with the hard
frame pointer and then store it back in its place.
will this code work?
Note: Here at (argument pointer - 8) location, I am pushing a copy of
return address earlier and after that the hard_frame_pointer is
pushed.
Now, I want to XOR the duplicate return address with the new
hard_frame_pointer_rtx generated after pushing the frame pointer on
the stack.
I wanted to know that will this code work to do the task?

      arg_ptr = cfun->machine->force_align_arg_pointer;
      r = gen_rtx_PLUS (Pmode, arg_ptr, -8);
      r = gen_rtx_MEM (Pmode, r);
      m = force_reg(Pmode,r);     // OR : m = copy_to_mode_reg(Pmode, r);
      m1 = simplify_binary_operation(XOR, Pmode, m, hard_frame_pointer_rtx);

      set1 = emit_insn(gen_rtx_SET (Pmode,r, m1));
      RTX_FRAME_RELATED_P (set1) = 1;


If not, please guide me with some solution that would allow me to
write a rtx variable value to a particular memory location.
Thank You
Waiting for an urgent reply from the community.
Thank You again.
Regards
-- 
Vaibhav Shrimali
BTech(ICT), DA-IICT
Gandhinagar

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: how to set some value at a memory location in stack
  2010-04-13  6:20 how to set some value at a memory location in stack Vaibhav Shrimali
@ 2010-04-14  0:21 ` Ian Lance Taylor
  2010-04-14  4:08   ` Vaibhav Shrimali
  0 siblings, 1 reply; 16+ messages in thread
From: Ian Lance Taylor @ 2010-04-14  0:21 UTC (permalink / raw)
  To: Vaibhav Shrimali; +Cc: gcc-help

Vaibhav Shrimali <vaibhav.shrimali@gmail.com> writes:

> I wanted to know : how to set some value at a particular memory
> location on the stack.
> Suppose I want to set a value stored in a rtx type variable to a
> memory location.
> Is the following code correct?
> I need to read a particular memory location, then XOR it with the hard
> frame pointer and then store it back in its place.
> will this code work?
> Note: Here at (argument pointer - 8) location, I am pushing a copy of
> return address earlier and after that the hard_frame_pointer is
> pushed.
> Now, I want to XOR the duplicate return address with the new
> hard_frame_pointer_rtx generated after pushing the frame pointer on
> the stack.
> I wanted to know that will this code work to do the task?
>
>       arg_ptr = cfun->machine->force_align_arg_pointer;
>       r = gen_rtx_PLUS (Pmode, arg_ptr, -8);
>       r = gen_rtx_MEM (Pmode, r);
>       m = force_reg(Pmode,r);     // OR : m = copy_to_mode_reg(Pmode, r);
>       m1 = simplify_binary_operation(XOR, Pmode, m, hard_frame_pointer_rtx);
>
>       set1 = emit_insn(gen_rtx_SET (Pmode,r, m1));
>       RTX_FRAME_RELATED_P (set1) = 1;
>
>
> If not, please guide me with some solution that would allow me to
> write a rtx variable value to a particular memory location.

I'm guessing that you are doing this after register allocation.  At
that point in the compilation you can no longer call force_reg, as
force_reg will try to create a new pseudo-register which will never
get allocated.  You have to pick a register to use instead.

If you are doing this before register allocation then it looks more or
less OK.  Does it work?

Ian

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: how to set some value at a memory location in stack
  2010-04-14  0:21 ` Ian Lance Taylor
@ 2010-04-14  4:08   ` Vaibhav Shrimali
  2010-04-14  5:10     ` Ian Lance Taylor
  0 siblings, 1 reply; 16+ messages in thread
From: Vaibhav Shrimali @ 2010-04-14  4:08 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

Ian, thanks for replying.
I am performing this task in the prologue in the section where the
hard frame pointer is pushed on the stack.
After that section comes the code:

  allocate = frame.to_allocate;

  if (!frame.save_regs_using_mov)
    ix86_emit_save_regs ();
  else
    allocate += frame.nregs * UNITS_PER_WORD;

here the space for the registers are allocated on the stack and I have
written my code before this one but I haven't allocated a register
specially for this task. So does this count?
If not, please tell me how and where can I allocate the register and
then use my code accordingly.
And by the way, the program is currently showing a segmentation fault
error which I am not able to solve.
I thought that there is some flaws in the code. If so please help me out.
Thank You


On Wed, Apr 14, 2010 at 5:50 AM, Ian Lance Taylor <iant@google.com> wrote:
> Vaibhav Shrimali <vaibhav.shrimali@gmail.com> writes:
>
>> I wanted to know : how to set some value at a particular memory
>> location on the stack.
>> Suppose I want to set a value stored in a rtx type variable to a
>> memory location.
>> Is the following code correct?
>> I need to read a particular memory location, then XOR it with the hard
>> frame pointer and then store it back in its place.
>> will this code work?
>> Note: Here at (argument pointer - 8) location, I am pushing a copy of
>> return address earlier and after that the hard_frame_pointer is
>> pushed.
>> Now, I want to XOR the duplicate return address with the new
>> hard_frame_pointer_rtx generated after pushing the frame pointer on
>> the stack.
>> I wanted to know that will this code work to do the task?
>>
>>       arg_ptr = cfun->machine->force_align_arg_pointer;
>>       r = gen_rtx_PLUS (Pmode, arg_ptr, -8);
>>       r = gen_rtx_MEM (Pmode, r);
>>       m = force_reg(Pmode,r);     // OR : m = copy_to_mode_reg(Pmode, r);
>>       m1 = simplify_binary_operation(XOR, Pmode, m, hard_frame_pointer_rtx);
>>
>>       set1 = emit_insn(gen_rtx_SET (Pmode,r, m1));
>>       RTX_FRAME_RELATED_P (set1) = 1;
>>
>>
>> If not, please guide me with some solution that would allow me to
>> write a rtx variable value to a particular memory location.
>
> I'm guessing that you are doing this after register allocation.  At
> that point in the compilation you can no longer call force_reg, as
> force_reg will try to create a new pseudo-register which will never
> get allocated.  You have to pick a register to use instead.
>
> If you are doing this before register allocation then it looks more or
> less OK.  Does it work?
>
> Ian
>



-- 
Vaibhav Shrimali
BTech(ICT), DA-IICT
Gandhinagar

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: how to set some value at a memory location in stack
  2010-04-14  4:08   ` Vaibhav Shrimali
@ 2010-04-14  5:10     ` Ian Lance Taylor
  2010-04-14 11:17       ` Vaibhav Shrimali
  0 siblings, 1 reply; 16+ messages in thread
From: Ian Lance Taylor @ 2010-04-14  5:10 UTC (permalink / raw)
  To: Vaibhav Shrimali; +Cc: gcc-help

Vaibhav Shrimali <vaibhav.shrimali@gmail.com> writes:

> I am performing this task in the prologue in the section where the
> hard frame pointer is pushed on the stack.

This is after register allocation, so you can not use force_reg.

> If not, please tell me how and where can I allocate the register and
> then use my code accordingly.

You have to figure out a hard register to use.  It should be safe to
use any call used register in the prologue, as long as it is not being
used for anything else in the prologue.  If you want this to be
generally useful, watch out for the regparm attribute.  The prologue
code is full of examples of using registers; read it and understand
what it is doing.

Ian

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: how to set some value at a memory location in stack
  2010-04-14  5:10     ` Ian Lance Taylor
@ 2010-04-14 11:17       ` Vaibhav Shrimali
  2010-04-14 15:53         ` Ian Lance Taylor
  0 siblings, 1 reply; 16+ messages in thread
From: Vaibhav Shrimali @ 2010-04-14 11:17 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

Ian I have one query.
I can use a hard register for this task. But will it allow me to
modify the memory location, between original return address and saved
frame pointer, stored in it?
I think it will be just saved in the "saved registers" area of stack.
The assembly conversion of the prologue I need is:

POP EAX		        ; new prologue start
PUSH EAX		; unencrypted return address
PUSH EAX		; duplicate return address
PUSH EBP		; standard prologue
MOVE EBP, ESP
XOR [EBP+4], EBP  	; [EBP+4] has EIP and XOR encryptes ret addr(EIP)

I want to know the function which allows me to write a value at a
memory address specified by a variable (generated by gen_rtx_MEM).
I thought force_reg is the one. Now, can I use ebx/ecx/...etc register
for the purpose.
OR will copy_to_mode_reg() function do the job?
OR is there any other function to do the job?


On Wed, Apr 14, 2010 at 10:40 AM, Ian Lance Taylor <iant@google.com> wrote:
> Vaibhav Shrimali <vaibhav.shrimali@gmail.com> writes:
>
>> I am performing this task in the prologue in the section where the
>> hard frame pointer is pushed on the stack.
>
> This is after register allocation, so you can not use force_reg.
>
>> If not, please tell me how and where can I allocate the register and
>> then use my code accordingly.
>
> You have to figure out a hard register to use.  It should be safe to
> use any call used register in the prologue, as long as it is not being
> used for anything else in the prologue.  If you want this to be
> generally useful, watch out for the regparm attribute.  The prologue
> code is full of examples of using registers; read it and understand
> what it is doing.
>
> Ian
>



-- 
Vaibhav Shrimali
BTech(ICT), DA-IICT
Gandhinagar

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: how to set some value at a memory location in stack
  2010-04-14 11:17       ` Vaibhav Shrimali
@ 2010-04-14 15:53         ` Ian Lance Taylor
  2010-04-15  4:57           ` Vaibhav Shrimali
  0 siblings, 1 reply; 16+ messages in thread
From: Ian Lance Taylor @ 2010-04-14 15:53 UTC (permalink / raw)
  To: Vaibhav Shrimali; +Cc: gcc-help

Vaibhav Shrimali <vaibhav.shrimali@gmail.com> writes:

> I can use a hard register for this task. But will it allow me to
> modify the memory location, between original return address and saved
> frame pointer, stored in it?

My point about the hard register was that you can't call force_reg
after register allocation.

> I think it will be just saved in the "saved registers" area of stack.
> The assembly conversion of the prologue I need is:
>
> POP EAX		        ; new prologue start
> PUSH EAX		; unencrypted return address
> PUSH EAX		; duplicate return address
> PUSH EBP		; standard prologue
> MOVE EBP, ESP
> XOR [EBP+4], EBP  	; [EBP+4] has EIP and XOR encryptes ret addr(EIP)
>
> I want to know the function which allows me to write a value at a
> memory address specified by a variable (generated by gen_rtx_MEM).
> I thought force_reg is the one. Now, can I use ebx/ecx/...etc register
> for the purpose.
> OR will copy_to_mode_reg() function do the job?
> OR is there any other function to do the job?

You need to copy your memory location into a register.  force_reg
copies it into a pseudo-register.  You need to copy it into a chosen
hard register.  Use emit_move_insn.

Ian

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: how to set some value at a memory location in stack
  2010-04-14 15:53         ` Ian Lance Taylor
@ 2010-04-15  4:57           ` Vaibhav Shrimali
  2010-04-15  8:03             ` Ian Lance Taylor
  0 siblings, 1 reply; 16+ messages in thread
From: Vaibhav Shrimali @ 2010-04-15  4:57 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

Well,
now I have stored the memory location, where I need to insert my
value, in the EDX register. I am not using force_reg() now.
I have stored the value to be inserted in a rtx type register.
But how do I set the value of memory location in EDX with the value
stored in a rtx type register?
Is there any library function which will allow me to do so?

Here is my code:

  if (frame_pointer_needed)
    { rtx r, set1,m1,edx,insn,temp;
      //Here hard frame pointer is pushed onto the stack
      insn = emit_insn (gen_push (hard_frame_pointer_rtx));
      RTX_FRAME_RELATED_P (insn) = 1;
      //Here hard frame pointer is updated
      insn = emit_move_insn (hard_frame_pointer_rtx, stack_pointer_rtx);
      RTX_FRAME_RELATED_P (insn) = 1;

      //my code starts from here.
      r = cfun->machine->force_align_arg_pointer;
      r = gen_rtx_PLUS (Pmode, r, -8);
      r = gen_rtx_MEM (Pmode, r);
      edx = gen_rtx_REG (Pmode, DX_REG);
      emit_move_insn(edx,r);
      //EDX now contains the memory location

      //Here I have stored the return address pushed on the stack in ret_addr
      //So the following code generates a rtx variable
      //which has the value ret_addr XOR hard_frame_pointer

      m1 = simplify_binary_operation(XOR, Pmode, ret_addr,
hard_frame_pointer_rtx);
     //now how to set memory location in edx with value m1??? Is there
any function
     //to do so.If not, please suggest me some other way of doing so.

    }

On Wed, Apr 14, 2010 at 7:44 PM, Ian Lance Taylor <iant@google.com> wrote:
> Vaibhav Shrimali <vaibhav.shrimali@gmail.com> writes:
>
>> I can use a hard register for this task. But will it allow me to
>> modify the memory location, between original return address and saved
>> frame pointer, stored in it?
>
> My point about the hard register was that you can't call force_reg
> after register allocation.
>
>> I think it will be just saved in the "saved registers" area of stack.
>> The assembly conversion of the prologue I need is:
>>
>> POP EAX                       ; new prologue start
>> PUSH EAX              ; unencrypted return address
>> PUSH EAX              ; duplicate return address
>> PUSH EBP              ; standard prologue
>> MOVE EBP, ESP
>> XOR [EBP+4], EBP      ; [EBP+4] has EIP and XOR encryptes ret addr(EIP)
>>
>> I want to know the function which allows me to write a value at a
>> memory address specified by a variable (generated by gen_rtx_MEM).
>> I thought force_reg is the one. Now, can I use ebx/ecx/...etc register
>> for the purpose.
>> OR will copy_to_mode_reg() function do the job?
>> OR is there any other function to do the job?
>
> You need to copy your memory location into a register.  force_reg
> copies it into a pseudo-register.  You need to copy it into a chosen
> hard register.  Use emit_move_insn.
>
> Ian
>



-- 
Vaibhav Shrimali
BTech(ICT), DA-IICT
Gandhinagar

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: how to set some value at a memory location in stack
  2010-04-15  4:57           ` Vaibhav Shrimali
@ 2010-04-15  8:03             ` Ian Lance Taylor
  2010-04-15  8:36               ` Vaibhav Shrimali
  0 siblings, 1 reply; 16+ messages in thread
From: Ian Lance Taylor @ 2010-04-15  8:03 UTC (permalink / raw)
  To: Vaibhav Shrimali; +Cc: gcc-help

Vaibhav Shrimali <vaibhav.shrimali@gmail.com> writes:

> now I have stored the memory location, where I need to insert my
> value, in the EDX register. I am not using force_reg() now.
> I have stored the value to be inserted in a rtx type register.
> But how do I set the value of memory location in EDX with the value
> stored in a rtx type register?
> Is there any library function which will allow me to do so?
>
> Here is my code:
>
>   if (frame_pointer_needed)
>     { rtx r, set1,m1,edx,insn,temp;
>       //Here hard frame pointer is pushed onto the stack
>       insn = emit_insn (gen_push (hard_frame_pointer_rtx));
>       RTX_FRAME_RELATED_P (insn) = 1;
>       //Here hard frame pointer is updated
>       insn = emit_move_insn (hard_frame_pointer_rtx, stack_pointer_rtx);
>       RTX_FRAME_RELATED_P (insn) = 1;
>
>       //my code starts from here.
>       r = cfun->machine->force_align_arg_pointer;
>       r = gen_rtx_PLUS (Pmode, r, -8);
>       r = gen_rtx_MEM (Pmode, r);
>       edx = gen_rtx_REG (Pmode, DX_REG);
>       emit_move_insn(edx,r);
>       //EDX now contains the memory location
>
>       //Here I have stored the return address pushed on the stack in ret_addr
>       //So the following code generates a rtx variable
>       //which has the value ret_addr XOR hard_frame_pointer
>
>       m1 = simplify_binary_operation(XOR, Pmode, ret_addr,
> hard_frame_pointer_rtx);
>      //now how to set memory location in edx with value m1??? Is there
> any function
>      //to do so.If not, please suggest me some other way of doing so.
>
>     }

You need to put the result of m1 somewhere.  There isn't really any
need to call simplify_binary_operation here.  To make this work, you
should know precisely which instructions you are doing to generate.
You can just generate them.  E.g.,
    emit_insn (gen_xorsi3 (DESTREG, SRC1, SRC2));

Ian

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: how to set some value at a memory location in stack
  2010-04-15  8:03             ` Ian Lance Taylor
@ 2010-04-15  8:36               ` Vaibhav Shrimali
  2010-04-15 15:41                 ` Ian Lance Taylor
  0 siblings, 1 reply; 16+ messages in thread
From: Vaibhav Shrimali @ 2010-04-15  8:36 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

Ian,
Thanks for all your help so far. I now think I am closer to my goal.
In order to execute :
XOR [EBP+4], [EBP]
after executing :
PUSH EBP

in the prologue, I need to use : emit_insn (gen_xorsi3 (DESTREG, SRC1, SRC2));
So I checked and I can generate a register such that:
rtx ebp_reg = gen_rtx_REG(Pmode, BP_REG);
this would be a hard register.
rtx ebp_plus = gen_rtx_PLUS(Pmode, ebp_reg, 4);

so now executing :-

emit_insn (gen_xorsi3 (ebp_plus, ebp_plus, ebp_reg));

I dont know if ebp_plus would be converted to [XOR+4] or not, although
it is derived from the hard register ebp_reg.

If I am wrong in this approach, please correct me.

Thank You for all your help so far.

On Thu, Apr 15, 2010 at 10:16 AM, Ian Lance Taylor <iant@google.com> wrote:
> Vaibhav Shrimali <vaibhav.shrimali@gmail.com> writes:
>
>> now I have stored the memory location, where I need to insert my
>> value, in the EDX register. I am not using force_reg() now.
>> I have stored the value to be inserted in a rtx type register.
>> But how do I set the value of memory location in EDX with the value
>> stored in a rtx type register?
>> Is there any library function which will allow me to do so?
>>
>> Here is my code:
>>
>>   if (frame_pointer_needed)
>>     { rtx r, set1,m1,edx,insn,temp;
>>       //Here hard frame pointer is pushed onto the stack
>>       insn = emit_insn (gen_push (hard_frame_pointer_rtx));
>>       RTX_FRAME_RELATED_P (insn) = 1;
>>       //Here hard frame pointer is updated
>>       insn = emit_move_insn (hard_frame_pointer_rtx, stack_pointer_rtx);
>>       RTX_FRAME_RELATED_P (insn) = 1;
>>
>>       //my code starts from here.
>>       r = cfun->machine->force_align_arg_pointer;
>>       r = gen_rtx_PLUS (Pmode, r, -8);
>>       r = gen_rtx_MEM (Pmode, r);
>>       edx = gen_rtx_REG (Pmode, DX_REG);
>>       emit_move_insn(edx,r);
>>       //EDX now contains the memory location
>>
>>       //Here I have stored the return address pushed on the stack in ret_addr
>>       //So the following code generates a rtx variable
>>       //which has the value ret_addr XOR hard_frame_pointer
>>
>>       m1 = simplify_binary_operation(XOR, Pmode, ret_addr,
>> hard_frame_pointer_rtx);
>>      //now how to set memory location in edx with value m1??? Is there
>> any function
>>      //to do so.If not, please suggest me some other way of doing so.
>>
>>     }
>
> You need to put the result of m1 somewhere.  There isn't really any
> need to call simplify_binary_operation here.  To make this work, you
> should know precisely which instructions you are doing to generate.
> You can just generate them.  E.g.,
>    emit_insn (gen_xorsi3 (DESTREG, SRC1, SRC2));
>
> Ian
>



-- 
Vaibhav Shrimali
BTech(ICT), DA-IICT
Gandhinagar

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: how to set some value at a memory location in stack
  2010-04-15  8:36               ` Vaibhav Shrimali
@ 2010-04-15 15:41                 ` Ian Lance Taylor
  2010-04-16  5:44                   ` Vaibhav Shrimali
  0 siblings, 1 reply; 16+ messages in thread
From: Ian Lance Taylor @ 2010-04-15 15:41 UTC (permalink / raw)
  To: Vaibhav Shrimali; +Cc: gcc-help

Vaibhav Shrimali <vaibhav.shrimali@gmail.com> writes:

> Thanks for all your help so far. I now think I am closer to my goal.
> In order to execute :
> XOR [EBP+4], [EBP]
> after executing :
> PUSH EBP
>
> in the prologue, I need to use : emit_insn (gen_xorsi3 (DESTREG, SRC1, SRC2));
> So I checked and I can generate a register such that:
> rtx ebp_reg = gen_rtx_REG(Pmode, BP_REG);
> this would be a hard register.
> rtx ebp_plus = gen_rtx_PLUS(Pmode, ebp_reg, 4);
>
> so now executing :-
>
> emit_insn (gen_xorsi3 (ebp_plus, ebp_plus, ebp_reg));
>
> I dont know if ebp_plus would be converted to [XOR+4] or not, although
> it is derived from the hard register ebp_reg.
>
> If I am wrong in this approach, please correct me.

At some point you have to try it and see what happens.  The dump files
will show you the generated RTL.

Ian

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: how to set some value at a memory location in stack
  2010-04-15 15:41                 ` Ian Lance Taylor
@ 2010-04-16  5:44                   ` Vaibhav Shrimali
  2010-04-16  8:35                     ` Ian Lance Taylor
  0 siblings, 1 reply; 16+ messages in thread
From: Vaibhav Shrimali @ 2010-04-16  5:44 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

Hey Ian,
I have been executing the code all this time. But apparently it was
generating segmentation fault error.
I configured the compiler with --disable-libssp option to disable the
stack protector. Also I modified the hard frame pointer offset in the
compute_frame_layout() method.
But still it is showing segmentation fault.

On Thu, Apr 15, 2010 at 7:41 PM, Ian Lance Taylor <iant@google.com> wrote:
> Vaibhav Shrimali <vaibhav.shrimali@gmail.com> writes:
>
>> Thanks for all your help so far. I now think I am closer to my goal.
>> In order to execute :
>> XOR [EBP+4], [EBP]
>> after executing :
>> PUSH EBP
>>
>> in the prologue, I need to use : emit_insn (gen_xorsi3 (DESTREG, SRC1, SRC2));
>> So I checked and I can generate a register such that:
>> rtx ebp_reg = gen_rtx_REG(Pmode, BP_REG);
>> this would be a hard register.
>> rtx ebp_plus = gen_rtx_PLUS(Pmode, ebp_reg, 4);
>>
>> so now executing :-
>>
>> emit_insn (gen_xorsi3 (ebp_plus, ebp_plus, ebp_reg));
>>
>> I dont know if ebp_plus would be converted to [XOR+4] or not, although
>> it is derived from the hard register ebp_reg.
>>
>> If I am wrong in this approach, please correct me.
>
> At some point you have to try it and see what happens.  The dump files
> will show you the generated RTL.
>
> Ian
>



-- 
Vaibhav Shrimali
BTech(ICT), DA-IICT
Gandhinagar

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: how to set some value at a memory location in stack
  2010-04-16  5:44                   ` Vaibhav Shrimali
@ 2010-04-16  8:35                     ` Ian Lance Taylor
  2010-04-16  8:46                       ` Vaibhav Shrimali
  0 siblings, 1 reply; 16+ messages in thread
From: Ian Lance Taylor @ 2010-04-16  8:35 UTC (permalink / raw)
  To: Vaibhav Shrimali; +Cc: gcc-help

Vaibhav Shrimali <vaibhav.shrimali@gmail.com> writes:

> I have been executing the code all this time. But apparently it was
> generating segmentation fault error.
> I configured the compiler with --disable-libssp option to disable the
> stack protector. Also I modified the hard frame pointer offset in the
> compute_frame_layout() method.
> But still it is showing segmentation fault.

Look at the generated code and see what is wrong.

It's very hard for us to answer a general question like "tell me what
is wrong with this code."  We have a somewhat better chance of
answering a specific question like "this code produces X and I want
Y."

Ian

> On Thu, Apr 15, 2010 at 7:41 PM, Ian Lance Taylor <iant@google.com> wrote:
>> Vaibhav Shrimali <vaibhav.shrimali@gmail.com> writes:
>>
>>> Thanks for all your help so far. I now think I am closer to my goal.
>>> In order to execute :
>>> XOR [EBP+4], [EBP]
>>> after executing :
>>> PUSH EBP
>>>
>>> in the prologue, I need to use : emit_insn (gen_xorsi3 (DESTREG, SRC1, SRC2));
>>> So I checked and I can generate a register such that:
>>> rtx ebp_reg = gen_rtx_REG(Pmode, BP_REG);
>>> this would be a hard register.
>>> rtx ebp_plus = gen_rtx_PLUS(Pmode, ebp_reg, 4);
>>>
>>> so now executing :-
>>>
>>> emit_insn (gen_xorsi3 (ebp_plus, ebp_plus, ebp_reg));
>>>
>>> I dont know if ebp_plus would be converted to [XOR+4] or not, although
>>> it is derived from the hard register ebp_reg.
>>>
>>> If I am wrong in this approach, please correct me.
>>
>> At some point you have to try it and see what happens.  The dump files
>> will show you the generated RTL.
>>
>> Ian
>>
>
>
>
> -- 
> Vaibhav Shrimali
> BTech(ICT), DA-IICT
> Gandhinagar

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: how to set some value at a memory location in stack
  2010-04-16  8:35                     ` Ian Lance Taylor
@ 2010-04-16  8:46                       ` Vaibhav Shrimali
  2010-04-16 10:01                         ` Vaibhav Shrimali
  2010-04-16 16:19                         ` Ian Lance Taylor
  0 siblings, 2 replies; 16+ messages in thread
From: Vaibhav Shrimali @ 2010-04-16  8:46 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

I am posting the config.log file generated.
It says segmentation fault and cc1: error: unrecognized command line
option "-std1" at a couple of places.
Please have a look at it. I am trying to track down the problem myself
but I am doubtful to succeed without an expert's help.
Thank You



-------------------------------------------------------------------------------------------------------------------------------
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by GNU C Runtime Library configure 1.0, which was
generated by GNU Autoconf 2.59.  Invocation command line was

  $ /home/vebs/gcc/gcc-4.3.3/libgcc/configure
--cache-file=./config.cache --enable-multilib --disable-libssp
--enable-languages=c,c++,fortran,java,objc
--program-transform-name=s,y,y, --with-target-subdir=i686-pc-linux-gnu
--build=i686-pc-linux-gnu --host=i686-pc-linux-gnu
--target=i686-pc-linux-gnu --srcdir=/home/vebs/gcc/gcc-4.3.3/libgcc
--disable-intermodule --enable-checking=yes,types --disable-coverage
--enable-languages=c

## --------- ##
## Platform. ##
## --------- ##

hostname = vebs-laptop
uname -m = i686
uname -r = 2.6.31-14-generic
uname -s = Linux
uname -v = #48-Ubuntu SMP Fri Oct 16 14:04:26 UTC 2009

/usr/bin/uname -p = unknown
/bin/uname -X     = unknown

/bin/arch              = unknown
/usr/bin/arch -k       = unknown
/usr/convex/getsysinfo = unknown
hostinfo               = unknown
/bin/machine           = unknown
/usr/bin/oslevel       = unknown
/bin/universe          = unknown

PATH: /usr/local/sbin
PATH: /usr/local/bin
PATH: /usr/sbin
PATH: /usr/bin
PATH: /sbin
PATH: /bin
PATH: /usr/games


## ----------- ##
## Core tests. ##
## ----------- ##

configure:1198: creating cache ./config.cache
configure:1373: checking for --enable-version-specific-runtime-libs
configure:1388: result: no
configure:1420: checking for a BSD-compatible install
configure:1475: result: /usr/bin/install -c
configure:1491: checking for gawk
configure:1520: result: no
configure:1491: checking for mawk
configure:1507: found /usr/bin/mawk
configure:1517: result: mawk
configure:1540: checking build system type
configure:1558: result: i686-pc-linux-gnu
configure:1566: checking host system type
configure:1580: result: i686-pc-linux-gnu
configure:1639: checking for i686-pc-linux-gnu-ar
configure:1665: result: ar
configure:1718: checking for i686-pc-linux-gnu-lipo
configure:1744: result: lipo
configure:1798: checking for i686-pc-linux-gnu-nm
configure:1824: result: /home/vebs/gcc/gcc-4.3.3-build/./gcc/nm
configure:1877: checking for i686-pc-linux-gnu-ranlib
configure:1903: result: ranlib
configure:1957: checking for i686-pc-linux-gnu-strip
configure:1983: result: strip
configure:2034: checking whether ln -s works
configure:2038: result: yes
configure:2055: checking for i686-pc-linux-gnu-gcc
configure:2081: result: /home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include
configure:2363: checking for C compiler version
configure:2366: /home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include --version </dev/null >&5
xgcc (GCC) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

configure:2369: $? = 0
configure:2371: /home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include -v </dev/null >&5
Reading specs from /home/vebs/gcc/gcc-4.3.3-build/./gcc/specs
Target: i686-pc-linux-gnu
Configured with: /home/vebs/gcc/gcc-4.3.3/configure --disable-libssp
Thread model: posix
gcc version 4.3.3 (GCC)
configure:2374: $? = 0
configure:2376: /home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include -V </dev/null >&5
xgcc: '-V' must come at the start of the command line
configure:2379: $? = 1
configure:2398: /home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include -o conftest -g
-fkeep-inline-functions   conftest.c  >&5
/usr/bin/ld: crtbegin.o: No such file: No such file or directory
collect2: ld returned 1 exit status
configure:2401: $? = 1
configure:2567: checking for suffix of object files
configure:2588: /home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include -c -g -fkeep-inline-functions
 conftest.c >&5
configure:2591: $? = 0
configure:2613: result: o
configure:2617: checking whether we are using the GNU C compiler
configure:2641: /home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include -c -g -fkeep-inline-functions
 conftest.c >&5
configure:2647: $? = 0
configure:2651: test -z
			 || test ! -s conftest.err
configure:2654: $? = 0
configure:2657: test -s conftest.o
configure:2660: $? = 0
configure:2673: result: yes
configure:2679: checking whether
/home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include accepts -g
configure:2700: /home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include -c -g  conftest.c >&5
configure:2706: $? = 0
configure:2710: test -z
			 || test ! -s conftest.err
configure:2713: $? = 0
configure:2716: test -s conftest.o
configure:2719: $? = 0
configure:2730: result: yes
configure:2747: checking for /home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include option to accept ANSI C
configure:2817: /home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include  -c -g
-fkeep-inline-functions  conftest.c >&5
conftest.c: In function 'e':
conftest.c:21: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
configure:2823: $? = 1
configure: failed program was:
| /* confdefs.h.  */
|
| #define PACKAGE_NAME "GNU C Runtime Library"
| #define PACKAGE_TARNAME "libgcc"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "GNU C Runtime Library 1.0"
| #define PACKAGE_BUGREPORT ""
| /* end confdefs.h.  */
| #include <stdarg.h>
| #include <stdio.h>
| #include <sys/types.h>
| #include <sys/stat.h>
| /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
| struct buf { int x; };
| FILE * (*rcsopen) (struct buf *, struct stat *, int);
| static char *e (p, i)
|      char **p;
|      int i;
| {
|   return p[i];
| }
| static char *f (char * (*g) (char **, int), char **p, ...)
| {
|   char *s;
|   va_list v;
|   va_start (v,p);
|   s = g (p, va_arg (v,int));
|   va_end (v);
|   return s;
| }
|
| /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
|    function prototypes and stuff, but not '\xHH' hex character constants.
|    These don't provoke an error unfortunately, instead are silently treated
|    as 'x'.  The following induces an error, until -std1 is added to get
|    proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
|    array size at least.  It's necessary to write '\x00'==0 to get something
|    that's true only with -std1.  */
| int osf4_cc_array ['\x00' == 0 ? 1 : -1];
|
| int test (int i, double x);
| struct s1 {int (*f) (int a);};
| struct s2 {int (*f) (double a);};
| int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *,
int), int, int);
| int argc;
| char **argv;
| int
| main ()
| {
| return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
|   ;
|   return 0;
| }
configure:2817: /home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include -qlanglvl=ansi -c -g
-fkeep-inline-functions  conftest.c >&5
xgcc: unrecognized option '-qlanglvl=ansi'
conftest.c: In function 'e':
conftest.c:21: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
configure:2823: $? = 1
configure: failed program was:
| /* confdefs.h.  */
|
| #define PACKAGE_NAME "GNU C Runtime Library"
| #define PACKAGE_TARNAME "libgcc"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "GNU C Runtime Library 1.0"
| #define PACKAGE_BUGREPORT ""
| /* end confdefs.h.  */
| #include <stdarg.h>
| #include <stdio.h>
| #include <sys/types.h>
| #include <sys/stat.h>
| /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
| struct buf { int x; };
| FILE * (*rcsopen) (struct buf *, struct stat *, int);
| static char *e (p, i)
|      char **p;
|      int i;
| {
|   return p[i];
| }
| static char *f (char * (*g) (char **, int), char **p, ...)
| {
|   char *s;
|   va_list v;
|   va_start (v,p);
|   s = g (p, va_arg (v,int));
|   va_end (v);
|   return s;
| }
|
| /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
|    function prototypes and stuff, but not '\xHH' hex character constants.
|    These don't provoke an error unfortunately, instead are silently treated
|    as 'x'.  The following induces an error, until -std1 is added to get
|    proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
|    array size at least.  It's necessary to write '\x00'==0 to get something
|    that's true only with -std1.  */
| int osf4_cc_array ['\x00' == 0 ? 1 : -1];
|
| int test (int i, double x);
| struct s1 {int (*f) (int a);};
| struct s2 {int (*f) (double a);};
| int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *,
int), int, int);
| int argc;
| char **argv;
| int
| main ()
| {
| return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
|   ;
|   return 0;
| }
configure:2817: /home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include -std1 -c -g
-fkeep-inline-functions  conftest.c >&5
cc1: error: unrecognized command line option "-std1"
configure:2823: $? = 1
configure: failed program was:
| /* confdefs.h.  */
|
| #define PACKAGE_NAME "GNU C Runtime Library"
| #define PACKAGE_TARNAME "libgcc"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "GNU C Runtime Library 1.0"
| #define PACKAGE_BUGREPORT ""
| /* end confdefs.h.  */
| #include <stdarg.h>
| #include <stdio.h>
| #include <sys/types.h>
| #include <sys/stat.h>
| /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
| struct buf { int x; };
| FILE * (*rcsopen) (struct buf *, struct stat *, int);
| static char *e (p, i)
|      char **p;
|      int i;
| {
|   return p[i];
| }
| static char *f (char * (*g) (char **, int), char **p, ...)
| {
|   char *s;
|   va_list v;
|   va_start (v,p);
|   s = g (p, va_arg (v,int));
|   va_end (v);
|   return s;
| }
|
| /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
|    function prototypes and stuff, but not '\xHH' hex character constants.
|    These don't provoke an error unfortunately, instead are silently treated
|    as 'x'.  The following induces an error, until -std1 is added to get
|    proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
|    array size at least.  It's necessary to write '\x00'==0 to get something
|    that's true only with -std1.  */
| int osf4_cc_array ['\x00' == 0 ? 1 : -1];
|
| int test (int i, double x);
| struct s1 {int (*f) (int a);};
| struct s2 {int (*f) (double a);};
| int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *,
int), int, int);
| int argc;
| char **argv;
| int
| main ()
| {
| return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
|   ;
|   return 0;
| }
configure:2817: /home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include -Ae -c -g
-fkeep-inline-functions  conftest.c >&5
<command-line>: error: missing '(' after predicate
conftest.c: In function 'e':
conftest.c:21: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
configure:2823: $? = 1
configure: failed program was:
| /* confdefs.h.  */
|
| #define PACKAGE_NAME "GNU C Runtime Library"
| #define PACKAGE_TARNAME "libgcc"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "GNU C Runtime Library 1.0"
| #define PACKAGE_BUGREPORT ""
| /* end confdefs.h.  */
| #include <stdarg.h>
| #include <stdio.h>
| #include <sys/types.h>
| #include <sys/stat.h>
| /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
| struct buf { int x; };
| FILE * (*rcsopen) (struct buf *, struct stat *, int);
| static char *e (p, i)
|      char **p;
|      int i;
| {
|   return p[i];
| }
| static char *f (char * (*g) (char **, int), char **p, ...)
| {
|   char *s;
|   va_list v;
|   va_start (v,p);
|   s = g (p, va_arg (v,int));
|   va_end (v);
|   return s;
| }
|
| /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
|    function prototypes and stuff, but not '\xHH' hex character constants.
|    These don't provoke an error unfortunately, instead are silently treated
|    as 'x'.  The following induces an error, until -std1 is added to get
|    proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
|    array size at least.  It's necessary to write '\x00'==0 to get something
|    that's true only with -std1.  */
| int osf4_cc_array ['\x00' == 0 ? 1 : -1];
|
| int test (int i, double x);
| struct s1 {int (*f) (int a);};
| struct s2 {int (*f) (double a);};
| int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *,
int), int, int);
| int argc;
| char **argv;
| int
| main ()
| {
| return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
|   ;
|   return 0;
| }
configure:2817: /home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include -Aa -D_HPUX_SOURCE -c -g
-fkeep-inline-functions  conftest.c >&5
<command-line>: error: missing '(' after predicate
conftest.c: In function 'e':
conftest.c:21: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
configure:2823: $? = 1
configure: failed program was:
| /* confdefs.h.  */
|
| #define PACKAGE_NAME "GNU C Runtime Library"
| #define PACKAGE_TARNAME "libgcc"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "GNU C Runtime Library 1.0"
| #define PACKAGE_BUGREPORT ""
| /* end confdefs.h.  */
| #include <stdarg.h>
| #include <stdio.h>
| #include <sys/types.h>
| #include <sys/stat.h>
| /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
| struct buf { int x; };
| FILE * (*rcsopen) (struct buf *, struct stat *, int);
| static char *e (p, i)
|      char **p;
|      int i;
| {
|   return p[i];
| }
| static char *f (char * (*g) (char **, int), char **p, ...)
| {
|   char *s;
|   va_list v;
|   va_start (v,p);
|   s = g (p, va_arg (v,int));
|   va_end (v);
|   return s;
| }
|
| /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
|    function prototypes and stuff, but not '\xHH' hex character constants.
|    These don't provoke an error unfortunately, instead are silently treated
|    as 'x'.  The following induces an error, until -std1 is added to get
|    proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
|    array size at least.  It's necessary to write '\x00'==0 to get something
|    that's true only with -std1.  */
| int osf4_cc_array ['\x00' == 0 ? 1 : -1];
|
| int test (int i, double x);
| struct s1 {int (*f) (int a);};
| struct s2 {int (*f) (double a);};
| int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *,
int), int, int);
| int argc;
| char **argv;
| int
| main ()
| {
| return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
|   ;
|   return 0;
| }
configure:2817: /home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include -Xc -D__EXTENSIONS__ -c -g
-fkeep-inline-functions  conftest.c >&5
xgcc: unrecognized option '-Xc'
conftest.c: In function 'e':
conftest.c:21: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
configure:2823: $? = 1
configure: failed program was:
| /* confdefs.h.  */
|
| #define PACKAGE_NAME "GNU C Runtime Library"
| #define PACKAGE_TARNAME "libgcc"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "GNU C Runtime Library 1.0"
| #define PACKAGE_BUGREPORT ""
| /* end confdefs.h.  */
| #include <stdarg.h>
| #include <stdio.h>
| #include <sys/types.h>
| #include <sys/stat.h>
| /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
| struct buf { int x; };
| FILE * (*rcsopen) (struct buf *, struct stat *, int);
| static char *e (p, i)
|      char **p;
|      int i;
| {
|   return p[i];
| }
| static char *f (char * (*g) (char **, int), char **p, ...)
| {
|   char *s;
|   va_list v;
|   va_start (v,p);
|   s = g (p, va_arg (v,int));
|   va_end (v);
|   return s;
| }
|
| /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
|    function prototypes and stuff, but not '\xHH' hex character constants.
|    These don't provoke an error unfortunately, instead are silently treated
|    as 'x'.  The following induces an error, until -std1 is added to get
|    proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
|    array size at least.  It's necessary to write '\x00'==0 to get something
|    that's true only with -std1.  */
| int osf4_cc_array ['\x00' == 0 ? 1 : -1];
|
| int test (int i, double x);
| struct s1 {int (*f) (int a);};
| struct s2 {int (*f) (double a);};
| int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *,
int), int, int);
| int argc;
| char **argv;
| int
| main ()
| {
| return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
|   ;
|   return 0;
| }
configure:2854: result: none needed
configure:2872: /home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include -c -g -fkeep-inline-functions
 conftest.c >&5
conftest.c:2: error: expected '=', ',', ';', 'asm' or '__attribute__'
before 'me'
configure:2878: $? = 1
configure: failed program was:
| #ifndef __cplusplus
|   choke me
| #endif
configure:3016: checking how to run the C preprocessor
configure:3051: /home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include -E  conftest.c
configure:3057: $? = 0
configure:3089: /home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include -E  conftest.c
conftest.c:9:28: error: ac_nonexistent.h: No such file or directory
configure:3095: $? = 1
configure: failed program was:
| /* confdefs.h.  */
|
| #define PACKAGE_NAME "GNU C Runtime Library"
| #define PACKAGE_TARNAME "libgcc"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "GNU C Runtime Library 1.0"
| #define PACKAGE_BUGREPORT ""
| /* end confdefs.h.  */
| #include <ac_nonexistent.h>
configure:3134: result: /home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include -E
configure:3158: /home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include -E  conftest.c
configure:3164: $? = 0
configure:3196: /home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include -E  conftest.c
conftest.c:9:28: error: ac_nonexistent.h: No such file or directory
configure:3202: $? = 1
configure: failed program was:
| /* confdefs.h.  */
|
| #define PACKAGE_NAME "GNU C Runtime Library"
| #define PACKAGE_TARNAME "libgcc"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "GNU C Runtime Library 1.0"
| #define PACKAGE_BUGREPORT ""
| /* end confdefs.h.  */
| #include <ac_nonexistent.h>
configure:3250: checking whether decimal floating point is supported
configure:3259: /home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include -c -g -fkeep-inline-functions
 conftest.c >&5
configure:3265: $? = 0
configure:3269: test -z
			 || test ! -s conftest.err
configure:3272: $? = 0
configure:3275: test -s conftest.o
configure:3278: $? = 0
configure:3289: result: yes
configure:3334: checking whether fixed-point is supported
configure:3343: /home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include -c -g -fkeep-inline-functions
 conftest.c >&5
conftest.c:1: error: fixed-point types not supported for this target
configure:3349: $? = 1
configure: failed program was:
| _Sat _Fract x;
configure:3373: result: no
configure:3408: checking for __attribute__((visibility("hidden")))
configure:3417: /home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include -Werror -S conftest.c -o
conftest.s 1>&5
conftest.c: In function 'foo':
conftest.c:1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
configure:3420: $? = 1
configure:3429: result: no
configure:3459: checking whether the target asssembler upports
thread-local storage
configure:3469: /home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include -c -g -fkeep-inline-functions
 conftest.c >&5
configure:3475: $? = 0
configure:3479: test -z
			 || test ! -s conftest.err
configure:3482: $? = 0
configure:3485: test -s conftest.o
configure:3488: $? = 0
configure:3500: result: yes
configure:3655: creating ./config.status

## ---------------------- ##
## Running config.status. ##
## ---------------------- ##

This file was extended by GNU C Runtime Library config.status 1.0, which was
generated by GNU Autoconf 2.59.  Invocation command line was

  CONFIG_FILES    =
  CONFIG_HEADERS  =
  CONFIG_LINKS    =
  CONFIG_COMMANDS =
  $ ./config.status

on vebs-laptop

config.status:696: creating Makefile
config.status:872: executing default commands

## ---------------- ##
## Cache variables. ##
## ---------------- ##

ac_cv_build=i686-pc-linux-gnu
ac_cv_build_alias=i686-pc-linux-gnu
ac_cv_c_compiler_gnu=yes
ac_cv_env_CC_set=set
ac_cv_env_CC_value='/home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include'
ac_cv_env_CFLAGS_set=set
ac_cv_env_CFLAGS_value='-g -fkeep-inline-functions'
ac_cv_env_CPPFLAGS_set=set
ac_cv_env_CPPFLAGS_value=
ac_cv_env_CPP_set=
ac_cv_env_CPP_value=
ac_cv_env_LDFLAGS_set=set
ac_cv_env_LDFLAGS_value=
ac_cv_env_build_alias_set=set
ac_cv_env_build_alias_value=i686-pc-linux-gnu
ac_cv_env_host_alias_set=set
ac_cv_env_host_alias_value=i686-pc-linux-gnu
ac_cv_env_target_alias_set=set
ac_cv_env_target_alias_value=i686-pc-linux-gnu
ac_cv_host=i686-pc-linux-gnu
ac_cv_host_alias=i686-pc-linux-gnu
ac_cv_objext=o
ac_cv_prog_AR=ar
ac_cv_prog_AWK=mawk
ac_cv_prog_CC='/home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include'
ac_cv_prog_CPP='/home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include -E'
ac_cv_prog_LIPO=lipo
ac_cv_prog_NM=/home/vebs/gcc/gcc-4.3.3-build/./gcc/nm
ac_cv_prog_RANLIB=ranlib
ac_cv_prog_STRIP=strip
ac_cv_prog_cc_g=yes
ac_cv_prog_cc_stdc=no
gcc_cv_have_cc_tls=yes
libgcc_cv_dfp=yes
libgcc_cv_fixed_point=no
libgcc_cv_hidden_visibility_attribute=no

## ----------------- ##
## Output variables. ##
## ----------------- ##

AR='ar'
AWK='mawk'
CC='/home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include'
CFLAGS='-g -fkeep-inline-functions'
CPP='/home/vebs/gcc/gcc-4.3.3-build/./gcc/xgcc
-B/home/vebs/gcc/gcc-4.3.3-build/./gcc/
-B/usr/local/i686-pc-linux-gnu/bin/
-B/usr/local/i686-pc-linux-gnu/lib/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include -E'
CPPFLAGS=''
DEFS='-DPACKAGE_NAME=\"GNU\ C\ Runtime\ Library\"
-DPACKAGE_TARNAME=\"libgcc\" -DPACKAGE_VERSION=\"1.0\"
-DPACKAGE_STRING=\"GNU\ C\ Runtime\ Library\ 1.0\"
-DPACKAGE_BUGREPORT=\"\" '
ECHO_C=''
ECHO_N='-n'
ECHO_T=''
EXEEXT=''
INSTALL_DATA='/usr/bin/install -c -m 644'
INSTALL_PROGRAM='/usr/bin/install -c'
INSTALL_SCRIPT='/usr/bin/install -c'
LDFLAGS=''
LIBOBJS=''
LIBS=''
LIPO='lipo'
LN_S='ln -s'
LTLIBOBJS=''
NM='/home/vebs/gcc/gcc-4.3.3-build/./gcc/nm'
OBJEXT='o'
PACKAGE_BUGREPORT=''
PACKAGE_NAME='GNU C Runtime Library'
PACKAGE_STRING='GNU C Runtime Library 1.0'
PACKAGE_TARNAME='libgcc'
PACKAGE_VERSION='1.0'
PATH_SEPARATOR=':'
RANLIB='ranlib'
SHELL='/bin/bash'
STRIP='strip'
ac_ct_AR=''
ac_ct_CC=''
ac_ct_LIPO=''
ac_ct_NM=''
ac_ct_RANLIB=''
ac_ct_STRIP=''
asm_hidden_op='.hidden'
bindir='${exec_prefix}/bin'
build='i686-pc-linux-gnu'
build_alias='i686-pc-linux-gnu'
build_cpu='i686'
build_libsubdir='build-i686-pc-linux-gnu'
build_os='linux-gnu'
build_subdir='build-i686-pc-linux-gnu'
build_vendor='pc'
datadir='${prefix}/share'
decimal_float='yes'
enable_decimal_float='bid'
enable_shared='yes'
exec_prefix='${prefix}'
extra_parts='crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o
crtprec32.o crtprec64.o crtprec80.o crtfastmath.o'
fixed_point='no'
host='i686-pc-linux-gnu'
host_alias='i686-pc-linux-gnu'
host_cpu='i686'
host_noncanonical='i686-pc-linux-gnu'
host_os='linux-gnu'
host_subdir='.'
host_vendor='pc'
includedir='${prefix}/include'
infodir='${prefix}/info'
libdir='${exec_prefix}/lib'
libexecdir='${exec_prefix}/libexec'
libgcc_topdir='/home/vebs/gcc/gcc-4.3.3/libgcc/..'
localstatedir='${prefix}/var'
mandir='${prefix}/man'
oldincludedir='/usr/include'
prefix='/usr/local'
program_transform_name='s,y,y,'
sbindir='${exec_prefix}/sbin'
set_have_cc_tls='-DHAVE_CC_TLS'
sharedstatedir='${prefix}/com'
slibdir='$(libdir)'
sysconfdir='${prefix}/etc'
target_alias='i686-pc-linux-gnu'
target_subdir='i686-pc-linux-gnu'
tmake_file=' $(srcdir)/config/i386/t-crtpc
$(srcdir)/config/i386/t-crtfm $(srcdir)/config/t-tls'
vis_hide=''

## ----------- ##
## confdefs.h. ##
## ----------- ##

#define PACKAGE_BUGREPORT ""
#define PACKAGE_NAME "GNU C Runtime Library"
#define PACKAGE_STRING "GNU C Runtime Library 1.0"
#define PACKAGE_TARNAME "libgcc"
#define PACKAGE_VERSION "1.0"

configure: exit 0

On Fri, Apr 16, 2010 at 11:28 AM, Ian Lance Taylor <iant@google.com> wrote:
> Vaibhav Shrimali <vaibhav.shrimali@gmail.com> writes:
>
>> I have been executing the code all this time. But apparently it was
>> generating segmentation fault error.
>> I configured the compiler with --disable-libssp option to disable the
>> stack protector. Also I modified the hard frame pointer offset in the
>> compute_frame_layout() method.
>> But still it is showing segmentation fault.
>
> Look at the generated code and see what is wrong.
>
> It's very hard for us to answer a general question like "tell me what
> is wrong with this code."  We have a somewhat better chance of
> answering a specific question like "this code produces X and I want
> Y."
>
> Ian
>
>> On Thu, Apr 15, 2010 at 7:41 PM, Ian Lance Taylor <iant@google.com> wrote:
>>> Vaibhav Shrimali <vaibhav.shrimali@gmail.com> writes:
>>>
>>>> Thanks for all your help so far. I now think I am closer to my goal.
>>>> In order to execute :
>>>> XOR [EBP+4], [EBP]
>>>> after executing :
>>>> PUSH EBP
>>>>
>>>> in the prologue, I need to use : emit_insn (gen_xorsi3 (DESTREG, SRC1, SRC2));
>>>> So I checked and I can generate a register such that:
>>>> rtx ebp_reg = gen_rtx_REG(Pmode, BP_REG);
>>>> this would be a hard register.
>>>> rtx ebp_plus = gen_rtx_PLUS(Pmode, ebp_reg, 4);
>>>>
>>>> so now executing :-
>>>>
>>>> emit_insn (gen_xorsi3 (ebp_plus, ebp_plus, ebp_reg));
>>>>
>>>> I dont know if ebp_plus would be converted to [XOR+4] or not, although
>>>> it is derived from the hard register ebp_reg.
>>>>
>>>> If I am wrong in this approach, please correct me.
>>>
>>> At some point you have to try it and see what happens.  The dump files
>>> will show you the generated RTL.
>>>
>>> Ian
>>>
>>
>>
>>
>> --
>> Vaibhav Shrimali
>> BTech(ICT), DA-IICT
>> Gandhinagar
>



-- 
Vaibhav Shrimali
BTech(ICT), DA-IICT
Gandhinagar

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: how to set some value at a memory location in stack
  2010-04-16  8:46                       ` Vaibhav Shrimali
@ 2010-04-16 10:01                         ` Vaibhav Shrimali
  2010-04-16 19:57                           ` Ian Lance Taylor
  2010-04-16 16:19                         ` Ian Lance Taylor
  1 sibling, 1 reply; 16+ messages in thread
From: Vaibhav Shrimali @ 2010-04-16 10:01 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

after building the compiler stops, it shows the error:
/home/vebs/gcc/gcc-4.3.3/libgcc/../gcc/libgcc2.c: In function ‘__muldi3’:
/home/vebs/gcc/gcc-4.3.3/libgcc/../gcc/libgcc2.c:566: internal
compiler error: Segmentation fault

and
the config.log file generated is the one that posted before this mail.

-- 
Vaibhav Shrimali
BTech(ICT), DA-IICT
Gandhinagar

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: how to set some value at a memory location in stack
  2010-04-16  8:46                       ` Vaibhav Shrimali
  2010-04-16 10:01                         ` Vaibhav Shrimali
@ 2010-04-16 16:19                         ` Ian Lance Taylor
  1 sibling, 0 replies; 16+ messages in thread
From: Ian Lance Taylor @ 2010-04-16 16:19 UTC (permalink / raw)
  To: Vaibhav Shrimali; +Cc: gcc-help

Vaibhav Shrimali <vaibhav.shrimali@gmail.com> writes:

> I am posting the config.log file generated.

That config.log file is fine.

Ian

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: how to set some value at a memory location in stack
  2010-04-16 10:01                         ` Vaibhav Shrimali
@ 2010-04-16 19:57                           ` Ian Lance Taylor
  0 siblings, 0 replies; 16+ messages in thread
From: Ian Lance Taylor @ 2010-04-16 19:57 UTC (permalink / raw)
  To: Vaibhav Shrimali; +Cc: gcc-help

Vaibhav Shrimali <vaibhav.shrimali@gmail.com> writes:

> after building the compiler stops, it shows the error:
> /home/vebs/gcc/gcc-4.3.3/libgcc/../gcc/libgcc2.c: In function ‘__muldi3’:
> /home/vebs/gcc/gcc-4.3.3/libgcc/../gcc/libgcc2.c:566: internal
> compiler error: Segmentation fault

http://gcc.gnu.org/wiki/DebuggingGCC

Ian

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2010-04-16 13:53 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-13  6:20 how to set some value at a memory location in stack Vaibhav Shrimali
2010-04-14  0:21 ` Ian Lance Taylor
2010-04-14  4:08   ` Vaibhav Shrimali
2010-04-14  5:10     ` Ian Lance Taylor
2010-04-14 11:17       ` Vaibhav Shrimali
2010-04-14 15:53         ` Ian Lance Taylor
2010-04-15  4:57           ` Vaibhav Shrimali
2010-04-15  8:03             ` Ian Lance Taylor
2010-04-15  8:36               ` Vaibhav Shrimali
2010-04-15 15:41                 ` Ian Lance Taylor
2010-04-16  5:44                   ` Vaibhav Shrimali
2010-04-16  8:35                     ` Ian Lance Taylor
2010-04-16  8:46                       ` Vaibhav Shrimali
2010-04-16 10:01                         ` Vaibhav Shrimali
2010-04-16 19:57                           ` Ian Lance Taylor
2010-04-16 16:19                         ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).