Skip to content

Commit 37b20cb

Browse files
audit sysimage for relocatability
1 parent d9b09ee commit 37b20cb

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/PackageCompiler.jl

+27
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ function create_sysimage(packages::Union{Nothing, Symbol, Vector{String}, Vector
425425
soname=nothing,
426426
compat_level::String="major",
427427
extra_precompiles::String = "",
428+
audit_relocatability::Bool = true
428429
)
429430

430431
if filter_stdlibs && incremental
@@ -536,6 +537,13 @@ function create_sysimage(packages::Union{Nothing, Symbol, Vector{String}, Vector
536537
end
537538
end
538539

540+
if audit_relocatability
541+
@info "Auditing sysimage relocatability"
542+
if audit_sysimage_relocatability(sysimage_path)
543+
@info "No issues found"
544+
end
545+
end
546+
539547
return nothing
540548
end
541549

@@ -1156,4 +1164,23 @@ function bundle_headers(dest_dir, header_files)
11561164
return
11571165
end
11581166

1167+
function audit_sysimage_relocatability(sysimg_path::String; paths::Vector{String} = [homedir(), DEPOT_PATH...])
1168+
1169+
none_found = true
1170+
sysimg_contents = open(io -> String(read(io)), sysimg_path, read=true)
1171+
1172+
for path in paths
1173+
found = String[]
1174+
for m in eachmatch(Regex("$(path)[^\0]+"), sysimg_contents)
1175+
push!(found, "[$(m.offset)] $(m.match)")
1176+
end
1177+
if !isempty(found)
1178+
@warn "absolute path `$path` found in $(length(found)) places:" found
1179+
none_found = false
1180+
end
1181+
end
1182+
1183+
return none_found
1184+
end
1185+
11591186
end # module

0 commit comments

Comments
 (0)