From: ron minnich <rminnich@lanl.gov>
To: 9fans@cse.psu.edu
Subject: [9fans] A simple question
Date: Wed, 9 Jul 2003 07:20:20 -0600 [thread overview]
Message-ID: <Pine.LNX.4.44.0307090702160.1936-100000@maxroach.lanl.gov> (raw)
I have a little program, a.c:
#include <blahblah.h>
int a(){ print("hi\n"); }
I want to link the a.8 program produced by 8.c against the 9pcdisk image
and produce an 8.out, something like this:
8l -T some-base-address a.8 9pcdisk
I want the 8.out to be JUST the a.8 with symbol fixups from 9pcdisk, and
based at 'some-base-address'.
Now obviously that doesn't *quite* work, since 9pcdisk is not something
you can link against. So what I'm really after is something like this:
8l -T some-base-address -d 9pcdisk a.8
This would use 9pcdisk to define the symbols.
I don't really want to work with 9pcdisk directly, so I did this:
nm 9pcdisk > kname
I get a log of entries in kname like this:
0x80400040 T somesymbol
And then all I need to do is set up 8l to read this file and pre-define a
bunch of symbols (or so I think).
So as a test I put this code into 8l, ripping off the readundefs code
(defs is an array of names of define files to use, defsp is how many there
are):
void
readdefs(void)
{
int i, n;
Sym *s;
Biobuf *b;
char *l, buf[256], *fields[3];
for(i = 0; i < defsp; i++) {
b = Bopen(defs[i], OREAD);
if(b == nil) {
diag("could not open %s: %r", defs[i]);
errorexit();
}
while((l = Brdline(b, '\n')) != nil) {
n = Blinelen(b);
if(n >= sizeof(buf)) {
diag("%s: line too long", defs[i]);
errorexit();
}
strncpy(buf, l, n);
n = getfields(buf, fields, nelem(fields), 1, "
\t\r\n");
if(n == nelem(fields)) {
diag("%s: bad format", defs[i]);
errorexit();
}
if ((*fields[1] != 'T') && (*fields[1] != 'D'))
continue;
s = lookup(fields[2], 0);
if (*fields[1] == 'T')
s->type = STEXT;
else
s->type = SDATA;
s->value = strtol(fields[0], 0, 0);
}
Bterm(b);
}
}
I.e. read the kname file, and for all the 'T' and 'D' entries, put a
symbol table entry in for those names.
Well, this sort of works, but I have not figured out how to make 8l NOT
change the values of these symbols. In other words, print starts out with
some value from 9pcdisk, but in 8.out it has a different value. Not what
I want at all. I want 8.out to have a fixed up symbol for print, with the
value found in 9pcdisk.
I also think I'm missing some bits which are probably needed to link
correctly. I set name, value, and type; I think I might need to set
frame; are version and become required?
If it's not obvious I need this to allow me to put code images into kernel
space and call them. I'm doing this via a device I've called zoot (#z)
since I don't believe anybody else is using #z. This work is for two uses:
modules and Plan 9 booting Plan 9. I started on Plan 9 booting Plan 9
since fixing 9load AND Plan 9 issues for linuxbios is twice as much work
as just trying to fix Plan 9 for linuxbios. If Plan 9 can boot Plan 9,
then I can stop worrying about 9load.
Now if somebody has already done both these things just tell me and I can
stop :-)
BTW #z, so far, is in port, not pc, and I hope to keep it that way.
ron
next reply other threads:[~2003-07-09 13:20 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-07-09 13:20 ron minnich [this message]
2003-07-10 3:59 ` Russ Cox
2003-07-10 5:37 ` Tad Hunt
2003-07-10 6:46 ` boyd, rounin
2003-07-10 11:14 ` ron minnich
2003-07-10 14:46 ` jmk
2003-07-10 16:32 ` Dan Cross
2003-07-10 16:37 ` boyd, rounin
2003-07-10 18:13 ` jmk
2003-07-10 19:13 ` boyd, rounin
2003-07-10 23:47 ` Bruce Ellis
2003-07-11 14:59 ` ron minnich
2003-07-10 17:15 ` Tad Hunt
2003-07-10 11:11 ` ron minnich
2003-07-10 11:31 ` Lucio De Re
2003-07-10 12:03 ` David Presotto
2003-07-10 14:14 ` boyd, rounin
2003-07-10 14:08 ` Lucio De Re
2003-07-10 14:24 ` David Presotto
2003-07-10 14:25 ` Lucio De Re
2003-07-10 15:06 ` boyd, rounin
2003-07-10 15:09 ` Jack Johnson
2003-07-11 4:41 ` Lucio De Re
2003-07-11 6:03 ` boyd, rounin
2003-07-11 6:11 ` Lucio De Re
2003-07-11 6:59 ` boyd, rounin
2003-07-11 8:13 ` northern snowfall
2003-07-11 16:10 ` Jack Johnson
2003-07-12 0:29 ` northern snowfall
2003-07-11 23:33 ` boyd, rounin
2003-07-10 15:09 ` rog
-- strict thread matches above, loose matches on Subject: below --
2002-09-19 19:36 [9fans] a " presotto
2002-09-19 19:34 Charles Forsyth
2002-09-19 18:55 yan zhao
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=Pine.LNX.4.44.0307090702160.1936-100000@maxroach.lanl.gov \
--to=rminnich@lanl.gov \
--cc=9fans@cse.psu.edu \
/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 NNTP newsgroup(s).