<div dir="ltr">Hi,<div><br></div><div>This is a proposal to add an option to lld that forces .dynamic sections to be read-only. </div><div><br></div><div><span style="color:rgb(33,33,33);font-size:13px">The .dynamic section is almost read-only except for the DT_DEBUG entry which requires the dynamic linker to modify a word. MIPS has long since had a solution to this using the DT_MIPS_RLD_MAP entry to give a pointer to another section which is writable. It would be nice to have this functionality on other targets as well however. Right now many dynamic linkers do not support this layer of indirection so this can't happen by default, it must be an option. Currently .dynamic gets mapped to a PT_GNU_RELRO section. PT_GNU_RELRO sections are not shared between instances of a executable however. It would be a nice optimization to share the .dynamic section of an application where possible. In particular we would like to have this option for Fuchsia. Other dynamic linkers, like musl, already have some support for this on non-MIPS targets as seen here: </span><a href="http://git.musl-libc.org/cgit/musl/tree/ldso/dynlink.c#n1629" target="_blank" style="font-size:13px">http://git.musl-libc.org/cgit/musl/tree/ldso/dynlink.c#n1629</a><span style="color:rgb(33,33,33);font-size:13px">. In particular the DT_DEBUG_INDIRECT entry is recognized.</span><br><br>This change would refactor code that already exists for MIPS specific .dynamic sections and make them available to other targets. Mostly this would just require renaming some things and moving a few lines around. The biggest part of this change would be to add the flag. I propose it be a -z keyword called "rodynamic".<br><br>I have already made a patch for this change which can be seen here: <a href="https://reviews.llvm.org/D33251" target="_blank">https://reviews.llvm.org/D33251</a><br><br>Best,<br>Jake</div></div>