[pacman-dev] [PATCH 2/3] libmakepkg: use readelf instead of file for finding ELF file types

Eli Schwartz eschwartz at archlinux.org
Wed Nov 27 17:58:57 UTC 2019


On 11/27/19 12:32 PM, Ethan Sommer wrote:
>>> --- a/scripts/libmakepkg/tidy/strip.sh.in
>>> +++ b/scripts/libmakepkg/tidy/strip.sh.in
>>> @@ -111,22 +111,20 @@ tidy_strip() {
>>>
>>>               local binary strip_flags
>>>               find . -type f -perm -u+w -print0 2>/dev/null | while IFS= read -rd '' binary ; do
>>> -                     case "$(file -bi "$binary")" in
>>> -                             *application/x-sharedlib*)  # Libraries (.so)
>>> +                     case "$(LC_ALL=C readelf -h "$binary" 2>/dev/null)" in
>>
>> More squelching of errors.
> The error redirection to null is because readelf outputs an error when
> the file it is run on isn't an ELF file at all, and obviously that error
> is unwanted.

Right, we just want all the other errors.

>> Incidentally, is the output of this, documented, or can it arbitrarily
>> change in the future? file is guaranteed to emit output in the
>> RFC-documented IANA media type format.
> These file types and their specification in the file header are part of
> the ELF spec

Let's pretend I stated from the beginning that I trust the readelf
program to be able to also interpret future revisions of the file format.

> , and the readelf output has remained consistent, at least
> the part that matters to us, and the relevant part is the same across 4
> different implementations, and I doubt there will be some change of the
> word 'Type:' being used, given that the ELF specification refers to those
> file types as 'types'.

I'll take that as a "no, but it's worked for long enough they probably
won't change it now". Which I suppose is not so unreasonable...

-- 
Eli Schwartz
Bug Wrangler and Trusted User

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 1601 bytes
Desc: OpenPGP digital signature
URL: <https://lists.archlinux.org/pipermail/pacman-dev/attachments/20191127/85ca2e32/attachment-0001.sig>


More information about the pacman-dev mailing list