[PATCH] D154641: [ELF] Add --compress-sections

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 7 01:52:32 PDT 2023


peter.smith added a comment.

> We compute the section content/size once in finalizeAddressDependentContent before compression. If the content or size changes, the compressed content will be invalid, but we don't detect changed content (e.g., data commands). However, we detect size changes in assignOffsets.

I guess this means that if the writeTo() has any relocations they won't work with compression. The presence of relocations or possibly use of one of the relocate functions could generate an error. It probably wouldn't be intuitive to a user, but would protect them from wasting hours wondering why their data was corrupt (I'm assuming few people read the documentation). Off the top of my head "Cannot compress <output section>, <input section> from <object> contains relocations."

In armlink which does read-write data compression, we have this rather complicated scheme:

- Allocate Final VMA Addresses, with predictions for LMA
- Filter out relocations (in non compressed sections) to linker defined symbols that depend on a compressed address, this is easier in armlink as linker defined symbols are heavily constrained.
- Resolve relocation
- Compress RW Data
- Allocate post compression addresses, VMA remain the same, LMA Addresses may change.
- Resolve the filtered relocations

This adds considerable complexity though.

Not had a chance to go through the code and tests yet, been a very busy week. Will try and do that as soon as possible.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154641/new/

https://reviews.llvm.org/D154641



More information about the llvm-commits mailing list