SIGSEGV handler Question



Hi,

I know that if a user-level signal handler is implemented to capture
SIGSEGV, the fault must be corrected by the signal handler before the
handler exits, so as to avoid infinite looping. Usually this is done by
changing the memory protection mode or perform a memory mapping on the
virtual address that causes the fault.

I'd like to ask if it is possible to write a signal handler to capture
SIGSEGV, and handles the fault by changing the virtual address the program
is accessing instead? For example, if a read to VM address 0x12340000 causes
a SIGSEGV, instead of changing the memory protection of 0x12340000 to
readable or perform a memory mapping on this address inside the signal
handler, is it possible to change the VM address to be accessed to, say
0x56780000 inside the handler (assume 0x56780000 is mapped and is readable)?

Thanks very much in advance!

Best Regards,
LaBird (Benny)
[Remove the 2nd, 8th and 9th character to get the actual email address.]


.



Relevant Pages

  • Re: Trapping writes to mmapd memory.
    ... mprotectchanges the access permission bits in the page table. ... only PROT_READ access, then the hardware gives a fault, and the Linux ... The signal handler can find the fault address, ... application already was catching SIGSEGV for some other purpose ...
    (comp.os.linux.development.system)
  • Re: How to run code before global constructors?
    ... The code is designed to fault if it's not ... >initialized and the signal handler handles the fault by doing the ... >uninitialized sections fault and the fault handler does the initialization. ... 24539 Neumuenster, Germany|F.W.A.K.(Rotten Apples), Love Career ...
    (comp.os.linux.development.apps)
  • Re: How to run code before global constructors?
    ... The code is designed to fault if it's not ... >>initialized and the signal handler handles the fault by doing the ... from constructing global objects would be too painful. ... allocation/deallocation. ...
    (comp.os.linux.development.apps)
  • Re: How to ignore SIGSEGV signal
    ... >> For this signal and a few others that can be generated by a fault detected ... >from the signal handler, it should resume executing exactly where it ... thus generating another segmentation violation. ... If one wants to continue execution, ...
    (comp.unix.programmer)
  • Re: SIGSEGV handler Question
    ... the fault must be corrected by the signal handler before the ... SIGSEGV, and handles the fault by changing the virtual address the program ...
    (comp.os.linux.development.apps)