Closed Mesabloo closed 3 years ago
Both to complete the issue, and to have a link for the ELF object file format: https://wiki.osdev.org/ELF
There is one problem with this: sections names are not necessarily the same across object file formats (for example, the .text
section might be named differently in the ELF format and the PE format).
We might need to select special identifiers and handle those internally, generating the correct sections depending on the target object file format.
Quick recap of available sections (taken from the specification):
data
: used for statically initialized datarodata
: used for read-only statically initialized dataudata
: used for un-initialized data (sometimes 0-initialized depending on the architecture)code
: contains executable instructionsextern.code
: contains all external (static and dynamic) function bindings*extern.data
: contains all external (static and dynamic) data bindings*(*): the type of binding is given using a special dyn
quantifier placed right before the name of the binding.
All assembly languages do have sections (one for code, one for read-only data, one for zero-initialized data, etc). I believe the reason is that object files do also have those sections (taking a look the ELF object file format), and that without them it isn't really easy to, for example, have global variables etc. We will need to have sections too. The problem being how to represent them in the source file. We may do
(with or without the braces) Further referencing
x
in thetext
section would yield a*s64
(for example,mov (x), %rax
would yield%rax: s64
).