Andreas Gruenbacher cf4d7a
#! /bin/bash
Andreas Gruenbacher cf4d7a
Michal Marek 0a417c
#############################################################################
Michal Marek 0a417c
# Copyright (c) 2007 Novell, Inc.
Michal Marek 0a417c
# All Rights Reserved.
Michal Marek 0a417c
#
Michal Marek 0a417c
# This program is free software; you can redistribute it and/or
Michal Marek 0a417c
# modify it under the terms of version 2 of the GNU General Public License as
Michal Marek 0a417c
# published by the Free Software Foundation.
Michal Marek 0a417c
#
Michal Marek 0a417c
# This program is distributed in the hope that it will be useful,
Michal Marek 0a417c
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Michal Marek 0a417c
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   See the
Michal Marek 0a417c
# GNU General Public License for more details.
Michal Marek 0a417c
#
Michal Marek 0a417c
# You should have received a copy of the GNU General Public License
Michal Marek 0a417c
# along with this program; if not, contact Novell, Inc.
Michal Marek 0a417c
#
Michal Marek 0a417c
# To contact Novell about this file by physical or electronic mail,
Michal Marek 0a417c
# you may find current contact information at www.novell.com
Michal Marek 0a417c
#############################################################################
Michal Marek 0a417c
Andreas Gruenbacher 37fa00
# The symtypes file format is as follows:
Andreas Gruenbacher 37fa00
#
Andreas Gruenbacher 37fa00
#  * Each object file has its own, independent section in the symtypes file.
Andreas Gruenbacher 37fa00
#    Except to avoid repeated identical definitions as explained later, each
Andreas Gruenbacher 37fa00
#    of these sections is independent.
Andreas Gruenbacher 37fa00
#
Andreas Gruenbacher 37fa00
#  * Lines starting with x# are definitions of types that are used later.
Andreas Gruenbacher 37fa00
#    Only definitions that are actually used show up in the dump. Lines not
Andreas Gruenbacher 37fa00
#    starting with x# indicate an exported symbol, e.g.,
Andreas Gruenbacher 37fa00
#
Andreas Gruenbacher 37fa00
#    t#u32 typedef unsigned int u32
Andreas Gruenbacher 37fa00
#    acpi_register_gsi int acpi_register_gsi (t#u32, int, int)
Andreas Gruenbacher 37fa00
#
Andreas Gruenbacher 37fa00
#  * To keep the dumps reasonably small, identical definitions are not
Andreas Gruenbacher 37fa00
#    repeated. Instead, only the fact that a symbols is being defined is noted.
Andreas Gruenbacher 37fa00
#    So instead of the full t#u32 definition from above, only "t#u32" appears
Andreas Gruenbacher 37fa00
#    after the first definition. If a type is defined differently in different
Andreas Gruenbacher 37fa00
#    places, the full definitions are given.
Andreas Gruenbacher 37fa00
#
Andreas Gruenbacher 37fa00
#
Andreas Gruenbacher 37fa00
# The checksums are computed taking into consideration all the definitions
Andreas Gruenbacher 37fa00
# known, recursively. For example, wherever struct acpi_processor_tx is used,
Andreas Gruenbacher 37fa00
# the defintions of typedef u16 as well as struct acpi_processor_tx define
Andreas Gruenbacher 37fa00
# the result:
Andreas Gruenbacher 37fa00
#
Andreas Gruenbacher 37fa00
#    t#u16 typedef unsigned short u16
Andreas Gruenbacher 37fa00
#    s#acpi_processor_tx struct acpi_processor_tx {t#u16 power;
Andreas Gruenbacher 37fa00
#                                                  t#u16 performance}
Andreas Gruenbacher 37fa00
#
Andreas Gruenbacher 37fa00
# Forward declarations are a problem: if a symbol only has been forward
Andreas Gruenbacher 37fa00
# declared it may be used, but the checksum will not include its definition.
Andreas Gruenbacher 37fa00
# If the symbols's definition later becomes known before the symbol is used,
Andreas Gruenbacher 37fa00
# this will change the checksum even if the actual types did not change.
Andreas Gruenbacher 37fa00
# This is an unsolved problem.
Andreas Gruenbacher 37fa00
Andreas Gruenbacher cf4d7a
if [ $# -ne 2 ]; then
Andreas Gruenbacher cf4d7a
    echo "Usage: ${0##*/} <symtypes1.gz> <symtypes2.gz>"
Andreas Gruenbacher cf4d7a
    echo "Show the differences between two /boot/symtypes-*.gz files."
Andreas Gruenbacher cf4d7a
    exit
Andreas Gruenbacher cf4d7a
fi
Andreas Gruenbacher cf4d7a
Andreas Gruenbacher cf4d7a
verbose_symtypes() {
Andreas Gruenbacher cf4d7a
    # The symtypes dumps have repeated identical type definitions stripped out.
Andreas Gruenbacher cf4d7a
    # Fill in the stripped-out definition to make the diff easier to understand.
Andreas Gruenbacher cf4d7a
Michal Marek a57536
    gzip -df < "$1" \
Andreas Gruenbacher cf4d7a
    | awk '
Andreas Gruenbacher cf4d7a
	$1 ~ /^.#.*/ {
Andreas Gruenbacher cf4d7a
	    if (NF != 1)
Andreas Gruenbacher cf4d7a
		syms[$1] = $0;
Andreas Gruenbacher cf4d7a
	    print syms[$1];
Andreas Gruenbacher cf4d7a
	    next;
Andreas Gruenbacher cf4d7a
	}
Andreas Gruenbacher cf4d7a
	{ print }
Andreas Gruenbacher cf4d7a
    '
Andreas Gruenbacher cf4d7a
}
Andreas Gruenbacher cf4d7a
Andreas Gruenbacher cf4d7a
diff -U0 --show-function-line='^/\*' --label "$1" --label "$2" \
Andreas Gruenbacher cf4d7a
    <(verbose_symtypes "$1") <(verbose_symtypes "$2")