public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c/10355: i386 regparm doco note on shlib use
@ 2003-04-08 22:26 Kevin Ryde
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Ryde @ 2003-04-08 22:26 UTC (permalink / raw)
  To: gcc-gnats


>Number:         10355
>Category:       c
>Synopsis:       i386 regparm doco note on shlib use
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          doc-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Apr 08 22:26:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        3.2.3 20030316 (Debian prerelease) (Debian testing/unstable)
>Organization:
>Environment:
System: Linux blah 2.2.15 #1 Tue Apr 25 17:13:48 EST 2000 i586 unknown unknown GNU/Linux
Architecture: i586
	<machine, os, target, libraries (multiple lines)>
host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,pascal,objc,ada --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.2 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-java-gc=boehm --enable-objc-gc i386-linux

>Description:
The i386 regparm attribute is not good for functions in shared
libraries on some systems.  It'd be nice to have a warning about that
in the manual.

>How-To-Repeat:
On Solaris 8, the loader's lazy binding resolver code clobbers eax,
ecx and edx, in accordance with the standard calling conventions,
meaning bad values reach the first call to a regparm function.

>Fix:
I'd like to propose the few words below.  GLIBC and FreeBSD are the
only loaders I've had a close look at.  Very possibly other BSD
flavours are safe too.


--=-=-=
Content-Disposition: attachment; filename=extend.texi.regparm-plt.diff

--- extend.texi.~1.127.~	2003-03-27 09:10:43.000000000 +1000
+++ extend.texi	2003-04-09 08:17:25.000000000 +1000
@@ -2360,6 +2360,7 @@
 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
 
 @item regparm (@var{number})
+@cindex @code{regparm} attribute
 @cindex functions that are passed arguments in registers on the 386
 On the Intel 386, the @code{regparm} attribute causes the compiler to
 pass up to @var{number} integer arguments in registers EAX,
@@ -2367,6 +2368,14 @@
 variable number of arguments will continue to be passed all of their
 arguments on the stack.
 
+Beware that on some ELF systems this attribute is unsuitable for
+global functions in shared libraries.  Lazy binding will send the
+first call via resolving code in the loader, which might assume EAX,
+EDX and ECX can be clobbered, as per the standard calling conventions.
+Solaris 8 is affected by this.  GNU systems with GLIBC 2.1 or higher,
+and FreeBSD, are believed to be safe though since the loaders there
+save all registers.
+
 @item stdcall
 @cindex functions that pop the argument stack on the 386
 On the Intel 386, the @code{stdcall} attribute causes the compiler to

--=-=-=--
>Release-Note:
>Audit-Trail:
>Unformatted:
 --=-=-=
 


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: c/10355: i386 regparm doco note on shlib use
@ 2003-05-20 22:28 bangerth
  0 siblings, 0 replies; 2+ messages in thread
From: bangerth @ 2003-05-20 22:28 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, user42

Synopsis: i386 regparm doco note on shlib use

State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Tue May 20 22:28:21 2003
State-Changed-Why:
    Patch committed. Thanks for your help!
    
    W.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10355


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-05-20 22:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-08 22:26 c/10355: i386 regparm doco note on shlib use Kevin Ryde
2003-05-20 22:28 bangerth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).