Subject: Re: ELF ld bug or do I misunderstand the concept?
To: None <is@jocelyn.rhein.de, tech-toolchain@netbsd.org>
From: Ross Harvey <ross@teraflop.com>
List: tech-toolchain
Date: 09/07/1998 15:03:18
> a) the section table, with entries for .text, .data, .bss, and some
> strange ones.
>
> b) the Program header, intended for actual program loading, only describing
> memory regions needed for an executable file loader.
>
> While playing around with my cross-toolchain, trying to verify what I
> understood, I found this (see the test.dump attachment):
>
> idx name size vma lma file off alignment
>
> 5 .sbss 00000000 f000082c f000082c 000008a0 2**0
> CONTENTS
> 6 .bss 00000100 f0000830 f0000830 000008a0 2**4
> ALLOC
>
> As I understand, the .bss should be 16 byte aligned, and is thus moved to
> virtual offset f0000830 -- f000092f (instead of f000082c -- f00009cb).
>
> The _end symbol tells the same story:
>
> f0000930 g O *ABS* 00000000 _end
>
> However, in the program header, we have:
>
> LOAD off 0x00000074 vaddr 0xf0000000 paddr 0xf0000000 align 2**4
> filesz 0x0000082c memsz 0x0000092c flags rwx
>
> which tells me that the program header generating code didn't notice that .bss
> was moved to satisfy its alignment restrictions.
>
> a) do I read this wrongly?
> b) if no: was this noticed (and fixed) in newer ld code?
Are you objecting to the filesz==082c or to the memesz==92c? I also will
guess that you really meant to say 82c-92b => 830-92f.
If the former, that looks fine to me. Remember that the bss sections don't
actually exist in the image file. The linker just assumes that the kernel
or run-time loader will set them up when the image is loaded...these days
with virtual zfod pages. So bss origin adjustment wouldn't actually affect
the origin or sizes of the text and data sections of the disk file
If the later, well, it's hard to imagine what a summary field really is
good for, and it _does_ still accurately reflect the sum total of the sizes.
The size would only change if the sections were contiguous. Since the
sections are loaded separately anyway...
(I hope there wasn't some more subtle meaning here that went right over
my head. :-)
--Ross Harvey