Skip to content

Commit 4cedf4d

Browse files
authored
feat: add validate-elf-alignment command (#23)
1 parent 561f4aa commit 4cedf4d

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ jobs:
7070
| `rock-build-extra-params` | Extra parameters for rock build:android | No | - |
7171
| `comment-bot` | Whether to comment PR with build link | No | `true` |
7272
| `custom-identifier` | Custom identifier used in artifact naming for re-sign and ad-hoc flows to distinguish builds with the same native fingerprint | No | - |
73+
| `validate-elf-alignment` | Validate 16KB ELF alignment of native libraries (Google Play compliance) | No | `false` |
7374

7475
## Artifact Naming
7576

@@ -150,6 +151,27 @@ The following mappings are set:
150151

151152
Both conventions are set simultaneously, so the action works with any existing build configuration.
152153

154+
## ELF Alignment Validation
155+
156+
When `validate-elf-alignment: true`, the action verifies that all native shared libraries (`.so` files) in the APK are 16KB page-size aligned, as required by [Google Play for Android 15+ devices](https://developer.android.com/guide/practices/page-sizes).
157+
158+
The check runs **only on fresh builds** (not on cached/downloaded artifacts) and **before** re-signing or uploading. It performs two levels of verification:
159+
160+
1. **Zip-level alignment** via `zipalign -P 16` — checks that `.so` entries are correctly aligned within the APK archive
161+
2. **ELF-level alignment** via `objdump` — inspects each shared library's LOAD segment to confirm `2**14` (16KB) or higher alignment
162+
163+
The command only supports APK files. If the build produces an AAB, the step will fail with a clear error. If any 64-bit library (`arm64-v8a`, `x86_64`) is misaligned, the workflow fails with a list of affected libraries.
164+
165+
Internally this uses `npx rock validate-elf-alignment`, which requires `objdump` available on the runner. `zipalign` from Android build-tools 35.0.0+ is optional but recommended for zip-level checks.
166+
167+
```yaml
168+
- uses: callstackincubator/android@v3
169+
with:
170+
github-token: ${{ secrets.GITHUB_TOKEN }}
171+
variant: 'release'
172+
validate-elf-alignment: true
173+
```
174+
153175
## Prerequisites
154176
155177
- Ubuntu runner

action.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ inputs:
7171
custom-identifier:
7272
description: 'Custom identifier used in artifact naming for re-sign and ad-hoc flows to distinguish builds with the same native fingerprint'
7373
required: false
74+
validate-elf-alignment:
75+
description: 'Validate ELF alignment of native libraries (16KB page size compliance for Google Play)'
76+
required: false
77+
default: 'false'
7478

7579
outputs:
7680
artifact-url:
@@ -270,6 +274,13 @@ runs:
270274
echo "ARTIFACT_PATH=$BINARY_PATH" >> $GITHUB_ENV
271275
shell: bash
272276

277+
- name: Validate ELF Alignment
278+
if: ${{ inputs.validate-elf-alignment == 'true' && !env.ARTIFACT_URL && env.ARTIFACT_PATH }}
279+
run: |
280+
npx rock validate-elf-alignment "${{ env.ARTIFACT_PATH }}"
281+
shell: bash
282+
working-directory: ${{ inputs.working-directory }}
283+
273284
- name: Download and Unpack Binary
274285
if: ${{ env.ARTIFACT_URL && inputs.re-sign == 'true' }}
275286
run: |

0 commit comments

Comments
 (0)