Is there any way we can override the hidden visibility by fvisibility=hidden flag
-
I have question
- Filename : lib_mylib.h
int fun();
int fun1(void);
int fun2(void);
2) Filename: lib_mylib.c */#include <stdio.h>
int fun() {
return 2;
}
int fun1(void) {
return 2;
}
int fun2(void) {
return 2;
}
3) File :my_lib_shared.c#include "my_lib.h"
int foo(void) {
return fun() + 4;
}
4) File: my_lib_shared.hint foo();
5) File driver.c/* filename: driver.c */
#include "my_lib.h"
#include "my_lib_shared.h"
#include <stdio.h>
int main() {
int x = foo() ;
return 0;
}
If I execute following steps1)gcc -fPIC -fvisibility=hidden -c my_lib.c -o lib_mylib.o
2)gcc -fPIC -fvisibility=hidden -shared -o libMyLibHidden.so lib_mylib.o
3)gcc -fPIC -c my_lib_shared.c -o my_lib_shared.o
4)gcc -shared -o libMyShared2.so my_lib_shared.o
5)gcc -L. -Wall -o test_hidden driver.c -lMyLibHidden -lMyShared2
he output of objdump is asobjdump -T libMyLibHidden.so
libMyLibHidden.so: file format elf64-x86-64
DYNAMIC SYMBOL TABLE:
0000000000000448 l d .init 0000000000000000 .init
0000000000000000 w D UND 0000000000000000 gmon_start
0000000000000000 w D UND 0000000000000000 _Jv_RegisterClasses
0000000000000658 g DF .fini 0000000000000000 Base _fini
0000000000000000 w D UND 0000000000000000 _deregisterTMCloneTable
0000000000000000 w D UND 0000000000000000 _ITM_registerTMCloneTable
0000000000000000 w DF UND 0000000000000126 GLIBC_2.2.5 _cxa_finalize
0000000000200938 g D ABS 0000000000000000 Base __bss_start
0000000000200948 g D ABS 0000000000000000 Base _end
0000000000200938 g D ABS 0000000000000000 Base _edata
0000000000000448 g DF .init 0000000000000000 Base _initI did not any reference of functions of fun, fun1 and fun2 in the above objdump. Which is expected
and I get following error at final linking step/tmp/ccMsEpFq.o: In function main': driver.c:(.text+0xe): undefined reference tofun' collect2: error: ld returned 1 exit status
but In my actual code and shared libraries of libQtGui.so i can see in my Makefile -fvisibility=hidden is given as flag but still the symbols are available in my dynamic symbol table of libQtGui.so
=--------------------------------My question
is is there any flag in gcc linux or way where we can override the hidden visibilty and make the symbols avaiable in shared libraries
or there any flag in gcc linux where we can export all the symbols in the shared library
The flags of my Makefile while making shared library of libQtGui.so are
CFLAGS = -m64 -pipe -g -O2 -fvisibility=hidden -Wall -W -D_REENTRANT -fPIC $(DEFINES) CXXFLAGS = -m64 -pipe -fpermissive -g -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -O2 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -D_REENTRANT -fPIC $(DEFINES) INCPATH = -I../../mkspecs/linux-g++-64 -I. -I../../include/QtCore -I../../include/QtCore -I../../include -I../../include/QtGui -I../3rdparty/libpng -I../3rdparty/zlib -I/usr/include/freetype2 -I../3rdparty/harfbuzz/src -Idialogs -I.moc/release-shared -I/usr/X11R6/include -I.uic/release-shared LINK = g++
LFLAGS = -m64 -Wl,-rpath/shared_libary_path -shared -Wl,-soname,libQtGui.so.4