From d734f6b418b6dcf34e4cc0e1d142542fdd1cf19f Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 7 Dec 2010 13:36:27 -0500 Subject: [PATCH] If file(1) can't identify the ELF binary type, try readelf(1). --- pp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/pp b/pp index 96e7a7855..f1d738fee 100755 --- a/pp +++ b/pp @@ -1,6 +1,6 @@ #!/bin/sh # (c) 2010 Quest Software, Inc. All rights reserved -pp_revision="298" +pp_revision="299" # Copyright 2010 Quest Software, Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -5316,10 +5316,34 @@ pp_rpm_writefiles () { *"executable (RISC System/6000)"*) farch=ppc;; *"64-bit XCOFF executable"*) - fatch=ppc64;; + farch=ppc64;; + *" ELF ") + farch=ELF;; *) farch=noarch;; esac + # If file(1) doesn't provide enough info, try readelf(1) + if test "$farch" = "ELF"; then + fo=`readelf -h "${pp_destdir}$p" | awk '{if ($1 == "Class:") {class=$2} else if ($1 == "Machine:") {machine=$0; sub(/^ *Machine: */, "", machine)}} END {print class " " machine}' 2>/dev/null` + case "$fo" in + "ELF32 Intel 80386") + farch=i386;; + "ELF64 "*[xX]"86-64") + farch=x86_64;; + "ELF32 PowerPC") + farch=ppc;; + "ELF64 PowerPC") + farch=ppc64;; + "ELF64 IA-64") + farch=ia64;; + "ELF32 IBM S/390") + farch=s390;; + "ELF64 IBM S/390") + farch=s390x;; + *) + farch=noarch;; + esac + fi pp_debug "file: $fo -> $farch" test x"$farch" = x"noarch" || pp_add_to_list pp_rpm_arch_seen $farch fi -- 2.40.0