[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

problem with libtool generated version script and underscores

From: Aleksey Demakov
Subject: problem with libtool generated version script and underscores
Date: Wed, 6 Feb 2008 02:51:11 +0600

Hi all,

I try to build a library (glib to be specific) with a cross-toolchain
that prepends underscore to C names. The problem is that the
symbols the library has to export do not get exported.

The command used to build the library is provided by the end of
the message. Please note the option "-export-symbols-regex "^g.*"".

I found that the version script that is generated by libtool does
not contain any underscores -- that is it uses original C names.
I played a bit with the version script and found that my toolchain
properly exports the required symbols if I add the underscores
to it.

Analyzing how libtool works I found in my libtool file the following
bits that seem relevant:

# Take the output of nm and produce a listing of raw symbols and C names.
global_symbol_pipe="sed -n -e 's/^.*[
]\\([ABCDGIRSTW][ABCDGIRSTW]*\\)[       ][
]*_\\([_A-Za-z][_A-Za-z0-9]*\\)\$/\\1 _\\2 \\2/p'"

# The commands to list exported symbols.
export_symbols_cmds="\$NM \$libobjs \$convenience |
\$global_symbol_pipe | \$SED 's/.* //' | sort | uniq >

So the global_symbol_pipe command produces output where a
column with underscored raw symbol is followed by a column with
a C name. Then $SED 's/.* //' leaves only the column with the
C-name which eventually gets into the version script.

I am confused about this. Is LD supposed to understand C-names
or raw symbol names in the version script? That is should I bug
the people who provided me with the toolchain or this is a libtool

By the way the option "-export-symbols-regex "^g.*"" used in the
glib Makefile also selects names without underscores so if libtool
were to produce underscores I would have a problem again but
this should be easy to fix on my own.


/bin/sh ../libtool --mode=link bfin-linux-uclibc-gcc  -D__UCLIBC__
-Wall  -L/home/avd/foo/local/sysroot/bfin-unknown-linux-gnu/lib
-Wl,/home/avd/foo/local/sysroot/bfin-unknown-linux-gnu/usr/lib -o -rpath /usr/lib  -version-info 1400:1:1400
-export-dynamic  -export-symbols-regex "^g.*" garray.lo gasyncqueue.lo
gatomic.lo gbacktrace.lo gbase64.lo gbookmarkfile.lo gcache.lo
gcompletion.lo gconvert.lo gdataset.lo gdate.lo gdir.lo gerror.lo
gfileutils.lo ghash.lo ghook.lo giochannel.lo gkeyfile.lo glist.lo
gmain.lo gmappedfile.lo gmarkup.lo gmem.lo gmessages.lo gnode.lo
goption.lo gpattern.lo gprimes.lo gqsort.lo gqueue.lo grel.lo grand.lo
gregex.lo gscanner.lo gsequence.lo gshell.lo gslice.lo gslist.lo
gstdio.lo gstrfuncs.lo gstring.lo gthread.lo gthreadpool.lo gtimer.lo
gtree.lo guniprop.lo gutf8.lo gunibreak.lo gunicollate.lo
gunidecomp.lo gutils.lo gprintf.lo libcharset/
gnulib/ giounix.lo gspawn.lo  -liconv  pcre/
generating symbol list for `'
bfin-linux-uclibc-nm  .libs/garray.o .libs/gasyncqueue.o
.libs/gatomic.o .libs/gbacktrace.o .libs/gbase64.o
.libs/gbookmarkfile.o .libs/gcache.o .libs/gcompletion.o
.libs/gconvert.o .libs/gdataset.o .libs/gdate.o .libs/gdir.o
.libs/gerror.o .libs/gfileutils.o .libs/ghash.o .libs/ghook.o
.libs/giochannel.o .libs/gkeyfile.o .libs/glist.o .libs/gmain.o
.libs/gmappedfile.o .libs/gmarkup.o .libs/gmem.o .libs/gmessages.o
.libs/gnode.o .libs/goption.o .libs/gpattern.o .libs/gprimes.o
.libs/gqsort.o .libs/gqueue.o .libs/grel.o .libs/grand.o
.libs/gregex.o .libs/gscanner.o .libs/gsequence.o .libs/gshell.o
.libs/gslice.o .libs/gslist.o .libs/gstdio.o .libs/gstrfuncs.o
.libs/gstring.o .libs/gthread.o .libs/gthreadpool.o .libs/gtimer.o
.libs/gtree.o .libs/guniprop.o .libs/gutf8.o .libs/gunibreak.o
.libs/gunicollate.o .libs/gunidecomp.o .libs/gutils.o .libs/gprintf.o
.libs/giounix.o .libs/gspawn.o  libcharset/.libs/libcharset.a
gnulib/.libs/libgnulib.a pcre/.libs/libpcre.a | sed -n -e 's/^.*[
]\([ABCDGIRSTW][ABCDGIRSTW]*\)[         ][
]*_\([_A-Za-z][_A-Za-z0-9]*\)$/\1 _\2 \2/p' | /bin/sed 's/.* //' |
| uniq > .libs/libglib-2.0.exp
/bin/grep -E -e "^g.*" ".libs/libglib-2.0.exp" > ".libs/libglib-2.0.expT"
mv -f ".libs/libglib-2.0.expT" ".libs/libglib-2.0.exp"
echo "{ global:" > .libs/libglib-2.0.ver
 cat .libs/libglib-2.0.exp | sed -e "s/\(.*\)/\1;/" >> .libs/libglib-2.0.ver
 echo "local: *; };" >> .libs/libglib-2.0.ver
 bfin-linux-uclibc-gcc -shared  .libs/garray.o .libs/gasyncqueue.o
.libs/gatomic.o .libs/gbacktrace.o .libs/gbase64.o
.libs/gcache.o .libs/gcompletion.o .libs/gconvert.o .libs/gdataset.o
.libs/gdate.o .libs/gdir.o .libs/gerror.o .libs/gfileutils.o
.libs/ghash.o .libs/ghook.o .libs/giochannel.o .libs/gkeyfile.o
.libs/glist.o .libs/gmain.o .libs/gmappedfile.o .libs/gmarkup.o
.libs/gmem.o .libs/gmessages.o .libs/gnode.o .libs/goption.o
.libs/gpattern.o .libs/gprimes.o .libs/gqsort.o .libs/gqueue.o
.libs/grel.o .libs/grand.o .libs/gregex.o .libs/gscanner.o
.libs/gsequence.o .libs/gshell.o .libs/gslice.o .libs/gslist.o
.libs/gstdio.o .libs/gstrfuncs.o .libs/gstring.o .libs/gthread.o
.libs/gthreadpool.o .libs/gtimer.o .libs/gtree.o .libs/guniprop.o
.libs/gutf8.o .libs/gunibreak.o .libs/gunicollate.o .libs/gunidecomp.o
.libs/gutils.o .libs/gprintf.o .libs/giounix.o .libs/gspawn.o
-Wl,--whole-archive libcharset/.libs/libcharset.a
gnulib/.libs/libgnulib.a pcre/.libs/libpcre.a -Wl,--no-whole-archive
-Wl,--rpath -Wl,/home/avd/foo/local/sysroot/bfin-unknown-linux-gnu/usr/lib
-Wl,--rpath -Wl,/home/avd/foo/local/sysroot/bfin-unknown-linux-gnu/usr/lib
-Wl,-soname -Wl, -Wl,-version-script
-Wl,.libs/libglib-2.0.ver -o .libs/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]