mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Petr Tesarik <ptesarik@suse.cz>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Andi Kleen <andi@firstfloor.org>,
	Roland McGrath <roland@redhat.com>,
	Petr Tesarik <ptesarik@suse.cz>
Subject: [PATCH v2 7/8] x86: check the size of GOT in vDSO
Date: Fri, 12 Jun 2009 15:40:39 +0200	[thread overview]
Message-ID: <1244814040-5810-8-git-send-email-ptesarik@suse.cz> (raw)
In-Reply-To: <1244814040-5810-1-git-send-email-ptesarik@suse.cz>

There should be no real entries in the GOT, because they are basically
pointers to dynamic symbols, and that will not work correctly without
a real dynamic linker for the vDSO.

However, the ABI pre-defines three entries in the GOT which are always
present, so the GOT section is never completely empty. We can check
that there are no extra entries beyond these three.

To make it work:
  - move the GOT into a separate section
  - check the size of that section
  - pass -m32 or -m64 to the pre-processor to get the correct
    definition of __SIZEOF_POINTER__

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
---
 arch/x86/vdso/Makefile          |    5 +++--
 arch/x86/vdso/vdso-layout.lds.S |   20 +++++++++++++++++++-
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
index 16a9020..8c7f06a 100644
--- a/arch/x86/vdso/Makefile
+++ b/arch/x86/vdso/Makefile
@@ -23,7 +23,8 @@ $(obj)/vdso.o: $(obj)/vdso.so
 
 targets += vdso.so vdso.so.dbg vdso.lds $(vobjs-y)
 
-export CPPFLAGS_vdso.lds += -P -C
+vdso-cppflags = -P -C
+export CPPFLAGS_vdso.lds += -m64 $(vdso-cppflags)
 
 VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -Wl,-soname=linux-vdso.so.1 \
 		      	-Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096
@@ -68,7 +69,7 @@ vdso32.so-$(VDSO32-y)		+= sysenter
 
 vdso32-images			= $(vdso32.so-y:%=vdso32-%.so)
 
-CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds)
+CPPFLAGS_vdso32.lds = -m32 $(vdso-cppflags)
 VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -Wl,-soname=linux-gate.so.1
 
 # This makes sure the $(obj) subdirectory exists even though vdso32/
diff --git a/arch/x86/vdso/vdso-layout.lds.S b/arch/x86/vdso/vdso-layout.lds.S
index ffd17e8..3b56e2f 100644
--- a/arch/x86/vdso/vdso-layout.lds.S
+++ b/arch/x86/vdso/vdso-layout.lds.S
@@ -44,13 +44,15 @@ SECTIONS
 	.dynamic : {
 		*(.dynamic)
 	} :text :dynamic
+	.got : {
+		*(.got.plt) *(.got)
+	} :text
 
 	.rodata : {
 		*(.rodata*)
 	} :text
 	.data : {
 		*(.data*)
-		*(.got.plt) *(.got)
 		*(.gnu.linkonce.d.*)
 		*(.bss*)
 		*(.gnu.linkonce.b.*)
@@ -113,6 +115,22 @@ SECTIONS
  */
 ASSERT(!SIZEOF(.broken), "The vdso linker script found a section that is bad. See vdso-layout.lds.S for details.");
 
+/* This assert is triggered if the resulting GOT is larger than the
+ * minimum defined by the ABI, i.e. there is some actual use of the
+ * GOT.
+ *
+ * To find the offending symbols you may:
+ *  1. temporarily disable this check
+ *  2. examine the dynamic relocations of the resulting vDSO with
+ *     objdump -R
+ *
+ * To find the places where the symbols were used, you may:
+ *  1. add -Wl,--emit-relocs to VDSO_LDFLAGS
+ *  2. run objdump -r on the resulting vDSO and look for all
+ *     GOT-type relocations.
+ */
+ASSERT(SIZEOF(.got) == 3*__SIZEOF_POINTER__, "The vdso linker script found a wrong reference to an external object. See vdso-layout.lds.S for details.");
+
 /*
  * Very old versions of ld do not recognize this name token; use the constant.
  */
-- 
1.6.0.2


  parent reply	other threads:[~2009-06-12 13:48 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-12 13:40 [PATCH v2 0/8] clean up vdso-layout.lds.S Petr Tesarik
2009-06-12 13:40 ` [PATCH v2 1/8] x86: Adjust the coding style of vdso-layout.lds.S Petr Tesarik
2009-06-12 13:40 ` [PATCH v2 2/8] x86: Remove .sdata from the vDSO linker script Petr Tesarik
2009-06-12 13:40 ` [PATCH v2 3/8] x86: Remove .dynbss " Petr Tesarik
2009-06-12 13:40 ` [PATCH v2 4/8] x86: add .broken section to " Petr Tesarik
2009-06-12 13:40 ` [PATCH v2 5/8] x86: mark altinstr-related sections in vDSO as broken Petr Tesarik
2009-06-12 13:40 ` [PATCH v2 6/8] x86: mark some standard sections as broken in a vDSO Petr Tesarik
2009-06-12 13:40 ` Petr Tesarik [this message]
2009-06-12 13:40 ` [PATCH v2 8/8] x86: remove unneeded section from the vDSO Petr Tesarik
2009-06-12 18:06 ` [PATCH v2 0/8] clean up vdso-layout.lds.S Sam Ravnborg
2009-06-15 15:16   ` Petr Tesarik
2009-06-15 15:27     ` Petr Tesarik
2009-06-15 16:51       ` H. Peter Anvin
2009-06-15 17:45         ` Petr Tesarik
2009-06-15 18:33           ` H. Peter Anvin
2009-06-16  7:53             ` Petr Tesarik
2009-06-16 10:12   ` Petr Tesarik
2009-06-16 10:22     ` Roland McGrath
2009-06-16  8:40 ` Roland McGrath
2009-06-16  9:55   ` Petr Tesarik
2009-06-16 10:34     ` Roland McGrath

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1244814040-5810-8-git-send-email-ptesarik@suse.cz \
    --to=ptesarik@suse.cz \
    --cc=andi@firstfloor.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=roland@redhat.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®