[PATCH] D91127: [ELF] Use input order instead of pattern order within an input section description
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 9 23:23:42 PST 2020
MaskRay created this revision.
MaskRay added reviewers: grimar, psmith.
Herald added subscribers: llvm-commits, mgrang, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
MaskRay requested review of this revision.
According to
https://sourceware.org/binutils/docs/ld/Input-Section-Basics.html#Input-Section-Basics
for `*(.a .b)`, the order should match the input order:
- for `ld 1.o 2.o`, sections from 1.o precede sections from 2.o
- within a file, `.a` and `.b` appear in the section header table order
This patch implements the behavior. For `SORT(a.*) b.* c.* SORT(d.*)`,
we create groups and sort within groups: `SORT(a.*) | b.* c.* | SORT(d.*)`
This patch also fixes 2 bugs:
- The second `SORT` in `*(SORT(...) SORT(...))` is incorrectly parsed as a file pattern
- A section may be added multiple times if it multiple patterns match it
The patch is in preparation for support for
`*(SORT_BY_INIT_PRIORITY(.init_array.* .ctors.*)) *(.init_array .ctors)`,
which will allow LLD to mix .ctors*/.init_array* like GNU ld (gold's --ctors-in-init-array):
PR48096
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D91127
Files:
lld/ELF/LinkerScript.cpp
lld/ELF/ScriptParser.cpp
lld/test/ELF/linkerscript/exclude-multiple.s
lld/test/ELF/linkerscript/sort2.s
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91127.304058.patch
Type: text/x-patch
Size: 7212 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201110/a6f18ad1/attachment.bin>
More information about the llvm-commits
mailing list