Skip to content

Commit

Permalink
x86, vdso: Error out if the vdso contains external references
Browse files Browse the repository at this point in the history
The vdso is a piece of userspace code which is supposed to be fully
self-contained.  Any external (undefined) reference is an error, and
should be caught at compile time.  This was giving us trouble when
compiling with -Os on gcc 4.5.0, for example (failed inline).

The need to do a buildtime check was pointed out by Andi Kleen.

Reported-by: Andi Kleen <andi@firstfloor.org>
LKML-Reference: <tip-*@vger.kernel.org>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
  • Loading branch information
H. Peter Anvin committed Jun 18, 2010
1 parent 7e27d6e commit 05d0b08
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion arch/x86/vdso/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ $(obj)/vdso32-syms.lds: $(vdso32.so-y:%=$(obj)/vdso32-%-syms.lds) FORCE
quiet_cmd_vdso = VDSO $@
cmd_vdso = $(CC) -nostdlib -o $@ \
$(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
-Wl,-T,$(filter %.lds,$^) $(filter %.o,$^)
-Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'

VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
GCOV_PROFILE := n
Expand Down
10 changes: 10 additions & 0 deletions arch/x86/vdso/checkundef.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
nm="$1"
file="$2"
"$nm" "$file" | grep '^ *U' > /dev/null 2>&1
if [ $? -eq 1 ]; then
exit 0
else
echo "$file: undefined symbols found" >&2
exit 1
fi

0 comments on commit 05d0b08

Please sign in to comment.