This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: noreturn function attribute and ret asm instruction


On Fri, 2003-09-12 at 18:25, Jim Wilson wrote:
> On Fri, 2003-09-12 at 10:14, Kristis Makris wrote:
> > Here %eax is used and it's previous value is not preserved. Again
> > conceptually I should be able to write in a high-level language such as
> > C with the option to tell gcc to preserve the registers it will end up
> > using on its own.
> 
> You haven't given any justification for why you want this feature.  We
> aren't going to add features that have no known use.  Maybe if you
> explained what you are trying to do, we could offer a better
> alternative, or give reasons why what you want to do won't work.

I'm sorry Jim. Let me provide some more information.

I am working on a framework with which functions that were compiled for
the linux kernel can be replaced with newer revisions of them during
runtime. As part of the redirection mechanism of a function call, the
original function image is overwritten with a trampoline that jumps to a
separate portion in memory (the handler of the redirection) where after
some bookeeping work a jump to the newer revision of the function is
made. At the time the newer function is jumped to, the processor state
should be the same as when the original version of the function was
called, with all the parameters it might have been passed on the stack,
and any register values unchanged. Conceptually I should be able to
write a complex handler in a high-level language without explicit calls
to the SAVE_ALL and RESTORE_ALL macros in linux that push *all* the
registers instead of only the ones that might be clobbered. The compiler
should be able to generate such C code. The handler itself is
dynamically genarated and customized per function image for better
performance, so I memcpy a handler template currently written in asm as
the actual handler of a function after replacing in it some jump and
variable addresses used. As more functionality needs to be added in the
handler (or conditionally compiled in it), the asm implementation
becomes uneccessarily complex, for what could be a more readable
implementation in C.

It just appears to me that one should never have to write anything in
assembly, unless using architecture dependent features such as using the
%cr2 register in x86 for paging. If I'm trying to add up two numbers or
grab a lock, I should be able to write that in C. I see this as a useful
feature, but gcc developers might look at this from a different angle. I
welcome your feedback.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]