All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.fornwall.jelf.ElfSymbolStructure Maven / Gradle / Ivy

There is a newer version: 0.9.8
Show newest version
package net.fornwall.jelf;

import java.io.IOException;

public class ElfSymbolStructure implements SymbolLocator {

    private final ElfParser parser;
    private final long offset;
    private final int entrySize;
    private final MemoizedObject stringTable;
    private final MemoizedObject hashTable;

    ElfSymbolStructure(final ElfParser parser, long offset, int entrySize, MemoizedObject stringTable, MemoizedObject hashTable) {
        this.parser = parser;
        this.offset = offset;
        this.entrySize = entrySize;
        this.stringTable = stringTable;
        this.hashTable = hashTable;
    }

    /** Returns the symbol at the specified index. The ELF symbol at index 0 is the undefined symbol. */
    @Override
    public ElfSymbol getELFSymbol(int index) throws IOException {
        return new ElfSymbol(parser, offset + index * entrySize, -1).setStringTable(stringTable.getValue());
    }

    @Override
    public ElfSymbol getELFSymbolByName(String name) throws IOException {
        if (hashTable == null) {
            return null;
        }
        return hashTable.getValue().getSymbol(this, name);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy