Skip to content

Commit 2d74288

Browse files
debian-package: add abi-checking
1 parent 7a49eea commit 2d74288

File tree

2 files changed

+73
-2
lines changed

2 files changed

+73
-2
lines changed

debian/changelog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
liblol (0.1.5~pre6-1) unstable; urgency=medium
22

3+
* add ABI checking
34
* not promoting symbol versions of libnsl.so
45
* use libxcrypt for libcrypto.so.1
56
* fix wrong version mapping for libpthread symbols

debian/rules

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ install_preload_libs_dir := $(install_libs_dir)/preload
263263
$(install_preload_libs_dir) $(install_libs_dir):
264264
mkdir -p $@
265265

266-
all-libs := $(libxcrypt_libs_targets) $(glibc_libs_targets) $(dummy_ld_so)
266+
all-libs-with-abi := $(libxcrypt_libs_targets) $(glibc_libs_targets)
267+
all-libs := $(all-libs-with-abi) $(dummy_ld_so)
267268

268269
install-libs: $(addprefix $(install_preload_libs_dir)/, $(notdir $(all-libs))) $(TMPDIR)/lib64/ld.so.1
269270
:
@@ -284,6 +285,74 @@ $(foreach lib-target, $(all-libs), $(eval $(call install-lib-rule,$(lib-target))
284285
symlink-hostlibs: $(install_libs_dir) $(install_preload_libs_dir)
285286
ln -sfv $(libdir)/libstdc++.so.6 $(install_preload_libs_dir)/
286287

288+
so_basename=$(foreach so,$(1),$(firstword $(subst ., ,$(notdir $(so)))))
289+
290+
abi_checking_dir := debian/build-dir/abi
291+
actual_abi_targets := $(addprefix $(abi_checking_dir)/actual/,$(addsuffix .abilist,$(call so_basename,$(notdir $(all-libs-with-abi)))))
292+
nw_abi_dir := glibc/sysdeps/unix/sysv/linux/loongarch/lp64
293+
ow_abi_dir := debian/abiversions
294+
295+
define gen-abilist
296+
LC_ALL=C objdump --dynamic-syms "$(1)" | \
297+
LC_ALL=C awk -f "glibc/scripts/abilist.awk"
298+
endef
299+
300+
define gen-actual-abi-rule
301+
$(addprefix $(abi_checking_dir)/actual/,$(addsuffix .abilist,$(call so_basename,$(notdir $(1))))): $(1)
302+
mkdir -p $$(dir $$@)
303+
$(call gen-abilist,$(1)) > $$@
304+
endef
305+
306+
$(foreach abi-target, $(all-libs-with-abi), $(eval $(call gen-actual-abi-rule,$(abi-target))))
307+
308+
$(abi_checking_dir)/ow/libc.abilist: $(addprefix $(ow_abi_dir)/,$(addsuffix .abilist, $(call so_basename,$(glibc_merged_libs) libc.so.6)))
309+
mkdir -p $(dir $@)
310+
cat $^ > $@
311+
312+
$(addprefix $(abi_checking_dir)/ow/,$(addsuffix .abilist, $(call so_basename,$(glibc_merged_libs)))):$(abi_checking_dir)/ow/%:$(ow_abi_dir)/%
313+
mkdir -p $(dir $@)
314+
cut -d" " -f 1 $< | uniq | \
315+
sed 's/$$/ __'$(basename $(notdir $@))'_version_placeholder F/' \
316+
>$@
317+
318+
$(abi_checking_dir)/ow/%.abilist:
319+
mkdir -p $(dir $@)
320+
if [ -f $(ow_abi_dir)/$(notdir $@) ]; then \
321+
cp $(ow_abi_dir)/$(notdir $@) $@; \
322+
else \
323+
touch $@; \
324+
fi
325+
326+
$(abi_checking_dir)/nw/%.abilist:
327+
mkdir -p $(dir $@)
328+
if [ -f $(nw_abi_dir)/$(notdir $@) ]; then \
329+
cp $(nw_abi_dir)/$(notdir $@) $@; \
330+
else \
331+
touch $@; \
332+
fi
333+
334+
$(abi_checking_dir)/nw/libcrypt.abilist: debian/build-dir/libxcrypt-normal/.libs/libcrypt.so.1
335+
mkdir -p $(dir $@)
336+
$(call gen-abilist,$<) > $@
337+
338+
$(abi_checking_dir)/expected/%.abilist: $(abi_checking_dir)/ow/%.abilist $(abi_checking_dir)/nw/%.abilist
339+
mkdir -p $(dir $@)
340+
cat $^ | sort | uniq > $@
341+
342+
abi-check-%: $(abi_checking_dir)/expected/%.abilist $(abi_checking_dir)/actual/%.abilist $(abi_checking_dir)/actual/libc.abilist
343+
missing=$$(bash -c "comm -23 $(word 1,$^) <(cat $(word 2,$^) $(word 3,$^) | sort | uniq)"); \
344+
extra=$$(comm -13 $(word 1,$^) $(word 2,$^)); \
345+
if [ "" != "$$missing" ]; then \
346+
echo "Missing symbols in $(patsubst abi-check-%,%,$@): $$missing"; \
347+
exit 1; \
348+
fi; \
349+
if [ "" != "$$extra" ]; then \
350+
echo "Extra symbols in $(patsubst abi-check-%,%,$@): $$extra"; \
351+
fi
352+
353+
abi-check: | $(addprefix abi-check-,$(sort $(basename $(notdir $(wildcard $(nw_abi_dir)/*.abilist) $(wildcard $(ow_abi_dir)/*.abilist)))))
354+
:
355+
287356
$(patchelf_bin):
288357
$(MAKE) -C $(patchelf_build_dir) all $(NJOBS)
289358
[ -f $@ ]
@@ -293,9 +362,10 @@ patch-src: patch-src.patchelf patch-src.glibc
293362
patch-src.%:
294363
cd $* && QUILT_PATCHES=../debian/patches/$* quilt push -a
295364

296-
override_dh_auto_configure: patch-src config-glibc config-patchelf config-libxcrypt
365+
override_dh_auto_configure: patch-src config-glibc config-patchelf config-libxcrypt config-libxcrypt-normal
297366
override_dh_auto_build: $(all-libs)
298367
override_dh_auto_install: install-libs symlink-hostlibs
368+
override_dh_auto_test: abi-check
299369

300370
override_dh_clean: clean-patch clean-patchelf
301371
dh_clean

0 commit comments

Comments
 (0)