flat assembler
Message board for the users of flat assembler.

Index > Main > Sections/segments a) readable b) order

Author
Thread Post new topic Reply to topic
jorido



Joined: 23 Jan 2017
Posts: 53
jorido 07 Oct 2017, 01:41
1)

When and when not is it needed to make a section or segment readable?
In one of the example in the "fasm" none of sections readable:

Code:
format ELF

section '.text' executable

 public _start
 _start:

 extrn writemsg

  mov esi,msg
  call  writemsg

  mov eax,1
  xor ebx,ebx
  int 0x80

section '.data' writeable

 msg db "Elves are coming!",0xA,0

    



2) Does the order of sections/segments matter?


Any difference between this one and the original example?


Code:

format ELF

section '.data' writeable

 msg db "Elves are coming!",0xA,0

section '.text' executable

 public _start
 _start:

 ;.........................

    
Post 07 Oct 2017, 01:41
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20306
Location: In your JS exploiting you and your system
revolution 07 Oct 2017, 05:15
1) The OS probably gives all sections the readable attribute even if you don't specify it, but this is only my guess. You will need to check the docs to see what Linux does here. Usually only executable sections make sense to be non-readable and non-writeable.

2) The order does not matter, You can put things in any order you want.
Post 07 Oct 2017, 05:15
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 07 Oct 2017, 13:13
The sections in ELF format do not have an attribute that would mean "readable". Only the run-time segments have, but they are a different entity (defined in "Program Header").
Post 07 Oct 2017, 13:13
View user's profile Send private message Visit poster's website Reply with quote
_shura



Joined: 22 May 2015
Posts: 61
_shura 07 Oct 2017, 17:47
Actually, Linux set all segments readable and executable by default, even if the segment is neither readable, writeable nor executable, as long as your executable file does not contain a gnu-stack-segment. So if you create a executable file, please use »segment gnustack«, if you create an object-file, please link everything with »ld -z noexecstack«. Anyway, afaik everything is readable, even if you did not actually set this flag.

Afaik there where some linux-versions, where the last segment must be writeable (I guess, it had something to do with the stack, that should be, of course, writeable), but I do not know, whether this is true for section or not.
Post 07 Oct 2017, 17:47
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.