We have using nm to check those symbols
You shouldn't: on ELF platforms, nm
is inadequate for the job. Use readelf -Ws
instead.
it exist but list as “t” instead of “T”,which means it is local symbols instead of external. Seams the A.a are build with -fvisibility=hidden after som investigation.
Your conclusion does not follow: there are many reasons a symbol may show up as a t
. Being compiled with -fvisibility=hidden
is only one of many possibilities.
Is there any way to export those symbols as global even it has been build with -fvisibility=hidden
The symbol table is just a linear table of Elf{32,64}_Sym[]
s. You can find the start of this table in the object file with readelf -WS foo.o | grep '.symtab'
, find the number of offending symbol from readelf -Ws
, and find the offset of the symbol in the foo.o
by combining the two:
sym-offset = .symtab offset + (sym-number * sizeof(Sym))
Once you have the offset, you can override its .st_info
with STV_DEFAULT
(if your theory is correct and you located the symbol correctly, you should find STV_HIDDEN
there currently).
Once you've patched your foo.o
, the symbol will no longer be hidden, and when you link foo.o
into B.so
, it will be global / exported.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…