< prev index next >

src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Linker.java

Print this page
rev 59383 : [mq]: final
   1 /*
   2  * Copyright (c) 2018, 2019, 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  */


  65         this.options = main.options;
  66         String name = options.outputName;
  67         objectFileName = name;
  68         libraryFileName = name;
  69 
  70         if (options.linkerpath != null && !(new File(options.linkerpath).exists())) {
  71             throw new InternalError("Invalid linker path: " + options.linkerpath);
  72         }
  73         String linkerPath;
  74         String linkerCheck;
  75 
  76         switch (options.osName) {
  77             case "Linux":
  78                 if (name.endsWith(".so")) {
  79                     objectFileName = name.substring(0, name.length() - ".so".length());
  80                 }
  81                 objectFileName = objectFileName + ".o";
  82                 linkerPath = (options.linkerpath != null) ? options.linkerpath : "ld";
  83                 linkerCmd = linkerPath + " -shared -z noexecstack -o " + libraryFileName + " " + objectFileName;
  84                 linkerCheck = linkerPath + " -v";
  85                 break;
  86             case "SunOS":
  87                 if (name.endsWith(".so")) {
  88                     objectFileName = name.substring(0, name.length() - ".so".length());
  89                 }
  90                 objectFileName = objectFileName + ".o";
  91                 linkerPath = (options.linkerpath != null) ? options.linkerpath : "ld";
  92                 linkerCmd = linkerPath + " -shared -o " + libraryFileName + " " + objectFileName;
  93                 linkerCheck = linkerPath + " -V";
  94                 break;
  95             case "Mac OS X":
  96                 if (name.endsWith(".dylib")) {
  97                     objectFileName = name.substring(0, name.length() - ".dylib".length());
  98                 }
  99                 objectFileName = objectFileName + ".o";
 100                 linkerPath = (options.linkerpath != null) ? options.linkerpath : "ld";
 101                 linkerCmd = linkerPath + " -dylib -o " + libraryFileName + " " + objectFileName;
 102                 linkerCheck = linkerPath + " -v";
 103                 break;
 104             default:
 105                 if (options.osName.startsWith("Windows")) {
 106                     if (name.endsWith(".dll")) {
 107                         objectFileName = name.substring(0, name.length() - ".dll".length());
 108                     }
 109                     objectFileName = objectFileName + ".obj";
 110                     linkerPath = (options.linkerpath != null) ? options.linkerpath : getWindowsLinkPath();
 111                     if (linkerPath == null) {
 112                         throw new InternalError("Can't locate Microsoft Visual Studio amd64 link.exe");
 113                     }


   1 /*
   2  * Copyright (c) 2018, 2020, 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  */


  65         this.options = main.options;
  66         String name = options.outputName;
  67         objectFileName = name;
  68         libraryFileName = name;
  69 
  70         if (options.linkerpath != null && !(new File(options.linkerpath).exists())) {
  71             throw new InternalError("Invalid linker path: " + options.linkerpath);
  72         }
  73         String linkerPath;
  74         String linkerCheck;
  75 
  76         switch (options.osName) {
  77             case "Linux":
  78                 if (name.endsWith(".so")) {
  79                     objectFileName = name.substring(0, name.length() - ".so".length());
  80                 }
  81                 objectFileName = objectFileName + ".o";
  82                 linkerPath = (options.linkerpath != null) ? options.linkerpath : "ld";
  83                 linkerCmd = linkerPath + " -shared -z noexecstack -o " + libraryFileName + " " + objectFileName;
  84                 linkerCheck = linkerPath + " -v";









  85                 break;
  86             case "Mac OS X":
  87                 if (name.endsWith(".dylib")) {
  88                     objectFileName = name.substring(0, name.length() - ".dylib".length());
  89                 }
  90                 objectFileName = objectFileName + ".o";
  91                 linkerPath = (options.linkerpath != null) ? options.linkerpath : "ld";
  92                 linkerCmd = linkerPath + " -dylib -o " + libraryFileName + " " + objectFileName;
  93                 linkerCheck = linkerPath + " -v";
  94                 break;
  95             default:
  96                 if (options.osName.startsWith("Windows")) {
  97                     if (name.endsWith(".dll")) {
  98                         objectFileName = name.substring(0, name.length() - ".dll".length());
  99                     }
 100                     objectFileName = objectFileName + ".obj";
 101                     linkerPath = (options.linkerpath != null) ? options.linkerpath : getWindowsLinkPath();
 102                     if (linkerPath == null) {
 103                         throw new InternalError("Can't locate Microsoft Visual Studio amd64 link.exe");
 104                     }


< prev index next >