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

src/jdk.aot/share/classes/jdk.tools.jaotc.binformat/src/jdk/tools/jaotc/binformat/elf/ElfSection.java

Print this page

        

*** 22,65 **** */ package jdk.tools.jaotc.binformat.elf; import java.nio.ByteBuffer; - import java.nio.ByteOrder; - import jdk.tools.jaotc.binformat.elf.Elf; - import jdk.tools.jaotc.binformat.elf.Elf.Elf64_Ehdr; import jdk.tools.jaotc.binformat.elf.Elf.Elf64_Shdr; import jdk.tools.jaotc.binformat.elf.Elf.Elf64_Rel; import jdk.tools.jaotc.binformat.elf.Elf.Elf64_Rela; import jdk.tools.jaotc.binformat.elf.Elf.Elf64_Sym; import jdk.tools.jaotc.binformat.elf.ElfByteBuffer; ! public class ElfSection { ! String name; ! ByteBuffer section; ! byte [] data; ! boolean hasrelocations; ! int sectionIndex; /** * String holding section name strings */ ! private static StringBuilder sectNameTab = new StringBuilder(); /** ! * Keeps track of bytes in section string table since strTabContent.length() ! * is number of chars, not bytes. */ private static int shStrTabNrOfBytes = 0; ! public ElfSection(String sectName, byte [] sectData, int sectFlags, ! int sectType, boolean hasRelocations, int align, ! int sectIndex) { section = ElfByteBuffer.allocate(Elf64_Shdr.totalsize); ! // Return all 0's for NULL section if (sectIndex == 0) { sectNameTab.append('\0'); shStrTabNrOfBytes += 1; data = null; --- 22,61 ---- */ package jdk.tools.jaotc.binformat.elf; import java.nio.ByteBuffer; import jdk.tools.jaotc.binformat.elf.Elf.Elf64_Shdr; import jdk.tools.jaotc.binformat.elf.Elf.Elf64_Rel; import jdk.tools.jaotc.binformat.elf.Elf.Elf64_Rela; import jdk.tools.jaotc.binformat.elf.Elf.Elf64_Sym; import jdk.tools.jaotc.binformat.elf.ElfByteBuffer; ! final class ElfSection { ! private final String name; ! private final ByteBuffer section; ! private final byte[] data; ! private final boolean hasrelocations; ! private final int sectionIndex; /** * String holding section name strings */ ! private final static StringBuilder sectNameTab = new StringBuilder(); /** ! * Keeps track of bytes in section string table since strTabContent.length() is number of chars, ! * not bytes. */ private static int shStrTabNrOfBytes = 0; ! ElfSection(String sectName, byte[] sectData, int sectFlags, int sectType, ! boolean hasRelocations, int align, int sectIndex) { section = ElfByteBuffer.allocate(Elf64_Shdr.totalsize); ! name = sectName; // Return all 0's for NULL section if (sectIndex == 0) { sectNameTab.append('\0'); shStrTabNrOfBytes += 1; data = null;
*** 69,90 **** } section.putInt(Elf64_Shdr.sh_name.off, shStrTabNrOfBytes); sectNameTab.append(sectName).append('\0'); shStrTabNrOfBytes += (sectName.getBytes().length + 1); - name = sectName; section.putInt(Elf64_Shdr.sh_type.off, sectType); section.putLong(Elf64_Shdr.sh_flags.off, sectFlags); section.putLong(Elf64_Shdr.sh_addr.off, 0); section.putLong(Elf64_Shdr.sh_offset.off, 0); if (sectName.equals(".shstrtab")) { section.putLong(Elf64_Shdr.sh_size.off, shStrTabNrOfBytes); data = sectNameTab.toString().getBytes(); ! } ! else { data = sectData; section.putLong(Elf64_Shdr.sh_size.off, sectData.length); } section.putLong(Elf64_Shdr.sh_entsize.off, 0); --- 65,84 ---- } section.putInt(Elf64_Shdr.sh_name.off, shStrTabNrOfBytes); sectNameTab.append(sectName).append('\0'); shStrTabNrOfBytes += (sectName.getBytes().length + 1); section.putInt(Elf64_Shdr.sh_type.off, sectType); section.putLong(Elf64_Shdr.sh_flags.off, sectFlags); section.putLong(Elf64_Shdr.sh_addr.off, 0); section.putLong(Elf64_Shdr.sh_offset.off, 0); if (sectName.equals(".shstrtab")) { section.putLong(Elf64_Shdr.sh_size.off, shStrTabNrOfBytes); data = sectNameTab.toString().getBytes(); ! } else { data = sectData; section.putLong(Elf64_Shdr.sh_size.off, sectData.length); } section.putLong(Elf64_Shdr.sh_entsize.off, 0);
*** 108,164 **** hasrelocations = hasRelocations; sectionIndex = sectIndex; } ! public String getName() { return name; } ! public long getSize() { return section.getLong(Elf64_Shdr.sh_size.off); } ! public int getDataAlign() { ! return ((int)section.getLong(Elf64_Shdr.sh_addralign.off)); } // Alignment requirements for the Elf64_Shdr structures ! public static int getShdrAlign() { return (4); } ! public byte[] getArray() { return section.array(); } ! public byte[] getDataArray() { return data; } ! public void setOffset(long offset) { section.putLong(Elf64_Shdr.sh_offset.off, offset); } ! public void setLink(int link) { section.putInt(Elf64_Shdr.sh_link.off, link); } ! public void setInfo(int info) { section.putInt(Elf64_Shdr.sh_info.off, info); } ! public long getOffset() { return (section.getLong(Elf64_Shdr.sh_offset.off)); } ! public boolean hasRelocations() { return hasrelocations; } ! public int getSectionId() { return sectionIndex; } } - - --- 102,156 ---- hasrelocations = hasRelocations; sectionIndex = sectIndex; } ! String getName() { return name; } ! long getSize() { return section.getLong(Elf64_Shdr.sh_size.off); } ! int getDataAlign() { ! return ((int) section.getLong(Elf64_Shdr.sh_addralign.off)); } // Alignment requirements for the Elf64_Shdr structures ! static int getShdrAlign() { return (4); } ! byte[] getArray() { return section.array(); } ! byte[] getDataArray() { return data; } ! void setOffset(long offset) { section.putLong(Elf64_Shdr.sh_offset.off, offset); } ! void setLink(int link) { section.putInt(Elf64_Shdr.sh_link.off, link); } ! void setInfo(int info) { section.putInt(Elf64_Shdr.sh_info.off, info); } ! long getOffset() { return (section.getLong(Elf64_Shdr.sh_offset.off)); } ! boolean hasRelocations() { return hasrelocations; } ! int getSectionId() { return sectionIndex; } }
src/jdk.aot/share/classes/jdk.tools.jaotc.binformat/src/jdk/tools/jaotc/binformat/elf/ElfSection.java
Index Unified diffs Context diffs Sdiffs Frames Patch New Old Previous File Next File