[PATCH] D40967: [LLD][ELF] Remove Duplicate .ARM.exidx sections

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 7 09:29:15 PST 2017


peter.smith created this revision.
Herald added subscribers: kristof.beyls, javed.absar, emaste, aemerson.

The ARM.exidx section contains a table of 8-byte entries with the first word of each entry an offset to the function it describes and the second word instructions for unwinding if an exception is thrown from that function. The SHF_LINK_ORDER processing will order the table in ascending order of the functions described by the exception table entries. As the address range of an exception table entry is terminated by the next table entry, it is possible to merge consecutive table entries that have identical unwind instructions.

      

For this implementation we define a table entry to be identical if:

- Both entries are the special EXIDX_CANTUNWIND.
- Both entries have the same inline unwind instructions.

We do not attempt to establish if table entries that are references to
.ARM.extab sections are identical.

      

This implementation works at a granularity of a single .ARM.exidx InputSection. If all entries in the InputSection are identical to the previous table entry we can remove the InputSection. A more sophisticated but more complex implementation would rewrite InputSection contents so that duplicates within a .ARM.exidx InputSection can be merged. The implementation works really well for code compiled with -ffunction-sections and for code such as llvm that is compiled without exceptions (reduces to a single EXIDX_CANTUNWIND). For the real code I've tested it on it seems to be about half as effective as the fine grained approach, reducing the table size to approximately 70% of its original size. The fine grained approach as used by gold and bfd reduces table size to about 55% of its original value. If projects need the find grained approach I can keep working on this.

This is patch 3 of 3 in sequence:
-D40964 Move SHF_LINK_ORDER processing earlier in Writer.cpp [NFC]
-D40966 Refactor to remove loop copying all Sections in OS->finalize() [NFC]
-Remove Duplicate .ARM.exidx sections


https://reviews.llvm.org/D40967

Files:
  ELF/Config.h
  ELF/Driver.cpp
  ELF/Options.td
  ELF/Writer.cpp
  test/ELF/arm-exidx-dedup.s
  test/ELF/arm-exidx-gc.s
  test/ELF/arm-exidx-order.s
  test/ELF/arm-exidx-sentinel-orphan.s
  test/ELF/arm-static-defines.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40967.125980.patch
Type: text/x-patch
Size: 11964 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171207/b64ac10d/attachment.bin>


More information about the llvm-commits mailing list