[PATCH] D23505: [ELF] - Linkrscript: change the way of creating PT_LOADs segments when LS is used.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 17 14:44:48 PDT 2016
ruiu added inline comments.
================
Comment at: ELF/Writer.cpp:968
@@ +967,3 @@
+ uintX_t NewFlags = Sec->getPhdrFlags();
+ if (((Load->H.p_flags & PF_W) == 0) && ((NewFlags & PF_W) != 0))
+ Load = addHdr(Dest, PT_LOAD, NewFlags);
----------------
grimar wrote:
> ruiu wrote:
> > What if the current section is writable and NewFlags are not writable? This code seems to merge them, but is it the right thing to do?
> That is what ld do. I think it is fine because writable sections go after all other ones.
> At least it is assumed they should.
I do not understand. Why it is guaranteed that writable sections are written after all other sections? If you are using linker scripts, you have a full control over the section layout, so you can put read-only sections before writable sections.
In addition to that, probably needless to say, but doing the same thing as ld does is not the ultimate goal. It's an important goal, but the ultimate goal should be to implement a logic that we understand and can justify. The last part is important. (So, we don't want to say "we don't know why, but this is what ld does, so do we.")
https://reviews.llvm.org/D23505
More information about the llvm-commits
mailing list