sgmarz / osblog

The Adventures of OS
MIT License
517 stars 70 forks source link

linker script MEMORY section #32

Open mikedilger opened 3 years ago

mikedilger commented 3 years ago

Just thought I'd mention that the MEMORY flags (airwx) don't mean what your comment implies. They don't apply to the memory, they apply to the section being allocated in that memory. It means something like this: 'allow sections that I didn't mention below and which have these flags set to be placed within this region of memory'.

Given your script, if an input file has a read only section or an initialized section and you didn't mention it in SECTIONS, and you put !r or !i in the memory flags, it will get discarded because there is no place for it.

Actually... since you are no longer inverting (!ri) I suppose the linker may put them in there anyways. But I'd change it to 'airwx' just to be safe. UPDATE: for some reason rust-lld doesn't accept 'i' or it's alias 'l'.

BTW: thanks for this OS blog, it's very helpful.