Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/BinaryObject.java10
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/BinaryObject.java10
2 files changed, 14 insertions, 6 deletions
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/BinaryObject.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/BinaryObject.java
index 771b14acc3..9c9a71df6c 100644
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/BinaryObject.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/BinaryObject.java
@@ -58,11 +58,15 @@ public class BinaryObject extends BinaryFile implements IBinaryObject {
*/
public ISymbol getSymbol(long addr) {
ISymbol[] syms = getSymbols();
- int i = Arrays.binarySearch(syms, new Long(addr));
- if (i < 0 || i >= syms.length) {
+ int insertion = Arrays.binarySearch(syms, new Long(addr));
+ if (insertion > 0) {
+ return syms[insertion];
+ }
+ if (insertion == -1) {
return null;
}
- return syms[i];
+ insertion = -insertion - 1;
+ return syms[insertion - 1];
}
/**
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/BinaryObject.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/BinaryObject.java
index fa0fd575c5..b5acdff084 100644
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/BinaryObject.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/BinaryObject.java
@@ -56,11 +56,15 @@ public class BinaryObject extends BinaryFile implements IBinaryObject {
*/
public ISymbol getSymbol(long addr) {
ISymbol[] syms = getSymbols();
- int i = Arrays.binarySearch(syms, new Long(addr));
- if (i < 0 || i >= syms.length) {
+ int insertion = Arrays.binarySearch(syms, new Long(addr));
+ if (insertion > 0) {
+ return syms[insertion];
+ }
+ if (insertion == -1) {
return null;
}
- return syms[i];
+ insertion = -insertion - 1;
+ return syms[insertion - 1];
}
/**

Back to the top