Skip to main content
summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarc-Andre Laperle2018-06-18 11:13:23 -0400
committerMarc-André Laperle2018-07-23 11:36:19 -0400
commit00df1402281abae45637be3c261744d63076801e (patch)
tree2bc32c5d8269d862dd0c8d64cde8ce037ea7a1f9 /core
parent836db69fb893e452a418d3c81670f13da9b12b1b (diff)
downloadorg.eclipse.cdt-00df1402281abae45637be3c261744d63076801e.tar.gz
org.eclipse.cdt-00df1402281abae45637be3c261744d63076801e.tar.xz
org.eclipse.cdt-00df1402281abae45637be3c261744d63076801e.zip
Bug 535911: Better error in the presence of compressed ELF section
This doesn't implement reading compressed ELF section, but at least it gives a more useful error instead of a simple "IllegalArgumentException" with no clue. Change-Id: Ib0ee1ab9e3aed7aeba184f13262b59ef21afcd32 Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core/.settings/.api_filters8
-rw-r--r--core/org.eclipse.cdt.core/META-INF/MANIFEST.MF2
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/Elf.java18
3 files changed, 26 insertions, 2 deletions
diff --git a/core/org.eclipse.cdt.core/.settings/.api_filters b/core/org.eclipse.cdt.core/.settings/.api_filters
index 98ebe05715..e054e9ba12 100644
--- a/core/org.eclipse.cdt.core/.settings/.api_filters
+++ b/core/org.eclipse.cdt.core/.settings/.api_filters
@@ -68,4 +68,12 @@
</message_arguments>
</filter>
</resource>
+ <resource path="utils/org/eclipse/cdt/utils/elf/Elf.java" type="org.eclipse.cdt.utils.elf.Elf$Section">
+ <filter comment="Unlikely API incompatibility" id="336658481">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.utils.elf.Elf.Section"/>
+ <message_argument value="SHF_COMPRESSED"/>
+ </message_arguments>
+ </filter>
+ </resource>
</component>
diff --git a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
index b018bbf4f9..39629cd922 100644
--- a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.core; singleton:=true
-Bundle-Version: 6.5.0.qualifier
+Bundle-Version: 6.6.0.qualifier
Bundle-Activator: org.eclipse.cdt.core.CCorePlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/Elf.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/Elf.java
index 812b22ec93..a516c1d9f3 100644
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/Elf.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/Elf.java
@@ -302,6 +302,10 @@ public class Elf {
public final static int SHF_WRITE = 1;
public final static int SHF_ALLOC = 2;
public final static int SHF_EXECINTR = 4;
+ /**
+ * @since 6.6
+ */
+ public final static int SHF_COMPRESSED = 2048;
/* note_types */
/**
@@ -324,17 +328,26 @@ public class Elf {
* @since 5.1
*/
public ByteBuffer mapSectionData() throws IOException {
+ makeSureNotCompressed();
sections_mapped = true;
return efile.getChannel().map(MapMode.READ_ONLY, sh_offset, sh_size).load().asReadOnlyBuffer();
}
public byte[] loadSectionData() throws IOException {
+ makeSureNotCompressed();
byte[] data = new byte[(int)sh_size];
efile.seek(sh_offset);
efile.read(data);
return data;
}
+ private void makeSureNotCompressed() throws IOException {
+ if ((sh_flags & SHF_COMPRESSED) != 0) {
+ // No point in continuing, any seek() or map() will be wrong.
+ throw new IOException("Compressed sections are unsupported (SHF_COMPRESSED): " + toString()); //$NON-NLS-1$
+ }
+ }
+
@Override
public String toString() {
try {
@@ -342,6 +355,7 @@ public class Elf {
final int shstrndx= ehdr.e_shstrndx & 0xffff; // unsigned short
if (shstrndx > sections.length || shstrndx < 0)
return EMPTY_STRING;
+ sections[shstrndx].makeSureNotCompressed();
int size = (int)sections[shstrndx].sh_size;
if (size <= 0 || size > efile.length())
return EMPTY_STRING;
@@ -367,10 +381,10 @@ public class Elf {
return EMPTY_STRING;
}
+ section.makeSureNotCompressed();
StringBuilder str = new StringBuilder();
//Most string symbols will be less than 50 bytes in size
byte [] tmp = new byte[50];
-
efile.seek(section.sh_offset + index);
while(true) {
int len = efile.read(tmp);
@@ -627,6 +641,7 @@ public class Elf {
if (section.sh_type != Section.SHT_DYNAMIC) {
return new Dynamic[0];
}
+ section.makeSureNotCompressed();
ArrayList<Dynamic> dynList = new ArrayList<Dynamic>();
efile.seek(section.sh_offset);
int off = 0;
@@ -1066,6 +1081,7 @@ public class Elf {
if (section.sh_entsize != 0) {
numSyms = (int)section.sh_size / (int)section.sh_entsize;
}
+ section.makeSureNotCompressed();
ArrayList<Symbol> symList = new ArrayList<Symbol>(numSyms);
long offset = section.sh_offset;
for (int c = 0; c < numSyms; offset += section.sh_entsize, c++) {

Back to the top