Red Hat Bugzilla – Bug 121775
Gcc is not restoring the global pointer after a memcpy call causing segv.
Last modified: 2007-11-30 17:06:54 EST
Description of problem:
The compiler gcc-c++-2.96-124.7.2 is producing incorrect code for the
source contained within test.cc through not restoring the global
pointer after a call to memcpy.
A call to memcpy is made in libc. The global pointer is set to the
correct value to point at the center of the static/global short data
section for that shared object. When the call returns it attempts to
do a offset from the global pointer for a load and crashes because it
has returned to the test executable where the stale global pointer is
not longer valid.
br.call.sptk.many b0 = memcpy# // Call to memcpy
addl r15 = @gprel(_.tmp_0.13#), gp //gp rel addr. used
//Before gp restored
st4 [r15] = r118 //Crash occurs here
.loc 1 58 0
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. run make on example provided
2. make test.s to view the issue in the assembly
Global pointer should be restored.
Phone: (505) 893-1255
Created attachment 99721 [details]
Test case for this bug.
This attachment comes with the readme on the bug and directions how to
I tested this with the gcc-c++-2.96-128.7.2 compiler and it
reproduces in the same manner.
Created attachment 99834 [details]
Makefile for testcase
Created attachment 99835 [details]
Created attachment 99836 [details]
This shows a run of the program, and inspection of
the assembly to show the problem block.
Created attachment 99837 [details]
Description of the problem
The attachment Mike C, created is really a zip file with msdos text
format files inside... I've reattached the file pieces as plain unix
The test.cc file is about as small, touching the big "r1" data
structure in almost any way makes the problem vanish.
This bug is filed against RHEL2.1, which is in maintenance phase.
During the maintenance phase, only security errata and select mission
critical bug fixes will be released for enterprise products. Since
this bug does not meet that criteria, it is now being closed.
For more information of the RHEL errata support policy, please visit:
If you feel this bug is indeed mission critical, please contact your
support representative. You may be asked to provide detailed
information on how this bug is affecting you.