Skip to content
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

[RFC] Symbol versioning in libutee.so, the easy part #5833

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions mk/lib.mk
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ lib-shlibfile-$(libname)-$(sm) := $(lib-shlibfile)
lib-libdir-$(libname)-$(sm) := $(out-dir)/$(base-prefix)$(libdir)
lib-needed-so-files := $(foreach l,$(libl),$(lib-shlibfile-$(l)-$(sm)))
lib-Ll-args := $(foreach l,$(libl),-L$(lib-libdir-$(l)-$(sm)) -l$(l))
lib-verscript := $(libdir)/lib$(libname).ver
endif
cleanfiles := $(lib-libfile) $(lib-shlibfile) $(lib-shlibstrippedfile) $(lib-shlibtafile) $(lib-libuuidln) $(cleanfiles)
libfiles := $(lib-libfile) $(lib-shlibfile) $(lib-shlibstrippedfile) $(lib-shlibtafile) $(lib-libuuidln) $(libfiles)
Expand All @@ -62,13 +63,17 @@ ifeq ($(CFG_ULIBS_SHARED),y)
ifeq ($(sm)-$(CFG_TA_BTI),ta_arm64-y)
lib-ldflags$(lib-shlibfile) += $$(call ld-option,-z force-bti) --fatal-warnings
endif
$(lib-shlibfile): $(objs) $(lib-needed-so-files)
ifneq (,$(wildcard $(lib-verscript)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so sure about the wildcard, that could hide an invalid value in lib-verscript.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its purpose is to make the version script optional. $(lib-verscript) is well defined above and only depends on the name of the library, not on any user input. It is for example lib/libutee/libutee.ver or lib/libutils/libutils.ver etc. so it seems pretty natural to use wildcard to obtain the name of the file if it exist or empty otherwise, no?

lib-ldflags$(lib-shlibfile) += --version-script $(lib-verscript)
verscript$(lib-shlibfile) := $(lib-verscript)
endif
$(lib-shlibfile): $(objs) $(lib-needed-so-files) $(verscript$(lib-shlibfile))
@$(cmd-echo-silent) ' LD $$@'
@mkdir -p $$(dir $$@)
$$(q)$$(LD$(sm)) $(lib-ldflags) -shared -z max-page-size=4096 \
$(call ld-option,-z separate-loadable-segments) \
$$(lib-ldflags$(lib-shlibfile)) \
--soname=$(libuuid) -o $$@ $$(filter-out %.so,$$^) $(lib-Ll-args)
--soname=$(libuuid) -o $$@ $$(filter-out %.so %.ver,$$^) $(lib-Ll-args)

$(lib-shlibstrippedfile): $(lib-shlibfile)
@$(cmd-echo-silent) ' OBJCOPY $$@'
Expand Down