Skip to content

Commit dc61a45

Browse files
authored
[Auditor] Make sure libraries for eabihf match this ABI (#976)
1 parent e4a68ca commit dc61a45

File tree

2 files changed

+46
-8
lines changed

2 files changed

+46
-8
lines changed

src/auditor/extra_checks.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,22 @@ function check_os_abi(oh::ObjectHandle, p::AbstractPlatform, rest...; verbose::B
99
if verbose
1010
msg = replace("""
1111
$(basename(path(oh))) has an ELF header OS/ABI value that is not set to FreeBSD
12-
($(ELF.ELFOSABI_FREEBSD)), this may be an issue at link time"
12+
($(ELF.ELFOSABI_FREEBSD)), this may be an issue at link time
1313
""", '\n' => ' ')
1414
@warn(strip(msg))
1515
end
1616
return false
1717
end
18+
elseif call_abi(p) == "eabihf"
19+
# Make sure the object file has the hard-float ABI. See Table 4-2 of
20+
# "ELF for the ARM Architecture" document
21+
# (https://developer.arm.com/documentation/ihi0044/e/).
22+
if iszero(header(oh).e_flags & 0x400)
23+
if verbose
24+
@error("$(basename(path(oh))) does not match the hard-float ABI")
25+
end
26+
return false
27+
end
1828
end
1929
return true
2030
end

test/auditing.jl

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ end
284284
""",
285285
# Build for our platform
286286
[platform],
287-
# Ensure our executable products are built
288-
Product[LibraryProduct("libfoo", :libfoo)],
287+
# Ensure our library product is built
288+
[LibraryProduct("libfoo", :libfoo)],
289289
# No dependencies
290290
Dependency[]
291291
)
@@ -317,7 +317,7 @@ end
317317
FileSource[],
318318
# Intsall a .dll into lib
319319
raw"""
320-
mkdir -p ${prefix}/lib
320+
mkdir -p "${libdir}"
321321
SRC=/usr/share/testsuite/c/dyn_link/libfoo/libfoo.c
322322
cc -o ${libdir}/no_id.${dlext} -shared $SRC
323323
cc -o ${libdir}/abs_id.${dlext} -Wl,-install_name,${libdir}/abs_id.${dlext} -shared $SRC
@@ -486,14 +486,14 @@ end
486486
FileSource[],
487487
# Build the library only with the versioned name
488488
raw"""
489-
mkdir -p ${prefix}/lib
490-
cc -o ${prefix}/lib/libfoo.${dlext}.1.0.0 -fPIC -shared /usr/share/testsuite/c/dyn_link/libfoo/libfoo.c
489+
mkdir -p "${libdir}"
490+
cc -o "${libdir}/libfoo.${dlext}.1.0.0" -fPIC -shared /usr/share/testsuite/c/dyn_link/libfoo/libfoo.c
491491
# Set the soname to a non-existing file
492-
patchelf --set-soname libfoo.so ${prefix}/lib/libfoo.${dlext}.1.0.0
492+
patchelf --set-soname libfoo.so "${libdir}/libfoo.${dlext}.1.0.0"
493493
""",
494494
# Build for Linux
495495
[linux_platform],
496-
# Ensure our executable products are built
496+
# Ensure our library product is built
497497
[LibraryProduct("libfoo", :libfoo)],
498498
# No dependencies
499499
Dependency[];
@@ -517,6 +517,34 @@ end
517517
end
518518
end
519519

520+
@testset "Auditor - other checks" begin
521+
mktempdir() do build_path
522+
@test_logs (:error, r"does not match the hard-float ABI") match_mode=:any begin
523+
autobuild(
524+
build_path,
525+
"hard_float_ABI",
526+
v"1.0.0",
527+
# No sources
528+
FileSource[],
529+
# Build a library which doesn't link to the standard library and
530+
# forces the soft-float ABI
531+
raw"""
532+
mkdir -p "${libdir}"
533+
echo 'int _start() { return 0; }' | /opt/${target}/bin/${target}-gcc -nostdlib -shared -mfloat-abi=soft -o "${libdir}/libfoo.${dlext}" -x c -
534+
""",
535+
# Build for Linux armv7l hard-float
536+
[Platform("armv7l", "linux"; call_abi = "eabihf", libc = "glibc")],
537+
# Ensure our library product is built
538+
[LibraryProduct("libfoo", :libfoo)],
539+
# No dependencies
540+
Dependency[];
541+
verbose = true,
542+
require_license = false
543+
)
544+
end
545+
end
546+
end
547+
520548
@testset "valid_library_path" begin
521549
linux = Platform("x86_64", "linux")
522550
macos = Platform("x86_64", "macos")

0 commit comments

Comments
 (0)