Cross gcc Mailing List Archive
[Prev][Next][Index][Thread]
Re: i386 and gcc
David Wood wrote:
>
> >So your system components run in ring 0 or ring 1? I don't see the utility
> >here; the only benefit to be achieved from segmentation then is the ability
> >to load without relocation.
> Yes and not only that - run time linking.
What issue, other than relocation, is there for runtime linking?
Compile
your linkable objects PIC and put them wherever you like, or build them
with a relocation table and fix them up when you load them. Relocation
is
the only significant issue, and it's really fairly trivial.
> For the rights or wrongs of it, I was taking OLE (or COM) as the model here
> where interface pointers are used but these use proxy stubs and the kernal
> does the rest (message pass) except in the case of in process servers, which is
> the simplest case and the one I was looking at.
Ick. Sharing execution space between independant tasks is Evil.
I'd be very careful about following Microsoft's lead on coding
techniques 8)
(Note that 'shared text' is a different issue altogether, and is in
general a Good Thing.)
Also, having said all these nasty things about your scheme, bear in
mind that it's not very hard to integrate assembly code with your
GCC code, and you could do something like this fairly easily (note that
I'm not an x86 assembly guru by any stretch of the imagination) :
/* these could be hidden in the assembler file */
u_long lcall_save_caller;
u_long lcall_tmp_cs;
u_long lcall_tmp_ip;
extern lcall(u_long target_cs, u_long target_ip, void *msg);
EXT(lcall):
/* save return address */
popl %eax
mov EXT(lcall_save_caller), %eax
/* save arguments */
popl %eax
mov EXT(lcall_tmp_cs), %eax
popl %eax
mov EXT(lcall_tmp_ip), %eax
/* stack our return address */
pushl $lcall_ret
pushl %cs
/* stack target address */
mov %eax, EXT(lcall_tmp_ip)
pushl %eax
mov %eax, EXT(lcall_tmp_cs)
pushl %eax
/* jumpt to target */
lret
lcall_ret:
/* replace arguments for caller to discard */
pushl $0
pushl $0
/* restore return address */
mov %eax, EXT(lcall_save_caller)
pushl $%eax
ret
Stick this in a file called "foo.S" (the uppercase S tells
make to feed it to cpp first), and EXT is normally a null
macro (#define EXT(x) x), then call it from your C code.
Best of luck 8)
> David
--
Mike Smith *BSD hack Unix hardware collector
The question "why are the fundamental laws of nature mathematical"
invites the trivial response "because we define as fundamental those
laws which are mathematical". Paul Davies, _The_Mind_of_God_
References:
Home |
Subject Index |
Thread Index