Mail Archives: djgpp/1999/04/05/17:41:06
snowball3 AT usa DOT net (Mark E.) writes:
> I'm experimenting with inline assembly by trying to create an alias to a
> libc function, but so far I've been unsuccessful.
> ...
> All I wanted was the 'jmp' instruction, not extra stack code. I've read the
> extended assembly portion of the gcc manual and I've tried out some of the
> constraints, but nothing gets rid of the extra code. Is there a way to tell
> asm() to output just the 'jmp' or am I out of luck?
asm does not output extra code for this function. Your jmp
instruction is output verbatim. Even if you can find a way to get rid
of extra code for setting standard stack frame generated by compiler
(try -fomit-frame-pointer, for example), you should not rely on it.
Instead, you can use the following
__asm__ __volatile__
(" .globl _memchr_alias\n"
"_memchr_alias:\n"
" jmp _memchr");
And prototype it correctly before calling your alias function:
void *memchr_alias (const void *string, int ch, size_t num);
Also, you can read about alias attribute, supported by gcc
info gcc "c ext" "function attr"
And read about `--wrap' option of ld
info ld invocation options
Or make your memchr_alias as inline function which calls memchr and
gcc will generate optimized code (but why don't you call memchr
directly?).
--
Michael Bukin
- Raw text -