Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Torregrosa Paez2015-10-15 08:57:52 +0000
committerPablo Torregrosa Paez2015-10-15 08:58:26 +0000
commit6239c7c1b602282a74b207a5516393f9abf591df (patch)
tree9b265f0b97e4e0fe84d4c0c8f39dd6a8e9136626 /target_explorer
parent94bac5392b3f553db7252d6e23144a3bc251fcdd (diff)
downloadorg.eclipse.tcf-6239c7c1b602282a74b207a5516393f9abf591df.tar.gz
org.eclipse.tcf-6239c7c1b602282a74b207a5516393f9abf591df.tar.xz
org.eclipse.tcf-6239c7c1b602282a74b207a5516393f9abf591df.zip
Target Explorer: Added getEntryPoints method to ElfUtils.
Change-Id: Ie9fd35b002836a3eb609b53a106d9ea05193a935 Signed-off-by: Pablo Torregrosa Paez <pablo.torregrosa@windriver.com>
Diffstat (limited to 'target_explorer')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.core.cdt/src/org/eclipse/tcf/te/core/cdt/elf/ElfUtils.java41
1 files changed, 40 insertions, 1 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.core.cdt/src/org/eclipse/tcf/te/core/cdt/elf/ElfUtils.java b/target_explorer/plugins/org.eclipse.tcf.te.core.cdt/src/org/eclipse/tcf/te/core/cdt/elf/ElfUtils.java
index 98e74b385..76e1a9f43 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.core.cdt/src/org/eclipse/tcf/te/core/cdt/elf/ElfUtils.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.core.cdt/src/org/eclipse/tcf/te/core/cdt/elf/ElfUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2012, 2015 Wind River Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
@@ -11,9 +11,12 @@ package org.eclipse.tcf.te.core.cdt.elf;
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.cdt.utils.elf.Elf;
import org.eclipse.cdt.utils.elf.Elf.ELFhdr;
+import org.eclipse.cdt.utils.elf.Elf.Symbol;
/**
* Provides ELF file utilities.
@@ -94,4 +97,40 @@ public final class ElfUtils {
}
return elfclass;
}
+
+ /**
+ * Returns a list with the entry point names in this file.
+ *
+ * @param file The file representation of the physical file to get the entry points.
+ * Must not be <code>null</code>.
+ * @return
+ */
+ public static String[] getEntryPoints(File file) throws IOException {
+ String[] entryPoints = null;
+ if (file!=null) {
+ Elf elfFile = null;
+ try {
+ elfFile = new Elf(file.getAbsolutePath());
+ elfFile.loadSymbols();
+
+ Symbol[] symbols = elfFile.getSymbols();
+ if (symbols != null) {
+ List<String> entryPointList = new ArrayList<String>();
+ for(Symbol s:symbols) {
+ if (s.st_type() == Elf.Symbol.STT_FUNC) {
+ entryPointList.add(s.toString());
+ }
+ }
+ entryPoints = entryPointList.toArray(new String[entryPointList.size()]);
+ }
+ }
+ finally {
+ if (elfFile != null) {
+ elfFile.dispose();
+ }
+ elfFile = null;
+ }
+ }
+ return entryPoints;
+ }
}

Back to the top