Blame SOURCES/find-provides.ksyms

67e50c
#! /bin/bash
67e50c
67e50c
IFS=$'\n'
67e50c
67e50c
for module in $(grep -E '/lib/modules/.+\.ko$'); do
67e50c
    if [[ -n $(nm $module | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):0x\1 \2:p') ]]; then
67e50c
        nm $module \
67e50c
        | sed -r -ne 's:^0*([0-9a-f]+) A __crc_(.+):0x\1 \2:p' \
67e50c
        | awk --non-decimal-data '{printf("ksym(%s) = 0x%08x\n", $2, $1)}' \
67e50c
        | LC_ALL=C sort -u
67e50c
    else
67e50c
        ELFRODATA=$(readelf -R .rodata $module | awk '/0x/{printf $2$3$4$5}')
67e50c
        if [[ -n $(readelf -h $module | grep "little endian") ]]; then
67e50c
            RODATA=$(echo $ELFRODATA | sed 's/\(..\)\(..\)\(..\)\(..\)/\4\3\2\1/g')
67e50c
        else
67e50c
            RODATA=$ELFRODATA
67e50c
        fi
67e50c
        for sym in $(nm $module | sed -r -ne 's:^0*([0-9a-f]+) R __crc_(.+):0x\1 \2:p'); do
67e50c
            echo $sym $RODATA
67e50c
        done \
67e50c
        | awk --non-decimal-data '{printf("ksym(%s) = 0x%08s\n", $2, substr($3,($1*2)+1,8))}' \
67e50c
        | LC_ALL=C sort -u
67e50c
    fi
67e50c
done