Skip to contentSkip to conversation

Naked Functions

DISCUSSION S kris 3 participants 3 messages May 27, 2003 – Jun 8, 2003

lore
Share & tools
lore

S kris

author
#0 lore raw

Hi,

I have come across some MS C code which uses 'naked' functions. How can I achieve a similar effect with GNU toolchain. I do not want to rewrite the code in assembly .s file and would prefer to do simple modifications to make it work with Linux.

Is the macro __attribute__((naked)) valid for the above purpose?
If not, what are the methods to generate the code for functions without its prolog and epilog code (naked functions) under Linux? Is prolog and epilog code generated by both MS tools and GNU tools (compilers) are same?

Please clarify the above queries.

Thanks in advance.

--Kris

_________________________________________________________________
Reconnect with old pals. Relive the happy times. http://www.batchmates.com/msn.asp With just one click.

#1 lore raw

Hi,

I've read some time ago about how writing a full programm without the headers. It's useful for write a boot sector for example, but I'm not sure for functions. But you can use it as a start point...

Just compile your program like this:

gcc -c test.c
ld -o test -Ttext 0x0 -e main test.o
objcopy -R .note -R .comment -S -O binary test test.bin

HTH,

André

Quoted 23 lines · S kris

Hi,

I have come across some MS C code which uses 'naked' functions. How can I achieve a similar effect with GNU toolchain. I do not want to rewrite the code in assembly .s file and would prefer to do simple modifications to make it work with Linux.

Is the macro __attribute__((naked)) valid for the above purpose?
If not, what are the methods to generate the code for functions without its prolog and epilog code (naked functions) under Linux? Is prolog and epilog code generated by both MS tools and GNU tools (compilers) are same?

Please clarify the above queries.

Thanks in advance.

--Kris

_________________________________________________________________
Reconnect with old pals. Relive the happy times. http://www.batchmates.com/msn.asp With just one click.

-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 1 line
André Wagner
#2 lore raw

HLA v1.49 is now available

In reply to S kris

Hi all,
HLA v1.49 is now available from the Webster download page
(http://webster.cs.ucr.edu).

HLA is the High Level Assembler for 80x86 processors. It runs under Linux and Windows. Carefully written programs are portable between the two OSes.

Lots of new sample code, lots of changes to the standard library, and a few bug fixes. Also, both Windows and Linux versions of the compiler are available with this release.

Big change: the new console routines are integrated into the standard library (portable between Linux and Windows).
This will probably break existing applications that use the console library routines. The older routines are available for separate linking to maintain compatibility.

New Iczelion conversions.
New "Windows Programming in Assembly (WPA) examples. Plus more!

Enjoy!
Randy Hyde