Re: gcc-4.1, gcl, function pointers and unexec
CCing Richard Sandiford and David Daney who might have an answer.
* Camm Maguire <camm@enhanced.com> [2007-05-16 13:32]:
> 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
> camm@vaughan:~/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)
> camm@vaughan:~/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)
> camm@vaughan:~/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 camm@enhanced.com
> ==========================================================================
> "The earth is but one country, and mankind its citizens." -- Baha'u'llah
>
>
> --
> To UNSUBSCRIBE, email to debian-mips-REQUEST@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
--
Martin Michlmayr
http://www.cyrius.com/
Reply to: