Bug 210129 - R_X86_64_PC32 against anonymous namespace in spite of -fPIC
R_X86_64_PC32 against anonymous namespace in spite of -fPIC
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
rawhide
x86_64 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-10-10 06:17 EDT by Axel Thimm
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-10-10 07:52:18 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Axel Thimm 2006-10-10 06:17:33 EDT
Description of problem:
The mythplugins build fail on linking videolist.o suggesting to use -fPIC, but
this has already been used:
[...]
g++ -c -pipe -pthread -I/usr/include/kde/artsc -I/usr/include/glib-2.0
-I/usr/lib64/glib-2.0/include -Wall -W -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 
-m64 -mtune=generic -fomit-frame-pointer -D_REENTRANT -DPIC -fPIC  -D_GNU_SOURCE
-DPREFIX=\"/usr\" -DMMX -DUSING_FREEBOX -D_FILE_OFFSET_BITS=64 -DQT_NO_DEBUG
-DQT_THREAD_SUPPORT -DQT_PLUGIN -DQT_SHARED -I/usr/l
ib64/qt-3.3/mkspecs/default -I. -I/usr/include -I/usr/kde/3.3/include
-I/usr/include -I/usr/include/v4l/ -I/usr/include -I/usr/lib64/qt-3.3/include -o
videolist.o videolist.cpp
videolist.cpp:413: warning: 'VideoListImp' has a field
'VideoListImp::m_metadata_tree' whose type uses the anonymous namespace
videolist.cpp:413: warning: 'VideoListImp' has a field
'VideoListImp::m_metadata_view_tree' whose type uses the anonymous namespace
[...]
g++ -shared -o libmythvideo.so main.o metadata.o videomanager.o videobrowser.o
videofilter.o dbcheck.o cleanup.o globalsettings.o videotree.o fileassoc.o
editmetadata.o videogallery.o videoselected.o videodlg.o
 videoscan.o videolist.o dbaccess.o metadatalistmanager.o globals.o dirscan.o
videoutils.o imagecache.o moc_videomanager.o moc_videobrowser.o
moc_videofilter.o moc_videotree.o moc_fileassoc.o moc_editmetadata.o
 moc_videogallery.o moc_videoselected.o moc_videodlg.o  -L/usr/kde/3.3/lib
-L/usr/lib64/qt-3.3/lib -L/usr/lib -lqt-mt -lpthread 
/usr/bin/ld: videolist.o: relocation R_X86_64_PC32 against `(anonymous
namespace)::tree_view_to_flat((anonymous namespace)::meta_dir_node&,
std::vector<Metadata*, std::allocator<Metadata*> >&)' can not be used 
when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value

Version-Release number of selected component (if applicable):
gcc-4.1.1-28

How reproducible:
always

Steps to Reproduce:
1.Try building mythplugins
2.
3.
  
Actual results:
See above

Expected results:


Additional info:
There is no asm in videolist.cpp
(http://svn.mythtv.org/trac/browser/branches/release-0-20-fixes/mythplugins/mythvideo/mythvideo/videolist.cpp).
The relevant parts (warnings and parts defining/referencing tree_view_to_flat) are:

    412 class VideoListImp
    413 {
[...]
    516     meta_dir_node m_metadata_tree; // master list for tree views
    517 
    518     metadata_view_list m_metadata_view_flat;
    519     meta_dir_node m_metadata_view_tree;
[...]
    975 namespace
    976 {
[...]
   1004     struct call_tree_flat
   1005     {
   1006         call_tree_flat(VideoListImp::metadata_view_list &list) :
m_list(list) {}
   1007 
   1008         void operator()(smart_dir_node &sdn)
   1009         {
   1010             void tree_view_to_flat(meta_dir_node &,
   1011                                    VideoListImp::metadata_view_list &);
   1012 
   1013             tree_view_to_flat(*(sdn.get()), m_list);
   1014         }
   1015 
   1016         VideoListImp::metadata_view_list &m_list;
   1017     };
   1018 
   1019     // Fills a flat view with pointers to all entries in a tree.
   1020     void tree_view_to_flat(meta_dir_node &tree,
   1021                            VideoListImp::metadata_view_list &flat)
   1022     {
   1023         std::back_insert_iterator<VideoListImp::metadata_view_list>
bip(flat);
   1024         std::transform(tree.entries_begin(), tree.entries_end(), bip,
   1025                        to_metadata_ptr());
   1026 
   1027         std::for_each(tree.dirs_begin(), tree.dirs_end(),
call_tree_flat(flat));
   1028     }
   1029 }
   1030 
   1031 void VideoListImp::update_meta_view(bool flat_list)
   1032 {
[...]
   1081         tree_view_to_flat(m_metadata_view_tree, m_metadata_view_flat);
   1082     }
   1083 
   1084     update_flat_index();
   1085 }

Thanks!
Comment 1 Jakub Jelinek 2006-10-10 07:52:18 EDT
anonymous namespaces are private in each translation unit, so if meta_dir_node
is defined in an anonymous namespace, the code is invalid if you use
VideoListImp class in more than one translation unit (since VideoListImp
definitions are in that case different (each meta_dir_node is unique) and
thus it violates ODR).
You really should fix the sources.

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