1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| [d_schris@fool.internal.doubleclick.net tmp]$ cat tabDyn.c
#include <stdio.h>
#include <stdlib.h>
#define MULTIPLICATEUR_TAILLE 1024
void tabDyn(int taille) {
int tab[taille*MULTIPLICATEUR_TAILLE];
unsigned long i;
for (i=0 ; i < (taille*MULTIPLICATEUR_TAILLE) ; i++) {
tab[i]=taille+(int)i;
}
}
int main(int argc, char *argv[]) {
if (argc != 2) {
fprintf(stderr,"utilisation: %s taille\n",argv[0]);
exit(EXIT_FAILURE);
}
tabDyn(atoi(argv[1]));
exit(EXIT_SUCCESS);
}
[d_schris@fool.internal.doubleclick.net tmp]$ gcc -std=c99 -O0 -g -Wall -o tabDyn tabDyn.c
[d_schris@fool.internal.doubleclick.net tmp]$ ./tabDyn 1024
[d_schris@fool.internal.doubleclick.net tmp]$ ./tabDyn 2048
Erreur de segmentation
[d_schris@fool.internal.doubleclick.net tmp]$ gdb ./tabDyn
GNU gdb DS Linux (9.3-1)
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-ds-linux"...
(gdb) disas tabDyn
Dump of assembler code for function tabDyn:
0x80484f0 <tabDyn>: push %ebp
0x80484f1 <tabDyn+1>: mov %esp,%ebp
0x80484f3 <tabDyn+3>: sub $0x18,%esp
0x80484f6 <tabDyn+6>: mov %esp,0xffffffec(%ebp)
0x80484f9 <tabDyn+9>: mov 0x8(%ebp),%eax
0x80484fc <tabDyn+12>: mov %eax,%eax
0x80484fe <tabDyn+14>: shl $0xa,%eax
0x8048501 <tabDyn+17>: lea 0xffffffff(%eax),%ecx
0x8048504 <tabDyn+20>: mov %ecx,0xfffffff0(%ebp)
0x8048507 <tabDyn+23>: movl $0x0,0xfffffff4(%ebp)
0x804850e <tabDyn+30>: mov 0xfffffff0(%ebp),%eax
0x8048511 <tabDyn+33>: mov 0xfffffff4(%ebp),%edx
0x8048514 <tabDyn+36>: shld $0x5,%eax,%edx
0x8048518 <tabDyn+40>: shl $0x5,%eax
0x804851b <tabDyn+43>: add $0x20,%eax
0x804851e <tabDyn+46>: adc $0x0,%edx
0x8048521 <tabDyn+49>: imul $0x4,%ecx,%eax
0x8048524 <tabDyn+52>: add $0x4,%eax
0x8048527 <tabDyn+55>: add $0xf,%eax
0x804852a <tabDyn+58>: shr $0x4,%eax
0x804852d <tabDyn+61>: mov %eax,%eax
0x804852f <tabDyn+63>: shl $0x4,%eax
0x8048532 <tabDyn+66>: sub %eax,%esp
0x8048534 <tabDyn+68>: mov %esp,0xffffffe8(%ebp)
0x8048537 <tabDyn+71>: movl $0x0,0xfffffffc(%ebp)
0x804853e <tabDyn+78>: mov %esi,%esi
0x8048540 <tabDyn+80>: mov 0x8(%ebp),%eax
0x8048543 <tabDyn+83>: mov %eax,%eax
0x8048545 <tabDyn+85>: shl $0xa,%eax
0x8048548 <tabDyn+88>: cmp %eax,0xfffffffc(%ebp)
0x804854b <tabDyn+91>: jb 0x8048550 <tabDyn+96>
0x804854d <tabDyn+93>: jmp 0x8048570 <tabDyn+128>
0x804854f <tabDyn+95>: nop
0x8048550 <tabDyn+96>: mov 0xfffffffc(%ebp),%eax
0x8048553 <tabDyn+99>: mov %eax,%eax
0x8048555 <tabDyn+101>: lea 0x0(,%eax,4),%edx
0x804855c <tabDyn+108>: mov 0xfffffffc(%ebp),%eax
0x804855f <tabDyn+111>: add 0x8(%ebp),%eax
0x8048562 <tabDyn+114>: mov 0xffffffe8(%ebp),%ecx
0x8048565 <tabDyn+117>: mov %eax,(%edx,%ecx,1)
0x8048568 <tabDyn+120>: lea 0xfffffffc(%ebp),%eax
0x804856b <tabDyn+123>: incl (%eax)
0x804856d <tabDyn+125>: jmp 0x8048540 <tabDyn+80>
0x804856f <tabDyn+127>: nop
0x8048570 <tabDyn+128>: mov 0xffffffec(%ebp),%esp
0x8048573 <tabDyn+131>: leave
---Type <return> to continue, or q <return> to quit---q
Quit
(gdb) quit
[d_schris@fool.internal.doubleclick.net tmp]$ |