[AArch64/bfd/2.24] relocation truncated to fit: R_AARCH64_LD64_GOT_LO12_NC against
David Abdurachmanov
david.abdurachmanov@gmail.com
Sat Jul 12 20:56:00 GMT 2014
On Jul 11, 2014, at 10:35 PM, Andreas Schwab wrote:
> David Abdurachmanov <david.abdurachmanov@gmail.com> writes:
>
>> I got these linker errors:
>>
>> libcvmfs.a(libcvmfs.a_pub.o): In function `TryArgumentFormatter':
>> :(.text+0x77044): relocation truncated to fit: R_AARCH64_LD64_GOT_LO12_NC against `js_GetErrorMessage'
>
> That usually happens when there are conflicting declarations, ie. the
> same variable has different types in different translation units. In
> other words, this is a bug in the sources, not in the linker.
I have some doubts about it. I removed SpiderMonkey from dependencies and
from code, then I had problems with cURL. I updated cURL, then I had different
cURL relocation problem. It always seems to be related to functions, e.g.,
passing a callback (function pointer). It's always R_AARCH64_LD64_GOT_LO12_NC.
The current one:
libcvmfs.a(libcvmfs.a_pub.o): In function `Curl_http':
:(.text+0x8234c): relocation truncated to fit: R_AARCH64_LD64_GOT_LO12_NC
against `Curl_FormReader'
000000000007e20c <Curl_FormReader>:
7e20c: a9bc7bfd stp x29, x30, [sp,#-64]!
7e210: 910003fd mov x29, sp
7e214: a90153f3 stp x19, x20, [sp,#16]
[snip]
0000000000081424 <Curl_http>:
81424: d10443ff sub sp, sp, #0x110
81428: a9047bfd stp x29, x30, [sp,#64]
8142c: 910103fd add x29, sp, #0x40
81430: a90553f3 stp x19, x20, [sp,#80]
81434: a9065bf5 stp x21, x22, [sp,#96]
81438: a90763f7 stp x23, x24, [sp,#112]
[snip]
82338: 94000000 bl 7e1e8 <Curl_FormInit>
8233c: 35001100 cbnz w0, 8255c <Curl_http+0x1138>
82340: f941be60 ldr x0, [x19,#888]
82344: f9002ae0 str x0, [x23,#80]
82348: 90000000 adrp x0, 7e20c <Curl_FormReader>
8234c: f9400000 ldr x0, [x0]
82350: f901c278 str x24, [x19,#896]
82354: f901be60 str x0, [x19,#888]
Relocation section '.rela.text' at offset 0x7c7c70 contains 19929 entries:
Offset Info Type Symbol's Value
Symbol's Name + Addend
000000000008234c 0000145300000138 R_AARCH64_LD64_GOT_LO1 000000000007e20c
Curl_FormReader + 0
That is enough to break it:
c++ test_libcvmfs.cc.o -o test_libcvmfs libcvmfs.a -lssl -lcrypto -lrt
-lpthread -ldl
libcvmfs.a is a "combined" static library of libcvmfs_only.a, libz.a,
libsqlite3.a, libcurl.a, and libcares.a.
Linking them altogether separate works fine (binary [test_libcvmfs] also
works):
c++ test_libcvmfs.cc.o -o test_libcvmfs libcvmfs_only.a libz.a libsqlite3.a
libcurl.a libcares.a -lssl -lcrypto -lrt -lpthread -ldl
What they do is to unpack all static libraries (libcvmfs_only.a, libz.a,
libsqlite3.a, libcurl.a, libcares.a), then merge them all together (ld -r
${OBJECTS} -o ${MERGED_OBJ}) and then keeps the public and weak symbols
(objcopy --keep-global-symbols=$PUBLIC_SYMS
--keep-global-symbols=$tmpdir/W_syms $MERGED_OBJ $MERGED_PUBLIC_OBJ). Then it's
packages in ar archive.
They combine them using combine_libs bash scripts:
combine_libs -public libcvmfs_public_syms.txt libcvmfs.a libz.a libsqlite3.a
libcurl.a libcares.a libcvmfs_only.a
combine_libs bash script is below.
More ideas? I will keep debugging it.
david
#!/bin/sh
set -x
PUBLIC_SYMS=""
if [ "$1" = "-public" ]; then
shift
PUBLIC_SYMS=$1
shift
fi
OUTLIB=$1
shift
OBJECTS=""
TDIRS=""
for inlib; do
inlib_base=`basename $inlib`
tmpdir=${inlib_base}.objdir.$$
TDIRS="$TDIRS $tmpdir"
if ( mkdir $tmpdir &&
cp $inlib $tmpdir/${inlib_base} &&
cd $tmpdir &&
ar x $inlib_base &&
rm $inlib_base ); then
OBJECTS="${OBJECTS} `ls $tmpdir/*`"
else
echo "Failed to extract $inlib for $OUTLIB."
exit 1
fi
done
# if a file containing a list of public symbols was specified, merge
# all the objects together and localize all non-public symbols
if [ "$PUBLIC_SYMS" != "" ]; then
tmpdir=${OUTLIB}.objdir.$$
TDIRS="$TDIRS $tmpdir"
MERGED_OBJ=$tmpdir/`basename $OUTLIB`.o
MERGED_PUBLIC_OBJ=$tmpdir/`basename $OUTLIB`_pub.o
# Note that we avoid localizing weak global symbols, because doing so
# causes STL stuff to fail when the library is linked.
if ( mkdir $tmpdir &&
ld -r ${OBJECTS} -o ${MERGED_OBJ} &&
( nm ${MERGED_OBJ} | awk ' $2 == "W" {print $3}' | sort | uniq > $tmpdir/W_syms ) &&
objcopy --keep-global-symbols=$PUBLIC_SYMS --keep-global-symbols=$tmpdir/W_syms $MERGED_OBJ $MERGED_PUBLIC_OBJ); then
# we just need this one merged object file
OBJECTS=$MERGED_PUBLIC_OBJ
else
echo "Failed to produce merged public object for $OUTLIB."
exit 1
fi
fi
rm -f $OUTLIB
ar r $OUTLIB ${OBJECTS} || exit 1
for dir in $TDIRS; do
rm -rf $dir
done
exit 0
More information about the Binutils
mailing list