[PATCH] D112925: [ELF] Better resemble GNU ld when placing orphan sections into memory regions

Igor Kudrin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 10 06:01:50 PST 2021


ikudrin updated this revision to Diff 386128.
ikudrin retitled this revision from "[ELF] Place an orphan section to the same memory region as its anchor section" to "[ELF] Better resemble GNU ld when placing orphan sections into memory regions".
ikudrin edited the summary of this revision.
ikudrin added a comment.

Thanks for the samples, @peter.smith!

My current understanding is that `GNU ld` puts orphan sections into the same memory regions as their anchor sections if the anchor sections are explicitly assigned to memory regions in the linker script. In that case, it ignores attributes and does the said assignment even if properties of sections and regions conflict. On the other hand, if the anchor section does not have the explicit association and its memory region is selected based on attributes, `GNU ld` does the same for corresponding orphan sections. That is what your example has demonstrated.

I have updated the patch to support these newly discovered cases. Unfortunately, your sample cannot be used as is in `lld` right now because the linker ignores the `r` attribute and thus is unable to put `.rodata.01` into the correct region. I am going to prepare another patch to fix that.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112925/new/

https://reviews.llvm.org/D112925

Files:
  lld/ELF/LinkerScript.cpp
  lld/ELF/LinkerScript.h
  lld/ELF/Writer.cpp
  lld/test/ELF/linkerscript/orphan-memory.test

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112925.386128.patch
Type: text/x-patch
Size: 7954 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211110/0ab2e92a/attachment-0001.bin>


More information about the llvm-commits mailing list