Bug 11031 - -fvisibility=hidden causes Text relocation errors
-fvisibility=hidden causes Text relocation errors
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Build
x64 Solaris
: P5 normal
: ---
Assigned To: Björn Jacke
Samba QA Contact
Depends on: 11073
  Show dependency treegraph
Reported: 2015-01-05 18:32 UTC by Tom Schulz
Modified: 2015-03-13 08:33 UTC (History)
1 user (show)

See Also:

patch for -fvisibility=hidden (579 bytes, patch)
2015-01-05 18:32 UTC, Tom Schulz
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Schulz 2015-01-05 18:32:40 UTC
Created attachment 10577 [details]
patch for -fvisibility=hidden

Note that this problem was reported in bug 10261, which is really about a different problem that produces similar error messages. I believe that this problem should have it's own bug report.

Building Samba 4.1.* on Solaris 10 i386 with GCC 4.7.2 produces 'Text relocation remains against symbol' errors. The error messages also include the following:

ld: fatal: relocations remain against allocatable but non-writable sections
collect2: error: ld returned 1 exit status

This is caused by specifying -fvisibility=hidden to the GCC compiler
The test for -fvisibility=hidden on Solaris produces:

[1/1] Compiling test.c
../test.c: In function 'main':
../test.c:1:1: warning: visibility attribute not supported in this
configuration; ignored [-Wattributes]
['/opt/local/bin/gcc', '-I/opt/local/include', '-fvisibility=hidden', '-MD',
'-I/usr/local/include', '-D_SAMBA_BUILD_=4', '-DHAVE_CONFIG_H=1',
'-D_GNU_SOURCE=1', '-D_XOPEN_SOURCE_EXTENDED=1', '../test.c', '-c', '-o',

But, despite the message saying ignored, the result can not be linked into a
shared library. Adding -Werror=attributes to the gcc command will turn this
into an error.This can be done by patching lib/replace/wscript to change

if conf.CHECK_CFLAGS('-fvisibility=hidden'):
if conf.CHECK_CFLAGS(['-fvisibility=hidden', '-Werror=attributes']):

Please see the attached patch.
Comment 1 Stefan Metzmacher 2015-03-13 08:33:08 UTC
Fixed in bug #11073.