Skip to content

Commit

Permalink
[GR-23612] Support prefixing symbol names with a common prefix.
Browse files Browse the repository at this point in the history
PullRequest: graal/7085
  • Loading branch information
olpaw committed Sep 7, 2020
2 parents 7545141 + e223225 commit b431ff7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,9 @@ public static Predicate<String> makeFilter(String[] definedFilters) {
@Option(help = "Use linker option to remove all local symbols from image.")//
public static final HostedOptionKey<Boolean> DeleteLocalSymbols = new HostedOptionKey<>(true);

@Option(help = "Common prefix used by method symbols in image.")//
public static final HostedOptionKey<String> ImageSymbolsPrefix = new HostedOptionKey<>("");

@Option(help = "Fold SecurityManager getter.", stability = OptionStability.EXPERIMENTAL, type = OptionType.Expert) //
public static final HostedOptionKey<Boolean> FoldSecurityManagerGetter = new HostedOptionKey<>(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ public class NativeImageOptions {
@Option(help = "Directory for temporary files generated during native image generation. If this option is specified, the temporary files are not deleted so that you can inspect them after native image generation")//
public static final HostedOptionKey<String> TempDirectory = new HostedOptionKey<>("");

@Option(help = "Test Mach-O debuginfo generation")//
public static final HostedOptionKey<Boolean> MachODebugInfoTesting = new HostedOptionKey<>(false);

@Option(help = "Suppress console error output for unittests")//
public static final HostedOptionKey<Boolean> SuppressStderr = new HostedOptionKey<>(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
import com.oracle.objectfile.ObjectFile.Section;
import com.oracle.objectfile.SectionName;
import com.oracle.objectfile.debuginfo.DebugInfoProvider;
import com.oracle.objectfile.macho.MachOObjectFile;
import com.oracle.svm.core.FrameAccess;
import com.oracle.svm.core.Isolates;
import com.oracle.svm.core.SubstrateOptions;
Expand Down Expand Up @@ -140,12 +139,7 @@ public NativeBootImage(NativeImageKind k, HostedUniverse universe, HostedMetaAcc
uniqueEntryPoints.addAll(entryPoints);

int pageSize = NativeImageOptions.getPageSize();
if (NativeImageOptions.MachODebugInfoTesting.getValue()) {
objectFile = new MachOObjectFile(pageSize);
} else {
objectFile = ObjectFile.getNativeObjectFile(pageSize);
}

objectFile = ObjectFile.getNativeObjectFile(pageSize);
objectFile.setByteOrder(ConfigurationValues.getTarget().arch.getByteOrder());
wordSize = FrameAccess.wordSize();
assert objectFile.getWordSizeInBytes() == wordSize;
Expand Down Expand Up @@ -717,7 +711,7 @@ public static String localSymbolNameForMethod(java.lang.reflect.Method m) {
*/
public static String localSymbolNameForMethod(ResolvedJavaMethod sm) {
/* We don't mangle local symbols, because they never need be referenced by an assembler. */
return SubstrateUtil.uniqueShortName(sm);
return SubstrateOptions.ImageSymbolsPrefix.getValue() + SubstrateUtil.uniqueShortName(sm);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,30 +409,25 @@ public LinkerInvocation write(DebugContext debug, Path outputDirectory, Path tem
String commandLine = SubstrateUtil.getShellCommandString(cmd, false);
debug.log("Using CompilerCommand: %s", commandLine);

if (NativeImageOptions.MachODebugInfoTesting.getValue()) {
System.out.printf("Testing Mach-O debuginfo generation - SKIP %s%n", commandLine);
return inv;
} else {
ProcessBuilder pb = new ProcessBuilder().command(cmd);
pb.directory(tempDirectory.toFile());
pb.redirectErrorStream(true);
int status;
ByteArrayOutputStream output;
try {
Process p = pb.start();

output = new ByteArrayOutputStream();
FileUtils.drainInputStream(p.getInputStream(), output);
status = p.waitFor();
} catch (IOException | InterruptedException e) {
throw handleLinkerFailure(e.toString(), commandLine, null);
}
ProcessBuilder pb = new ProcessBuilder().command(cmd);
pb.directory(tempDirectory.toFile());
pb.redirectErrorStream(true);
int status;
ByteArrayOutputStream output;
try {
Process p = pb.start();

debug.log(DebugContext.VERBOSE_LEVEL, "%s", output);
output = new ByteArrayOutputStream();
FileUtils.drainInputStream(p.getInputStream(), output);
status = p.waitFor();
} catch (IOException | InterruptedException e) {
throw handleLinkerFailure(e.toString(), commandLine, null);
}

if (status != 0) {
throw handleLinkerFailure("Linker command exited with " + status, commandLine, output.toString());
}
debug.log(DebugContext.VERBOSE_LEVEL, "%s", output);

if (status != 0) {
throw handleLinkerFailure("Linker command exited with " + status, commandLine, output.toString());
}
}
return inv;
Expand Down

0 comments on commit b431ff7

Please sign in to comment.