[lld] [llvm] [lld-macho] Fix thunks for non-__text TEXT sections (PR #99052)
Leonard Grey via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 22 11:27:58 PDT 2024
================
@@ -89,9 +90,17 @@ static int sectionOrder(OutputSection *osec) {
StringRef segname = osec->parent->name;
// Sections are uniquely identified by their segment + section name.
if (segname == segment_names::text) {
+ if (osec->name == section_names::header)
+ return -7;
+ if (osec->name == section_names::text)
+ return -6;
+ // Ensure all code sections are contiguous with `__text` for thunk
+ // calculations.
+ if (sections::isCodeSection(osec->name, segment_names::text, osec->flags) &&
+ osec->name != section_names::stubHelper) {
+ return -5;
----------------
speednoisemovement wrote:
This is partly just to be closer to existing behavior, and partly for jankier reasons: we expect `__text` to be the biggest section, so we need it to go first so it can trip `needsThunks`.
I guess the options are:
- Keep it that way and put the above as a comment
- Not encode the assumption and sort code sections by size
WDYT?
https://github.com/llvm/llvm-project/pull/99052
More information about the llvm-commits
mailing list