This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Segmentation fault using shared object on AIX 5.1
- From: sdowning at fame dot com (Stuart F. Downing)
- To: gcc-help at gcc dot gnu dot org
- Date: 14 May 2003 15:20:26 -0400
- Subject: Segmentation fault using shared object on AIX 5.1
Overview
I am getting a segmentation fault when I run a program linked with a
shared object I generated with gcc.
Background
gcc -v
reports...
Reading specs from /usr/local/lib/gcc-lib/powerpc-ibm-aix5.1.0.0/3.2.2/specs
Configured with: ../gcc-3.2.2/configure --disable-nls
Thread model: aix
gcc version 3.2.2
(I obtained this gcc as a binary distro from http://aixpdslib.seas.ucla.edu)
I compile a source file as follows
gcc -g -pthread -D_LARGE_FILES -c source.c
This is subsequently partially linked into a shared object with other
modules as follows...
gcc -shared -pthread -D_LARGE_FILES -o shared.o source.o other_mod.o other_lib.a -lc -lm -ls
The result is then linked into the main program
gcc -g main.c -o main ./shared.o -lc -lm -ls
When I run the program, I get a segmentation fault just before a
function in source.c is entered, in prologue code that looks like this
(from gdb using stepi)
main () at /vobs/devp/reg/misc/main.c:33
1: x/i $pc 0x10000418 <main+200>: addi r3,r1,120
1: x/i $pc 0x1000041c <main+204>: addi r4,r1,124
1: x/i $pc 0x10000420 <main+208>: addi r5,r1,72
1: x/i $pc 0x10000424 <main+212>: addi r6,r1,56
1: x/i $pc 0x10000428 <main+216>: addi r7,r1,88
1: x/i $pc 0x1000042c <main+220>: addi r8,r1,104
1: x/i $pc 0x10000430 <main+224>: bl 0x10000570 <cfmopcn>
0x10000570 in cfmopcn ()
1: x/i $pc 0x10000570 <cfmopcn>: lwz r12,120(r2)
0x10000574 in cfmopcn ()
1: x/i $pc 0x10000574 <cfmopcn+4>: stw r2,20(r1)
0x10000578 in cfmopcn ()
1: x/i $pc 0x10000578 <cfmopcn+8>: lwz r0,0(r12)
0x1000057c in cfmopcn ()
1: x/i $pc 0x1000057c <cfmopcn+12>: lwz r2,4(r12)
0x10000580 in cfmopcn ()
1: x/i $pc 0x10000580 <cfmopcn+16>: mtctr r0
0x10000584 in cfmopcn ()
1: x/i $pc 0x10000584 <cfmopcn+20>: bctr
Program received signal SIGSEGV, Segmentation fault.
0x00d38f5c in ?? ()
1: x/i $pc 0xd38f5c: Cannot access memory at address 0xd38f5c
Disabling display 1 to avoid infinite recursion.
using objdump -D I can see that this prolog code is in main, not in
source.o
0000000010000690 <.cfmopcn>:
10000690: 81 82 00 7c l r12,120(r2)
10000694: 90 41 00 14 st r2,20(r1)
10000698: 80 0c 00 00 l r0,0(r12)
1000069c: 80 4c 00 04 l r2,4(r12)
100006a0: 7c 09 03 a6 mtctr r0
100006a4: 4e 80 04 20 bctr
100006a8: 00 00 00 00 .long 0x0
100006ac: 00 0c a0 00 .long 0xca000
100006b0: 00 00 00 00 .long 0x0
100006b4: 00 00 00 18 .long 0x18
If I compile source.c with the IBM compiler as follows, no
segmentation fault...
cc -qthreaded -D_LARGE_FILES -c source.c
Also, if I link main with the gcc .o's directly, without creating a
shared object, it doesn't seg fault.
Anyone have experience with this?
--
Stuart Downing