src/jdk.aot/share/classes/jdk.tools.jaotc.binformat/src/jdk/tools/jaotc/binformat/elf/ElfSymtab.java
Index
Unified diffs
Context diffs
Sdiffs
Frames
Patch
New
Old
Previous File
Next File
*** old/src/jdk.aot/share/classes/jdk.tools.jaotc.binformat/src/jdk/tools/jaotc/binformat/elf/ElfSymtab.java Tue Aug 22 11:46:27 2017
--- new/src/jdk.aot/share/classes/jdk.tools.jaotc.binformat/src/jdk/tools/jaotc/binformat/elf/ElfSymtab.java Tue Aug 22 11:46:27 2017
*** 22,66 ****
--- 22,63 ----
*/
package jdk.tools.jaotc.binformat.elf;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
import jdk.tools.jaotc.binformat.elf.Elf;
import jdk.tools.jaotc.binformat.elf.Elf.Elf64_Sym;
import jdk.tools.jaotc.binformat.elf.ElfSymbol;
import jdk.tools.jaotc.binformat.elf.ElfByteBuffer;
! public class ElfSymtab {
! final class ElfSymtab {
! ArrayList<ElfSymbol>localSymbols = new ArrayList<ElfSymbol>();
! ArrayList<ElfSymbol>globalSymbols = new ArrayList<ElfSymbol>();
! private final ArrayList<ElfSymbol> localSymbols = new ArrayList<>();
! private final ArrayList<ElfSymbol> globalSymbols = new ArrayList<>();
/**
* number of symbols added
*/
! private int symbolCount;
/**
* String holding symbol table strings
*/
! private final StringBuilder strTabContent = new StringBuilder();
/**
! * Keeps track of bytes in string table since strTabContent.length() is number of chars, not
- * is number of chars, not bytes.
*/
private int strTabNrOfBytes = 0;
- public ElfSymtab() {
symbolCount = 0;
}
public ElfSymbol addSymbolEntry(String name, byte type, byte bind,
byte secHdrIndex, long offset, long size) {
+ ElfSymbol addSymbolEntry(String name, byte type, byte bind, byte secHdrIndex, long offset, long size) {
// Get the current symbol index and append symbol name to string table.
int index;
ElfSymbol sym;
if (name.isEmpty()) {
*** 74,84 ****
--- 71,81 ----
// chars (UTF16), keep track of bytes on our own.
index = strTabNrOfBytes;
// strTabContent.append("_").append(name).append('\0');
strTabContent.append(name).append('\0');
// + 1 for null, + 1 for "_"
! // strTabNrOfBytes += (name.getBytes().length + 1 + 1);
strTabNrOfBytes += (name.getBytes().length + 1);
sym = new ElfSymbol(symbolCount, index, type, bind, secHdrIndex, offset, size);
if ((bind & Elf64_Sym.STB_GLOBAL) != 0)
globalSymbols.add(sym);
*** 90,147 ****
--- 87,145 ----
}
// Update the symbol indexes once all symbols have been added.
// This is required since we'll be reordering the symbols in the
// file to be in the order of Local then global.
- public void updateIndexes() {
int index = 0;
// Update the local symbol indexes
- for (int i = 0; i < localSymbols.size(); i++ ) {
ElfSymbol sym = localSymbols.get(i);
sym.setIndex(index++);
}
// Update the global symbol indexes
- for (int i = 0; i < globalSymbols.size(); i++ ) {
ElfSymbol sym = globalSymbols.get(i);
sym.setIndex(index++);
}
}
public int getNumLocalSyms() { return localSymbols.size(); }
public int getNumGlobalSyms() { return globalSymbols.size(); }
+ int getNumLocalSyms() {
+ return localSymbols.size();
+ }
+ int getNumGlobalSyms() {
+ return globalSymbols.size();
+ }
// Create a single byte array that contains the symbol table entries
- public byte[] getSymtabArray() {
! int index = 0;
! ByteBuffer symtabData = ElfByteBuffer.allocate(symbolCount*Elf64_Sym.totalsize);
byte [] retarray;
! ByteBuffer symtabData = ElfByteBuffer.allocate(symbolCount * Elf64_Sym.totalsize);
! byte[] retarray;
updateIndexes();
// Add the local symbols
- for (int i = 0; i < localSymbols.size(); i++ ) {
ElfSymbol sym = localSymbols.get(i);
- byte [] arr = sym.getArray();
symtabData.put(arr);
}
// Add the global symbols
- for (int i = 0; i < globalSymbols.size(); i++ ) {
ElfSymbol sym = globalSymbols.get(i);
- byte [] arr = sym.getArray();
symtabData.put(arr);
}
retarray = symtabData.array();
return (retarray);
}
// Return the string table array
- public byte[] getStrtabArray() {
- byte [] strs = strTabContent.toString().getBytes();
return (strs);
}
}
src/jdk.aot/share/classes/jdk.tools.jaotc.binformat/src/jdk/tools/jaotc/binformat/elf/ElfSymtab.java
Index
Unified diffs
Context diffs
Sdiffs
Frames
Patch
New
Old
Previous File
Next File