Bug 493712

Summary: Relocation R_X86_64_PC32 error when compiling C++ code with -fvisibility-inlines-hidden
Product: Red Hat Enterprise Linux 5 Reporter: Robert Hancock <robert.hancock>
Component: gcc43Assignee: Jakub Jelinek <jakub>
Status: CLOSED INSUFFICIENT_DATA QA Contact:
Severity: medium Docs Contact:
Priority: low    
Version: 5.3CC: law
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-03-21 19:14:20 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Robert Hancock 2009-04-02 19:17:47 UTC
Description of problem:
We have a class defined like this defined in a header file:

template <class state_t, class event_t>
class UFSM_Base_FSM
{

...

    virtual ~UFSM_Base_FSM()
    {
	monitor.release();
    }
}

and a class that inherits from it:

class MFSM_FSM
    : public UFSM_Base_FSM<int,mobj_msg_id_t>
{

...

    virtual ~MFSM_FSM();		/* Destructor */
}

with the empty destructor being defined non-inline.

When the MFSM_FSM class is compiled using -fvisibility-inlines-hidden and the code is built into a shared library, this error results:

/usr/bin/ld: mfsm_fsm.o: relocation R_X86_64_PC32 against `UFSM_Base_FSM<int, mobj_msg_id_t>::~UFSM_Base_FSM()' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value

The -fPIC flag is being used when compiling all code.

Version-Release number of selected component (if applicable):
gcc43-4.3.2-7.el5

How reproducible:
Every time

Steps to Reproduce:
1. Compile code like the above and link into shared library (not sure how reproducible the problem is without the entire code base)
2.
3.
  
Actual results:
link succeeds

Expected results:
link fails

Additional info:

Comment 1 Jeff Law 2013-03-21 19:14:20 UTC
This kind of error can result from incorrect command line options, undefined virtual methods, a linker bug with protected symbols, etc.

Without a full testcase we can not fully analyze this problem to determine if it is a problem in your code, the compiler, assembler or linker.  A full testcase would consist of source code and the exact commands you use to show the problem.

It is also the case that gcc43 is no longer supported on the Red Hat Enterprise Linux platform.  It was replaced by "gcc44" a while back.

I'm closing this as INSUFFICIENT_DATA; you may reopen it by providing the requested information so that we can fully analyze the issue.