How to use mprotect/make a code segment memory writable? [solved] lazarus / 32-Linux ---------------------------------------------------------------------- pik33 · 2019-07-08 15:13 I have an asm code (ARM, RPi) which I want to move from a bare metal environment to Lazarus/Linux on RPi. It writes values to the procedure area so the program causes the exception. Is there any way to set a code area memory writable (while linking or runtime)? I read the ld linker has -N option which does this but I don't know if Lazarus (2.0.0) uses LD and if yes, how to pass the parameter to the linker. I tried -k in option with no success (a lot of linker errors) Edit: I found a mprotect system call. How to use it in Lazarus? ---------------------------------------------------------------------- pik33 · 2019-07-09 07:32 Solved Code: [Select]function Do_SysCall(sysnr,param1,param2,param3:cardinal):integer; external name 'FPC_SYSCALL3'; function fpmprotect(addr,size,prot:cardinal):longint; begin  result:=Do_SysCall(125,addr,size,prot); end; ---------------------------------------------------------------------- marcov · 2019-07-09 09:22 The do_syscalls are available via unit syscall, so you don't need to declare it with external