-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nrf_compress: Add ARM thumb decompression code #17035
nrf_compress: Add ARM thumb decompression code #17035
Conversation
nordicjm
commented
Aug 27, 2024
The following west manifest projects have been modified in this Pull Request:
Note: This message is automatically posted and updated by the Manifest GitHub Action. |
CI InformationTo view the history of this post, clich the 'edited' button above Inputs:Sources:sdk-nrf: PR head: fabe6fe9100ed2d9222d064736ada7c430e03844 more detailssdk-nrf:
Github labels
List of changed files detected by CI (10)
Outputs:ToolchainVersion: 2aae60c2f9 Test Spec & Results: ✅ Success; ❌ Failure; 🟠 Queued; 🟡 Progress; ◻️ Skipped;
|
5028ab9
to
4d83fad
Compare
You can find the documentation preview for this PR at this link. It will be updated about 10 minutes after the documentation build succeeds. Note: This comment is automatically posted by the Documentation Publishing GitHub Action. |
Can you explain how this backend will be used. In chain with LZM2? |
Yes, what this code does it change relative jumps to absolute jumps, so if you imagine 7 functions all calling 1 function in the code, you can't compress those jumps because they're all unique, but if you replace the relative address with the absolute address, all of those can be replace. So you run this filter before compressing with lzma, you compress with only absolute addresses, then on the other end you decompress with lzma and change the absolute addresses back to relatives. On one of the matter sample applications the addition of the ARM thumb filter saved ~22KiB for the update |
4522d46
to
7423400
Compare
uint32_t i = 0; | ||
|
||
while ((i + 4) <= buf_size) { | ||
if ((buf[i + 1] & 0xF8) == 0xF0 && (buf[i + 3] & 0xF8) == 0xF8) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that this is same as in https://github.com/kobolabs/liblzma/blob/87b7682ce4b1c849504e2b3641cebaad62aaef87/src/liblzma/simple/armthumb.c, but is it possible that this has not been updated for Thumb 2 instruction set?
According to the armv7-m Architecture manual, the opcode, that is here 0xF8, has format:
1 1 J1 1 J2
so, yes it will have value 0xF8, but also 0xD0, 0xD8, 0xF0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a quick look through a disassembly of hello world and all the branch instructions are f0. On the test with the matter sample application this saved 20 or so KiB so I think the ones that are used by GCC seem to be covered well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that is true that compilers tend to favor some opcodes.
Adds armthumb filter files taken from xz-5.6.2.tar.gz, the license for these files is as follows: LZMA SDK is written and placed in the public domain by Igor Pavlov. Some code in LZMA SDK is based on public domain code from another developers: 1) PPMd var.H (2001): Dmitry Shkarin 2) SHA-256: Wei Dai (Crypto++ library) Anyone is free to copy, modify, publish, use, compile, sell, or distribute the original LZMA SDK code, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. LZMA SDK code is compatible with open source licenses, for example, you can include it to GNU GPL or GNU LGPL code. Signed-off-by: Jamie McCrae <[email protected]>
Allows usage of the ARM thumb filter Signed-off-by: Jamie McCrae <[email protected]>
Adds a test to ensure the library is working Signed-off-by: Jamie McCrae <[email protected]>
7423400
to
fabe6fe
Compare