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

Offline AntonPotapov

  • Jr. Member
  • *
  • Posts: 10
Re: Linux x86. call error when linking gcc
« Reply #15 on: April 27, 2023, 03:44:01 PM »
I found the types of sections:
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.

Yes, thank you. Now I've got it figured out.