通用 ELF 中的重定位(EM:183)

问题描述 投票:0回答:1

这以前有用过。我不知道发生了什么,问题是我不能再跑了。我正在使用 Ubuntu 16.04 x86-64 对 aarch64 架构与 ARM cpu 进行交叉编译。

这就是我正在运行的配置:

./configure --host=aarch64-linux-gnu --prefix=/data/data/papi/independent --exec-prefix=/data/data/papi/dependent --with-static-lib=yes -- with-shared-lib=no --with-static-tools --with-arch=aarch64 --with-CPU=arm --with-ffsll --with-walltimer=cycle --with-tls=__thread --with -virtualtimer=clock_cputime_id --with-perf-events

运行配置的日志:

checking for architecture... aarch64
checking for OS... linux
checking for OS version... 4.15.0-29-generic
checking for perf_event workaround level... autodetect
checking for if MIC should be used... no
checking for aarch64-linux-gnu-xlc... no
checking for aarch64-linux-gnu-icc... no
checking for aarch64-linux-gnu-gcc... aarch64-linux-gnu-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether aarch64-linux-gnu-gcc accepts -g... yes
checking for aarch64-linux-gnu-gcc option to accept ISO C89... none needed
checking for aarch64-linux-gnu-xlf... no
checking for aarch64-linux-gnu-ifort... no
checking for aarch64-linux-gnu-gfortran... no
checking for aarch64-linux-gnu-f95... no
checking for aarch64-linux-gnu-f90... no
checking for aarch64-linux-gnu-f77... no
checking for xlf... no
checking for ifort... no
checking for gfortran... gfortran
configure: WARNING: using cross tools not prefixed with host triplet
checking whether we are using the GNU Fortran 77 compiler... yes
checking whether gfortran accepts -g... yes
checking for mpicc... mpicc
checking for gawk... gawk
checking how to run the C preprocessor... aarch64-linux-gnu-gcc -E
checking whether ln -s works... yes
checking whether make sets $(MAKE)... yes
checking for aarch64-linux-gnu-ranlib... aarch64-linux-gnu-ranlib
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for ANSI C header files... (cached) yes
checking for inline... inline
checking whether time.h and sys/time.h may both be included... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking c_asm.h usability... no
checking c_asm.h presence... no
checking for c_asm.h... no
checking intrinsics.h usability... no
checking intrinsics.h presence... no
checking for intrinsics.h... no
checking mach/mach_time.h usability... no
checking mach/mach_time.h presence... no
checking for mach/mach_time.h... no
checking sched.h usability... yes
checking sched.h presence... yes
checking for sched.h... yes
checking for gethrtime... no
checking for read_real_time... no
checking for time_base_to_time... no
checking for clock_gettime... yes
checking for mach_absolute_time... no
checking for sched_getcpu... yes
checking for dlopen and dlerror symbols in base system... not found
checking for dlopen and dlerror symbols in -ldl... found
checking for native compiler for header generation... gcc
checking for debug build... 
checking for -Wno-override-init... 1
checking for CPU type... arm
forcing use of pthread mutexes... 
checking for ffsll... yes
checking for working gettid... no
checking for working syscall(SYS_gettid)... yes
checking for which real time clock to use... cycle
checking for high performance thread local storage... __thread
checking for which virtual timer to use... clock_cputime_id
checking for static user preset events... no
checking for static PAPI preset events... yes
checking for whether to build static library... yes
checking for whether to build shared library... no
checking for static compile of tests and utilities... yes
checking for linking with papi shared library of tests and utilities... no
checking platform... linux-pe
checking for components to build... perf_event perf_event_uncore
checking for PAPI event CSV filename to use... papi_events.csv
configure: Compiling genpapifdef with gcc because cross compiling
configure: Generating fpapi.h
configure: Generating f77papi.h
configure: Generating f90papi.h
configure: Rules.pfm4_pe will be included in the generated Makefile
configure: creating ./config.status
config.status: creating Makefile
config.status: creating papi.pc
config.status: creating components/Makefile_comp_tests.target
config.status: creating testlib/Makefile.target
config.status: creating utils/Makefile.target
config.status: creating ctests/Makefile.target
config.status: creating ftests/Makefile.target
config.status: creating validation_tests/Makefile.target
config.status: creating config.h

运行 make 后:

(...)

mpicc -I../testlib -I../validation_tests -I.. -I.  -g -Wextra -DUSE_PTHREAD_MUTEXES  -Wall -O1  first.c ../testlib/libtestlib.a ../testlib/do_loops.o ../libpapi.a -ldl -static -o mpifirst 
/usr/bin/ld: ../testlib/libtestlib.a(test_utils.o): Relocations in generic ELF (EM: 183)
/usr/bin/ld: ../testlib/libtestlib.a(test_utils.o): Relocations in generic ELF (EM: 183)
/usr/bin/ld: ../testlib/libtestlib.a(test_utils.o): Relocations in generic ELF (EM: 183)
/usr/bin/ld: ../testlib/libtestlib.a(test_utils.o): Relocations in generic ELF (EM: 183)
/usr/bin/ld: ../testlib/libtestlib.a(test_utils.o): Relocations in generic ELF (EM: 183)
/usr/bin/ld: ../testlib/libtestlib.a(test_utils.o): Relocations in generic ELF (EM: 183)
../testlib/libtestlib.a: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
Makefile.recipies:230: recipe for target 'mpifirst' failed
make[2]: *** [mpifirst] Error 1
make[2]: Leaving directory '/home/lfpm1993/Desktop/papi/src/ctests'
Makefile.inc:240: recipe for target 'ctests' failed
make[1]: *** [ctests] Error 2
make[1]: Leaving directory '/home/lfpm1993/Desktop/papi/src'
Rules.pfm4_pe:42: recipe for target 'libpfm4/lib/libpfm.a' failed
make: *** [libpfm4/lib/libpfm.a] Error 2

文件 test_utils.o 给出:

test_utils.o:ELF 64 位 LSB 可重定位,ARM aarch64,版本 1 (SYSV),未剥离

在我看来,它是我正在尝试构建的文件的正确类型。

有什么解决办法的线索吗?

谢谢, 路易斯

linux cross-compiling elf
1个回答
4
投票
mpicc -I../testlib ...  first.c ../testlib/libtestlib.a ...
/usr/bin/ld: ../testlib/libtestlib.a(test_utils.o): Relocations in generic ELF (EM: 183)

这调用了错误的链接器(系统链接器),并且很可能还调用了错误的编译器来编译

first.c

当你跑步时会发生什么”

mpicc -c  -I../testlib -I../validation_tests -I.. -I.  -DUSE_PTHREAD_MUTEXES first.c
file first.o

我打赌它说的是

ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
,这可以解释你的问题:你的
libtestlib.a
是针对所需的架构进行编译的,但你的主程序不是。

我可以通过尝试将

x86_64
foo.o
aarch64
对象库链接来重现此确切的错误消息。

这以前有用过。

可能您之前修改了

PATH
,使得
mpicc
找到了目标
gcc
。以及您如何忽略适当设置
PATH

(依赖于

Makefile
和其他环境变量的
PATH
是最糟糕的——它们在一个 shell 中工作,但在另一个 shell 中不起作用。)

© www.soinside.com 2019 - 2024. All rights reserved.