Skip to content

Commit bc0f847

Browse files
committed
gh-actions: print elf alignment
1 parent 45621c8 commit bc0f847

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

.github/workflows/go.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,38 @@ jobs:
9999
# WHERE tag = 'DW_TAG_subprogram'
100100
# ORDER BY function_size DESC
101101
# LIMIT 50;"
102+
readelf -l jni/arm64-v8a/*.so
103+
104+
# from: cs.android.com/android/platform/superproject/main/+/main:system/extras/tools/check_elf_alignment.sh;drc=97bcb31779;l=87
105+
RED="\e[31m"
106+
GREEN="\e[32m"
107+
ENDCOLOR="\e[0m"
108+
109+
unaligned_libs=()
110+
111+
echo
112+
echo "=== ELF alignment ==="
113+
114+
matches="$(find jni/arm64-v8a/ -type f)"
115+
IFS=$'\n'
116+
for match in $matches; do
117+
[[ $(file "${match}") == *"ELF"* ]] || continue
118+
119+
res="$(objdump -p "${match}" | grep LOAD | awk '{ print $NF }' | head -1)"
120+
if [[ $res =~ 2\*\*(1[4-9]|[2-9][0-9]|[1-9][0-9]{2,}) ]]; then
121+
echo -e "${match}: ${GREEN}ALIGNED${ENDCOLOR} ($res)"
122+
else
123+
echo -e "${match}: ${RED}UNALIGNED${ENDCOLOR} ($res)"
124+
unaligned_libs+=("${match}")
125+
fi
126+
done
127+
128+
if [ ${#unaligned_libs[@]} -gt 0 ]; then
129+
echo -e "${RED}Found ${#unaligned_libs[@]} unaligned libs (only arm64-v8a/x86_64 libs need to be aligned).${ENDCOLOR}"
130+
elif [ -n "${dir_filename}" ]; then
131+
echo -e "ELF Verification Successful"
132+
fi
133+
echo "====================="
102134
shell: bash
103135

104136
# github.com/actions/upload-artifact

0 commit comments

Comments
 (0)