Commit-ID: 05d0b0889ca9d033a960542af7f8a13b3ad4f630
Gitweb: http://git.kernel.org/tip/05d0b0889ca9d033a960542af7f8a13b3ad4f630
Author: H. Peter Anvin <[email protected]>
AuthorDate: Fri, 18 Jun 2010 14:36:26 -0700
Committer: H. Peter Anvin <[email protected]>
CommitDate: Fri, 18 Jun 2010 14:46:21 -0700
x86, vdso: Error out if the vdso contains external references
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 <[email protected]>
LKML-Reference: <tip-*@vger.kernel.org>
Signed-off-by: H. Peter Anvin <[email protected]>
---
arch/x86/vdso/Makefile | 3 ++-
arch/x86/vdso/checkundef.sh | 10 ++++++++++
2 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
index 6b4ffed..4a2afa1 100644
--- a/arch/x86/vdso/Makefile
+++ b/arch/x86/vdso/Makefile
@@ -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
diff --git a/arch/x86/vdso/checkundef.sh b/arch/x86/vdso/checkundef.sh
new file mode 100755
index 0000000..490be1c
--- /dev/null
+++ b/arch/x86/vdso/checkundef.sh
@@ -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
> diff --git a/arch/x86/vdso/checkundef.sh b/arch/x86/vdso/checkundef.sh
> new file mode 100755
> index 0000000..490be1c
> --- /dev/null
> +++ b/arch/x86/vdso/checkundef.sh
> @@ -0,0 +1,10 @@
> +#!/bin/sh
> +nm="$1"
> +file="$2"
> +"$nm" "$file" | grep '^ *U' > /dev/null 2>&1
Does that really handle the failed inline, static function case?
In this case you get a function which is not 'U', but it's
just in the wrong section. I think that would need to be checked too.
-Andi
--
[email protected] -- Speaking for myself only.
On 06/19/2010 12:27 AM, Andi Kleen wrote:
>> diff --git a/arch/x86/vdso/checkundef.sh b/arch/x86/vdso/checkundef.sh
>> new file mode 100755
>> index 0000000..490be1c
>> --- /dev/null
>> +++ b/arch/x86/vdso/checkundef.sh
>> @@ -0,0 +1,10 @@
>> +#!/bin/sh
>> +nm="$1"
>> +file="$2"
>> +"$nm" "$file" | grep '^ *U' > /dev/null 2>&1
>
> Does that really handle the failed inline, static function case?
>
> In this case you get a function which is not 'U', but it's
> just in the wrong section. I think that would need to be checked too.
>
Makes sense.
-hpa
--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
Hi,
On Fri, 18 Jun 2010 22:16:05 GMT "tip-bot for H. Peter Anvin" <[email protected]> wrote:
>
> diff --git a/arch/x86/vdso/checkundef.sh b/arch/x86/vdso/checkundef.sh
> new file mode 100755
> index 0000000..490be1c
> --- /dev/null
> +++ b/arch/x86/vdso/checkundef.sh
> @@ -0,0 +1,10 @@
> +#!/bin/sh
> +nm="$1"
> +file="$2"
> +"$nm" "$file" | grep '^ *U' > /dev/null 2>&1
Quoting $nm here doesn't work if you are building with ccache like this:
make CROSS_COMPILE="ccache ...."
--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/
Stephen Rothwell wrote:
> Hi,
>
> On Fri, 18 Jun 2010 22:16:05 GMT "tip-bot for H. Peter Anvin" <[email protected]> wrote:
>> diff --git a/arch/x86/vdso/checkundef.sh b/arch/x86/vdso/checkundef.sh
>> new file mode 100755
>> index 0000000..490be1c
>> --- /dev/null
>> +++ b/arch/x86/vdso/checkundef.sh
>> @@ -0,0 +1,10 @@
>> +#!/bin/sh
>> +nm="$1"
>> +file="$2"
>> +"$nm" "$file" | grep '^ *U' > /dev/null 2>&1
>
> Quoting $nm here doesn't work if you are building with ccache like this:
>
> make CROSS_COMPILE="ccache ...."
Hmmm... in some ways I'm not sure if that's a feature or a bug, but I
guess it's the only way currently provided. Sigh.
-hpa
Commit-ID: 18642a57df02a044b91219d3176128996ddc81a5
Gitweb: http://git.kernel.org/tip/18642a57df02a044b91219d3176128996ddc81a5
Author: H. Peter Anvin <[email protected]>
AuthorDate: Tue, 27 Jul 2010 23:52:29 -0700
Committer: H. Peter Anvin <[email protected]>
CommitDate: Tue, 27 Jul 2010 23:52:29 -0700
x86, vdso: Don't quote $nm in the script for checking vdso references
Don't quote $nm in the script for checking the vdso for external
references. Doing so breaks multiword constructs, like using
CROSS_COMPILE='ccache '.
Reported-by: Stephen Rothwell <[email protected]>
Signed-off-by: H. Peter Anvin <[email protected]>
LKML-Reference: <[email protected]>
---
arch/x86/vdso/checkundef.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/arch/x86/vdso/checkundef.sh b/arch/x86/vdso/checkundef.sh
index 490be1c..7ee90a9 100755
--- a/arch/x86/vdso/checkundef.sh
+++ b/arch/x86/vdso/checkundef.sh
@@ -1,7 +1,7 @@
#!/bin/sh
nm="$1"
file="$2"
-"$nm" "$file" | grep '^ *U' > /dev/null 2>&1
+$nm "$file" | grep '^ *U' > /dev/null 2>&1
if [ $? -eq 1 ]; then
exit 0
else