src/jdk.aot/share/classes/jdk.tools.jaotc.binformat/src/jdk/tools/jaotc/binformat/macho/MachOSection.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/macho/MachOSection.java

src/jdk.aot/share/classes/jdk.tools.jaotc.binformat/src/jdk/tools/jaotc/binformat/macho/MachOSection.java

Print this page

        

*** 22,115 **** */ package jdk.tools.jaotc.binformat.macho; import java.nio.ByteBuffer; - import java.nio.ByteOrder; - import jdk.tools.jaotc.binformat.macho.MachO; import jdk.tools.jaotc.binformat.macho.MachO.section_64; import jdk.tools.jaotc.binformat.macho.MachOByteBuffer; ! public class MachOSection { ! ByteBuffer section; ! byte [] data; ! boolean hasrelocations; ! public MachOSection(String sectName, String segName, byte [] sectData, int sectFlags, boolean hasRelocations, int align) { section = MachOByteBuffer.allocate(section_64.totalsize); // TODO: Hotspot uses long section names. // They are getting truncated. // Is this a problem?? byte[] sectNameBytes = sectName.getBytes(); ! int sectNameMax = section_64.sectname.sz < sectNameBytes.length ? ! section_64.sectname.sz : sectNameBytes.length; ! ! for (int i = 0; i < sectNameMax; i++) ! section.put(section_64.sectname.off+i, sectNameBytes[i]); byte[] segNameBytes = segName.getBytes(); ! int segNameMax = section_64.segname.sz < segNameBytes.length ? ! section_64.segname.sz : segNameBytes.length; ! ! for (int i = 0; i < segNameMax; i++) ! section.put(section_64.segname.off+i, segNameBytes[i]); section.putLong(section_64.size.off, sectData.length); ! section.putInt(section_64.align.off, ! 31 - Integer.numberOfLeadingZeros(align)); section.putInt(section_64.flags.off, sectFlags); data = sectData; hasrelocations = hasRelocations; } ! public long getSize() { return section.getLong(section_64.size.off); } ! public int getAlign() { return (1 << section.getInt(section_64.align.off)); } ! public byte[] getArray() { return section.array(); } ! public byte[] getDataArray() { return data; } ! public void setAddr(long addr) { section.putLong(section_64.addr.off, addr); } ! public long getAddr() { return (section.getLong(section_64.addr.off)); } ! public void setOffset(int offset) { section.putInt(section_64.offset.off, offset); } ! public int getOffset() { return (section.getInt(section_64.offset.off)); } ! public void setReloff(int offset) { section.putInt(section_64.reloff.off, offset); } ! public void setRelcount(int count) { section.putInt(section_64.nreloc.off, count); } ! public boolean hasRelocations() { return hasrelocations; } } - - --- 22,108 ---- */ package jdk.tools.jaotc.binformat.macho; import java.nio.ByteBuffer; import jdk.tools.jaotc.binformat.macho.MachO.section_64; import jdk.tools.jaotc.binformat.macho.MachOByteBuffer; ! final class MachOSection { ! private final ByteBuffer section; ! private final byte[] data; ! private final boolean hasrelocations; ! MachOSection(String sectName, String segName, byte[] sectData, int sectFlags, boolean hasRelocations, int align) { section = MachOByteBuffer.allocate(section_64.totalsize); // TODO: Hotspot uses long section names. // They are getting truncated. // Is this a problem?? byte[] sectNameBytes = sectName.getBytes(); ! int sectNameMax = section_64.sectname.sz < sectNameBytes.length ? section_64.sectname.sz : sectNameBytes.length; + for (int i = 0; i < sectNameMax; i++) { + section.put(section_64.sectname.off + i, sectNameBytes[i]); + } byte[] segNameBytes = segName.getBytes(); ! int segNameMax = section_64.segname.sz < segNameBytes.length ? section_64.segname.sz : segNameBytes.length; + for (int i = 0; i < segNameMax; i++) { + section.put(section_64.segname.off + i, segNameBytes[i]); + } section.putLong(section_64.size.off, sectData.length); ! section.putInt(section_64.align.off, 31 - Integer.numberOfLeadingZeros(align)); section.putInt(section_64.flags.off, sectFlags); data = sectData; hasrelocations = hasRelocations; } ! long getSize() { return section.getLong(section_64.size.off); } ! int getAlign() { return (1 << section.getInt(section_64.align.off)); } ! byte[] getArray() { return section.array(); } ! byte[] getDataArray() { return data; } ! void setAddr(long addr) { section.putLong(section_64.addr.off, addr); } ! long getAddr() { return (section.getLong(section_64.addr.off)); } ! void setOffset(int offset) { section.putInt(section_64.offset.off, offset); } ! int getOffset() { return (section.getInt(section_64.offset.off)); } ! void setReloff(int offset) { section.putInt(section_64.reloff.off, offset); } ! void setRelcount(int count) { section.putInt(section_64.nreloc.off, count); } ! boolean hasRelocations() { return hasrelocations; } }
src/jdk.aot/share/classes/jdk.tools.jaotc.binformat/src/jdk/tools/jaotc/binformat/macho/MachOSection.java
Index Unified diffs Context diffs Sdiffs Frames Patch New Old Previous File Next File