Author Topic: Linux x86. call error when linking gcc  (Read 14965 times)

Offline AntonPotapov

  • Jr. Member
  • *
  • Posts: 13
Re: Linux x86. call error when linking gcc
« Reply #15 on: April 27, 2023, 03:44:01 PM »
I found the types of sections: https://nasm.us/doc/nasmdoc8.html#section-8.9.2
Yep. 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
Yes, thank you. Now I've got it figured out.