1
1
mirror of https://github.com/rui314/mold.git synced 2024-11-15 14:36:25 +03:00

[tests] Improve test for -spare-dynamic-tags

The default size and offsets of the .dynamic section are not necessarily
same with different builds of clang. For example, some builds can make
clang pass --hash-style=gnu to the linker and some --hash-style=both.

This change updates the test to compute the difference in size of the
.dynamic section before and after using the flag -spare-dynamic-tags,
making it independent of the compiler build.

Signed-off-by: Nehal J Wani <nehaljw.kkd1@gmail.com>
This commit is contained in:
Nehal J Wani 2021-07-03 22:12:36 -04:00
parent 70d1acd744
commit be6d443bc8
No known key found for this signature in database
GPG Key ID: 87F40C1A586E6978

View File

@ -8,11 +8,12 @@ mkdir -p $t
echo '.globl main; main:' | cc -o $t/a.o -c -x assembler -
clang -fuse-ld=`pwd`/../mold -o $t/exe $t/a.o
readelf --wide --sections $t/exe > $t/log
grep -Pq '\.dynamic.*\b0001b0\b' $t/log
size_before=$((16#$(readelf --wide --sections $t/exe | grep .dynamic | tr -s ' ' | cut -d ' ' -f7)))
clang -fuse-ld=`pwd`/../mold -o $t/exe $t/a.o -Wl,-spare-dynamic-tags=100
readelf --wide --sections $t/exe > $t/log
grep -Pq '\.dynamic.*\b002010\b' $t/log
size_after=$((16#$(readelf --wide --sections $t/exe | grep .dynamic | tr -s ' ' | cut -d ' ' -f7)))
# Ensure space for 95 additional spare tags has been added (default: 5)
[[ $(( $size_after - $size_before )) == $(( 16*95 )) ]]
echo OK