flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Possible documentation bug

Thread Post new topic Reply to topic
Your code has a bug

Joined: 06 May 2005
Posts: 4624
Location: Argentina
There is a part of the documentation that says this
2.4.4 Executable and Linkable Format wrote:
To create executable file, follow the format choice directive with the executable keyword. It allows to use entry directive followed by the value to set as entry point of program. On the other hand it makes extrn and public directives unavailable, and instead of section there should be the segment directive used, followed only by one or more segment permission flags. The origin of segment is aligned to page (4096 bytes), and available flags for are: readable, writeable and executable.

I think that a reader with non deep knowledge of ELF specification could think that the origin is of the form [mem_offset mod 4096 = 0] when actually is [mem_offset mod 4096 = file_offset mod 4096]. If the user really needs a page aligned address he will need to use "align 4096" even if the previous line was the segment declaration. What is true, however, is that the first accessible byte within the segment is aligned to page size and the segment virtual space size is multiple of 4096 too, but, those first and last bytes may be overlapped with either elf metadata or another segment (still, you're allowed to access it at the permissions you specified without any trouble).

format ELF executable

segment readable
label firstByte at origin mod 4096

;origin <> firstByte
label lastByte at ($ + 4095) mod 4096
;end <> lastByte    
Post 08 Jul 2007, 21:49
View user's profile Send private message 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.