11
Programming with NASM / Re: Linux x86. Align segmtnt elf_i386 (p_align)
« Last post by fredericopissarra on April 27, 2023, 10:25:45 PM »You didn't read a line about what I wrote about sections attributes, did ya?
Yes, thank you. Now I've got it figured out.I found the types of sections: https://nasm.us/doc/nasmdoc8.html#section-8.9.2Yep. Of those, usually you'll use .text, .data, .rodata and/or .bss.
All .xxx are system sections with predefined attributes. You can create your own sections without the '.', like in mysection which will have always the attributes noexec and nowrite, by default. Of course you can override this.
Since Linux (and Windows) use paging, these sections will be placed (probably) in different pages with specific attributes. Then, in your case, as you defined mysection without attributes, this page (4 KiB) will be readonly (noexec) and not executable (noexec), hence the segmentation fault. As I told you before, you only need to set exec attribute to override this:Code: [Select]section mysection exec ; mysection isn't a system section, now with exec attrib set.
[]s
Fred
#/bin/bash
ld -m elf_i386 -o main main.o
#/bin/bash
ld -m elf_i386 -n -o main main.o
I found the types of sections: https://nasm.us/doc/nasmdoc8.html#section-8.9.2Yep. Of those, usually you'll use .text, .data, .rodata and/or .bss.
section mysection exec ; mysection isn't a system section, now with exec attrib set.
Thanks, I will keep that in mind. As long as I am programming in linux. It is easier for me to write programs in linux. or so it seems to meI recently started learning assembler. And I'm trying different ways of writing code. Next I plan to learn SSE. and above mentioned ABI, I'll read about it too.Since you are using NASM (necessarily for x86), search for SysV ABI for i386 and amd64 (or x86_64) and study it... If you are using Windows, take a look at Microsoft calling conventions (or MS ABI)...
ABI are useful if you mix code with C and use syscalls/system libraries...
I recently started learning assembler. And I'm trying different ways of writing code. Next I plan to learn SSE. and above mentioned ABI, I'll read about it too.Since you are using NASM (necessarily for x86), search for SysV ABI for i386 and amd64 (or x86_64) and study it... If you are using Windows, take a look at Microsoft calling conventions (or MS ABI)...
Thanks Fred!I recently started learning assembler. And I'm trying different ways of writing code. Next I plan to learn SSE. and above mentioned ABI, I'll read about it too.
Hi again Anton,
I think we may need to ask WHY you are doing some of the things you do. Maybe you have something special in mind.
Best,
Frank
Frank was asking Anton why he is doing what he is doingOops!