[lld] [lld][MachO] Fix symbol inseration in `transplantSymbolsAtOffset` (PR #120737)
Carlo Cabrera via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 20 06:12:51 PST 2024
https://github.com/carlocab created https://github.com/llvm/llvm-project/pull/120737
The existing comparison does not insert symbols in the intended place.
Unfortunately, it is not very clear how to test this. Suggestions
appreciated.
Closes #120559.
>From 627f54b4bf7fdc8d07630d756cac2c351ff0cae5 Mon Sep 17 00:00:00 2001
From: Bjorn Pettersson <bjorn.a.pettersson at ericsson.com>
Date: Fri, 20 Dec 2024 22:08:49 +0800
Subject: [PATCH] [lld][MachO] Fix symbol inseration in
`transplantSymbolsAtOffset`
The existing comparison does not insert symbols in the intended place.
Unfortunately, it is not very clear how to test this. Suggestions
appreciated.
Closes #120559.
---
lld/MachO/SymbolTable.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lld/MachO/SymbolTable.cpp b/lld/MachO/SymbolTable.cpp
index f0a92da8777e13..36e421b52abcac 100644
--- a/lld/MachO/SymbolTable.cpp
+++ b/lld/MachO/SymbolTable.cpp
@@ -69,7 +69,7 @@ static void transplantSymbolsAtOffset(InputSection *fromIsec,
// Ensure the symbols will still be in address order after our insertions.
auto insertIt = llvm::upper_bound(toIsec->symbols, toOff,
[](uint64_t off, const Symbol *s) {
- return cast<Defined>(s)->value < off;
+ return cast<Defined>(s)->value > off;
});
llvm::erase_if(fromIsec->symbols, [&](Symbol *s) {
auto *d = cast<Defined>(s);
More information about the llvm-commits
mailing list