+ private Symtab _symtab;
+ public Symtab getSymtab() throws IOException {
+ if(_symtab != null) return _symtab;
+
+ SHeader sh = sectionWithName(".symtab");
+ if(sh == null || sh.type != SHeader.SHT_SYMTAB) return null;
+
+ SHeader sth = sectionWithName(".strtab");
+ if(sth == null || sth.type != SHeader.SHT_STRTAB) return null;
+
+ byte[] strtab = new byte[sth.size];
+ DataInputStream dis = new DataInputStream(sth.getInputStream());
+ dis.readFully(strtab);
+ dis.close();
+
+ return _symtab = new Symtab(sh.getInputStream(),sh.size,strtab);
+ }
+
+ public class Symtab {
+ public Symbol[] symbols;
+
+ Symtab(InputStream is, int size, byte[] strtab) throws IOException {
+ DataInputStream dis = new DataInputStream(is);
+ int count = size/16;
+ symbols = new Symbol[count];
+ for(int i=0;i<count;i++) symbols[i] = new Symbol(dis,strtab);
+ dis.close();
+ }
+ }
+
+ public class Symbol {
+ public String name;
+ public int addr;
+ public int size;
+ public byte info;
+ public byte type;
+ public byte other;
+ public SHeader sheader;
+
+ public final static int STT_FUNC = 2;
+
+ Symbol(DataInputStream dis, byte[] strtab) throws IOException {
+ name = getString(dis.readInt(),strtab);
+ addr = dis.readInt();
+ size = dis.readInt();
+ info = dis.readByte();
+ type = (byte)(info&0xf);
+ other = dis.readByte();
+ // FIXME: Find sheader entry
+ dis.readShort();
+ }
+ }
+