< prev index next >

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

Print this page
rev 49736 : 8185505: AArch64: Port AOT to AArch64
Reviewed-by: duke
   1 /*
   2  * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   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  */


 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      *


   1 /*
   2  * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   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  */


 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 >