[Kos-dev] Not a bug, just a strange thing with recent binutils
Thomas Petazzoni
kos-dev@enix.org
Wed, 30 May 2001 16:38:59 +0200
hi,
I told you in previous e-mails that recent binutils (2.11.90 for
instance) generated two program headers, when old binutils (2.9.5 or
2.10) generated only one program header with the same set of sources !
in fact we used the link script below
******** First link script ***************
OUTPUT_FORMAT("elf32-i386","elf32-i386","elf32-i386");
ENTRY(_start)
OUTPUT_ARCH("i386")
SECTIONS {
. = 0x200000 + SIZEOF_HEADERS;
_b_loader = .;
. = ALIGN(4096);
.text : { *(.text)
etext = .; _etext = .; }
.data : { *(.data)
edata = .; _edata = .; }
.bss : { *(.bss) *(COMMON)
end = .; _end = .; }
_e_loader = .;
}
********* End of first link script **************
and with this script, the binary file contained only one program header
with old version of binutils. and grub was able to load it, everything
worked well.
then we used the same link script (why changing ?) with recent binutils
and it didn't work anymore. grub wasn't able to laod the file because
there was 2 program headers. strange. i said it was a bug. but if you
use the following link script
************ Second link script *************
OUTPUT_FORMAT("elf32-i386","elf32-i386","elf32-i386");
ENTRY(_start)
OUTPUT_ARCH("i386")
SECTIONS {
. = 0x200000 + SIZEOF_HEADERS;
_b_loader = .;
. = ALIGN(4096);
.text : { *(.text)
etext = .; _etext = .; }
.data : { *(.data) *(.rodata) <=== i just added
.rodata here !
edata = .; _edata = .; }
.bss : { *(.bss) *(COMMON)
end = .; _end = .; }
_e_loader = .;
}
*************** End of second link script ************
everything worked well again, only one program header was generated even
with recent binutils, and grub was happy.
Conclusion : it was not really a bug, but there's still a problem,
binutils do not generate the same number of program headers, with the
same set of sources. i don't know when to put two or more program
headers, but i know grub is now very happy :)
thx for all,
thomas
--
PETAZZONI Thomas
thomas.petazzoni@meridon.com
ICQ : 34937744
Projet KOS : http://kos.enix.org