السلام عليكم و رحمة الله و بركاته ...
لدي برنامج مكتوب بلغة السي و لكنه يعمل بشكل صحيح فقط إذا تم عمل compile للبرنامج بنسخة قديمة من gcc ، حيث إن النسخة التي لدي حاليا هي 4.4.3 ، و على غير النسخ القديمة فإن النسخ الجديدة تقوم بحجز مكان أكثر مما هو مطلوب للـstack frame.
فهل يوجد خيار للـgcc بحيث أجعله يقوم بعمل compile بنسخة قديمة ؟ أو على الأقل ألا يحجز مكانا أكثر مما هو مطلوب ؟
و هذا هو برنامجي ...
/* Objective: a program to print
* 1- the current %ebp, %esp of the current stack frame
* 2- the previous %ebp, %esp of the previous stack frame
* 3- prints the values of the local variables of the previous stack frame*/
#include <stdio.h>
void my_stack_frame(int a) /* a = number of variables of the previous stack frame */
{
int *ip;
int x=0;
ip = &x;
// printing current %ebp, %esp
printf("The current %%ebp = %p \nThe current %%esp = %p\n\n", (ip+2), ip);
// printing the previous %ebp, %esp
printf("The previous %%ebp = %p \nThe previous %%esp = %p\n\n", (ip+5+a), (ip+5));
// printing the values of the local variables of the previous stack frame
int i;
ip = ip+4+a; /* ip points to the first variable of the previous stack frame */
for (i=0; i<a; i++)
{
printf("The variable number %d of the previous stack frame contains : %d\n", (i+1), *ip);
ip--;
}
}
int main()
{
int a=1;
int b=2;
int c=3;
my_stack_frame(3);
return 0;
}ملاحظة : لم أعلم ما إذا كان يجب علي وضع البرنامج هنا أم في قسم اللينوكس ، فالرجاء من المشرفين نقله إذا لم يكن هذا هو المكان المناسب.