Bug 493712 - Relocation R_X86_64_PC32 error when compiling C++ code with -fvisibility-inlines-hidden
Relocation R_X86_64_PC32 error when compiling C++ code with -fvisibility-inli...
Status: CLOSED INSUFFICIENT_DATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: gcc43 (Show other bugs)
5.3
All Linux
low Severity medium
: rc
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2009-04-02 15:17 EDT by Robert Hancock
Modified: 2013-03-21 15:14 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-03-21 15:14:20 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Robert Hancock 2009-04-02 15:17:47 EDT
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 15:14:20 EDT
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.

Note You need to log in before you can comment on or make changes to this bug.