«на страничках с данными запросто может не оказаться разрешения на exec.» более того, на той же линуксе .data естественно стоит без прав на исполнение: #include <stdio.h>
typedef int (*pf)(int, int); char c[] = {85,-119,-27,-117,69,12,3,69,8,93,-61,-112}; pf sum = (pf)c;
int main() {
printf("sum=%p\n", sum);
printf("%d\n", sum(5, 6)); return 0;
}
$ cc -o a test.c
$ gdb ./a
GNU gdb Red Hat Linux (6.5-37.el5rh)
Copyright (C) 2006 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 "i386-redhat-linux-gnu"...(no debugging symbols found)
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) r
Starting program: /tmp/foo/tmp/a
(no debugging symbols found)
(no debugging symbols found)
(no debug