aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/lld/ELF/LinkerScript.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2025-12-27 23:23:22 +0000
committerDimitry Andric <dim@FreeBSD.org>2026-04-25 14:14:02 +0000
commite64bea71c21eb42e97aa615188ba91f6cce0d36d (patch)
tree62aa9d1dc27620bdcc0128f6f1ed30a5eac88b54 /contrib/llvm-project/lld/ELF/LinkerScript.cpp
parent770cf0a5f02dc8983a89c6568d741fbc25baa999 (diff)
parent294ba569803972323a64670451a82af53c660541 (diff)
Diffstat (limited to 'contrib/llvm-project/lld/ELF/LinkerScript.cpp')
-rw-r--r--contrib/llvm-project/lld/ELF/LinkerScript.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/contrib/llvm-project/lld/ELF/LinkerScript.cpp b/contrib/llvm-project/lld/ELF/LinkerScript.cpp
index a5d08f4979da..b55c19933a13 100644
--- a/contrib/llvm-project/lld/ELF/LinkerScript.cpp
+++ b/contrib/llvm-project/lld/ELF/LinkerScript.cpp
@@ -1021,10 +1021,6 @@ void LinkerScript::addOrphanSections() {
}
};
- // For further --emit-reloc handling code we need target output section
- // to be created before we create relocation output section, so we want
- // to create target sections first. We do not want priority handling
- // for synthetic sections because them are special.
size_t n = 0;
for (InputSectionBase *isec : ctx.inputSections) {
// Process InputSection and MergeInputSection.
@@ -1037,10 +1033,18 @@ void LinkerScript::addOrphanSections() {
if (ctx.arg.relocatable && (isec->flags & SHF_LINK_ORDER))
continue;
- if (auto *sec = dyn_cast<InputSection>(isec))
- if (InputSectionBase *rel = sec->getRelocatedSection())
- if (auto *relIS = dyn_cast_or_null<InputSectionBase>(rel->parent))
- add(relIS);
+ if (auto *sec = dyn_cast<InputSection>(isec)) {
+ if (InputSectionBase *relocated = sec->getRelocatedSection()) {
+ // For --emit-relocs and -r, ensure the output section for .text.foo
+ // is created before the output section for .rela.text.foo.
+ add(relocated);
+ // EhInputSection sections are not added to ctx.inputSections. If we see
+ // .rela.eh_frame, ensure the output section for the synthetic
+ // EhFrameSection is created first.
+ if (auto *p = dyn_cast_or_null<InputSectionBase>(relocated->parent))
+ add(p);
+ }
+ }
add(isec);
if (ctx.arg.relocatable)
for (InputSectionBase *depSec : isec->dependentSections)