gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gcl-devel] gcc-4.1, gcl, function pointers and unexec


From: Camm Maguire
Subject: [Gcl-devel] gcc-4.1, gcl, function pointers and unexec
Date: Wed, 16 May 2007 13:32:08 -0400
User-agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.3 (Unebigory ōmae) APEL/10.3 Emacs/21.2 (i386-debian-linux-gnu) MULE/5.0 (SAKAKI)

Greetings! gcc-4.1 breaks saving of initialized function pointers via
unexec.  This worked in gcc 3.x.

=============================================================================
#include <math.h>
void * gcl_cos=(void *)cos;
int reset_plt(void) {gcl_cos=(void *)cos;}

int main() {
 
     return 0;

}
=============================================================================

When the above snippet is linked and run under gdb, gcl_cos points
directly to an address beyond the address space of the executable,
i.e. in the shared memory area (i.e. no plt like entry as on x86 where
a trampoline address is stored in the executable itself)

(on vaughn dchroot sid)

(gdb) file raw_pre_gcl
A program is being debugged already.  Kill it? (y or n) y

Load new symbol table from "/home/camm/gclcvs-2.7.0/unixport/raw_pre_gcl"? (y 
or n) y
Reading symbols from /home/camm/gclcvs-2.7.0/unixport/raw_pre_gcl...done.
(gdb) r
Starting program: /home/camm/gclcvs-2.7.0/unixport/raw_pre_gcl 

Breakpoint 1, main (argc=1, argv=0x7fb33d94, envp=0x7fb33d9c) at main.c:619
619       return gcl_main ( argc, argv, envp );
(gdb) p gcl_cos
$15 = (void *) 0x2ab1b6a0
(gdb) shell
address@hidden:~/gclcvs-2.7.0/unixport$ ldd raw_pre_gcl
        libm.so.6 => /lib/libm.so.6 (0x2ab00000)
        libc.so.6 => /lib/libc.so.6 (0x2abbc000)
        /lib/ld.so.1 (0x2aaa8000)
address@hidden:~/gclcvs-2.7.0/unixport$ ldd saved_pre_gcl
        libm.so.6 => /lib/libm.so.6 (0x2ab00000)
        libc.so.6 => /lib/libc.so.6 (0x2abbc000)
        /lib/ld.so.1 (0x2aaa8000)
address@hidden:~/gclcvs-2.7.0/unixport$ exit
exit
(gdb) file saved_pre_gcl  ## unexeced version
A program is being debugged already.  Kill it? (y or n) y

Load new symbol table from "/home/camm/gclcvs-2.7.0/unixport/saved_pre_gcl"? (y 
or n) y
Reading symbols from /home/camm/gclcvs-2.7.0/unixport/saved_pre_gcl...done.
(gdb) r
Starting program: /home/camm/gclcvs-2.7.0/unixport/saved_pre_gcl 

Breakpoint 1, main (argc=1, argv=0x7fa80d94, envp=0x7fa80d9c) at main.c:619
619       return gcl_main ( argc, argv, envp );
(gdb) p gcl_cos
$16 = (void *) 0x801523e0
(gdb) p reset_plt()
$17 = 716289696
(gdb) p gcl_cos
$18 = (void *) 0x2ab1b6a0
(gdb) 

Is this expected?  Is there a work around?

Take care,
-- 
Camm Maguire                                            address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah




reply via email to

[Prev in Thread] Current Thread [Next in Thread]