WSL의 clang에 두 개의 라이브러리로 구성된 애플리케이션을 연결하고 있습니다. 내가 사용하는 명령은 다음과 같습니다(단순화).
clang -m32 -fsanitize=address -L _build/ -l:lib1.lib -l:lib2.lib -o test
$ uname -a
Linux ******* 4.4.0-19041-Microsoft #1237-Microsoft Sat Sep 11 14:32:00 PST 2021 x86_64 x86_64 x86_64 GNU/Linux
clang이 LD를 사용하도록 구성되었으며 연결 프로세스가 성공적으로 완료되었습니다. 하지만 파일을 실행하려고 하면
bash: ./test: cannot execute binary file: Exec format error
libc6-i386을 설치했습니다.
$ sudo apt install libc6-i386
Reading package lists... Done
Building dependency tree
Reading state information... Done
libc6-i386 is already the newest version (2.31-0ubuntu9.7).
0 upgraded, 0 newly installed, 0 to remove and 70 not upgraded.
$ file ./test
./test: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, BuildID[sha1]=dfdda2604f517942b1904bb686aa07b09f7ad968, for GNU/Linux 3.2.0, with debug_info, not stripped
$ objdump -p ./test
./test: file format elf32-i386
Program Header:
PHDR off 0x00000034 vaddr 0x08048034 paddr 0x08048034 align 2**2
filesz 0x00000180 memsz 0x00000180 flags r--
INTERP off 0x000001b4 vaddr 0x080481b4 paddr 0x080481b4 align 2**0
filesz 0x00000013 memsz 0x00000013 flags r--
LOAD off 0x00000000 vaddr 0x08048000 paddr 0x08048000 align 2**12
filesz 0x00026d60 memsz 0x00026d60 flags r--
LOAD off 0x00027000 vaddr 0x0806f000 paddr 0x0806f000 align 2**12
filesz 0x00217414 memsz 0x00217414 flags r-x
LOAD off 0x0023f000 vaddr 0x08287000 paddr 0x08287000 align 2**12
filesz 0x000c538c memsz 0x000c538c flags r--
LOAD off 0x00305104 vaddr 0x0834e104 paddr 0x0834e104 align 2**12
filesz 0x000230bc memsz 0x004879dc flags rw-
DYNAMIC off 0x003058b8 vaddr 0x0834e8b8 paddr 0x0834e8b8 align 2**2
filesz 0x00000128 memsz 0x00000128 flags rw-
NOTE off 0x000001c8 vaddr 0x080481c8 paddr 0x080481c8 align 2**2
filesz 0x00000044 memsz 0x00000044 flags r--
TLS off 0x00305104 vaddr 0x0834e104 paddr 0x0834e104 align 2**2
filesz 0x00000000 memsz 0x00000040 flags r--
EH_FRAME off 0x002be780 vaddr 0x08306780 paddr 0x08306780 align 2**2
filesz 0x0000821c memsz 0x0000821c flags r--
STACK off 0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**4
filesz 0x00000000 memsz 0x00000000 flags rw-
RELRO off 0x00305104 vaddr 0x0834e104 paddr 0x0834e104 align 2**0
filesz 0x00001efc memsz 0x00001efc flags r--
Dynamic Section:
NEEDED libpthread.so.0
NEEDED librt.so.1
NEEDED libm.so.6
NEEDED libdl.so.2
NEEDED libgcc_s.so.1
NEEDED libc.so.6
NEEDED ld-linux.so.2
INIT 0x0806f000
FINI 0x082863fc
PREINIT_ARRAY 0x0834e104
PREINIT_ARRAYSZ 0x00000004
INIT_ARRAY 0x0834e108
INIT_ARRAYSZ 0x000002a0
FINI_ARRAY 0x0834e3a8
FINI_ARRAYSZ 0x000001cc
GNU_HASH 0x0804820c
STRTAB 0x08059644
SYMTAB 0x0804d8b4
STRSZ 0x000120d2
SYMENT 0x00000010
DEBUG 0x00000000
PLTGOT 0x08350000
PLTRELSZ 0x00000138
PLTREL 0x00000011
JMPREL 0x0806ec28
REL 0x0806d038
RELSZ 0x00001bf0
RELENT 0x00000008
VERNEED 0x0806cec8
VERNEEDNUM 0x00000006
VERSYM 0x0806b716
Version References:
required from libgcc_s.so.1:
0x0b792653 0x00 14 GCC_3.3
0x0b792650 0x00 13 GCC_3.0
required from ld-linux.so.2:
0x0d696913 0x00 10 GLIBC_2.3
0x0d696911 0x00 08 GLIBC_2.1
required from libm.so.6:
0x0d696910 0x00 16 GLIBC_2.0
0x06969183 0x00 07 GLIBC_2.23
required from libdl.so.2:
0x0d696910 0x00 09 GLIBC_2.0
0x0d696911 0x00 05 GLIBC_2.1
required from libpthread.so.0:
0x09691a73 0x00 15 GLIBC_2.2.3
0x0d696911 0x00 06 GLIBC_2.1
0x0d696910 0x00 03 GLIBC_2.0
required from libc.so.6:
0x09691a74 0x00 18 GLIBC_2.2.4
0x0d696916 0x00 17 GLIBC_2.6
0x0d696911 0x00 12 GLIBC_2.1
0x0d696912 0x00 11 GLIBC_2.2
0x06969196 0x00 04 GLIBC_2.16
0x0d696910 0x00 02 GLIBC_2.0
나는 또한 성공하지 못한 채 GCC 프론트엔드와 연결을 시도했습니다.
-m32 없이 빌드/링크하면 작동하지만 -m32가 필요합니다.
아이디어가 부족합니다. 어디를 봐야 할지 조언을 주실 수 있는 분 계십니까?
답변1
해결되었습니다.
문제는 내가 아직 WSL1을 사용하고 있다는 것입니다.