dyld: EXIDX location #17

Closed
opened 2020-06-24 14:39:37 +08:00 by pca006132 · 1 comment

Each entry in the EXIDX contains:

  1. A PREL31 offset to the start of the function.
  2. A word with the following options:
    1. bit31 = 0: PREL31 offset to the start of the table entry (EXTAB) of the function.
    2. bit31 = 1: an exception handling table entry.
    3. 0x1: EXIDX_CANTUNWIND.

The first word is used for binary search for the exception handling entry of a function by its PC. The current dyld changes the relative position between the EXIDX and other parts of the ELF as the EXIDX is cloned to a vector. Hence, the unwinder would not be able to find the correct entry for the function.

Fix: either preserve the original position of the EXIDX section, or recompute the offset for the PC.

References:

@astro

Each entry in the EXIDX contains: 1. A PREL31 offset to the start of the function. 2. A word with the following options: 1. bit31 = 0: PREL31 offset to the start of the table entry (EXTAB) of the function. 2. bit31 = 1: an exception handling table entry. 3. `0x1`: EXIDX_CANTUNWIND. The first word is used for binary search for the exception handling entry of a function by its PC. The current dyld changes the relative position between the EXIDX and other parts of the ELF as the EXIDX is cloned to a vector. Hence, the unwinder would not be able to find the correct entry for the function. Fix: either preserve the original position of the EXIDX section, or recompute the offset for the PC. References: * Section 4 and 5 of https://static.docs.arm.com/ihi0038/b/IHI0038B_ehabi.pdf * Section 4.6 of https://static.docs.arm.com/ihi0044/e/IHI0044E_aaelf.pdf @astro

Loading it into the Image sounds like the most logical solution.

$ arm-none-eabihf-readelf -l artiq-zynq/examples/blink_forever.elf                                                   *[master] 
                                              
Elf file type is DYN (Shared object file)
Entry point 0x1000
There are 9 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x00000034 0x00000034 0x00120 0x00120 R   0x4
  LOAD           0x000000 0x00000000 0x00000000 0x002ec 0x002ec R   0x1000
  LOAD           0x001000 0x00001000 0x00001000 0x000e0 0x000e0 R E 0x1000
  LOAD           0x002000 0x00002000 0x00002000 0x00058 0x00058 RW  0x1000
  LOAD           0x003000 0x00003000 0x00003000 0x00024 0x00024 RW  0x1000
  DYNAMIC        0x002000 0x00002000 0x00002000 0x00058 0x00058 RW  0x4
  GNU_RELRO      0x002000 0x00002000 0x00002000 0x00058 0x01000 R   0x1
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0
  EXIDX          0x000290 0x00000290 0x00000290 0x00010 0x00010 R   0x4

In this sample EXIDX overlaps with a load segment. Seems it is to be loaded already and we just have to keep the address.

Loading it into the `Image` sounds like the most logical solution. ``` $ arm-none-eabihf-readelf -l artiq-zynq/examples/blink_forever.elf *[master] Elf file type is DYN (Shared object file) Entry point 0x1000 There are 9 program headers, starting at offset 52 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align PHDR 0x000034 0x00000034 0x00000034 0x00120 0x00120 R 0x4 LOAD 0x000000 0x00000000 0x00000000 0x002ec 0x002ec R 0x1000 LOAD 0x001000 0x00001000 0x00001000 0x000e0 0x000e0 R E 0x1000 LOAD 0x002000 0x00002000 0x00002000 0x00058 0x00058 RW 0x1000 LOAD 0x003000 0x00003000 0x00003000 0x00024 0x00024 RW 0x1000 DYNAMIC 0x002000 0x00002000 0x00002000 0x00058 0x00058 RW 0x4 GNU_RELRO 0x002000 0x00002000 0x00002000 0x00058 0x01000 R 0x1 GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0 EXIDX 0x000290 0x00000290 0x00000290 0x00010 0x00010 R 0x4 ``` In this sample `EXIDX` overlaps with a load segment. Seems it is to be loaded already and we just have to keep the address.
astro closed this issue 2020-06-25 08:04:44 +08:00
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/artiq-zynq#17
There is no content yet.