Skip to content

Commit eb4b56a

Browse files
authored
[Auditor] Improve check for amv7l float ABI (#1000)
A binary is accpetable for this platform also if it doesn't specify any float ABI.
1 parent ae84d4a commit eb4b56a

File tree

2 files changed

+35
-7
lines changed

2 files changed

+35
-7
lines changed

src/auditor/extra_checks.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ function check_os_abi(oh::ObjectHandle, p::AbstractPlatform, rest...; verbose::B
1818
elseif call_abi(p) == "eabihf"
1919
# Make sure the object file has the hard-float ABI. See Table 4-2 of
2020
# "ELF for the ARM Architecture" document
21-
# (https://developer.arm.com/documentation/ihi0044/e/).
22-
if iszero(header(oh).e_flags & 0x400)
21+
# (https://developer.arm.com/documentation/ihi0044/e/). Note: `0x000`
22+
# means "no specific float ABI", `0x400` == EF_ARM_ABI_FLOAT_HARD.
23+
if header(oh).e_flags & 0xF00 (0x000, 0x400)
2324
if verbose
2425
@error("$(basename(path(oh))) does not match the hard-float ABI")
2526
end

test/auditing.jl

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,9 @@ end
564564
end
565565

566566
@testset "Auditor - other checks" begin
567+
platform = Platform("armv7l", "linux"; call_abi = "eabihf", libc = "glibc")
567568
mktempdir() do build_path
568-
@test_logs (:error, r"does not match the hard-float ABI") match_mode=:any begin
569+
build_output_meta = @test_logs (:error, r"libsoft.so does not match the hard-float ABI") match_mode=:any begin
569570
autobuild(
570571
build_path,
571572
"hard_float_ABI",
@@ -575,19 +576,45 @@ end
575576
# Build a library which doesn't link to the standard library and
576577
# forces the soft-float ABI
577578
raw"""
578-
mkdir -p "${libdir}"
579-
echo 'int _start() { return 0; }' | /opt/${target}/bin/${target}-gcc -nostdlib -shared -mfloat-abi=soft -o "${libdir}/libfoo.${dlext}" -x c -
579+
mkdir -p "${libdir}" "${bindir}"
580+
# This library has hard-float ABI
581+
echo 'int test() { return 0; }' | cc -shared -fPIC -o "${libdir}/libhard.${dlext}" -x c -
582+
# This library has soft-float ABI
583+
echo 'int _start() { return 0; }' | /opt/${target}/bin/${target}-gcc -nostdlib -shared -mfloat-abi=soft -o "${libdir}/libsoft.${dlext}" -x c -
584+
# hello_world built by Go doesn't specify any float ABI
585+
make -C /usr/share/testsuite/go/hello_world/
586+
cp "/tmp/testsuite/${target}/go/hello_world/hello_world" "${bindir}/hello_world"
580587
""",
581588
# Build for Linux armv7l hard-float
582-
[Platform("armv7l", "linux"; call_abi = "eabihf", libc = "glibc")],
589+
[platform],
583590
# Ensure our library product is built
584-
[LibraryProduct("libfoo", :libfoo)],
591+
[
592+
LibraryProduct("libhard", :libhard),
593+
LibraryProduct("libsoft", :libsoft),
594+
ExecutableProduct("hello_world", :hello_world),
595+
],
585596
# No dependencies
586597
Dependency[];
598+
compilers = [:c, :go],
587599
verbose = true,
588600
require_license = false
589601
)
590602
end
603+
604+
@test haskey(build_output_meta, platform)
605+
tarball_path, tarball_hash = build_output_meta[platform][1:2]
606+
@test isfile(tarball_path)
607+
608+
# Unpack it somewhere else
609+
@test verify(tarball_path, tarball_hash)
610+
testdir = joinpath(build_path, "testdir")
611+
mkdir(testdir)
612+
unpack(tarball_path, testdir)
613+
# Remove libsoft.so, we want to run audit only on the other products
614+
rm(joinpath(testdir, "lib", "libsoft.so"))
615+
# Make sure `hello_world` passes the float ABI check even if it doesn't
616+
# set `EF_ARM_ABI_FLOAT_HARD`.
617+
@test Auditor.audit(Prefix(testdir); platform=platform, require_license=false)
591618
end
592619
end
593620

0 commit comments

Comments
 (0)