package/linux-tools: Exclude checking PE binaries from perf test
PATCH 1/1 package/linux-tools: Exclude checking PE binaries from perf test
Since upstream Linux commit ed21d6d7c48e6e96c2d617e304a7ebfbd17b1807 ("perf tests: Add test for PE binary format support") present in >= v5.10 there is an unconditional installation of PE binaries which will be rejected by the check-bin-arch script.
Make sure that these binaries are excluded from being checked to allow the installation of the perf tests.
--- package/linux-tools/linux-tool-perf.mk.in | 4 ++++ 1 file changed, 4 insertions(+)
package/linux-tools/linux-tool-perf.mk.in +4 -0
@@ -169,6 +169,10 @@ define PERF_INSTALL_REMOVE_SCRIPTS $(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/scripts/ $(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/tests/ endef + +LINUX_TOOLS_BIN_ARCH_EXCLUDE += \ + /usr/libexec/perf-core/tests/pe-file.exe \ + /usr/libexec/perf-core/tests/pe-file.exe.debug endif define PERF_INSTALL_TARGET_CMDS
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hello Florian,
Quoted 10 lines · On Tue, 27 Sep 2022 15:11:33 -0700 Florian Fainelli <[email protected]>…
Since upstream Linux commit
ed21d6d7c48e6e96c2d617e304a7ebfbd17b1807("perf tests: Add test for PE binary format support") present in >= v5.10 there is an unconditional installation of PE binaries which will be rejected by the check-bin-arch script.Make sure that these binaries are excluded from being checked to allow the installation of the perf tests.
Fixes 6fcdaa4c5096 ("package/linux-tools: Allow installation of perf scripts")Signed-off-by Florian Fainelli <[email protected]>
Thanks for the patch! Before merging it, I'd like to understand a little bit more how readelf behaves for these PE files. Indeed in check-bin-arch, we are doing:
arch=$(LC_ALL=C ${readelf} -h "${TARGET_DIR}/${f}" 2>&1 | \
sed -r -e '/^ Machine: +(.+)/!d; s//\1/;' | head -1)
# If no architecture found, assume it was not an ELF file
if test "${arch}" = "" ; then
continue
fifor a PE file, I would expect readelf to badly fail, and therefore ${arch} to be empty, and the file simply ignored.
What is the behavior/output of readelf on these PE files?
Thanks!
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 28 lines · Thomas Petazzoni
Hello Florian,
Quoted 10 lines · On Tue, 27 Sep 2022 15:11:33 -0700 Florian Fainelli <[email protected]>…
Since upstream Linux commit
ed21d6d7c48e6e96c2d617e304a7ebfbd17b1807("perf tests: Add test for PE binary format support") present in >= v5.10 there is an unconditional installation of PE binaries which will be rejected by the check-bin-arch script.Make sure that these binaries are excluded from being checked to allow the installation of the perf tests.
Fixes 6fcdaa4c5096 ("package/linux-tools: Allow installation of perf scripts")Signed-off-by Florian Fainelli <[email protected]>Thanks for the patch! Before merging it, I'd like to understand a little bit more how readelf behaves for these PE files. Indeed in check-bin-arch, we are doing:
arch=$(LC_ALL=C ${readelf} -h "${TARGET_DIR}/${f}" 2>&1 | \ sed -r -e '/^ Machine: +(.+)/!d; s//\1/;' | head -1) # If no architecture found, assume it was not an ELF file if test "${arch}" = "" ; then continue fi
Quoted 4 lines
for a PE file, I would expect readelf to badly fail, and therefore ${arch} to be empty, and the file simply ignored.
What is the behavior/output of readelf on these PE files?
If I use my host system readelf which is packaged from binutils-x86-64-linux-gnu, I get no output and all is well, however when check-bin-arch is called and it uses $(TARGET_READELF), I do get:
./host/bin/aarch64-linux-readelf -h build/linux-custom/tools/perf/tests/pe-file.exe | sed -r -e '/^ Machine: +(.+)/!d; s//\1/;' | head -1 IMAGE_FILE_MACHINE_AMD64 (0x8664)
which is what prompted me to issue this patch in the first place.
I should mention that the readelf binary in this case is the LLVM Object Reader and it does support PE/COFF which is probably why it even remotely attempts to parse the file.
Signature · 5 lines
Florian _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 4 lines · On Wed, 28 Sep 2022 15:28:58 -0700 Florian Fainelli <[email protected]>…
./host/bin/aarch64-linux-readelf -h build/linux-custom/tools/perf/tests/pe-file.exe | sed -r -e '/^
Machine: +(.+)/!d; s//\1/;' | head -1IMAGE_FILE_MACHINE_AMD64(0x8664)
Could you provide the full output? In other words, I'm interested to see if it's really readelf showing the same "Machine:" field as for regular ELF files, or if it's something somewhat different that we could distinguish.
Quoted 3 lines
I should mention that the readelf binary in this case is the LLVM Object Reader and it does support PE/COFF which is probably why it even remotely attempts to parse the file.
How come your readelf is from LLVM? Are you using an external toolchain that isn't based on the standard GNU Binutils?
Thanks!
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 8 lines · Thomas Petazzoni
Quoted 4 lines · On Wed, 28 Sep 2022 15:28:58 -0700 Florian Fainelli <[email protected]>…
./host/bin/aarch64-linux-readelf -h build/linux-custom/tools/perf/tests/pe-file.exe | sed -r -e '/^
Machine: +(.+)/!d; s//\1/;' | head -1IMAGE_FILE_MACHINE_AMD64(0x8664)
Quoted 4 lines
Could you provide the full output? In other words, I'm interested to see if it's really readelf showing the same "Machine:" field as for regular ELF files, or if it's something somewhat different that we could distinguish.
Sure, please find attached.
Quoted 7 lines
Quoted 4 lines
I should mention that the readelf binary in this case is the LLVM Object Reader and it does support PE/COFF which is probably why it even remotely attempts to parse the file.
How come your readelf is from LLVM? Are you using an external toolchain that isn't based on the standard GNU Binutils?
Correct, I am using a custom built LLVM toolchain that uses the Clang integrated assembler and none of the binutils binaries, or any GNU component for that matter.
Signature · 1 line
Florian
ImageFileHeader {
Machine: IMAGE_FILE_MACHINE_AMD64 (0x8664)
SectionCount: 11
TimeDateStamp: 1970-01-01 00:00:00 (0x0)
PointerToSymbolTable: 0xC000
SymbolCount: 1115
StringTableSize: 6373
OptionalHeaderSize: 240
Characteristics [ (0x27)
IMAGE_FILE_EXECUTABLE_IMAGE (0x2)
IMAGE_FILE_LARGE_ADDRESS_AWARE (0x20)
IMAGE_FILE_LINE_NUMS_STRIPPED (0x4)
IMAGE_FILE_RELOCS_STRIPPED (0x1) ]
}
ImageOptionalHeader {
Magic: 0x20B
MajorLinkerVersion: 2
MinorLinkerVersion: 34
SizeOfCode: 8192
SizeOfInitializedData: 40960
SizeOfUninitializedData: 4096
AddressOfEntryPoint: 0x14F0
BaseOfCode: 0x1000
ImageBase: 0x400000
SectionAlignment: 4096
FileAlignment: 4096
MajorOperatingSystemVersion: 4
MinorOperatingSystemVersion: 0
MajorImageVersion: 0
MinorImageVersion: 0
MajorSubsystemVersion: 5
MinorSubsystemVersion: 2
SizeOfImage: 53248
SizeOfHeaders: 4096
Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI (0x3)
Characteristics [ (0x0)
]
SizeOfStackReserve: 2097152
SizeOfStackCommit: 4096
SizeOfHeapReserve: 1048576
SizeOfHeapCommit: 4096
NumberOfRvaAndSize: 16
DataDirectory {
ExportTableRVA: 0x0
ExportTableSize: 0x0
ImportTableRVA: 0x9000
ImportTableSize: 0x750
ResourceTableRVA: 0x0
ResourceTableSize: 0x0
ExceptionTableRVA: 0x6000
ExceptionTableSize: 0x258
CertificateTableRVA: 0x0
CertificateTableSize: 0x0
BaseRelocationTableRVA: 0x0
BaseRelocationTableSize: 0x0
DebugRVA: 0x5000
DebugSize: 0x1C
ArchitectureRVA: 0x0
ArchitectureSize: 0x0
GlobalPtrRVA: 0x0
GlobalPtrSize: 0x0
TLSTableRVA: 0x4040
TLSTableSize: 0x28
LoadConfigTableRVA: 0x0
LoadConfigTableSize: 0x0
BoundImportRVA: 0x0
BoundImportSize: 0x0
IATRVA: 0x91CC
IATSize: 0x190
DelayImportDescriptorRVA: 0x0
DelayImportDescriptorSize: 0x0
CLRRuntimeHeaderRVA: 0x0
CLRRuntimeHeaderSize: 0x0
ReservedRVA: 0x0
ReservedSize: 0x0 }
}
DOSHeader {
Magic: MZ
UsedBytesInTheLastPage: 144
FileSizeInPages: 3
NumberOfRelocationItems: 0
HeaderSizeInParagraphs: 4
MinimumExtraParagraphs: 0
MaximumExtraParagraphs: 65535
InitialRelativeSS: 0
InitialSP: 184
Checksum: 0
InitialIP: 0
InitialRelativeCS: 0
AddressOfRelocationTable: 64
OverlayNumber: 0
OEMid: 0
OEMinfo: 0
AddressOfNewExeHeader: 128
}
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Florian, All,
On 2022-09-28 15:28 -0700, Florian Fainelli spake thusly:
Quoted 40 lines · Thomas Petazzoni
Quoted 25 lines
Quoted 10 lines · On Tue, 27 Sep 2022 15:11:33 -0700 Florian Fainelli <[email protected]>…
Since upstream Linux commit
ed21d6d7c48e6e96c2d617e304a7ebfbd17b1807("perf tests: Add test for PE binary format support") present in >= v5.10 there is an unconditional installation of PE binaries which will be rejected by the check-bin-arch script.Make sure that these binaries are excluded from being checked to allow the installation of the perf tests.
Fixes 6fcdaa4c5096 ("package/linux-tools: Allow installation of perf scripts")Signed-off-by Florian Fainelli <[email protected]>Thanks for the patch! Before merging it, I'd like to understand a little bit more how readelf behaves for these PE files. Indeed in check-bin-arch, we are doing:
arch=$(LC_ALL=C ${readelf} -h "${TARGET_DIR}/${f}" 2>&1 | \ sed -r -e '/^ Machine: +(.+)/!d; s//\1/;' | head -1) # If no architecture found, assume it was not an ELF file if test "${arch}" = "" ; then continue fiQuoted 4 lines
for a PE file, I would expect readelf to badly fail, and therefore ${arch} to be empty, and the file simply ignored.
What is the behavior/output of readelf on these PE files?
If I use my host system readelf which is packaged from binutils-x86-64-linux-gnu, I get no output and all is well, however when check-bin-arch is called and it uses $(TARGET_READELF), I do get:
./host/bin/aarch64-linux-readelf -h build/linux-custom/tools/perf/tests/pe-file.exe | sed -r -e '/^ Machine:
+(.+)/!d; s//\1/;' | head -1IMAGE_FILE_MACHINE_AMD64(0x8664)
Quoted 5 lines
which is what prompted me to issue this patch in the first place.
I should mention that the readelf binary in this case is the LLVM Object Reader and it does support PE/COFF which is probably why it even remotely attempts to parse the file.
OK, but isn't that flawed? It is named 'readelf', so I would expect it to not report on non-ELF files, at least by default (i.e. unless a specific option flag is passed).
If a readelf tool does not behave like a readelf tool should behave, isn't that a bug in that specific readelf tool to begin with?
Otherwise, it is very intriguing how you managed to have a toolchain without gcc et al, be usable for Buildroot that only knows about the GNU ecosystem.
Is that a publicly available toolchain? Can you share the recipe how that toolchain was generated? Do you have special, local changes in Buildroot to accomodate that toolchain? Will you submit those changes?
That would allow adding more testing to avoid such issue in the future. Otherwise, I am not fan of adding such exclusion for private cases that we can not (easily) reproduce, as those cases are not supported.
Regards,
Yann E. MORIN.
Quoted 6 lines
Signature · 5 lines
Florian _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 49 lines · Yann E. MORIN
Florian, All,
On 2022-09-28 15:28 -0700, Florian Fainelli spake thusly:
Quoted 40 lines · Thomas Petazzoni
Quoted 25 lines
Quoted 10 lines · On Tue, 27 Sep 2022 15:11:33 -0700 Florian Fainelli <[email protected]>…
Since upstream Linux commit
ed21d6d7c48e6e96c2d617e304a7ebfbd17b1807("perf tests: Add test for PE binary format support") present in >= v5.10 there is an unconditional installation of PE binaries which will be rejected by the check-bin-arch script.Make sure that these binaries are excluded from being checked to allow the installation of the perf tests.
Fixes 6fcdaa4c5096 ("package/linux-tools: Allow installation of perf scripts")Signed-off-by Florian Fainelli <[email protected]>Thanks for the patch! Before merging it, I'd like to understand a little bit more how readelf behaves for these PE files. Indeed in check-bin-arch, we are doing:
arch=$(LC_ALL=C ${readelf} -h "${TARGET_DIR}/${f}" 2>&1 | \ sed -r -e '/^ Machine: +(.+)/!d; s//\1/;' | head -1) # If no architecture found, assume it was not an ELF file if test "${arch}" = "" ; then continue fiQuoted 4 lines
for a PE file, I would expect readelf to badly fail, and therefore ${arch} to be empty, and the file simply ignored.
What is the behavior/output of readelf on these PE files?
If I use my host system readelf which is packaged from binutils-x86-64-linux-gnu, I get no output and all is well, however when check-bin-arch is called and it uses $(TARGET_READELF), I do get:
./host/bin/aarch64-linux-readelf -h build/linux-custom/tools/perf/tests/pe-file.exe | sed -r -e '/^ Machine:
+(.+)/!d; s//\1/;' | head -1IMAGE_FILE_MACHINE_AMD64(0x8664)Quoted 5 lines
which is what prompted me to issue this patch in the first place.
I should mention that the readelf binary in this case is the LLVM Object Reader and it does support PE/COFF which is probably why it even remotely attempts to parse the file.
Quoted 6 lines
OK, but isn't that flawed? It is named 'readelf', so I would expect it to not report on non-ELF files, at least by default (i.e. unless a specific option flag is passed).
If a readelf tool does not behave like a readelf tool should behave, isn't that a bug in that specific readelf tool to begin with?
Markus can correct me but it seems to me llvm-readelf is LLVM's own doing and aliases to llvm-readobj, given that PE executable support was built into the toolchain, it happily went into parsing the PE files. I suppose that in premise llvm-readelf should retrict itself to parsing ELF files, clearly LLVM developers thought differently.
Quoted 6 lines
Otherwise, it is very intriguing how you managed to have a toolchain without gcc et al, be usable for Buildroot that only knows about the GNU ecosystem.
Is that a publicly available toolchain?
Not yet, but soon.
Quoted 1 line
Can you share the recipe how that toolchain was generated?
Yes that will be done.
Quoted 1 line
Do you have special, local changes in Buildroot to accomodate that toolchain? Will you submit those changes?
Yes a few and yes we will, provided there is interest from the buildroot community to have support for a GNU-free and musl-libc based toolchain. The approach we took for now is that we provide a GNU-compatible wrapper and set of executable names such that you build with clang/LLVM but you don't really need to know about it, except where it matters.
Quoted 4 lines
That would allow adding more testing to avoid such issue in the future. Otherwise, I am not fan of adding such exclusion for private cases that we can not (easily) reproduce, as those cases are not supported.
Fair enough, how about we make sure the toolchain is available, can be re-created by anyone who desires so and then we submit the changes to buildroot that we have so you see the full picture?
Signature · 5 lines
Florian _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Florian, All,
On 2022-10-03 10:21 -0700, Florian Fainelli spake thusly:
Quoted 5 lines · Yann E. MORIN
Quoted 4 lines
On 2022-09-28 15:28 -0700, Florian Fainelli spake thusly:
Quoted 3 lines · Thomas Petazzoni
Quoted 2 lines
On Tue, 27 Sep 2022 15:11:33 -0700
Florian Fainelli <[email protected]> wrote:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Since upstream Linux commit
ed21d6d7c48e6e96c2d617e304a7ebfbd17b1807("perf tests: Add test for PE binary format support") present in >= v5.10 there is an unconditional installation of PE binaries which will be rejected by the check-bin-arch script.Make sure that these binaries are excluded from being checked to allow the installation of the perf tests.
[--SNIP--]
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
I should mention that the readelf binary in this case is the LLVM Object Reader and it does support PE/COFF which is probably why it even remotely attempts to parse the file.
Is that a publicly available toolchain?
Can you share the recipe how that toolchain was generated?Yes that will be done.
Great!
Quoted 3 lines
Quoted 1 line
Do you have special, local changes in Buildroot to accomodate that toolchain? Will you submit those changes?
Yes a few and yes we will, provided there is interest from the buildroot community to have support for a GNU-free and musl-libc based toolchain.
I am personally not interested in a "GNU-free" toolchain. However, I am very much interested in an llvm-based toolchain.
Semantics, semantics! ;-)
Quoted 4 lines
The
approach we took for now is that we provide a GNU-compatible wrapper and set of executable names such that you build with clang/LLVM but you don't really need to know about it, except where it matters.
Yes, that sounds like a good approach.
Quoted 6 lines
Quoted 3 lines
That would allow adding more testing to avoid such issue in the future. Otherwise, I am not fan of adding such exclusion for private cases that we can not (easily) reproduce, as those cases are not supported.
Fair enough, how about we make sure the toolchain is available, can be re-created by anyone who desires so and then we submit the changes to buildroot that we have so you see the full picture?
Yes, that would be awesome!
As I said above: having support for using an llvm-based toolchain would be very interesting!
Regards,
Yann E. MORIN.
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Florian, All,
On 2022-09-27 15:11 -0700, Florian Fainelli spake thusly:
Quoted 10 lines
Since upstream Linux commit
ed21d6d7c48e6e96c2d617e304a7ebfbd17b1807("perf tests: Add test for PE binary format support") present in >= v5.10 there is an unconditional installation of PE binaries which will be rejected by the check-bin-arch script.Make sure that these binaries are excluded from being checked to allow the installation of the perf tests.
Fixes 6fcdaa4c5096 ("package/linux-tools: Allow installation of perf scripts")Signed-off-by Florian Fainelli <[email protected]>
I've finally applied to master, thanks.
However, I wonder if we could not be a bit more robust in check-bin-arch itself, something like:
diff --git a/support/scripts/check-bin-arch b/support/scripts/check-bin-arch
index 27cc59bca0..2920a95ae3 100755
--- a/support/scripts/check-bin-arch
+++ b/support/scripts/check-bin-arch
@@ -58,6 +58,9 @@ exitcode=0
IFS="
"
+# ELF magic
+ELF_MAGIC="$(printf "\x7f\x45\x4c\x46")"
+
while read f; do
for ignore in "${IGNORES[@]}"; do
if [[ "${f}" =~ ^"${ignore}" ]]; then
@@ -71,13 +74,19 @@ while read f; do
continue
fi
+ # Check if it looks like it is an ELF file
+ read -N 4 magic <"${TARGET_DIR}/${f}"
+ if [ "${magic}" != "${ELF_MAGIC}" ]; then
+ continue
+ fi
+
# Get architecture using readelf. We pipe through 'head -1' so
# that when the file is a static library (.a), we only take
# into account the architecture of the first object file.
arch=$(LC_ALL=C ${readelf} -h "${TARGET_DIR}/${f}" 2>&1 | \
sed -r -e '/^ Machine: +(.+)/!d; s//\1/;' | head -1)
-# If no architecture found, assume it was not an ELF file
+# If no architecture found, assume it was in fact not an ELF file
if test "${arch}" = "" ; then
continue
fi(with the read -N 4 trick as discussed in [0])
Thoughts?
Regards,
Yann E. MORIN.
Quoted 26 lines
--- package/linux-tools/linux-tool-perf.mk.in | 4 ++++ 1 file changed, 4 insertions(+)package/linux-tools/linux-tool-perf.mk.in +4
-0@@ -169,6 +169,10 @@ define PERF_INSTALL_REMOVE_SCRIPTS $(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/scripts/ $(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/tests/ endef + +LINUX_TOOLS_BIN_ARCH_EXCLUDE += \ + /usr/libexec/perf-core/tests/pe-file.exe \ + /usr/libexec/perf-core/tests/pe-file.exe.debug endif define PERF_INSTALL_TARGET_CMDSSignature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 55 lines · Yann E. MORIN
Florian, All,
On 2022-09-27 15:11 -0700, Florian Fainelli spake thusly:
Quoted 10 lines
Since upstream Linux commit
ed21d6d7c48e6e96c2d617e304a7ebfbd17b1807("perf tests: Add test for PE binary format support") present in >= v5.10 there is an unconditional installation of PE binaries which will be rejected by the check-bin-arch script.Make sure that these binaries are excluded from being checked to allow the installation of the perf tests.
Fixes 6fcdaa4c5096 ("package/linux-tools: Allow installation of perf scripts")Signed-off-by Florian Fainelli <[email protected]>I've finally applied to master, thanks.
However, I wonder if we could not be a bit more robust in check-bin-arch itself, something like:
diff --git a/support/scripts/check-bin-arch b/support/scripts/check-bin-arch index 27cc59bca0..2920a95ae3 100755 --- a/support/scripts/check-bin-arch +++ b/support/scripts/check-bin-arch @@ -58,6 +58,9 @@ exitcode=0 IFS=" " +# ELF magic +ELF_MAGIC="$(printf "\x7f\x45\x4c\x46")" + while read f; do for ignore in "${IGNORES[@]}"; do if [[ "${f}" =~ ^"${ignore}" ]]; then @@ -71,13 +74,19 @@ while read f; do continue fi + # Check if it looks like it is an ELF file + read -N 4 magic <"${TARGET_DIR}/${f}" + if [ "${magic}" != "${ELF_MAGIC}" ]; then + continue + fi + # Get architecture using readelf. We pipe through 'head -1' so # that when the file is a static library (.a), we only take # into account the architecture of the first object file. arch=$(LC_ALL=C ${readelf} -h "${TARGET_DIR}/${f}" 2>&1 | \ sed -r -e '/^ Machine: +(.+)/!d; s//\1/;' | head -1) -# If no architecture found, assume it was not an ELF file +# If no architecture found, assume it was in fact not an ELF file if test "${arch}" = "" ; then continue fi
Quoted 3 lines
(with the read -N 4 trick as discussed in [0])
Thoughts?
That would work for me!
Signature · 5 lines
Florian _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Florian" == Florian Fainelli <[email protected]> writes:
Since upstream Linux commit
ed21d6d7c48e6e96c2d617e304a7ebfbd17b1807("perf tests: Add test for PE binary format support") present in >= v5.10 there is an unconditional installation of PE binaries which will be rejected by the check-bin-arch script.
Quoted 5 lines
Make sure that these binaries are excluded from being checked to allow the installation of the perf tests.
Fixes 6fcdaa4c5096 ("package/linux-tools: Allow installation of perf scripts")Signed-off-by Florian Fainelli <[email protected]>
Committed to 2023.02.x, thanks.
Signature · 5 lines
Bye, Peter Korsgaard _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot