Subject: Re: kern/21844: netwinder kernal cannot be linked because link_set_* sections overlap with .data
To: None <tech-toolchain@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: tech-toolchain
Date: 06/12/2003 13:33:10
In article <m3adcnq5yy.fsf@gossamer.airs.com>,
Ian Lance Taylor <ian@airs.com> wrote:

Well, as long as we are on the subject of gld, I have a question:
I am trying to put a NetBSD ident section in the kernel. The code
is #ifdef notyet in /usr/src/sys/conf/newvers.sh because I don't
know how to convince the linker to work. When I enable it, the
linker prints:

    ld: netbsd: Not enough room for program headers (allocated 3, need 4)
    ld: final link failed: Bad value

This is because the ident section is:

__asm(
        ".section\t\".note.netbsd.ident\", \"a\"\n"
        "\t.p2align\t2\n"
        "\t.long\t" _S(ELF_NOTE_NETBSD_NAMESZ) "\n"
        "\t.long\t" _S(ELF_NOTE_NETBSD_DESCSZ) "\n"
        "\t.long\t" _S(ELF_NOTE_TYPE_NETBSD_TAG) "\n"
        "\t.ascii\t" _S(ELF_NOTE_NETBSD_NAME) "\n"
        "\t.long\t" _S(__NetBSD_Version__) "\n"
        "\t.p2align\t2\n"
);

And this ident section causes another program header to be allocated?!?
How do I fix this?

christos

>I don't know what ``as-is'' would mean in this case.  Anyhow, if the
>GNU linker docs imply that, they are wrong.  The GNU linker for ELF
>sorts orphaned sections by guessing where it thinks they should go
>based on their characteristics.
>
>If the docs are really misleading, I encourage you to send a bug
>report to binutils@sources.redhat.com, or just to me.
>
>Ian