public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@bigpond.net.au>
To: Denis Vlasenko <vda@ilport.com.ua>
Cc: binutils@sourceware.org, Ingo Molnar <mingo@elte.hu>,
		Linus Torvalds <torvalds@osdl.org>,
	Gerd Hoffmann <kraxel@suse.de>, 	Andrew Morton <akpm@osdl.org>,
	linux-kernel@vger.kernel.org,
		Chuck Ebbert <76306.1226@compuserve.com>,
	binutils@sources.redhat.com
Subject: Re: as bug (was: Re: smp/up alternatives crash when CONFIG_HOTPLUG_CPU)
Date: Fri, 05 May 2006 12:26:00 -0000	[thread overview]
Message-ID: <20060505122029.GB11597@bubble.grove.modra.org> (raw)
Message-ID: <20060505122600.Hs_HsA8tpBWgbXRwRPKklS9dK05FDYDoYrgC4K_aDBw@z> (raw)
In-Reply-To: <200605051145.54643.vda@ilport.com.ua>

On Fri, May 05, 2006 at 11:45:54AM +0300, Denis Vlasenko wrote:
> 
> .section .smp_altinstr_replacement,"awx"
> .section        .sched.text,"ax",@progbits
>         call    _spin_unlock    #
> 661:
> 2:      jle 2b  #
> 662:
> .section .smp_altinstr_replacement,"awx"
>         .fill 662b-661b,1,0x42

gas should give a better error message here, but really, gas shouldn't
be expected to assemble this.  In essence, you have forward references
in that expression for the .fill length..

Some background:  Gas is a single pass assembler.  It emits code and
data into "frags", buffers containing some fixed number of bytes and
possibly a variable length tail.  The variable length part allows
various features, notably that of variable length instructions.  Symbols
are defined relative to their frags.  Until the frag addresses are
finalized, an expresion involving subtraction of two symbols in
different frags cannot be evaluated correctly.  With the testcase above
you have exactly that situation.  The x86 "jle" instruction can be two
sizes, either 6 bytes or 2 bytes depending on the offset needed, and gas
doesn't have the smarts to recognize that the "jle" above is just 2
bytes.  Instead, it assumes a variable size, putting the "jle" in its
own frag.  This means that label "661" and "662" are in separate frags
with "661" at offset 5 in its frag, and "662" at offset 0.

Since you define the ".smp_altinstr_replacement" section before the
".sched.text section", gas tries to finalize ".smp_altinstr_replacement"
first.  When it tries to calculate the fill size using
   (<base addr "662" frag>+<offset "662">)
    - (<base addr "661" frag>+<offset "661">)
the frag base addresses have not yet been set, and zero is used.  ie.
gas tries to assemble ".fill -5,1,0x42".

A workaround is to ensure that the ".sched.text" section is defined
before ".smp_altinst_replacement".

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

  parent reply	other threads:[~2006-05-05 12:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20060419094630.GA14800@elte.hu>
     [not found] ` <20060420152609.GA21993@elte.hu>
     [not found]   ` <20060421074858.GA28858@elte.hu>
2006-05-05  8:41     ` Denis Vlasenko
2006-05-05  8:46       ` Denis Vlasenko
2006-05-05  9:41         ` Denis Vlasenko
2006-05-05 12:23         ` Alan Modra [this message]
2006-05-05 12:26           ` Alan Modra
2006-05-05 13:38           ` Denis Vlasenko
2006-05-05 14:21             ` Denis Vlasenko
2006-05-06 11:24             ` Alan Modra
2006-05-06 11:26               ` Alan Modra
2006-05-07 23:03                 ` as bug Nick Clifton
2006-05-08 12:15                   ` Alan Modra

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=20060505122029.GB11597@bubble.grove.modra.org \
    --to=amodra@bigpond.net.au \
    --cc=76306.1226@compuserve.com \
    --cc=akpm@osdl.org \
    --cc=binutils@sources.redhat.com \
    --cc=binutils@sourceware.org \
    --cc=kraxel@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=torvalds@osdl.org \
    --cc=vda@ilport.com.ua \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).