Technical article 104915

Relinking the kernel fails with "...can't allocate section .bss..."

OpenServer 5.0.0

Written · Last revised

Problem

When the kernel is relinked, it fails with this error:

ld locore.o 34: can't allocate section .bss into owner KV_loads
ld fatal: Error(s). No output written to unix
ERROR: Can not link-edit unix

Cause

The kernel has exceeded its maximum size, 8MB. This is usually caused by:

1. Increasing a kernel tunable to a very large value.

2. Adding a device driver that uses very large internal data structures.

Solution

In the case of "1. Increasing a kernel tunable to a very large value", check:

/etc/conf/cf.d/stune

to determine if any of the recommended maximums have been exceeded as defined in:

/etc/conf/cf.d/mtune

For any that seem too large, try reducing them by running the configure(ADM) utility.

In the case of "2. Adding a device driver that uses very large internal data structures", determine the sizes of the various device drivers on your system using the following procedure: Note: This will require the SCO Development System to be installed, which you may wish to consider removing from the kernel.

1. Cut the following shell script from this script and put it
   into a file,  for example, /tmp/sizeof. Make sure that the
   file is executable by running:
# chmod 755 /tmp/sizeof
-----8<-----cut here---8<------cut here---8<-------cut here-------8<-------
#!/bin/sh
#
# usage: sizeof <file> <file> ...
#
global_bss()
{
        /usr/ccs/bin/coff/nm -p $1 | grep " [cC] " | awk -F\| '
BEGIN   {
                total=0;
        }
        {
                total += $1
        }
END     {
                printf "%d\n", total
        }
'
}
bsize()
{
        file=$1
        tag=$2
        set -- `size $file`
        global=`global_bss $file`
        total=`expr $global + $7`
        global=`expr $global + $5`
        echo "$tag: $1(text) + $3(data) + $global(bss) = $total"
}
bss_archive()
{
        archive=$1
        base=`basename $1 .a`
        opwd=`pwd`
        full="$opwd/$1"
        dir=/tmp/${base}$$
        [ -d $dir ] || mkdir $dir
        cd $dir
        idar x $full
        for x in *
        do
                bsize $x "$archive[$x]"
        done
        cd $opwd
        rm -rf $dir
}
if [ $# -eq 0 ]
then
        echo "$0: usage: $0 <file> <file> ..."
        exit 1
fi

for x in "$@" do if [ -f $x ] then case $x in

                *.o)    bsize $x $x
                        ;;
                *.a)    bss_archive $x
                        ;;
                esac
        else
                echo "$0: $x not found"
        fi
done
exit 0
-----8<-----cut here---8<------cut here---8<-------cut here-------8<-------

2. Log in as the root user and:

# cd /etc/conf/cf.d
# ./link_unix -p

The kernel relink will still fail but this will leave behind all the space.o files which were generated when the kernel was linked.

3. Then:
# cd /etc/conf/pack.d

And run the above shell script with the space.o files as parameters.

For example, if the script is saved in /tmp/sizeof:

# /tmp/sizeof */space.o

Look for unusually large totals, for example:

spam/space.o: 0(text) + 32(data) + 8000480(bss) = 8000512

This shows that the "spam" driver's space.o file allocates nearly 8MB of space.

If investigating the space.o files does not reveal anything, you can try the Driver.o files:

# /tmp/sizeof */Driver.o

Although the above is not a real example, note that drivers can be easily excluded from kernel relinks by editing:

/etc/conf/sdevice.d/<driver name>

and changing any "Y" in the file to an "N".

NOTE:     Editing a driver's sdevice file may cause subsequent
          kernel relink errors.

Where possible you should use the mkdev(ADM) scripts to remove SCO supplied device drivers, or refer to the documentation supplied with your 3rd party device driver to determine the recommended driver removal procedure.

See also

configure(ADM); link_unix(ADM); mtune(F); stune(F); mkdev(ADM);
size(ADM); nm(ADM)

From the Xinuos technical article database, record 104915. Reproduced with permission. The original is at www.sco.com/ta/104915, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.