mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Petr Tesarik <ptesarik@suse.cz>
To: Sam Ravnborg <sam@ravnborg.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	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>
Subject: Re: [PATCH v2 0/8] clean up vdso-layout.lds.S
Date: Mon, 15 Jun 2009 17:16:42 +0200	[thread overview]
Message-ID: <1245079002.17481.118.camel@nathan.suse.cz> (raw)
In-Reply-To: <20090612180626.GB18203@uranus.ravnborg.org>

Sam Ravnborg píše v Pá 12. 06. 2009 v 20:06 +0200:
> On Fri, Jun 12, 2009 at 03:40:32PM +0200, Petr Tesarik wrote:
> > The handling of various sections in the VDSO linker script
> > looks pretty haphazard. This patch series cleans it up in
> > these regards:
> > 
> >  - improve the coding style
> >  - remove superfluous sections
> >  - issue a linker error if a section is encountered which
> >    is known not to work
> >  - check that the .got section is empty, except for the
> >    three entries defined by the ABI
> >  - discard sections which are not useful to user-space
> > 
> > Petr Tesarik (8):
> >   x86: Adjust the coding style of vdso-layout.lds.S
> >   x86: Remove .sdata from the vDSO linker script
> >   x86: add .broken section to the vDSO linker script
> >   x86: mark altinstr-related sections in vDSO as broken
> >   x86: mark some standard sections as broken in a vDSO
> >   x86: check the size of GOT in vDSO
> >   x86: remove unneeded section from the vDSO
> The above looks good.
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> 
> > 
> >   x86: Remove .dynbss from the vDSO linker script
> This one I am a little reluctant about as I do not understand
> why ld sometimes adds and sometimes does not add this section.
> At least judging from the arch specific linker scripts some archs
> include it and others do not.

The .dynbss section is a place to put symbols which are defined by
dynamic objects, are referenced by regular objects, and are not
functions. Space for these objects is allocated in the process image and
the dynamic linker copies the object data (using a copy relocation).

This is normally not needed, but if the process image uses the address
of a shared object in a read-only section, the link editor (ld) cannot
use the object in the DSO directly (since its address is only known at
runtime).

An example can probably explain it better:

$ cat >shared.c <<EOF
int shared_object[100];
EOF
$ cat >exe.c <<EOF
#include <stdio.h>
extern int shared_object[100];
int main(void) {
	printf("%p\n", &shared_object); 
	return 0;
}
EOF

It seems pretty obvious to me that a .dynbss section can never occur in
a DSO, because:

 1. a DSO must be position-independent, i.e. it cannot put absolute
    addresses into a constant section
 2. even if the DSO could do such a thing, the object is not allocated
    in the DSO; consequently, there will never be a copy relocation,
    and no need to have any data in .dynbss

I agree that the current documentation of the purpose of various ELF
sections is insufficient, so it's not easy to understand it. But I think
Roland also understands enough of it to confirm my reasoning.

I'm going to publish the knowledge I got during this vDSO excercise
soon.

Petr Tesarik



  reply	other threads:[~2009-06-15 15:16 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-12 13:40 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 ` [PATCH v2 7/8] x86: check the size of GOT in vDSO Petr Tesarik
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 [this message]
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=1245079002.17481.118.camel@nathan.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=sam@ravnborg.org \
    --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®