Don't Recompile with -no-pie
X86-64 NASM Assembly and PIE
If you get the following runtime error when attempting to execute a 64-bit C application that links with a 64-bit NASM assembly object on Linux:
./a.out: Symbol `printf' causes overflow in R_X86_64_PC32 relocation
Segmentation fault (core dumped)
Don't do what is commonly suggested on other blogs and recompile with -no-pie. From the NASM Manual:Segmentation fault (core dumped)
Calling procedures outside your shared library has to be done by means of a procedure linkage table, or PLT
All this means is that in order to be PIE-compatible under Linux, change:call printfTo:
call printf wrt ..pltThen recompile everything and the 64-bit NASM assembly object will be able to call printf in a position-independent way.
Comments
Post a Comment