[PATCH] D105158: [ELF] Preserve section order within an INSERT AFTER command

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 29 16:14:11 PDT 2021


MaskRay created this revision.
MaskRay added reviewers: grimar, peter.smith.
Herald added subscribers: arichardson, emaste.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

For

  SECTIONS {
    text.0 : {}
    text.1 : {}
    text.2 : {}
  } INSERT AFTER .data;

the current order is `.data text.2 text.1 text.0`. It makes more sense to
preserve the specified order and thus improve compatibility with GNU ld.

For

  SECTIONS { text.0 : {} } INSERT AFTER .data;
  SECTIONS { text.3 : {} } INSERT AFTER .data;

GNU ld somehow collects sections with `INSERT AFTER .data` together (IMO
inconsistent) but I think it makes more sense to execute the commands in order
and get `.data text.3 text.0` instead.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105158

Files:
  lld/ELF/LinkerScript.cpp
  lld/ELF/LinkerScript.h
  lld/ELF/ScriptParser.cpp
  lld/test/ELF/linkerscript/insert-multi.test

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105158.355392.patch
Type: text/x-patch
Size: 4431 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210629/661e898f/attachment.bin>


More information about the llvm-commits mailing list