7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 package jdk.tools.jaotc.binformat.pecoff; 25 26 import java.nio.ByteBuffer; 27 import java.nio.ByteOrder; 28 29 import jdk.tools.jaotc.binformat.NativeSymbol; 30 import jdk.tools.jaotc.binformat.pecoff.PECoff; 31 import jdk.tools.jaotc.binformat.pecoff.PECoff.IMAGE_SYMBOL; 32 import jdk.tools.jaotc.binformat.pecoff.PECoffByteBuffer; 33 34 public class PECoffSymbol extends NativeSymbol { 35 ByteBuffer sym; 36 37 public PECoffSymbol(int symbolindex, int strindex, byte type, byte storageclass, 38 byte sectindex, long offset, long size) { 39 super(symbolindex); 40 sym = PECoffByteBuffer.allocate(IMAGE_SYMBOL.totalsize); 41 42 // We don't use short names 43 sym.putInt(IMAGE_SYMBOL.Short.off, 0); 44 45 sym.putInt(IMAGE_SYMBOL.Long.off, strindex); 46 sym.putInt(IMAGE_SYMBOL.Value.off, (int)offset); 47 48 // Section indexes start at 1 but we manage the index internally 49 // as 0 relative except in this structure 50 sym.putChar(IMAGE_SYMBOL.SectionNumber.off, (char)(sectindex+1)); 51 52 sym.putChar(IMAGE_SYMBOL.Type.off, (char)type); 53 sym.put(IMAGE_SYMBOL.StorageClass.off, storageclass); 54 sym.put(IMAGE_SYMBOL.NumberOfAuxSymbols.off, (byte)0); 55 } 56 57 public byte[] getArray() { 58 return sym.array(); 59 } 60 } 61 | 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 package jdk.tools.jaotc.binformat.pecoff; 25 26 import java.nio.ByteBuffer; 27 28 import jdk.tools.jaotc.binformat.NativeSymbol; 29 import jdk.tools.jaotc.binformat.pecoff.PECoff.IMAGE_SYMBOL; 30 import jdk.tools.jaotc.binformat.pecoff.PECoffByteBuffer; 31 32 final class PECoffSymbol extends NativeSymbol { 33 private final ByteBuffer sym; 34 35 PECoffSymbol(int symbolindex, int strindex, byte type, byte storageclass, byte sectindex, long offset) { 36 super(symbolindex); 37 sym = PECoffByteBuffer.allocate(IMAGE_SYMBOL.totalsize); 38 39 // We don't use short names 40 sym.putInt(IMAGE_SYMBOL.Short.off, 0); 41 42 sym.putInt(IMAGE_SYMBOL.Long.off, strindex); 43 sym.putInt(IMAGE_SYMBOL.Value.off, (int) offset); 44 45 // Section indexes start at 1 but we manage the index internally 46 // as 0 relative except in this structure 47 sym.putChar(IMAGE_SYMBOL.SectionNumber.off, (char) (sectindex + 1)); 48 49 sym.putChar(IMAGE_SYMBOL.Type.off, (char) type); 50 sym.put(IMAGE_SYMBOL.StorageClass.off, storageclass); 51 sym.put(IMAGE_SYMBOL.NumberOfAuxSymbols.off, (byte) 0); 52 } 53 54 byte[] getArray() { 55 return sym.array(); 56 } 57 } |