Commit b2348dbf authored by Ripinder Singh's avatar Ripinder Singh
Browse files
Merge branch 'main' of ssh://forge.3gpp.org:29419/ivas-codec-pc/ivas-codec into 1154-add-rtpdump-support-no-pi-appliance
parents 86f10242 8682b5a1
Loading
Loading
Loading
Loading
Loading
+93 −0
Original line number Diff line number Diff line
#!/usr/bin/env bash

#
#   (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
#   Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
#   Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
#   Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
#   contributors to this repository. All Rights Reserved.
#
#   This software is protected by copyright law and by international treaties.
#   The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
#   Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
#   Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
#   Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
#   contributors to this repository retain full ownership rights in their respective contributions in
#   the software. This notice grants no license of any kind, including but not limited to patent
#   license, nor is any license granted by implication, estoppel or otherwise.
#
#   Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
#   contributions.
#
#   This software is provided "AS IS", without any express or implied warranties. The software is in the
#   development stage. It is intended exclusively for experts who have experience with such software and
#   solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
#   and fitness for a particular purpose are hereby disclaimed and excluded.
#
#   Any dispute, controversy or claim arising under or in relation to providing this software shall be
#   submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
#   accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
#   the United Nations Convention on Contracts on the International Sales of Goods.
#

# fp_insn_finder.sh
# Usage: ./find_fp_insn.sh <executable>
# disassembles executable, lists common floating-point instructions

set -euo pipefail

if [ $# -ne 1 ]; then
  echo "Usage: $0 <executable>"
  echo "Find floating-point instructions in an executable based on assembler instructions"
  echo "Pre-requisites: Perl or gawk"
  exit 1
fi

EXE="$1"
if [ ! -x "$EXE" ]; then
  echo "Error: '$EXE' is no executable"
  exit 2
fi

perl_avail=0
# check, whether we have perl installed
if command -v perl >/dev/null 2>&1; then
  perl_avail=1
fi

gawk_avail=0
awk_option=""
# check, whether we have awk (POSIX) or gawk (GNU) on the system
if command -v gawk >/dev/null 2>&1; then
    gawk_avail=1
    awk_option="--posix"
fi


if [ $perl_avail -ne 0 ]; then

    objdump -d -Mintel "$EXE" \
    | perl -nE '
    # Regex for floating-point instructions
    our $fp = qr/\b(?:fadd|fsub|fmul|fdiv|fld|fst|movss|movsd|addss|addsd|subss|subsd|mulss|mulsd|divss|divsd)\b/;
    if    (/^[0-9a-f]+ <([^>]+)>:/) { $func = $1 }
    elsif (/$fp/)                   { say "$func: $_" }
    '

else

    objdump -d -Mintel "$EXE" |
    awk ${awk_option} '
    /^[0-9a-f]+ </ {
        # Extract function names
        sub(/^[0-9a-f]+ </, "")
        sub(/>:.*$/, "")
        func = $0
        next
    }
    /(^|[^[:alnum:]_])(fadd|fsub|fmul|fdiv|fld|fst|movss|movsd|addss|addsd|subss|subsd|mulss|mulsd|divss|divsd)($|[^[:alnum:]_])/ {
        print func ": " $0
    }
    '

fi