[PATCH] D32399: [LLD] Order writable executable sections before writable ones
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 24 15:05:39 PDT 2017
ruiu added inline comments.
================
Comment at: lld/ELF/Writer.cpp:698
if (AIsExec != BIsExec)
- return BIsExec;
+ return (A->Flags & SHF_WRITE) ? AIsExec : BIsExec;
}
----------------
kettenis wrote:
> ruiu wrote:
> > Is there any problem if you just return `AIsExec`?
> Yes. Then read-only executable sections would be sorted before read-only sections, which is not what we want. Basically the current ordering is:
>
> R
> RX
> RW <- contains .bss
> RWX
>
> I propose we change this to
>
> R
> RX
> RWX
> RW <- contains .bss
>
I believe this code is correct, but this function seems a bit puzzling to me. Each decision-making code block is well-commented and clear about what it does, but as a whole it's not easy to predict what this function returns for some two sections. I want to make this as simple as your example
R
RX
RWX
RW.
Do you think you can improve this function? If you don't have a bandwidth to handle it, I'll try to simplify.
https://reviews.llvm.org/D32399
More information about the llvm-commits
mailing list