Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/MachO/MachODynamicLink.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ struct MachODynamicLinks{H <: MachOHandle, C <: MachOLoadCmdRef{H,MachOLoadDylib
cmds::Vector{C}
end

function MachODynamicLinks(lcs::MachOLoadCmds)
ld_cmds = findall(lcs, [MachOLoadDylibCmd])
function MachODynamicLinks(lcs::MachOLoadCmds{H}) where {H <: MachOHandle}
ld_cmds = MachOLoadCmdRef{H,MachOLoadDylibCmd{H}}[c for c in findall(lcs, [MachOLoadDylibCmd])]
return MachODynamicLinks(handle(lcs), ld_cmds)
end
MachODynamicLinks(oh::MachOHandle) = MachODynamicLinks(MachOLoadCmds(oh))
Expand Down
5 changes: 5 additions & 0 deletions test/macobj/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
# Regenerates the Mach-O object fixture in this directory. Requires `clang`.
set -euo pipefail
cd "$(dirname "$0")"
echo 'int foo(void) { return 1; }' | clang --target=x86_64-apple-macos10.10 -O2 -c -x c -o foo.o -
Binary file added test/macobj/foo.o
Binary file not shown.
9 changes: 9 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,15 @@ test_fat_libfoo("./mac64/libfoo_fat64.dylib")
test_fat_libfoo(IOBuffer(read("./mac64/libfoo_fat64.dylib")))
test_metal("./macmetal/dummy")

@testset "MachO object without dylib dependencies" begin
oh = only(readmeta(open("./macobj/foo.o", "r")))
@test oh isa MachOHandle
@test isrelocatable(oh)
@test isempty(DynamicLinks(oh))
@test isempty(path.(DynamicLinks(oh)))
@test isempty(rpaths(RPath(oh)))
end

@testset "MachO minimum OS version" begin
# LC_VERSION_MIN_MACOSX
let oh = only(readmeta(open("./mac64/libfoo.dylib", "r")))
Expand Down
Loading