public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/14346] New: With -fpic/-fPIC, thunks jump through PLT, not directly to thunked function
@ 2004-02-29 16:12 hp at gcc dot gnu dot org
2004-02-29 16:14 ` [Bug target/14346] " hp at gcc dot gnu dot org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: hp at gcc dot gnu dot org @ 2004-02-29 16:12 UTC (permalink / raw)
To: gcc-bugs
As in summary. Because thunks do not set up the PIC register, going through the
PLT causes a SEGV in best case. Another PIC construct than for normal calls
must be used, but unfortunately the only (currently) available PC-relative PIC
reloc for cris-axis-linux-gnu requests a PLT. The thunked function is global.
Using a local symbol makes the linker omit the redirection through the PLT and
the jump goes directly to the right place.
On trunk and 3.4 branch, the thunk uses a local symbol (equated to the thunked
function, generated by generic code), so TRT happens.
See <URL:http://gcc.gnu.org/ml/gcc-patches/2003-06/msg02603.html> for
the first of the patch where the generic local-thunk was implemented (needed
follow-up patches for correctness). I'll go with a target-local patch.
Testcase:
-------------- th1.h
class B
{
int bb1;
int bb2;
public:
virtual void b();
};
extern class B* mka();
-------------- th1.cc (compile and link with -fpic -shared -o libth1.so)
#include "th1.h"
class A
{
int aa;
public:
virtual void a() = 0;
};
class C : public A, public B
{
int cc;
public:
virtual void b();
virtual void a();
};
extern "C" void abort (void);
extern "C" void exit (int);
class B* mka (void)
{
return new C;
}
void C::b(void)
{
exit (0);
}
void B::b(void)
{
abort ();
}
void C::a(void)
{
abort ();
}
-------------- m.cc (compile and link with -L. -lth1, expect normal exit)
#include "th1.h"
extern "C" void abort (void);
int ii[10];
int main(void)
{
register int picreg
#if defined (__CRIS__) && !defined (__PIC__) && !defined (__pic__)
__asm__ ("r0")
#endif
= -1;
class B *bb = mka();
bb->b();
// Make sure picreg is alive and used after bb->b() above.
asm ("" : : "r" (picreg));
abort ();
}
--
Summary: With -fpic/-fPIC, thunks jump through PLT, not directly
to thunked function
Product: gcc
Version: unknown
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P1
Component: target
AssignedTo: hp at gcc dot gnu dot org
ReportedBy: hp at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: cris-axis-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14346
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/14346] With -fpic/-fPIC, thunks jump through PLT, not directly to thunked function
2004-02-29 16:12 [Bug target/14346] New: With -fpic/-fPIC, thunks jump through PLT, not directly to thunked function hp at gcc dot gnu dot org
@ 2004-02-29 16:14 ` hp at gcc dot gnu dot org
2004-02-29 16:31 ` [Bug target/14346] [3.3 only] " hp at gcc dot gnu dot org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: hp at gcc dot gnu dot org @ 2004-02-29 16:14 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2004-02-29 16:14:01
date| |
Target Milestone|--- |3.3.4
Version|unknown |3.2.1
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14346
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/14346] [3.3 only] With -fpic/-fPIC, thunks jump through PLT, not directly to thunked function
2004-02-29 16:12 [Bug target/14346] New: With -fpic/-fPIC, thunks jump through PLT, not directly to thunked function hp at gcc dot gnu dot org
2004-02-29 16:14 ` [Bug target/14346] " hp at gcc dot gnu dot org
@ 2004-02-29 16:31 ` hp at gcc dot gnu dot org
2004-02-29 21:46 ` cvs-commit at gcc dot gnu dot org
2004-02-29 21:52 ` hp at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: hp at gcc dot gnu dot org @ 2004-02-29 16:31 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |critical
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14346
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/14346] [3.3 only] With -fpic/-fPIC, thunks jump through PLT, not directly to thunked function
2004-02-29 16:12 [Bug target/14346] New: With -fpic/-fPIC, thunks jump through PLT, not directly to thunked function hp at gcc dot gnu dot org
2004-02-29 16:14 ` [Bug target/14346] " hp at gcc dot gnu dot org
2004-02-29 16:31 ` [Bug target/14346] [3.3 only] " hp at gcc dot gnu dot org
@ 2004-02-29 21:46 ` cvs-commit at gcc dot gnu dot org
2004-02-29 21:52 ` hp at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-02-29 21:46 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-02-29 21:46 -------
Subject: Bug 14346
CVSROOT: /cvs/gcc
Module name: gcc
Branch: gcc-3_3-branch
Changes by: hp@gcc.gnu.org 2004-02-29 21:46:29
Modified files:
gcc : ChangeLog
gcc/config/cris: cris.c
Log message:
PR target/14346
* config/cris/cris.c (cris_asm_output_mi_thunk): For PIC, prepend
TAB to jumping "add.d" insn. Avoid PLT indirection by equating a
local symbol and jumping through it.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.913&r2=1.16114.2.914
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/cris/cris.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.32.4.2&r2=1.32.4.3
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14346
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/14346] [3.3 only] With -fpic/-fPIC, thunks jump through PLT, not directly to thunked function
2004-02-29 16:12 [Bug target/14346] New: With -fpic/-fPIC, thunks jump through PLT, not directly to thunked function hp at gcc dot gnu dot org
` (2 preceding siblings ...)
2004-02-29 21:46 ` cvs-commit at gcc dot gnu dot org
@ 2004-02-29 21:52 ` hp at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: hp at gcc dot gnu dot org @ 2004-02-29 21:52 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From hp at gcc dot gnu dot org 2004-02-29 21:52 -------
See <URL:http://gcc.gnu.org/ml/gcc-patches/2004-02/msg02798.html>.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14346
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-02-29 21:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-29 16:12 [Bug target/14346] New: With -fpic/-fPIC, thunks jump through PLT, not directly to thunked function hp at gcc dot gnu dot org
2004-02-29 16:14 ` [Bug target/14346] " hp at gcc dot gnu dot org
2004-02-29 16:31 ` [Bug target/14346] [3.3 only] " hp at gcc dot gnu dot org
2004-02-29 21:46 ` cvs-commit at gcc dot gnu dot org
2004-02-29 21:52 ` hp at gcc dot gnu dot org
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).