asm-examples icon indicating copy to clipboard operation
asm-examples copied to clipboard

gcc required `-no-pie` (at least for `hello_world`, at least for me)

Open rowanthorpe opened this issue 6 years ago • 1 comments

When building and running hello_world.asm (on my GNU/Linux system) as per the README I got the following error:

% nasm -f elf64 hello_world.asm && gcc -o hello_world hello_world.o && ./hello_world
./hello_world: Symbol `printf' causes overflow in R_X86_64_PC32 relocation
[1]    24557 segmentation fault  ./hello_world

The -no-pie GCC flag was required to solve it, as per this stack-overflow answer:

% nasm -f elf64 hello_world.asm && gcc -no-pie -o hello_world hello_world.o && ./hello_world 
Res: Hello world!

It would be useful to add a note about this to the README, even as a footnote for people whose (more recent) GCC defaults to PIE.

rowanthorpe avatar Jun 19 '18 17:06 rowanthorpe