src/jdk.aot/share/classes/jdk.tools.jaotc.binformat/src/jdk/tools/jaotc/binformat/pecoff/PECoffSymtab.java
Index Unified diffs Context diffs Sdiffs Frames Patch New Old Previous File Next File hotspot Cdiff src/jdk.aot/share/classes/jdk.tools.jaotc.binformat/src/jdk/tools/jaotc/binformat/pecoff/PECoffSymtab.java

src/jdk.aot/share/classes/jdk.tools.jaotc.binformat/src/jdk/tools/jaotc/binformat/pecoff/PECoffSymtab.java

Print this page

        

*** 25,64 **** import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.ArrayList; - import jdk.tools.jaotc.binformat.pecoff.PECoff; import jdk.tools.jaotc.binformat.pecoff.PECoff.IMAGE_SYMBOL; import jdk.tools.jaotc.binformat.pecoff.PECoffSymbol; import jdk.tools.jaotc.binformat.pecoff.PECoffByteBuffer; ! public class PECoffSymtab { ! ArrayList<PECoffSymbol>symbols = new ArrayList<PECoffSymbol>(); /** * number of symbols added */ ! int symbolCount; /** * String holding symbol table strings */ ! private StringBuilder strTabContent; /** ! * Keeps track of bytes in string table since strTabContent.length() ! * is number of chars, not bytes. */ private int strTabNrOfBytes; /** * String holding Linker Directives */ ! private StringBuilder directives; ! public PECoffSymtab() { symbolCount = 0; strTabContent = new StringBuilder(); directives = new StringBuilder(); // The first 4 bytes of the string table contain --- 25,63 ---- import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.ArrayList; import jdk.tools.jaotc.binformat.pecoff.PECoff.IMAGE_SYMBOL; import jdk.tools.jaotc.binformat.pecoff.PECoffSymbol; import jdk.tools.jaotc.binformat.pecoff.PECoffByteBuffer; ! final class PECoffSymtab { ! ArrayList<PECoffSymbol> symbols = new ArrayList<>(); /** * number of symbols added */ ! private int symbolCount; /** * String holding symbol table strings */ ! private final StringBuilder strTabContent; /** ! * Keeps track of bytes in string table since strTabContent.length() is number of chars, not ! * bytes. */ private int strTabNrOfBytes; /** * String holding Linker Directives */ ! private final StringBuilder directives; ! PECoffSymtab() { symbolCount = 0; strTabContent = new StringBuilder(); directives = new StringBuilder(); // The first 4 bytes of the string table contain
*** 70,90 **** // Linker Directives start with 3 spaces to signify ANSI directives.append(" "); } ! public PECoffSymbol addSymbolEntry(String name, byte type, byte storageclass, ! byte secHdrIndex, long offset, long size) { // Get the current symbol index and append symbol name to string table. int index; PECoffSymbol sym; if (name.isEmpty()) { index = 0; strTabContent.append('\0'); strTabNrOfBytes += 1; ! sym = new PECoffSymbol(symbolCount, index, type, storageclass, secHdrIndex, offset, size); symbols.add(sym); } else { int nameSize = name.getBytes().length; // We can't trust strTabContent.length() since that is --- 69,88 ---- // Linker Directives start with 3 spaces to signify ANSI directives.append(" "); } ! PECoffSymbol addSymbolEntry(String name, byte type, byte storageclass, byte secHdrIndex, long offset) { // Get the current symbol index and append symbol name to string table. int index; PECoffSymbol sym; if (name.isEmpty()) { index = 0; strTabContent.append('\0'); strTabNrOfBytes += 1; ! sym = new PECoffSymbol(symbolCount, index, type, storageclass, secHdrIndex, offset); symbols.add(sym); } else { int nameSize = name.getBytes().length; // We can't trust strTabContent.length() since that is
*** 92,151 **** index = strTabNrOfBytes; // strTabContent.append('_').append(name).append('\0'); strTabContent.append(name).append('\0'); strTabNrOfBytes += (nameSize + 1); ! sym = new PECoffSymbol(symbolCount, index, type, storageclass, secHdrIndex, offset, size); symbols.add(sym); ! if (storageclass == IMAGE_SYMBOL.IMAGE_SYM_CLASS_EXTERNAL) addDirective(name, type); } symbolCount++; return (sym); } private void addDirective(String name, byte type) { directives.append("/EXPORT:" + name); ! if(type != IMAGE_SYMBOL.IMAGE_SYM_DTYPE_FUNCTION) { directives.append(",DATA"); } directives.append(" "); } ! public int getSymtabCount() { return symbolCount; } ! public int getStrtabSize() { return strTabNrOfBytes; } // Return a byte array that contains the symbol table entries ! public byte[] getSymtabArray() { ! ByteBuffer symtabData = PECoffByteBuffer.allocate(symbolCount*IMAGE_SYMBOL.totalsize); symtabData.order(ByteOrder.LITTLE_ENDIAN); // copy all symbols ! for (int i = 0; i < symbolCount; i++ ) { PECoffSymbol sym = symbols.get(i); ! byte [] arr = sym.getArray(); symtabData.put(arr); } return (symtabData.array()); } // Return the string table array ! public byte[] getStrtabArray() { ! byte [] strs = strTabContent.toString().getBytes(); // Update the size of the string table ByteBuffer buff = ByteBuffer.wrap(strs); buff.order(ByteOrder.LITTLE_ENDIAN); buff.putInt(0, strTabNrOfBytes); return (strs); } ! public byte[] getDirectiveArray() { return (directives.toString().getBytes()); } } --- 90,150 ---- index = strTabNrOfBytes; // strTabContent.append('_').append(name).append('\0'); strTabContent.append(name).append('\0'); strTabNrOfBytes += (nameSize + 1); ! sym = new PECoffSymbol(symbolCount, index, type, storageclass, secHdrIndex, offset); symbols.add(sym); ! if (storageclass == IMAGE_SYMBOL.IMAGE_SYM_CLASS_EXTERNAL) { addDirective(name, type); } + } symbolCount++; return (sym); } private void addDirective(String name, byte type) { directives.append("/EXPORT:" + name); ! if (type != IMAGE_SYMBOL.IMAGE_SYM_DTYPE_FUNCTION) { directives.append(",DATA"); } directives.append(" "); } ! int getSymtabCount() { return symbolCount; } ! int getStrtabSize() { return strTabNrOfBytes; } // Return a byte array that contains the symbol table entries ! byte[] getSymtabArray() { ! ByteBuffer symtabData = PECoffByteBuffer.allocate(symbolCount * IMAGE_SYMBOL.totalsize); symtabData.order(ByteOrder.LITTLE_ENDIAN); // copy all symbols ! for (int i = 0; i < symbolCount; i++) { PECoffSymbol sym = symbols.get(i); ! byte[] arr = sym.getArray(); symtabData.put(arr); } return (symtabData.array()); } // Return the string table array ! byte[] getStrtabArray() { ! byte[] strs = strTabContent.toString().getBytes(); // Update the size of the string table ByteBuffer buff = ByteBuffer.wrap(strs); buff.order(ByteOrder.LITTLE_ENDIAN); buff.putInt(0, strTabNrOfBytes); return (strs); } ! byte[] getDirectiveArray() { return (directives.toString().getBytes()); } }
src/jdk.aot/share/classes/jdk.tools.jaotc.binformat/src/jdk/tools/jaotc/binformat/pecoff/PECoffSymtab.java
Index Unified diffs Context diffs Sdiffs Frames Patch New Old Previous File Next File