< prev index next >

src/jdk.aot/share/classes/jdk.tools.jaotc.binformat/src/jdk/tools/jaotc/binformat/BinaryContainer.java

Print this page




 509         Symbol gotSymbol = extLinkageGOTContainer.createGotSymbol(s);
 510         extLinkageGOTContainer.createSymbol(gotSymbol.getOffset(), Kind.OBJECT, Binding.GLOBAL, 8, name);
 511     }
 512 
 513     /**
 514      * Create a platform-specific binary file representing the content of the
 515      * {@code BinaryContainer} object.
 516      *
 517      * This method is called after creating and performing any necessary changes to the contents of
 518      * code stream, symbol tables and relocation tables is completely finalized
 519      *
 520      * @param outputFileName name of output file
 521      *
 522      * @throws IOException in case of file creation failure
 523      */
 524     public void createBinary(String outputFileName) throws IOException {
 525         String osName = System.getProperty("os.name");
 526         switch (osName) {
 527             case "Linux":
 528             case "SunOS":
 529                 JELFRelocObject elfobj = new JELFRelocObject(this, outputFileName);
 530                 elfobj.createELFRelocObject(relocationTable, symbolTable.values());
 531                 break;
 532             case "Mac OS X":
 533                 JMachORelocObject machobj = new JMachORelocObject(this, outputFileName);
 534                 machobj.createMachORelocObject(relocationTable, symbolTable.values());
 535                 break;
 536             default:
 537                 if (osName.startsWith("Windows")) {
 538                     JPECoffRelocObject pecoffobj = new JPECoffRelocObject(this, outputFileName);
 539                     pecoffobj.createPECoffRelocObject(relocationTable, symbolTable.values());
 540                     break;
 541                 } else
 542                     throw new InternalError("Unsupported platform: " + osName);
 543         }
 544     }
 545 
 546     /**
 547      * Add symbol to the symbol table. If the existing symbol is undefined and the specified symbol
 548      * is not undefined, replace the existing symbol information with that specified.
 549      *


 557             throw new InternalError("Symbol: " + symInfo.getName() + " already exists in SymbolTable");
 558         } else {
 559             // System.out.println("# Symbol [" + name + "] [" + symInfo.getValue() + "] [" +
 560             // symInfo.getSection().getContainerName() + "] [" + symInfo.getSize() + "]");
 561             symbolTable.put(symInfo.getName(), symInfo);
 562         }
 563     }
 564 
 565     public boolean addStringOffset(String name, Integer offset) {
 566         offsetStringTable.put(name, offset);
 567         return true;
 568     }
 569 
 570     /**
 571      * Add relocation entry for {@code symName}. Multiple relocation entries for a given symbol may
 572      * exist.
 573      *
 574      * @param info relocation information to be added
 575      */
 576     public void addRelocation(Relocation info) {
 577         // System.out.println("# Relocation [" + symName + "] [" + info.getOffset() + "] [" +
 578         // info.getSection().getContainerName() + "] [" + info.getSymbol().getName() + "] [" +
 579         // info.getSymbol().getOffset() + " @ " + info.getSymbol().getSection().getContainerName() +
 580         // "]");
 581         if (relocationTable.containsKey(info.getSymbol())) {
 582             relocationTable.get(info.getSymbol()).add(info);
 583         } else if (uniqueRelocationTable.containsKey(info.getSymbol())) {
 584             // promote
 585             ArrayList<Relocation> list = new ArrayList<>(2);
 586             list.add(uniqueRelocationTable.get(info.getSymbol()));
 587             list.add(info);
 588             relocationTable.put(info.getSymbol(), list);
 589             uniqueRelocationTable.remove(info.getSymbol());
 590         } else {
 591             uniqueRelocationTable.put(info.getSymbol(), info);
 592         }
 593     }
 594 
 595     /**
 596      * Get symbol with name {@code symName}.
 597      *




 509         Symbol gotSymbol = extLinkageGOTContainer.createGotSymbol(s);
 510         extLinkageGOTContainer.createSymbol(gotSymbol.getOffset(), Kind.OBJECT, Binding.GLOBAL, 8, name);
 511     }
 512 
 513     /**
 514      * Create a platform-specific binary file representing the content of the
 515      * {@code BinaryContainer} object.
 516      *
 517      * This method is called after creating and performing any necessary changes to the contents of
 518      * code stream, symbol tables and relocation tables is completely finalized
 519      *
 520      * @param outputFileName name of output file
 521      *
 522      * @throws IOException in case of file creation failure
 523      */
 524     public void createBinary(String outputFileName) throws IOException {
 525         String osName = System.getProperty("os.name");
 526         switch (osName) {
 527             case "Linux":
 528             case "SunOS":
 529                 JELFRelocObject elfobj = JELFRelocObject.newInstance(this, outputFileName);
 530                 elfobj.createELFRelocObject(relocationTable, symbolTable.values());
 531                 break;
 532             case "Mac OS X":
 533                 JMachORelocObject machobj = new JMachORelocObject(this, outputFileName);
 534                 machobj.createMachORelocObject(relocationTable, symbolTable.values());
 535                 break;
 536             default:
 537                 if (osName.startsWith("Windows")) {
 538                     JPECoffRelocObject pecoffobj = new JPECoffRelocObject(this, outputFileName);
 539                     pecoffobj.createPECoffRelocObject(relocationTable, symbolTable.values());
 540                     break;
 541                 } else
 542                     throw new InternalError("Unsupported platform: " + osName);
 543         }
 544     }
 545 
 546     /**
 547      * Add symbol to the symbol table. If the existing symbol is undefined and the specified symbol
 548      * is not undefined, replace the existing symbol information with that specified.
 549      *


 557             throw new InternalError("Symbol: " + symInfo.getName() + " already exists in SymbolTable");
 558         } else {
 559             // System.out.println("# Symbol [" + name + "] [" + symInfo.getValue() + "] [" +
 560             // symInfo.getSection().getContainerName() + "] [" + symInfo.getSize() + "]");
 561             symbolTable.put(symInfo.getName(), symInfo);
 562         }
 563     }
 564 
 565     public boolean addStringOffset(String name, Integer offset) {
 566         offsetStringTable.put(name, offset);
 567         return true;
 568     }
 569 
 570     /**
 571      * Add relocation entry for {@code symName}. Multiple relocation entries for a given symbol may
 572      * exist.
 573      *
 574      * @param info relocation information to be added
 575      */
 576     public void addRelocation(Relocation info) {
 577         // System.out.println("# Relocation [" + info.getSymbol() + "] [" + info.getOffset() + "] [" +
 578         // info.getSection().getContainerName() + "] [" + info.getSymbol().getName() + "] [" +
 579         // info.getSymbol().getOffset() + " @ " + info.getSymbol().getSection().getContainerName() +
 580         // "]");
 581         if (relocationTable.containsKey(info.getSymbol())) {
 582             relocationTable.get(info.getSymbol()).add(info);
 583         } else if (uniqueRelocationTable.containsKey(info.getSymbol())) {
 584             // promote
 585             ArrayList<Relocation> list = new ArrayList<>(2);
 586             list.add(uniqueRelocationTable.get(info.getSymbol()));
 587             list.add(info);
 588             relocationTable.put(info.getSymbol(), list);
 589             uniqueRelocationTable.remove(info.getSymbol());
 590         } else {
 591             uniqueRelocationTable.put(info.getSymbol(), info);
 592         }
 593     }
 594 
 595     /**
 596      * Get symbol with name {@code symName}.
 597      *


< prev index next >