[parisc-linux] Program counter from sigcontext, constructors

John David Anglin dave@hiauly1.hia.nrc.ca
Sat, 26 Apr 2003 13:33:49 -0400 (EDT)


> Which versions did you try? :)
> 
> bash-2.05b$ gcc-3.0 -fPIC -g test-fpic.c; ./a.out
> Segmentation fault

gcc version 3.2.3 20030316 (Debian prerelease)
gcc version 3.3 20030419 (prerelease)
gcc version 3.4 20030115 (experimental)

> Crashes under 3.0.4, looks like the possible PIC register bug we saw
> with the double printf. I recommend you move to a newer gcc if possible.
> I spent a few minutes looking at assembler output and %r19 looks to low
> to be valid...

This is a bug in 3.0.4.  If you look at the assembler output for the
testcase, you will see the following:

	.section	.ctors,"aw"
	.long	my_start

This is incorrect.  The code should be:

	.section	.ctors,"aw",@progbits
	.align	4
	.word	P%my_start

Using a plabel constructor causes $$dyncall to correctly load the
pic register for the call to my_start.  This is necessary because
the startup file crtbegin.o is not compiled as pic code and the
code in __do_global_ctors_aux clobbers the pic register.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)