Re: "Unknown symbol TOC. (err 0)" on little endian power 8, any solution for it?

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

 



I figure out a way today to fix "Unknown symbol TOC. (err 0)" issue.
That is use -mabi=elfv1 to build all your kernel related code. Let me
describe how to recreate it:

1, in A.c, need to call extern function defined in kernel module C,
and module A is built in user-space, under ppc64le, gcc or g++ will
use ABIv2 by default(-mabi=elfv2) to make the module A.o, so A.o has
ABI format of elfv2. If we use "readelf -a A.o" to check its symbol
table, we could find "UND TOC"

2, module B is a kernel module and include the module A.o, but in
Ubuntu 14.04, 3.13.0-29-generic, its kernel does not support ABIv2
yet, any code that built with kernel will use ABIv1 by default, so
B.ko is with ABIv1, but A.o is integrated into B.ko. If we use
"readelf -a B.ko", then could find "UND TOC" in B.ko too

3, Build kernel module C, and insert C.ko first, then insert B.ko,
will find inserting of B.ko failed, in dmesg

"Unknown symbol TOC. (err 0)"

- how to fix
use -mabi=elfv1 to build A.o!

2014-07-16 0:31 GMT+08:00 Tian Zhan <tzhan.subscribe@xxxxxxxxx>:
> Hi everyone,
>
> I am porting one project to little endian Power 8, on Ubuntu 14.04,
> hit this TOC unknown issue. I checked the code in project(in both C++
> and assembly file), no such TOC symbol ever used.
>
> And what's worse, I did not know which module should be blamed for
> this TOC issue, because lots of modules in my project have this TOC
> symbol(using objdump -t to check), but when they were linked together,
> only one TOC left. For example, A B C module both have TOC, then A B C
> linked together to generate D, only one TOC left in D, finally insert
> module D into Linux kernel, and hit unknown symbol TOC problem.
>
> g++ flags that I used:
> -m64 -mlittle-endian -mno-altivec -mtune=power4 -funit-at-a-time
> -fno-ivopts -Wa,-maltivec -D_FORTIFY_SOURCE=0 -fno-stack-protector
>
> ld flags:
> -m64 -melf64ppc
>
> kernel version:
> 3.13.0-29-generic
>
> gcc version:
> gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2
>
> I use to think that this issue is related with ABIv2 flag that created
> first time for little endian power, and kernel did not support the new
> ABI perfectly, since I saw lots of Linux kernel patches checked-in for
> this new flag(but these patches are not in 3.13.0-29 Ubuntu kernel),
> for example, the below 3 patches:
>
> - Build little endian ppc64 kernel with ABIv2
> 721aeaa9fdf35a672eef8ebdc4cd04bde38c3cea
>
> - Don't build assembly files with ABIv2
> http://patchwork.ozlabs.org/patch/341691/
>
>     We avoid ABIv2 when building c files since commit b2ca8c89 (powerpc:
>     Don't use ELFv2 ABI to build the kernel). Do the same for assembly
>     files.
>
> 58aedccb1907f05f702f0f6d8f8a57e8efe485b7
>
> - powerpc: EXPORT_SYMBOL(.TOC.)
>
>     For the ELFv2 ABI, powerpc introduces a magic symbol ".TOC.".  depmod
>     then complains that this doesn't resolve (so does modpost, but we could
>     easily fix that).  To export this, we need to use asm.
>
>     modpost and depmod both strip "." from symbols for the old PPC64 ELFv1
>     ABI, so we actually export a "TOC.".
>
> 9baeaef64095eab00c232f55df2e7c2d8e89845d
>
> Any idea or suggestion for this TOC issue? Thanks very much for you help.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux