inline asm, 64-bit asm, intercepting segfaults, etc.
This isn't a question, per se, but it addresses some questions I had that I couldn't find answered anywhere in the inhabited universe.
I've posted some examples of inline assembly, some macros for defining global functions, how to look up the "context" after a segfault and keep running (displays the kind of memory: read-only, read-write, inaccessible without crashing), and some other stuff.
Mostly fairly simple and written in the gcc dialect, but shows how to write and get disassembly for intel syntax as well.
Should be helpful for anyone interested in assembler, especially AT&T syntax inlined in C/C++ programs. (The asm to C++ interfacing isn't written yet but you can call the C++ through a cdecl intermediary easily enough.)
The code and macros and even the psig_context struct example might provide clues about how to do this stuff for other cpus, though I concentrate on intel 32 and 64 bit thingies.
Here are the three currently existing blog entries on the subject.
Assembler Stuff: Asm and Inline Asm
Macros to simplify definitions of functions inlined in a dummy code section within a simple C function and looks at the intermediate gcc asm output file for the function and all the rest of the C output.
ASM: 64 bit intel asm in linux
Shows what happens on the stack in 64 bit calls.
The demo code for this one is pretty interesting. :-) Give it a whirl if you've got a sec.
ASM: Intercepting (and using) Errors (like segfaults) in asm (aka SEH)
The demo uses segfaults programmatically (not try/catch) to set a flag showing the type of memory accesses available.
|All times are GMT -5. The time now is 02:47 PM.|