@@ -2,6 +2,7 @@ using Test
22using BinaryBuilderBase
33using BinaryBuilderBase: platform_dlext, platform_exeext, prefer_clang
44using Pkg
5+ using ObjectFile
56
67@testset " Wrappers utilities" begin
78 @test nbits (Platform (" i686" , " linux" )) == 32
@@ -171,21 +172,26 @@ end
171172 """
172173 test_script = """
173174 set -e
175+ cd /workspace
174176 # Make sure setting `CCACHE` doesn't affect the compiler wrappers.
175177 export CCACHE=pwned
176178 export USE_CCACHE=false
177179 echo '$(test_c) ' > test.c
178180 # Build shared library
179181 $(compiler) -shared test.c -o libtest.\$ {dlext}
180-
181- # Print out the notes in the library
182- readelf -n libtest.\$ {dlext}
183182 """
184183 cmd = ` /bin/bash -c "$(test_script) "`
185184 @test run (ur, cmd, iobuff)
186- seekstart (iobuff)
187- # Make sure the compiled library has the note section for the build-id
188- @test occursin (" NT_GNU_BUILD_ID" , readchomp (iobuff))
185+
186+ # Load the library file and test it for the build-id
187+ lib_path = joinpath (dir, " libtest." * platform_dlext (platform))
188+ lib = open (lib_path)
189+ obj_handles = readmeta (lib)
190+ obj = first (obj_handles)
191+ secs = Sections (obj)
192+
193+ # The section must exist for the build-id to be present
194+ @test ! isnothing (findfirst (s -> section_name (s) == " .note.gnu.build-id" , secs))
189195 end
190196 end
191197
@@ -203,23 +209,26 @@ end
203209 """
204210 test_script = """
205211 set -e
206- # We need readpe to get the information from the library
207- apk add pev
212+ cd /workspace
208213 # Make sure setting `CCACHE` doesn't affect the compiler wrappers.
209214 export CCACHE=pwned
210215 export USE_CCACHE=false
211216 echo '$(test_c) ' > test.c
212217 # Build shared library
213218 $(compiler) -shared test.c -o libtest.\$ {dlext}
214-
215- # Print out the notes in the library
216- readpe libtest.\$ {dlext}
217219 """
218220 cmd = ` /bin/bash -c "$(test_script) "`
219221 @test run (ur, cmd, iobuff)
220- seekstart (iobuff)
221- # Make sure the compiled library has the section for the build-id
222- @test occursin (" .buildid" , readchomp (iobuff))
222+
223+ # Load the library file and test it for the build-id
224+ lib_path = joinpath (dir, " libtest." * platform_dlext (platform))
225+ lib = open (lib_path)
226+ obj_handles = readmeta (lib)
227+ obj = first (obj_handles)
228+ secs = Sections (obj)
229+
230+ # The section must exist for the build-id to be present
231+ @test ! isnothing (findfirst (s -> section_name (s) == " .buildid" , secs))
223232 end
224233 end
225234
0 commit comments