From 6ec5680cf50653ffd980eaee8bfb9e22b26d0ba0 Mon Sep 17 00:00:00 2001 From: Elliot Saba Date: Tue, 7 May 2024 17:30:47 -0700 Subject: [PATCH] Improve type stability of `rpaths(RPath(oh::ELFHandle))` Previously, we'd get `Vector{Any}`, but we actually want `Vector{AbstractString}`. --- src/ELF/ELFDynamicLink.jl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ELF/ELFDynamicLink.jl b/src/ELF/ELFDynamicLink.jl index f06ef4f..fc43ca9 100644 --- a/src/ELF/ELFDynamicLink.jl +++ b/src/ELF/ELFDynamicLink.jl @@ -89,7 +89,7 @@ Stores the RPath entries from an ELF object """ struct ELFRPath{H <: ELFHandle} <: RPath{H} section_ref::SectionRef{H} - rpath::Vector + rpath::Vector{<:AbstractString} end """ @@ -106,8 +106,13 @@ function RPath(oh::ELFHandle) des = ELFDynEntries(oh, [DT_RPATH, DT_RUNPATH]) # Lookup each and every one of those strings, split them out into paths - colon_paths = [strtab_lookup(d) for d in des] - paths = vcat([split(p, ":") for p in colon_paths]...) + colon_paths = String[strtab_lookup(d) for d in des] + paths = AbstractString[] + for colon_path in colon_paths + for component in split(colon_path, ':') + push!(paths, component) + end + end # Return our RPath object return ELFRPath(dyn_section, paths) @@ -115,4 +120,4 @@ end Section(rpath::ELFRPath) = rpath.section_ref handle(rpath::ELFRPath) = handle(Section(rpath)) -rpaths(rpath::ELFRPath) = rpath.rpath \ No newline at end of file +rpaths(rpath::ELFRPath) = rpath.rpath