Skip to content

Commit dda1e95

Browse files
amlutoH. Peter Anvin
authored andcommitted
x86/vdso: Create .build-id links for unstripped vdso files
With this change, doing 'make vdso_install' and telling gdb: set debug-file-directory /lib/modules/KVER/vdso will enable vdso debugging with symbols. This is useful for testing, but kernel RPM builds will probably want to manually delete these symlinks or otherwise do something sensible when they strip the vdso/*.so files. If ld does not support --build-id, then the symlinks will not be created. Note that kernel packagers that use vdso_install may need to adjust their packaging scripts to accomdate this change. For example, Fedora's scripts create build-id symlinks themselves in a different location, so the spec should probably be updated to remove the symlinks created by make vdso_install. Signed-off-by: Andy Lutomirski <[email protected]> Link: http://lkml.kernel.org/r/a424b189ce3ced85fe1e82d032a20e765e0fe0d3.1403291930.git.luto@amacapital.net Signed-off-by: H. Peter Anvin <[email protected]>
1 parent 0e3727a commit dda1e95

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

arch/x86/vdso/Makefile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,24 @@ quiet_cmd_vdso = VDSO $@
169169
sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
170170

171171
VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) \
172-
-Wl,-Bsymbolic $(LTO_CFLAGS)
172+
$(call cc-ldoption, -Wl$(comma)--build-id) -Wl,-Bsymbolic $(LTO_CFLAGS)
173173
GCOV_PROFILE := n
174174

175175
#
176-
# Install the unstripped copies of vdso*.so.
176+
# Install the unstripped copies of vdso*.so. If our toolchain supports
177+
# build-id, install .build-id links as well.
177178
#
178179
quiet_cmd_vdso_install = INSTALL $(@:install_%=%)
179-
cmd_vdso_install = cp $< $(MODLIB)/vdso/$(@:install_%=%)
180+
define cmd_vdso_install
181+
cp $< "$(MODLIB)/vdso/$(@:install_%=%)"; \
182+
if readelf -n $< |grep -q 'Build ID'; then \
183+
buildid=`readelf -n $< |grep 'Build ID' |sed -e 's/^.*Build ID: \(.*\)$$/\1/'`; \
184+
first=`echo $$buildid | cut -b-2`; \
185+
last=`echo $$buildid | cut -b3-`; \
186+
mkdir -p "$(MODLIB)/vdso/.build-id/$$first"; \
187+
ln -sf "../../$(@:install_%=%)" "$(MODLIB)/vdso/.build-id/$$first/$$last.debug"; \
188+
fi
189+
endef
180190

181191
vdso_img_insttargets := $(vdso_img_sodbg:%.dbg=install_%)
182192

0 commit comments

Comments
 (0)