Skip to content

Commit fec860e

Browse files
committed
Actually fix, possibly???
1 parent 61bf5a7 commit fec860e

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

src/auditor/dynamic_linkage.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ using ObjectFile.ELF
22

33
function os_from_elf_note(oh::ELFHandle)
44
for section in Sections(oh)
5-
section_handle(section) == ELF.SHT_NOTE || continue
5+
section_type(section) == ELF.SHT_NOTE || continue
66
seek(oh, section_offset(section))
77
name_length = read(oh, UInt32)
88
iszero(name_length) && continue

test/auditing.jl

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ end
846846
@testset "OS/ABI: $platform" for platform in [Platform("x86_64", "freebsd"),
847847
Platform("aarch64", "freebsd")]
848848
mktempdir() do build_path
849-
build_output_meta = @test_logs (:warn, r"libwrong.so has an ELF header OS/ABI value that is not set to FreeBSD") match_mode=:any begin
849+
build_output_meta = @test_logs (:warn, r"Skipping binary analysis of lib/lib(nonote|badosabi)\.so \(incorrect platform\)") match_mode=:any begin
850850
autobuild(
851851
build_path,
852852
"OSABI",
@@ -858,16 +858,20 @@ end
858858
apk update
859859
apk add binutils
860860
mkdir -p "${libdir}"
861-
echo 'int wrong() { return 0; }' | cc -shared -fPIC -o "${libdir}/libwrong.${dlext}" -x c -
862-
echo 'int right() { return 0; }' | cc -shared -fPIC -o "${libdir}/libright.${dlext}" -x c -
861+
cd "${libdir}"
862+
echo 'int wrong() { return 0; }' | cc -shared -fPIC -o "libwrong.${dlext}" -x c -
863+
echo 'int right() { return 0; }' | cc -shared -fPIC -o "libright.${dlext}" -x c -
864+
cp "libwrong.${dlext}" "libnonote.${dlext}"
865+
strip --remove-section=.note.tag "libnonote.${dlext}"
866+
mv "libwrong.${dlext}" "libbadosabi.${dlext}"
863867
# NetBSD runs anywhere, which implies that anything that runs is for NetBSD, right?
864-
elfedit --output-osabi=NetBSD "${libdir}/libwrong.${dlext}"
865-
strip --remove-section=.note.tag "${libdir}/libwrong.${dlext}"
868+
elfedit --output-osabi=NetBSD "libbadosabi.${dlext}"
866869
""",
867870
[platform],
868871
# Ensure our library product is built
869872
[
870-
LibraryProduct("libwrong", :libwrong),
873+
LibraryProduct("libbadosabi", :libbadosabi),
874+
LibraryProduct("libnonote", :libnonote),
871875
LibraryProduct("libright", :libright),
872876
],
873877
# No dependencies
@@ -891,13 +895,24 @@ end
891895
@test is_for_platform(oh, platform)
892896
@test check_os_abi(oh, platform)
893897
end
894-
readmeta(joinpath(testdir, "lib", "libwrong.so")) do ohs
898+
readmeta(joinpath(testdir, "lib", "libnonote.so")) do ohs
899+
oh = only(ohs)
900+
@test !is_for_platform(oh, platform)
901+
@test !check_os_abi(oh, platform)
902+
@test_logs((:warn, r"libnonote.so does not have a FreeBSD-branded ELF note"),
903+
match_mode=:any, check_os_abi(oh, platform; verbose=true))
904+
end
905+
readmeta(joinpath(testdir, "lib", "libbadosabi.so")) do ohs
895906
oh = only(ohs)
896907
@test !is_for_platform(oh, platform)
897908
@test !check_os_abi(oh, platform)
909+
@test_logs((:warn, r"libbadosabi.so has an ELF header OS/ABI value that is not set to FreeBSD"),
910+
match_mode=:any, check_os_abi(oh, platform; verbose=true))
898911
end
899912
# Only audit the library we didn't mess with in the recipe
900-
rm(joinpath(testdir, "lib", "libwrong.so"))
913+
for bad in ("nonote", "badosabi")
914+
rm(joinpath(testdir, "lib", "lib$bad.so"))
915+
end
901916
@test Auditor.audit(Prefix(testdir); platform=platform, require_license=false)
902917
end
903918
end

0 commit comments

Comments
 (0)