All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: Absolute symbols in vmlinux_64.lds.S
@ 2009-03-10  4:37 Jeremy Fitzhardinge
  2009-03-10  5:32 ` Yinghai Lu
  0 siblings, 1 reply; 12+ messages in thread
From: Jeremy Fitzhardinge @ 2009-03-10  4:37 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Ingo Molnar, Eric W. Biederman, the arch/x86 maintainers,
	Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 631 bytes --]



Yinghai Lu <yinghai@kernel.org> wrote:

>Jeremy Fitzhardinge wrote:
>> Why does vmlinux_64.lds.S use absolute symbols for things like
>> __bss_start/stop:
>> 
>>  __bss_start = .;        /* BSS */
>>  .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
>>     *(.bss.page_aligned)
>>     *(.bss)
>>     }
>>  __bss_stop = .;
>> 
>> 
>> vmlinux_32.lds.S puts __bss_start/stop into the .bss section itself.  Is
>> there some particular reason they need to be absolute symbols
>> (relocation?).
>> 
>
>they are the same.

Do you mean it makes no difference?

	J
-- 
Sent from my Android phone with K-9. Please excuse my brevity.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Absolute symbols in vmlinux_64.lds.S
  2009-03-10  4:37 Absolute symbols in vmlinux_64.lds.S Jeremy Fitzhardinge
@ 2009-03-10  5:32 ` Yinghai Lu
  0 siblings, 0 replies; 12+ messages in thread
From: Yinghai Lu @ 2009-03-10  5:32 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: Ingo Molnar, Eric W. Biederman, the arch/x86 maintainers,
	Linux Kernel Mailing List

Jeremy Fitzhardinge wrote:
> 
> Yinghai Lu <yinghai@kernel.org> wrote:
> 
>> Jeremy Fitzhardinge wrote:
>>> Why does vmlinux_64.lds.S use absolute symbols for things like
>>> __bss_start/stop:
>>>
>>>  __bss_start = .;        /* BSS */
>>>  .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
>>>     *(.bss.page_aligned)
>>>     *(.bss)
>>>     }
>>>  __bss_stop = .;
>>>
>>>
>>> vmlinux_32.lds.S puts __bss_start/stop into the .bss section itself.  Is
>>> there some particular reason they need to be absolute symbols
>>> (relocation?).
>>>
>> they are the same.
> 
> Do you mean it makes no difference?

Sure. System.map should tell the value after the building.

YH

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Absolute symbols in vmlinux_64.lds.S
  2009-03-10 21:25         ` Eric W. Biederman
@ 2009-03-10 22:26           ` Jeremy Fitzhardinge
  0 siblings, 0 replies; 12+ messages in thread
From: Jeremy Fitzhardinge @ 2009-03-10 22:26 UTC (permalink / raw)
  To: Eric W. Biederman
  Cc: H. Peter Anvin, Sam Ravnborg, Yinghai Lu, Ingo Molnar,
	the arch/x86 maintainers, Linux Kernel Mailing List

Eric W. Biederman wrote:
> Is anyone interested in writing a patch testing it and changing things?
>
> If not things should be good enough for now.
>   

Yeah, I'm just testing one now.

    J

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Absolute symbols in vmlinux_64.lds.S
  2009-03-10 20:20       ` H. Peter Anvin
@ 2009-03-10 21:25         ` Eric W. Biederman
  2009-03-10 22:26           ` Jeremy Fitzhardinge
  0 siblings, 1 reply; 12+ messages in thread
From: Eric W. Biederman @ 2009-03-10 21:25 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Sam Ravnborg, Yinghai Lu, Jeremy Fitzhardinge, Ingo Molnar,
	the arch/x86 maintainers, Linux Kernel Mailing List

"H. Peter Anvin" <hpa@kernel.org> writes:

> Eric W. Biederman wrote:
>> 
>> I have no complaint with that.  I believe the symbols are absolute
>> simply because they were originally coded that way and the relocatable
>> kernel work on x86_64 didn't need them to change.
>> 
>
> I have a vague memory of a bug in the x86-64 ld.

Oh.  I'm certain of it.  ld has all kinds of bugs off and on,
occasionally we are bound to run into a few of them.

ld bugs isn't the reason for using absolute linker symbols.  We use a
bunch of relative linker symbols as well.  All of the generic linker
scripts sections use them as well as a few of the x86_64 specific
sections.

For crazy things like 0 relative per cpu sections it might matter.
For the rest of the symbols absolute or relative simply
doesn't matter.

Is anyone interested in writing a patch testing it and changing things?

If not things should be good enough for now.

Eric

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Absolute symbols in vmlinux_64.lds.S
  2009-03-10  5:49     ` Eric W. Biederman
@ 2009-03-10 20:20       ` H. Peter Anvin
  2009-03-10 21:25         ` Eric W. Biederman
  0 siblings, 1 reply; 12+ messages in thread
From: H. Peter Anvin @ 2009-03-10 20:20 UTC (permalink / raw)
  To: Eric W. Biederman
  Cc: Sam Ravnborg, Yinghai Lu, Jeremy Fitzhardinge, Ingo Molnar,
	the arch/x86 maintainers, Linux Kernel Mailing List

Eric W. Biederman wrote:
> 
> I have no complaint with that.  I believe the symbols are absolute
> simply because they were originally coded that way and the relocatable
> kernel work on x86_64 didn't need them to change.
> 

I have a vague memory of a bug in the x86-64 ld.

	-hpa


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Absolute symbols in vmlinux_64.lds.S
  2009-03-10  5:57     ` Yinghai Lu
@ 2009-03-10 11:24       ` Sam Ravnborg
  0 siblings, 0 replies; 12+ messages in thread
From: Sam Ravnborg @ 2009-03-10 11:24 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Jeremy Fitzhardinge, Ingo Molnar, Eric W. Biederman,
	the arch/x86 maintainers, Linux Kernel Mailing List

On Mon, Mar 09, 2009 at 10:57:19PM -0700, Yinghai Lu wrote:
> On Mon, Mar 9, 2009 at 10:37 PM, Sam Ravnborg <sam@ravnborg.org> wrote:
> > On Mon, Mar 09, 2009 at 06:23:55PM -0700, Yinghai Lu wrote:
> >> Jeremy Fitzhardinge wrote:
> >> > Why does vmlinux_64.lds.S use absolute symbols for things like
> >> > __bss_start/stop:
> >> >
> >> >  __bss_start = .;        /* BSS */
> >> >  .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
> >> >     *(.bss.page_aligned)
> >> >     *(.bss)
> >> >     }
> >> >  __bss_stop = .;
> >> >
> >> >
> >> > vmlinux_32.lds.S puts __bss_start/stop into the .bss section itself.  Is
> >> > there some particular reason they need to be absolute symbols
> >> > (relocation?).
> >> >
> >>
> >> they are the same.
> >
> > Thats depends on the value of '.' where you assign __bss_start.
> > We have had several bugs where the symbol assinged outside the
> > section was less than expected because the linker aling the
> > start of the section equal to the lrgest alignment requirement
> > of a member in the section.
> >
> > So in this case if '.' equals to 0xabcd and the lagest
> > alignment requirement inside the block is 0x1000 and we have
> > __bss_start1 = .;
> > .bss : {
> >        __bss_start2 = .;
> >        *(.bss.page_aligned)
> > }
> >
> > Then you would see that:
> > __bss_start1 equals 0xabcd
> > __bss_start2 equals 0xb000
> 
> good to know...
> 
> anyway, more lines
> 
>   . = ALIGN(PAGE_SIZE);
>   __nosave_begin = .;
>   .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
>       *(.data.nosave)
>   } :data.init2 /* use another section data.init2, see PERCPU_VADDR() above */
>   . = ALIGN(PAGE_SIZE);
>   __nosave_end = .;
> 
>   __bss_start = .;              /* BSS */
>   .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
>         *(.bss.page_aligned)
>         *(.bss)
>         }
>   __bss_stop = .;
> 
>   _end = . ;
> 
> 
> there are extra ALIGN(PAGE_SIZE) between them....

So you say that we do hit this issue here - right.
But the better way to do it is to include the assignment inside the {} block,
thus we are not dependent on an ALIGN() that logically belongs to .data_nosave.

	Sam

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Absolute symbols in vmlinux_64.lds.S
  2009-03-10  5:37   ` Sam Ravnborg
  2009-03-10  5:49     ` Eric W. Biederman
@ 2009-03-10  5:57     ` Yinghai Lu
  2009-03-10 11:24       ` Sam Ravnborg
  1 sibling, 1 reply; 12+ messages in thread
From: Yinghai Lu @ 2009-03-10  5:57 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Jeremy Fitzhardinge, Ingo Molnar, Eric W. Biederman,
	the arch/x86 maintainers, Linux Kernel Mailing List

On Mon, Mar 9, 2009 at 10:37 PM, Sam Ravnborg <sam@ravnborg.org> wrote:
> On Mon, Mar 09, 2009 at 06:23:55PM -0700, Yinghai Lu wrote:
>> Jeremy Fitzhardinge wrote:
>> > Why does vmlinux_64.lds.S use absolute symbols for things like
>> > __bss_start/stop:
>> >
>> >  __bss_start = .;        /* BSS */
>> >  .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
>> >     *(.bss.page_aligned)
>> >     *(.bss)
>> >     }
>> >  __bss_stop = .;
>> >
>> >
>> > vmlinux_32.lds.S puts __bss_start/stop into the .bss section itself.  Is
>> > there some particular reason they need to be absolute symbols
>> > (relocation?).
>> >
>>
>> they are the same.
>
> Thats depends on the value of '.' where you assign __bss_start.
> We have had several bugs where the symbol assinged outside the
> section was less than expected because the linker aling the
> start of the section equal to the lrgest alignment requirement
> of a member in the section.
>
> So in this case if '.' equals to 0xabcd and the lagest
> alignment requirement inside the block is 0x1000 and we have
> __bss_start1 = .;
> .bss : {
>        __bss_start2 = .;
>        *(.bss.page_aligned)
> }
>
> Then you would see that:
> __bss_start1 equals 0xabcd
> __bss_start2 equals 0xb000

good to know...

anyway, more lines

  . = ALIGN(PAGE_SIZE);
  __nosave_begin = .;
  .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
      *(.data.nosave)
  } :data.init2 /* use another section data.init2, see PERCPU_VADDR() above */
  . = ALIGN(PAGE_SIZE);
  __nosave_end = .;

  __bss_start = .;              /* BSS */
  .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
        *(.bss.page_aligned)
        *(.bss)
        }
  __bss_stop = .;

  _end = . ;


there are extra ALIGN(PAGE_SIZE) between them....

YH

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Absolute symbols in vmlinux_64.lds.S
  2009-03-10  5:37   ` Sam Ravnborg
@ 2009-03-10  5:49     ` Eric W. Biederman
  2009-03-10 20:20       ` H. Peter Anvin
  2009-03-10  5:57     ` Yinghai Lu
  1 sibling, 1 reply; 12+ messages in thread
From: Eric W. Biederman @ 2009-03-10  5:49 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Yinghai Lu, Jeremy Fitzhardinge, Ingo Molnar,
	the arch/x86 maintainers, Linux Kernel Mailing List

Sam Ravnborg <sam@ravnborg.org> writes:

> On Mon, Mar 09, 2009 at 06:23:55PM -0700, Yinghai Lu wrote:
>> Jeremy Fitzhardinge wrote:
>> > Why does vmlinux_64.lds.S use absolute symbols for things like
>> > __bss_start/stop:
>> > 
>> >  __bss_start = .;        /* BSS */
>> >  .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
>> >     *(.bss.page_aligned)
>> >     *(.bss)
>> >     }
>> >  __bss_stop = .;
>> > 
>> > 
>> > vmlinux_32.lds.S puts __bss_start/stop into the .bss section itself.  Is
>> > there some particular reason they need to be absolute symbols
>> > (relocation?).
>> > 
>> 
>> they are the same.
>
> Thats depends on the value of '.' where you assign __bss_start.
> We have had several bugs where the symbol assinged outside the
> section was less than expected because the linker aling the
> start of the section equal to the lrgest alignment requirement
> of a member in the section.
>
> So in this case if '.' equals to 0xabcd and the lagest
> alignment requirement inside the block is 0x1000 and we have
> __bss_start1 = .;
> .bss : {
> 	__bss_start2 = .;
> 	*(.bss.page_aligned)
> }
>
> Then you would see that:
> __bss_start1 equals 0xabcd
> __bss_start2 equals 0xb000
>
> Which may result in unexpected behaviour.
>
> The case I have in mind prevented the kernel from booting!
> So unless there are specific reasons (which should be documented)
> then always move the assignmnets inside the {} block.

I have no complaint with that.  I believe the symbols are absolute
simply because they were originally coded that way and the relocatable
kernel work on x86_64 didn't need them to change.

Eric

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Absolute symbols in vmlinux_64.lds.S
  2009-03-10  1:23 ` Yinghai Lu
@ 2009-03-10  5:37   ` Sam Ravnborg
  2009-03-10  5:49     ` Eric W. Biederman
  2009-03-10  5:57     ` Yinghai Lu
  0 siblings, 2 replies; 12+ messages in thread
From: Sam Ravnborg @ 2009-03-10  5:37 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Jeremy Fitzhardinge, Ingo Molnar, Eric W. Biederman,
	the arch/x86 maintainers, Linux Kernel Mailing List

On Mon, Mar 09, 2009 at 06:23:55PM -0700, Yinghai Lu wrote:
> Jeremy Fitzhardinge wrote:
> > Why does vmlinux_64.lds.S use absolute symbols for things like
> > __bss_start/stop:
> > 
> >  __bss_start = .;        /* BSS */
> >  .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
> >     *(.bss.page_aligned)
> >     *(.bss)
> >     }
> >  __bss_stop = .;
> > 
> > 
> > vmlinux_32.lds.S puts __bss_start/stop into the .bss section itself.  Is
> > there some particular reason they need to be absolute symbols
> > (relocation?).
> > 
> 
> they are the same.

Thats depends on the value of '.' where you assign __bss_start.
We have had several bugs where the symbol assinged outside the
section was less than expected because the linker aling the
start of the section equal to the lrgest alignment requirement
of a member in the section.

So in this case if '.' equals to 0xabcd and the lagest
alignment requirement inside the block is 0x1000 and we have
__bss_start1 = .;
.bss : {
	__bss_start2 = .;
	*(.bss.page_aligned)
}

Then you would see that:
__bss_start1 equals 0xabcd
__bss_start2 equals 0xb000

Which may result in unexpected behaviour.

The case I have in mind prevented the kernel from booting!
So unless there are specific reasons (which should be documented)
then always move the assignmnets inside the {} block.

	Sam

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Absolute symbols in vmlinux_64.lds.S
  2009-03-09 23:59 Jeremy Fitzhardinge
  2009-03-10  1:23 ` Yinghai Lu
@ 2009-03-10  1:36 ` Eric W. Biederman
  1 sibling, 0 replies; 12+ messages in thread
From: Eric W. Biederman @ 2009-03-10  1:36 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: Yinghai Lu, Ingo Molnar, the arch/x86 maintainers,
	Linux Kernel Mailing List

Jeremy Fitzhardinge <jeremy@goop.org> writes:

> Why does vmlinux_64.lds.S use absolute symbols for things like __bss_start/stop:
>
>  __bss_start = .;		/* BSS */
>  .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
> 	*(.bss.page_aligned)
> 	*(.bss)
> 	}
>  __bss_stop = .;
>
>
> vmlinux_32.lds.S puts __bss_start/stop into the .bss section itself.  Is there
> some particular reason they need to be absolute symbols (relocation?).

It is more that in vmlinux_32.lds.S they needed to be section relative, to
deal with relocation.

For the 64bit kernel the relocation happens at the level under the page table
so does not show up in vmlinux_64.lds.S.  Which means it was probably
laziness that didn't get it changed simply because it hasn't matter.

Eric

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Absolute symbols in vmlinux_64.lds.S
  2009-03-09 23:59 Jeremy Fitzhardinge
@ 2009-03-10  1:23 ` Yinghai Lu
  2009-03-10  5:37   ` Sam Ravnborg
  2009-03-10  1:36 ` Eric W. Biederman
  1 sibling, 1 reply; 12+ messages in thread
From: Yinghai Lu @ 2009-03-10  1:23 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: Ingo Molnar, Eric W. Biederman, the arch/x86 maintainers,
	Linux Kernel Mailing List

Jeremy Fitzhardinge wrote:
> Why does vmlinux_64.lds.S use absolute symbols for things like
> __bss_start/stop:
> 
>  __bss_start = .;        /* BSS */
>  .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
>     *(.bss.page_aligned)
>     *(.bss)
>     }
>  __bss_stop = .;
> 
> 
> vmlinux_32.lds.S puts __bss_start/stop into the .bss section itself.  Is
> there some particular reason they need to be absolute symbols
> (relocation?).
> 

they are the same.

YH

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Absolute symbols in vmlinux_64.lds.S
@ 2009-03-09 23:59 Jeremy Fitzhardinge
  2009-03-10  1:23 ` Yinghai Lu
  2009-03-10  1:36 ` Eric W. Biederman
  0 siblings, 2 replies; 12+ messages in thread
From: Jeremy Fitzhardinge @ 2009-03-09 23:59 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Ingo Molnar, Eric W. Biederman, the arch/x86 maintainers,
	Linux Kernel Mailing List

Why does vmlinux_64.lds.S use absolute symbols for things like 
__bss_start/stop:

  __bss_start = .;		/* BSS */
  .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
	*(.bss.page_aligned)
	*(.bss)
	}
  __bss_stop = .;


vmlinux_32.lds.S puts __bss_start/stop into the .bss section itself.  Is 
there some particular reason they need to be absolute symbols (relocation?).

Thanks,
    J

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2009-03-10 22:27 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-10  4:37 Absolute symbols in vmlinux_64.lds.S Jeremy Fitzhardinge
2009-03-10  5:32 ` Yinghai Lu
  -- strict thread matches above, loose matches on Subject: below --
2009-03-09 23:59 Jeremy Fitzhardinge
2009-03-10  1:23 ` Yinghai Lu
2009-03-10  5:37   ` Sam Ravnborg
2009-03-10  5:49     ` Eric W. Biederman
2009-03-10 20:20       ` H. Peter Anvin
2009-03-10 21:25         ` Eric W. Biederman
2009-03-10 22:26           ` Jeremy Fitzhardinge
2009-03-10  5:57     ` Yinghai Lu
2009-03-10 11:24       ` Sam Ravnborg
2009-03-10  1:36 ` Eric W. Biederman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.