I just want to report that, I do not know if it shall be considered as a bug, as bad use, as undocumented feature:
Lets compile some Linux kernel with Fedora 6 default toolchain: [EMAIL PROTECTED] ~]$ ld --version GNU ld version 2.17.50.0.3-6 20060715 [EMAIL PROTECTED] ~]$ readelf -v GNU readelf 2.17.50.0.3-6 20060715 [EMAIL PROTECTED] tmp]$ tar xjf ../linux2/linux-2.6.20.tar.bz2 [EMAIL PROTECTED] tmp]$ cd linux-2.6.20 [EMAIL PROTECTED] linux-2.6.20]$ cp ../../linux2/linux-2.6.20-gujin/.config . [EMAIL PROTECTED] linux-2.6.20]$ make oldconfig > log [EMAIL PROTECTED] linux-2.6.20]$ make vmlinux >> log ... few warnings ... [EMAIL PROTECTED] linux-2.6.20]$ readelf -l vmlinux Elf file type is EXEC (Executable file) Entry point 0x100000 There are 3 program headers, starting at offset 52 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x001000 0xc0100000 0x00100000 0x3995e0 0x3995e0 R E 0x1000 LOAD 0x39b000 0xc049a000 0x0049a000 0x75085 0xaf000 RWE 0x1000 NOTE 0x000000 0x00000000 0x00000000 0x00000 0x00000 R 0x4 Section to Segment mapping: Segment Sections... 00 .text __ex_table .rodata .pci_fixup __param 01 .data .data_nosave .data.page_aligned .data.cacheline_aligned .data.read_mostly .data.init_task .init.text .init.data .init.setup .initcall.init .con_initcall.init .security_initcall.init .altinstructions .altinstr_replacement .exit.text .init.ramfs .bss 02 [EMAIL PROTECTED] linux-2.6.20]$ OK, everything is fine. The ld script affects manually the program header by: /* arch/i386/kernel/vmlinux.lds.S */ PHDRS { text PT_LOAD FLAGS(5); /* R_E */ data PT_LOAD FLAGS(7); /* RWE */ note PT_NOTE FLAGS(4); /* R__ */ } And the text section goes to the :text program header, it is linked at a fixed address. .text : AT(ADDR(.text) - LOAD_OFFSET) { ... } :text = 0x9090 Now I want to create another text section - I was thinking that a new program header would be added or an error message because I create it a another address, using the patch at sourceforge at: http://sourceforge.net/project/showfiles.php?group_id=15465&package_id=174813&release_id=482035 The important extract is: SECTIONS { .realmode 0 : AT (ADDR(.bss) + SIZEOF(.bss) - LOAD_OFFSET) { ... all my sections ... } :text = 0x9090 . = 0xc0000000 ; /* or more */ .text : AT(ADDR(.text) - LOAD_OFFSET) { ... original part ... } :text = 0x9090 [EMAIL PROTECTED] linux-2.6.20]$ patch -p1 < ../../linux/gujin-patch-2.6.20-rc5 patching file arch/i386/Kconfig patching file arch/i386/kernel/Makefile patching file arch/i386/kernel/realmode.c patching file arch/i386/kernel/setup.c patching file arch/i386/kernel/vmlinux.lds.S patching file arch/i386/Makefile patching file include/asm-i386/realmode.h patching file Makefile patching file scripts/gzcopy.c patching file scripts/gzparam.c [EMAIL PROTECTED] linux-2.6.20]$ make linux-2.6.20.kgz > log But nothing change and I do not get any warning or error for a section containing code not linked to a program header: [EMAIL PROTECTED] linux-2.6.20]$ readelf -l vmlinux Elf file type is EXEC (Executable file) Entry point 0x100000 There are 3 program headers, starting at offset 52 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x001000 0xc0100000 0x00100000 0x44a830 0x44a830 R E 0x1000 LOAD 0x44c000 0xc049a000 0x0049a000 0x75085 0xaf000 RWE 0x1000 NOTE 0x000000 0x00000000 0x00000000 0x00000 0x00000 R 0x4 Section to Segment mapping: Segment Sections... 00 .bss .text __ex_table .rodata .pci_fixup __param .data .data_nosave .data.page_aligned .data.cacheline_aligned .data.read_mostly .data.init_task .init.text .init.data .init.setup .initcall.init .con_initcall.init .security_initcall.init .altinstructions .altinstr_replacement .exit.text .init.ramfs 01 .bss .data .data_nosave .data.page_aligned .data.cacheline_aligned .data.read_mostly .data.init_task .init.text .init.data .init.setup .initcall.init .con_initcall.init .security_initcall.init .altinstructions .altinstr_replacement .exit.text .init.ramfs 02 [EMAIL PROTECTED] linux-2.6.20]$ And there is something wrong once using strip from this file: [EMAIL PROTECTED] linux-2.6.20]$ objcopy -S vmlinux vmlinux.stripped BFD: vmlinux.stripped: warning: allocated section `.realmode' not in segment [EMAIL PROTECTED] linux-2.6.20]$ readelf -l vmlinux.stripped Elf file type is EXEC (Executable file) Entry point 0x100000 There are 3 program headers, starting at offset 52 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x001000 0xc0100000 0x00100000 0x40f085 0x449000 R E 0x1000 LOAD 0x411000 0xc049a000 0x0049a000 0x75085 0xaf000 RWE 0x1000 NOTE 0x000000 0x00000000 0x00000000 0x00000 0x00000 R 0x4 Section to Segment mapping: Segment Sections... 00 .bss .text __ex_table .rodata .pci_fixup __param .data .data_nosave .data.page_aligned .data.cacheline_aligned .data.read_mostly .data.init_task .init.text .init.data .init.setup .initcall.init .con_initcall.init .security_initcall.init .altinstructions .altinstr_replacement .exit.text .init.ramfs 01 .bss .data .data_nosave .data.page_aligned .data.cacheline_aligned .data.read_mostly .data.init_task .init.text .init.data .init.setup .initcall.init .con_initcall.init .security_initcall.init .altinstructions .altinstr_replacement .exit.text .init.ramfs 02 [EMAIL PROTECTED] linux-2.6.20]$ Note that the first program header MemSiz overlap the second program header: 0x00100000 + 0x449000 > 0x0049a000 And the two FileSiz are not aligned so the memset at PhysAddr+FileSiz is done at an unaligned address so will be slow. I do not know what should be the behaviour, just something seems wrong. Something completely different, when using the linux patch I posted on LKM, where a new program header is created for this section, and is removed if i want to get rid of the section .realmode completely because I want to generate the old target, you can ask me the question: [EMAIL PROTECTED] linux-2.6.20-gujin]$ objcopy -R .note -R .comment -R .realmode -S vmlinux vmlinux.tmp BFD: vmlinux: warning: Empty loadable segment detected, is this intentional ? [EMAIL PROTECTED] linux-2.6.20-gujin]$ My answer is that it is not needed to keep this empty loadable segment, you can strip it. I do not care of the warning because that command is used "-O binary" by Linux Makefile and does not produce the warning. Thanks, Etienne. -- Summary: problems with linker / strip / BFD Product: binutils Version: 2.17 Status: NEW Severity: normal Priority: P2 Component: binutils AssignedTo: unassigned at sources dot redhat dot com ReportedBy: etienne_lorrain at yahoo dot fr CC: bug-binutils at gnu dot org GCC build triplet: i386-redhat-linux GCC host triplet: i386-redhat-linux GCC target triplet: i386-redhat-linux http://sourceware.org/bugzilla/show_bug.cgi?id=4007 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils