From: Eduardo Pereira Habkost <ehabkost@conectiva.com.br>
To: Robert de Bath <robert$@mayday.cix.co.uk>
Cc: Linux-8086 <linux-8086@vger.kernel.org>
Subject: Re: ELKS memcpy_fromfs() failing. Wrong variable offsets
Date: Wed, 2 Jun 2004 09:52:31 -0300 [thread overview]
Message-ID: <20040602125230.GX21172@duckman.distro.conectiva> (raw)
In-Reply-To: <609c173af82cc283@mayday.cix.co.uk>
[-- Attachment #1: Type: text/plain, Size: 3158 bytes --]
On Wed, Jun 02, 2004 at 09:47:25AM +0100, Robert de Bath wrote:
<snip>
>
> Oh my, confusion reigns.
I guess so. 8)
>
> Okay first the si and di variables are usually defined as callee saves
> unless you're compiling with the '-Mc' option.
>
> The "memcpy_fromfs.off" stuff is generated for optimising the push/pop
> of the si and di variables. It's a reasonably recent addition so all
> accesses of si and si can be eliminated if they are unused. However,
> it's only turned on if you use '-O'.
I've seen that this .off stuff was added between 0.16.0 and 0.16.15. That
is why the (wrong) ELKS code used to work.
>
> Ie: this is working as it should.
>
> You have highlighted a bug though, the definition some of the 'set'
> variables is actually wrong, they should have memcpy_fromfs.off added
> when it might be non-zero.
>
> BTW: You should really be using those variables to access C arguments
> and locals, the '_memcpy_fromfs.ds' is for stack pointer relative the
> '.memcpy_fromfs.ds' is for 'bp' relative.
Hey, nice! I've never looked at that code before, and I didn't know what
the author have assumed about the offsets of the variables, but
these [._]<function>.<variable> macros are what I was looking for
fixing the code. Thanks. :)
BTW: these [._]<function>.<variable>macros are available since old
versions, right? I will change ELKS code to use them.
>
> I can fix the bug in one of two ways; either actually add the
> 'memcpy_fromfs.off' variable to the 'set' variables or simply
> have the compiler assume that any '#asm' will use si and di.
> (The asm("...") function will not however.)
>
> Actually I think assuming that #asm uses si/di is best because as this
> example has shown it is quite likely to be true, plus, it's the failsafe
> option.
>
> (PS: It's also very easy to do :-) see attached. )
>
> So do you want me to make it like it was before? :-)
No, I just wanted to understand what happened. Now I understand the
Right Way to access variables and parameters inside #asm. :)
I think that forcing the user to save DI and SI if he wants to use the
registers is ok, unless it would break some existing software. It's up
to you. Adding a way to make #asm tell the compiler which registers it
will use (and maybe assume by default that it will change all registers)
would be interesting, too.
>
> --
> Rob. (Robert de Bath <robert$ @ debath.co.uk>)
> <http://www.cix.co.uk/~mayday>
>
> diff -Nurd linux86.old/bcc/table.c linux86/bcc/table.c
> --- linux86.old/bcc/table.c Sun Jul 28 08:43:13 2002
> +++ linux86/bcc/table.c Wed Jun 2 09:37:56 2004
> @@ -400,6 +400,11 @@
> register struct symstruct *symptr;
> int i;
>
> + if (framep && optimise && !callersaves) {
> + regfuse |= callee1mask;
> + outnstr("! Assuming #asm uses all callee saves registers");
> + }
> +
> for (i = 0; i < HASHTABSIZE; ++i)
> for (symptr = hashtab[i]; symptr != NULL; symptr = symptr->next)
> if (symptr->storage == LOCAL)
--
Eduardo
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2004-06-02 12:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20040601222140.GV21172@duckman.distro.conectiva>
2004-06-02 8:47 ` ELKS memcpy_fromfs() failing. Wrong variable offsets Robert de Bath
2004-06-02 12:52 ` Eduardo Pereira Habkost [this message]
2004-06-02 16:10 ` [bcc patch] Fix variable offset macros for #asm (was: Re: ELKS memcpy_fromfs() failing. Wrong variable offsets) Eduardo Pereira Habkost
2004-06-03 14:20 ` Miguel Bolanos
2004-06-03 14:19 ` ELKS memcpy_fromfs() failing. Wrong variable offsets Miguel Bolanos
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=20040602125230.GX21172@duckman.distro.conectiva \
--to=ehabkost@conectiva.com.br \
--cc=linux-8086@vger.kernel.org \
--cc=robert$@mayday.cix.co.uk \
/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