From owner-svn-src-all@FreeBSD.ORG Thu Nov 6 22:45:03 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B827B84F; Thu, 6 Nov 2014 22:45:03 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A4707897; Thu, 6 Nov 2014 22:45:03 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sA6Mj3WD018465; Thu, 6 Nov 2014 22:45:03 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sA6Mj3nT018464; Thu, 6 Nov 2014 22:45:03 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201411062245.sA6Mj3nT018464@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Thu, 6 Nov 2014 22:45:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r274199 - head/tools/build X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Nov 2014 22:45:03 -0000 Author: bapt Date: Thu Nov 6 22:45:03 2014 New Revision: 274199 URL: https://svnweb.freebsd.org/changeset/base/274199 Log: Add a quick and dirty script to check validity of links in elf files Added: head/tools/build/check-links.sh (contents, props changed) Added: head/tools/build/check-links.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/build/check-links.sh Thu Nov 6 22:45:03 2014 (r274199) @@ -0,0 +1,37 @@ +#!/bin/sh +# $FreeBSD$ + +mime=$(file --mime-type $1) +case $mime in +*application/x-executable);; +*application/x-sharedlib);; +*) echo "Not an elf file" >&2 ; exit 1;; +esac + +# Check for useful libs +list_libs="" +for lib in $(readelf -d $1 | awk '$2 == "(NEEDED)" { sub(/\[/,"",$NF); sub(/\]/,"",$NF); print $NF }'); do + echo -n "checking if $lib is needed: " + libpath=$(ldd $1 | awk -v lib=$lib '$1 == lib { print $3 }') + list_libs="$list_libs $libpath" + foundone=0 + for fct in $(nm -D $libpath | awk '$2 == "T" || $2 == "W" || $2 == "B" { print $3 }'); do + nm -D $1 | awk -v s=$fct '$1 == "U" && $2 == s { found=1 ; exit } END { if (found != 1) { exit 1 } }' && foundone=1 && break + done + if [ $foundone -eq 1 ]; then + echo "yes" + else + echo "no" + fi +done + +for sym in $(nm -D $1 | awk '$1 == "U" { print $2 }'); do + found=0 + for l in ${list_libs} ; do + nm -D $l | awk -v s=$sym '($2 == "T" || $2 == "W" || $2 == "B") && $3 == s { found=1 ; exit } END { if (found != 1) { exit 1 } }' && found=1 && break + done + if [ $found -eq 0 ]; then + echo "Unresolved symbol $sym" + fi +done +