LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   inline asm, 64-bit asm, intercepting segfaults, etc. (http://www.linuxquestions.org/questions/programming-9/inline-asm-64-bit-asm-intercepting-segfaults-etc-927639/)

rainbowsally 02-04-2012 05:10 PM

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
http://www.linuxquestions.org/questi...ine-asm-34412/
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
http://www.linuxquestions.org/questi...n-linux-34435/
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)
http://www.linuxquestions.org/questi...aka-seh-34436/
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:09 AM.