交叉编译出现提示 plugin needed to handle lto object

Posted 为了维护世界和平_

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了交叉编译出现提示 plugin needed to handle lto object相关的知识,希望对你有一定的参考价值。


zynq平台下 移植openamp,交叉编译出现 plugin needed to handle lto object问题

shell环境下交叉编译输出

[ 94%] Building C object lib/CMakeFiles/metal-static.dir/system/generic/xlnx_common/irq.c.obj
cd /home/wy/openamp/libmetal-master/build/lib && /opt/aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc -DDEFAULT_LOGGER_ON -DMETAL_INTERNAL -I/home/wy/openamp/libmetal-master/build/lib/include  -Wall -Werror -Wextra        -flto -Os -I/opt/pkg/petalinux/2020.2/ZYNQ/build/tmp/work/zynqmp_generic-xilinx-linux/fsbl/2020.2+gitAUTOINC+08b9f4304d-r0/build/fsbl/zynqmp_fsbl_bsp/psu_cortexa53_0/include   -Wall -Werror -Wextra -o CMakeFiles/metal-static.dir/system/generic/xlnx_common/irq.c.obj   -c /home/wy/openamp/libmetal-master/lib/system/generic/xlnx_common/irq.c
[100%] Linking C static library libmetal.a
cd /home/wy/openamp/libmetal-master/build/lib && /usr/bin/cmake -P CMakeFiles/metal-static.dir/cmake_clean_target.cmake
cd /home/wy/openamp/libmetal-master/build/lib && /usr/bin/cmake -E cmake_link_script CMakeFiles/metal-static.dir/link.txt --verbose=1
aarch64-linux-gnu-ar qc libmetal.a  CMakeFiles/metal-static.dir/dma.c.obj CMakeFiles/metal-static.dir/device.c.obj CMakeFiles/metal-static.dir/init.c.obj CMakeFiles/metal-static.dir/io.c.obj CMakeFiles/metal-static.dir/irq.c.obj CMakeFiles/metal-static.dir/log.c.obj CMakeFiles/metal-static.dir/shmem.c.obj CMakeFiles/metal-static.dir/softirq.c.obj CMakeFiles/metal-static.dir/version.c.obj CMakeFiles/metal-static.dir/system/generic/condition.c.obj CMakeFiles/metal-static.dir/system/generic/device.c.obj CMakeFiles/metal-static.dir/system/generic/init.c.obj CMakeFiles/metal-static.dir/system/generic/io.c.obj CMakeFiles/metal-static.dir/system/generic/irq.c.obj CMakeFiles/metal-static.dir/system/generic/shmem.c.obj CMakeFiles/metal-static.dir/system/generic/time.c.obj CMakeFiles/metal-static.dir/system/generic/zynqmp_a53/sys.c.obj CMakeFiles/metal-static.dir/system/generic/xlnx_common/irq.c.obj
BFD: CMakeFiles/metal-static.dir/dma.c.obj: plugin needed to handle lto object
BFD: CMakeFiles/metal-static.dir/device.c.obj: plugin needed to handle lto object
BFD: CMakeFiles/metal-static.dir/init.c.obj: plugin needed to handle lto object
BFD: CMakeFiles/metal-static.dir/io.c.obj: plugin needed to handle lto object
BFD: CMakeFiles/metal-static.dir/irq.c.obj: plugin needed to handle lto object
BFD: CMakeFiles/metal-static.dir/log.c.obj: plugin needed to handle lto object
BFD: CMakeFiles/metal-static.dir/shmem.c.obj: plugin needed to handle lto object
BFD: CMakeFiles/metal-static.dir/softirq.c.obj: plugin needed to handle lto object
BFD: CMakeFiles/metal-static.dir/version.c.obj: plugin needed to handle lto object
BFD: CMakeFiles/metal-static.dir/system/generic/condition.c.obj: plugin needed to handle lto object
BFD: CMakeFiles/metal-static.dir/system/generic/device.c.obj: plugin needed to handle lto object
BFD: CMakeFiles/metal-static.dir/system/generic/init.c.obj: plugin needed to handle lto object
BFD: CMakeFiles/metal-static.dir/system/generic/io.c.obj: plugin needed to handle lto object
BFD: CMakeFiles/metal-static.dir/system/generic/irq.c.obj: plugin needed to handle lto object
BFD: CMakeFiles/metal-static.dir/system/generic/shmem.c.obj: plugin needed to handle lto object
BFD: CMakeFiles/metal-static.dir/system/generic/time.c.obj: plugin needed to handle lto object
BFD: CMakeFiles/metal-static.dir/system/generic/zynqmp_a53/sys.c.obj: plugin needed to handle lto object
BFD: CMakeFiles/metal-static.dir/system/generic/xlnx_common/irq.c.obj: plugin needed to handle lto object
/opt/aarch64-linux-gnu/bin/aarch64-linux-gnu-ranlib libmetal.a

生成的静态库libmetal.a

使用此静态库时,输出未定义 undefined reference to

/tmp/ccCjNKbE.ltrans0.ltrans.o: In function `rpmsg_endpoint_cb':
<artificial>:(.text+0x26c): undefined reference to `rpmsg_send_offchannel_raw'
/tmp/ccCjNKbE.ltrans0.ltrans.o: In function `zynqmp_linux_r5_proc_remove':
<artificial>:(.text+0x2e0): undefined reference to `metal_irq_disable'
<artificial>:(.text+0x2f0): undefined reference to `metal_irq_register'
<artificial>:(.text+0x2f8): undefined reference to `metal_device_close'
<artificial>:(.text+0x30c): undefined reference to `metal_device_close'
/tmp/ccCjNKbE.ltrans0.ltrans.o: In function `zynqmp_linux_r5_proc_init':
<artificial>:(.text+0x364): undefined reference to `metal_device_open'
<artificial>:(.text+0x424): undefined reference to `metal_device_open'
<artificial>:(.text+0x48c): undefined reference to `metal_irq_register'
<artificial>:(.text+0x494): undefined reference to `metal_irq_enable'
<artificial>:(.text+0x4bc): undefined reference to `metal_device_close'
<artificial>:(.text+0x4c4): undefined reference to `metal_device_close'
/tmp/ccCjNKbE.ltrans0.ltrans.o: In function `main':
<artificial>:(.text.startup+0x28): undefined reference to `init_system'
<artificial>:(.text.startup+0x78): undefined reference to `remoteproc_init'
<artificial>:(.text.startup+0xbc): undefined reference to `remoteproc_mmap'
<artificial>:(.text.startup+0xf8): undefined reference to `remoteproc_set_rsc_table'
<artificial>:(.text.startup+0x110): undefined reference to `remoteproc_remove'
<artificial>:(.text.startup+0x174): undefined reference to `remoteproc_get_io_with_pa'
<artificial>:(.text.startup+0x26c): undefined reference to `remoteproc_create_virtio'
<artificial>:(.text.startup+0x2a8): undefined reference to `rpmsg_virtio_init_shm_pool'
<artificial>:(.text.startup+0x2cc): undefined reference to `rpmsg_init_vdev'
<artificial>:(.text.startup+0x2e8): undefined reference to `remoteproc_remove_virtio'
<artificial>:(.text.startup+0x324): undefined reference to `rpmsg_create_ept'
<artificial>:(.text.startup+0x35c): undefined reference to `metal_irq_save_disable'
<artificial>:(.text.startup+0x378): undefined reference to `metal_irq_restore_enable'
<artificial>:(.text.startup+0x384): undefined reference to `remoteproc_get_notification'
<artificial>:(.text.startup+0x398): undefined reference to `rpmsg_destroy_ept'
<artificial>:(.text.startup+0x3a4): undefined reference to `metal_irq_restore_enable'
<artificial>:(.text.startup+0x3b4): undefined reference to `rpmsg_deinit_vdev'
<artificial>:(.text.startup+0x3c0): undefined reference to `remoteproc_remove_virtio'
<artificial>:(.text.startup+0x3e8): undefined reference to `remoteproc_remove'
<artificial>:(.text.startup+0x3ec): undefined reference to `cleanup_system'

使用nm查看静态库中的函数

#nm libmetal.a
...
irq.c.obj:
0000000000000000 d $d
0000000000000000 d irq_cntrs
00000000000001ac T metal_irq_disable
00000000000001a4 T metal_irq_enable
0000000000000000 t metal_irq_get_controller
0000000000000130 T metal_irq_register
0000000000000078 T metal_irq_register_controller
0000000000000044 t _metal_irq_set_enable
0000000000000000 t $x
...

函数确实存在,为啥提示找不到?

仔细看一下编译出来的静态库打印输出,有提示

plugin needed to handle lto object

这原来是错误,源码生成的.o文件是正确的,在使用xxx-ar生成静态库阶段出现错误。在编译的时候没有提示错误,警告也没有 晕倒!!!

如何解决

创建文件夹bfd-plugins,注意新建文件夹的路径,要在交叉编译工具的lib下

bfd-plugins

将库文件liblto_plugin.so拷贝到此文件夹下,软连接一同拷贝

cp -D  /opt/aarch64-linux-gnu/libexec/gcc/aarch64-linux-gnu/5.2.1/liblto_plugin.so  /opt/aarch64-linux-gnu/lib/bfd-plugins/
root@ubuntu:/opt/aarch64-linux-gnu/lib/bfd-plugins# ls -l
lrwxrwxrwx 1 root root     22 Oct 26 23:01 liblto_plugin.so -> liblto_plugin.so.0.0.0
lrwxrwxrwx 1 root root     22 Oct 26 23:01 liblto_plugin.so.0 -> liblto_plugin.so.0.0.0
-rwxr-xr-x 1 root root 278206 Oct 26 23:01 liblto_plugin.so.0.0.0

这样再交叉编译就不会有 plugin needed to handle lto object 错误提示了,交叉编译的静态库使用正常。

以上是关于交叉编译出现提示 plugin needed to handle lto object的主要内容,如果未能解决你的问题,请参考以下文章

extract-text-webpack-plugin(you may need an appropriate loader to handle this file type)

Win10蓝屏提示Your PC/Device needs to be repaired

Win10蓝屏提示Your PC/Device needs to be repaired怎么办

Win10蓝屏提示Your PC/Device needs to be repaired怎么办?

我的数码相框.c文件用arm-linux-gcc交叉编译时出现错误,如tgzip.c:309:undefined reference to

You need to run build with JDK or have tools.jar问题解决