Permalink
Browse files

part II of porting matching .o and .dll symbols to Windows

git-svn-id: https://svn.r-project.org/R/trunk@58505 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information...
ripley
ripley committed Feb 27, 2012
1 parent f25d3f7 commit 30939a094ca3d164a8d8c677c99999374cc60b9f
Showing with 32 additions and 8 deletions.
  1. +2 −0 share/make/shlib.mk
  2. +5 −0 share/make/winshlib.mk
  3. +25 −8 src/library/tools/R/sotools.R
View
@@ -14,6 +14,8 @@ shlib-clean:
@rm -rf .libs _libs
@rm -f $(OBJECTS)
+
+## FIXME: why not Rscript?
symbols.rds: $(OBJECTS)
@$(ECHO) "tools:::.shlib_objects_symbol_tables()" | \
$(R_HOME)/bin/R --vanilla --slave --args $(OBJECTS)
View
@@ -24,3 +24,8 @@ $(SHLIB): $(OBJECTS)
.PHONY: all shlib-clean
shlib-clean:
@rm -f $(OBJECTS)
+
+## FIXME: why not Rscript?
+symbols.rds: $(OBJECTS)
+ @$(ECHO) "tools:::.shlib_objects_symbol_tables()" | \
+ $(R_HOME)/bin$(R_ARCH)/Rterm.exe --vanilla --slave --args $(OBJECTS)
@@ -1,13 +1,8 @@
if(.Platform$OS.type == "windows") {
read_symbols_from_dll <- function(f, rarch)
{
- ## FIXME: should be able to use multilib objdump now
- ff <- file.path(R.home("etc"), rarch, "Makeconf")
- if(!file.exists(ff)) return()
- etc <- readLines(ff)
- bp <- grep("^BINPREF", etc, value = TRUE)
- bp <- sub("^BINPREF = +", "", bp)
- DLL_nm <- paste0(bp, "objdump.exe")
+ ## reasonable to assume this in the path
+ DLL_nm <- "objdump.exe"
if(!nzchar(Sys.which(DLL_nm))) return()
f <- file_path_as_absolute(f)
s0 <- suppressWarnings(system2(DLL_nm, c("-x", shQuote(f)),
@@ -21,6 +16,28 @@ if(.Platform$OS.type == "windows") {
s2 <- grep("\t[0-9a-f]+\t +[0-9]+", s1, value = TRUE)
sub(".* ([_A-Za-z0-9]+)$", "\\1", s2)
}
+ read_symbols_from_object_file <- function(f)
+ {
+ ## reasonable to assume this in the path
+ if(!nzchar(nm <- Sys.which("nm.exe"))) return()
+ f <- file_path_as_absolute(f)
+ if(!(file.info(f)$size)) return()
+ s <- strsplit(system(sprintf("%s -Pg %s", shQuote(nm), shQuote(f)),
+ intern = TRUE),
+ " +")
+ ## Cannot simply rbind() this because elements may have 2-4
+ ## entries.
+ n <- length(s)
+ tab <- matrix("", nrow = n, ncol = 4L)
+ colnames(tab) <- c("name", "type", "value", "size")
+ ## Compute desired i and j positions in tab.
+ i <- rep.int(seq_len(n), sapply(s, length))
+ j <- unlist(lapply(s, seq_along))
+
+ tab[n * (j - 1L) + i] <- unlist(s)
+
+ tab
+ }
} else {
read_symbols_from_object_file <- function(f)
{
@@ -118,7 +135,7 @@ so_symbol_names_table <-
"solaris, Fortran, solf95, stop, _f90_stop_char",
## Windows statically links libstdc++, libgfortran
- # "windows, C, gcc, abort, abort", # lots of false positives
+ "windows, C, gcc, abort, abort", # lots of false positives
"windows, C, gcc, assert, _assert",
"windows, C, gcc, exit, exit",
"windows, C, gcc, printf, printf",

0 comments on commit 30939a0

Please sign in to comment.