1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-17 13:15:44 +02:00

Chech the range of the st_shndx field, some values

are reserved.
This commit is contained in:
Alain Magloire 2004-01-13 20:50:06 +00:00
parent d9c8a82d89
commit 04ea9e6ee1
2 changed files with 32 additions and 15 deletions

View file

@ -1,3 +1,11 @@
2004-01-13 Alain Magloire
Small fix on in the elf parser, we have to check for
Elf.Symbol.SHN_HIPROC, Elf.Symbol.SHN_LOPROC
that the st_shndx field is not is in this range.
* utils/org/eclipse/cdt/utils/elf/ElfHelper.java
2004-1-5 David Inglis
PR 49851

View file

@ -123,10 +123,13 @@ public class ElfHelper {
for (int i = 0; i < dynsyms.length; i++) {
if (dynsyms[i].st_bind() == Elf.Symbol.STB_GLOBAL && dynsyms[i].st_type() == Elf.Symbol.STT_FUNC) {
int idx = dynsyms[i].st_shndx;
if (idx < 0)
continue;
if (sections[idx].sh_type == Elf.Section.SHT_NULL)
if (idx < Elf.Symbol.SHN_HIPROC && idx > Elf.Symbol.SHN_LOPROC) {
String name = dynsyms[i].toString();
if (name != null && name.trim().length() > 0)
v.add(dynsyms[i]);
} else if (idx >= 0 && sections[idx].sh_type == Elf.Section.SHT_NULL) {
v.add(dynsyms[i]);
}
}
}
@ -144,11 +147,13 @@ public class ElfHelper {
for (int i = 0; i < dynsyms.length; i++) {
if (dynsyms[i].st_bind() == Elf.Symbol.STB_GLOBAL && dynsyms[i].st_type() == Elf.Symbol.STT_OBJECT) {
int idx = dynsyms[i].st_shndx;
if (idx < 0)
continue;
if (sections[idx].sh_type == Elf.Section.SHT_NULL)
if (idx < Elf.Symbol.SHN_HIPROC && idx > Elf.Symbol.SHN_LOPROC) {
String name = dynsyms[i].toString();
if (name != null && name.trim().length() > 0)
v.add(dynsyms[i]);
} else if (idx >= 0 && sections[idx].sh_type == Elf.Section.SHT_NULL) {
v.add(dynsyms[i]);
}
}
}
@ -181,11 +186,13 @@ public class ElfHelper {
for (int i = 0; i < symbols.length; i++) {
if (symbols[i].st_bind() == Elf.Symbol.STB_GLOBAL && symbols[i].st_type() == Elf.Symbol.STT_FUNC) {
int idx = symbols[i].st_shndx;
if (idx < 0)
continue;
if (sections[idx].sh_type != Elf.Section.SHT_NULL)
if (idx < Elf.Symbol.SHN_HIPROC && idx > Elf.Symbol.SHN_LOPROC) {
String name = symbols[i].toString();
if (name != null && name.trim().length() > 0)
v.add(symbols[i]);
} else if (idx >= 0 && sections[idx].sh_type != Elf.Section.SHT_NULL) {
v.add(symbols[i]);
}
}
}
@ -203,11 +210,13 @@ public class ElfHelper {
for (int i = 0; i < symbols.length; i++) {
if (symbols[i].st_bind() == Elf.Symbol.STB_GLOBAL && symbols[i].st_type() == Elf.Symbol.STT_OBJECT) {
int idx = symbols[i].st_shndx;
if (idx < 0)
continue;
if (sections[idx].sh_type != Elf.Section.SHT_NULL)
if (idx < Elf.Symbol.SHN_HIPROC && idx > Elf.Symbol.SHN_LOPROC) {
String name = symbols[i].toString();
if (name != null && name.trim().length() > 0)
v.add(symbols[i]);
} else if (idx >= 0 && sections[idx].sh_type != Elf.Section.SHT_NULL) {
v.add(symbols[i]);
}
}
}