When matching brand to the ELF binary by notes, try to find a brand
authorkib <kib@FreeBSD.org>
Thu, 4 Feb 2016 20:55:49 +0000 (20:55 +0000)
committerkib <kib@FreeBSD.org>
Thu, 4 Feb 2016 20:55:49 +0000 (20:55 +0000)
commit977f53633ffa1e668405525673a702136b3c640d
tree3b13780ea92cd6e19d6f1a99dc601b5f2e3db03b
parent90ae570ac2c2e37f4c958f0dc31bd40995034958
When matching brand to the ELF binary by notes, try to find a brand
with interpreter name exactly matching one wanted by the binary.  If
no such brand exists, return first brand which accepted the binary by
note.

The change fixes a regression after r292749, where e.g. our two ia32
compat brands, ia32_brand_info and ia32_brand_oinfo, only differ by
the interpeter path and binary matches to a brand by linkage order.
Then old binaries which require /usr/libexec/ld-elf.so.1 but matched
against ia32_brand_info with interp_path /libexec/ld-elf.so.1, were
considered requiring non-standard interpreter name, and magic to force
ld-elf32.so.1 did not happen.

Note that it might make sense to apply the same selection of brands
for other matching criteria, SCO EI_OSABI and 3.x string.

Reported and tested by: dwmalone
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
sys/kern/imgact_elf.c