flat assembler
Message board for the users of flat assembler.

flat assembler > Linux > Explain Like I'm 5: Segments in ELF files.

Thread Post new topic Reply to topic

Joined: 21 Apr 2013
Posts: 5
Location: Bloomington
Consider the following hello world program:

format ELF64 executable 0
entry main

segment readable executable

    mov rax, 1
    mov rdi, 1
    mov rsi, msg
    mov rdx, len

    mov rax, 60
    xor rdi, rdi

segment readable writeable

msg db "Hello World!", 10
len = $ - msg    

What do the segment directives in this program do? I tried experimenting with it to understand what they do. First, I removed the executable permission flag from the first segment. To my surprise, the code still worked. Next, I removed the readable permission flag from the second segment and the code still worked. Finally, I removed both the segment directives and the code still worked fine.

So, what do these segment directive do? Explain like I'm 5.
Post 13 Mar 2018, 22:44
View user's profile Send private message Send e-mail 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-2018, Tomasz Grysztar.

Powered by rwasa.