0

我正在尝试在使用readelf -S libtest.soclang11 & '--target=arm-linux-androideabi21 -march=armv7-a' & cflags '-funwind-table -fno-exceptions' 编译的 32 位 libtest.so 上使用该命令。在输出中找不到“.eh_frame”或“.eh_frame_hdr”段。但是,在64位so中肯定是存在的(编译时使用'--target=aarch64-linux-android21')。有人知道原因吗?

32bit:
---------------------------------------------------------------------------------
There are 29 section headers, starting at offset 0x2c3c6b8:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .interp           PROGBITS        00000174 000174 000013 00   A  0   0  1
  [ 2] .note.android.ide NOTE            00000188 000188 000098 00   A  0   0  4
  [ 3] .note.crashpad.in NOTE            00000220 000220 00001c 00   A  0   0  4
  [ 4] .note.gnu.build-i NOTE            0000023c 00023c 000024 00   A  0   0  4
  [ 5] .dynsym           DYNSYM          00000260 000260 005550 10   A 10   1  4
  [ 6] .gnu.version      VERSYM          000057b0 0057b0 000aaa 02   A  5   0  2
  [ 7] .gnu.version_r    VERNEED         0000625c 00625c 000060 00   A 10   3  4
  [ 8] .gnu.hash         GNU_HASH        000062bc 0062bc 001a14 00   A  5   0  4
  [ 9] .hash             HASH            00007cd0 007cd0 002ab0 04   A  5   0  4
  [10] .dynstr           STRTAB          0000a780 00a780 016bf6 00   A  0   0  1
  [11] .rel.dyn          LOOS+0x1        00021378 021378 0297f6 01   A  5   0  4
  [12] .ARM.exidx        ARM_EXIDX       0004ab70 04ab70 1be028 00  AL 16   0  4
  [13] .rel.plt          REL             00208b98 208b98 000db0 08   A  5  23  4
  [14] .rodata           PROGBITS        00209a00 209a00 55b9ac 00 AMS  0   0 256
  [15] .ARM.extab        PROGBITS        007653ac 7653ac 005d04 00   A  0   0  4
  [16] .text             PROGBITS        0076b0c0 76b0c0 22e96f4 00  AX  0   0 64
  [17] .plt              PROGBITS        02a547c0 2a547c0 001b80 00  AX  0   0 16
  [18] .fini_array       FINI_ARRAY      02a57340 2a56340 000008 00  WA  0   0  4
  [19] .data.rel.ro      PROGBITS        02a57348 2a56348 1c300c 00  WA  0   0  8
  [20] .init_array       INIT_ARRAY      02c1a354 2c19354 000018 00  WA  0   0  4
  [21] .dynamic          DYNAMIC         02c1a36c 2c1936c 000100 08  WA 10   0  4
  [22] .got              PROGBITS        02c1a46c 2c1946c 000298 00  WA  0   0  4
  [23] .got.plt          PROGBITS        02c1a704 2c19704 0006e4 00  WA  0   0  4
  [24] .bss.rel.ro       NOBITS          02c1ade8 2c19de8 000000 00  WA  0   0  1
  [25] .data             PROGBITS        02c1bde8 2c19de8 022624 00  WA  0   0  8
  [26] .bss              NOBITS          02c3e410 2c3c40c 439c3c 00  WA  0   0 16
  [27] .comment          PROGBITS        00000000 2c3c40c 000193 01  MS  0   0  1
  [28] .shstrtab         STRTAB          00000000 2c3c59f 000116 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
  L (link order), O (extra OS processing required), G (group), T (TLS),
  C (compressed), x (unknown), o (OS specific), E (exclude),
  y (purecode), p (processor specific)
---------------------------------------------------------------------------------

64bit:
---------------------------------------------------------------------------------
There are 28 section headers, starting at offset 0x59b4b30:

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .note.android.ide NOTE             0000000000000238  00000238
       0000000000000098  0000000000000000   A       0     0     4
  [ 2] .note.crashpad.in NOTE             00000000000002d0  000002d0
       0000000000000020  0000000000000000   A       0     0     4
  [ 3] .note.gnu.build-i NOTE             00000000000002f0  000002f0
       0000000000000024  0000000000000000   A       0     0     4
  [ 4] .dynsym           DYNSYM           0000000000000318  00000318
       0000000000007cb0  0000000000000018   A       9     1     8
  [ 5] .gnu.version      VERSYM           0000000000007fc8  00007fc8
       0000000000000a64  0000000000000002   A       4     0     2
  [ 6] .gnu.version_r    VERNEED          0000000000008a2c  00008a2c
       0000000000000060  0000000000000000   A       9     3     4
  [ 7] .gnu.hash         GNU_HASH         0000000000008a90  00008a90
       00000000000018e0  0000000000000000   A       4     0     8
  [ 8] .hash             HASH             000000000000a370  0000a370
       0000000000002998  0000000000000004   A       4     0     4
  [ 9] .dynstr           STRTAB           000000000000cd08  0000cd08
       000000000001949f  0000000000000000   A       0     0     1
  [10] .rela.dyn         LOOS+0x2         00000000000261a8  000261a8
       0000000000137999  0000000000000001   A       4     0     8
  [11] .rela.plt         RELA             000000000015db48  0015db48
       0000000000002af0  0000000000000018  AI       4    24     8
  [12] .rodata           PROGBITS         0000000000160700  00160700
       00000000006e0d98  0000000000000000 AMS       0     0     256
  [13] .gcc_except_table PROGBITS         0000000000841498  00841498
       0000000000000f84  0000000000000000   A       0     0     4
  [14] .eh_frame_hdr     PROGBITS         000000000084241c  0084241c
       00000000003539c4  0000000000000000   A       0     0     4
  [15] .eh_frame         PROGBITS         0000000000b95de0  00b95de0
       0000000000d5494c  0000000000000000   A       0     0     8
  [16] .text             PROGBITS         00000000018ea740  018ea740
       0000000003cb336c  0000000000000000  AX       0     0     64
  [17] malloc_hook       PROGBITS         000000000559daac  0559daac
       00000000000000c8  0000000000000000  AX       0     0     2
  [18] .plt              PROGBITS         000000000559db80  0559db80
       0000000000001cc0  0000000000000000  AX       0     0     16
  [19] .data.rel.ro      PROGBITS         00000000055a0840  0559f840
       00000000003a4d48  0000000000000000  WA       0     0     8
  [20] .fini_array       FINI_ARRAY       0000000005945588  05944588
       0000000000000010  0000000000000008  WA       0     0     8
  [21] .init_array       INIT_ARRAY       0000000005945598  05944598
       0000000000000020  0000000000000000  WA       0     0     8
  [22] .dynamic          DYNAMIC          00000000059455b8  059445b8
       0000000000000200  0000000000000010  WA       9     0     8
  [23] .got              PROGBITS         00000000059457b8  059447b8
       000000000001c578  0000000000000000  WA       0     0     8
  [24] .got.plt          PROGBITS         0000000005961d30  05960d30
       0000000000000e68  0000000000000000  WA       0     0     8
  [25] .data             PROGBITS         0000000005963b98  05961b98
       0000000000052e78  0000000000000000  WA       0     0     8
  [26] .bss              NOBITS           00000000059b6a40  059b4a10
       00000000004cbb40  0000000000000000  WA       0     0     64
  [27] .shstrtab         STRTAB           0000000000000000  059b4a10
       000000000000011b  0000000000000000           0     0     1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
  L (link order), O (extra OS processing required), G (group), T (TLS),
  C (compressed), x (unknown), o (OS specific), E (exclude),
  p (processor specific)
---------------------------------------------------------------------------------
4

1 回答 1

0

我在 arm32 的 libtest.so 中发现 -funwind-table 和 -fno-unwind-table 的大小不同:

-funwind-table:
    FILE SIZE        VM SIZE    
 --------------  -------------- 
   5.2%  2.77Mi   4.8%  2.77Mi    .ARM.exidx
   0.0%  25.6Ki   0.0%  25.6Ki    .ARM.extab

-fno-unwind-table:
    FILE SIZE        VM SIZE    
 --------------  -------------- 
   0.0%  5.36Ki   0.0%  5.36Ki    .ARM.exidx
   0.0%  5.62Ki   0.0%  5.62Ki    .ARM.extab

因此,arm32 的展开表信息在 .ARM.exidx/.ARM.extab 中,与 arm64 中的 .eh_frame/.eh_frame_hdr 不同。

于 2021-10-21T02:05:17.827 回答