Bug 11490 - gold: unbootable Linux kernel, wrong alignment for .rodata/.text ". = ALIGN((1 << 21));"
Summary: gold: unbootable Linux kernel, wrong alignment for .rodata/.text ". = ALIGN((...
Status: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.21
: P2 normal
Target Milestone: ---
Assignee: Ian Lance Taylor
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-12 18:03 UTC by Török Edwin
Modified: 2010-04-22 21:22 UTC (History)
1 user (show)

See Also:
Host: x86_64-linux-gnu
Target: x86_64-linux-gnu
Build: x86_64-linux-gnu
Last reconfirmed:


Attachments
working kernel .config (14.99 KB, text/plain)
2010-04-12 18:06 UTC, Török Edwin
Details
not working .config (14.99 KB, text/plain)
2010-04-12 18:07 UTC, Török Edwin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Török Edwin 2010-04-12 18:03:26 UTC
Tried to compile Linux 2.6.33, and 2.6.34-rc3 with gold.
Linking succeeded, but it fails to boot, it just keeps on rebooting.

To reproduce (you can also download just the tarball, but its easier if you just
clone if you want to test multiple versions):
1. git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
2. git checkout v2.6.34-rc3 (or v2.6.33)
3. Use my attached .config on x86-64
4. Build it, I used gcc version 4.4.3 (Debian 4.4.3-7), and
GNU gold (GNU Binutils 2.20.51.20100410) 1.9

gold was built from CVS, with a simple --enable-gold, make all-gold,
and then copying ld-new to /usr/local/bin/ld, clearing bash's cache (hash -r),
and building Linux using 'make'.

5. Try to boot it either on a real system, or with qemu-system-x86_64/kvm
(recommended):
kvm -kernel arch/x86/boot/bzImage

On a failed boot you just see the BIOS version flashing, and no messages from
the kernel.

6. Use the normal (non-gold/bfd) linker, I used GNU ld (GNU Binutils for Debian)
2.20.1-system.20100303.
7. make clean
8. make 
Try to boot the kernel with kvm/qemu as above.
On a successful boot you should see some kernel messages, and finally a kernel
panic because we didn't provide it a disk to boot from.

(Note: you could also just rm vmlinux, and make bzImage, but if you keep moving
from gold to system linker and back at some point it'll complain about wrong
kallsyms values).

This is the KVM I used, but you can try to boot the kernel with anything that
would normally boot it.
QEMU PC emulator version 0.12.3 (qemu-kvm-0.12.3), Copyright (c) 2003-2008
Fabrice Bellard

See the discussion here (and earlier):
http://sourceware.org/ml/binutils/2010-04/msg00141.html
http://sourceware.org/ml/binutils/2010-04/msg00139.html

". = ALIGN((1 << 21));" should propagate to .p_align, but doesn't.

Will attach an updated diff of section/program headers as requested on the ML.
Comment 1 Török Edwin 2010-04-12 18:06:05 UTC
Created attachment 4717 [details]
working kernel .config

This .config results in a working kernel. It doesn't need the 2MB alignment.
Comment 2 Török Edwin 2010-04-12 18:07:38 UTC
Created attachment 4718 [details]
not working .config

When built with this .config and gold, kernel fails to boot.
With the usual LD it works fine.
Comment 3 Török Edwin 2010-04-12 18:35:52 UTC
head of eu-readelf -a diff of CVS gold vs BFD ld (- gold, + bfd):

--- egold	2010-04-12 21:33:46.000000000 +0300
+++ ebfd	2010-04-12 21:33:50.000000000 +0300
@@ -10,63 +10,63 @@
   Version:                           1 (current)
   Entry point address:               0x1000000
   Start of program headers:          64 (bytes into file)
-  Start of section headers:          10864240 (bytes into file)
+  Start of section headers:          14721456 (bytes into file)
   Flags:                             
   Size of this header:               64 (bytes)
   Size of program header entries:    56 (bytes)
   Number of program headers entries: 6
   Size of section header entries:    64 (bytes)
   Number of section headers entries: 37
-  Section header string table index: 36
+  Section header string table index: 34
 
 Section Headers:
 [Nr] Name                 Type         Addr             Off      Size     ES
Flags Lk Inf Al
 [ 0]                      NULL         0000000000000000 00000000 00000000  0  
     0   0  0
-[ 1] .text                PROGBITS     ffffffff81000000 00001000 003d0bd5  0 AX
    0   0 4096
-[ 2] .notes               NOTE         ffffffff813d0bd8 003d1bd8 00000024  0 A
     0   0  4
-[ 3] __ex_table           PROGBITS     ffffffff813d0c00 003d1c00 000040c0  0 A
     0   0  8
-[ 4] .rodata              PROGBITS     ffffffff81400000 00401000 001b6972  0 A
     0   0 64
-[ 5] __bug_table          PROGBITS     ffffffff815b6978 005b7978 000053f4  0 A
     0   0  1
-[ 6] .pci_fixup           PROGBITS     ffffffff815bbd70 005bcd70 00001720  0 A
     0   0 16
-[ 7] __ksymtab            PROGBITS     ffffffff815bd490 005be490 0000bc00  0 A
     0   0 16
-[ 8] __ksymtab_gpl        PROGBITS     ffffffff815c9090 005ca090 00005e30  0 A
     0   0 16
-[ 9] __kcrctab            PROGBITS     ffffffff815ceec0 005cfec0 00005e00  0 A
     0   0  8
-[10] __kcrctab_gpl        PROGBITS     ffffffff815d4cc0 005d5cc0 00002f18  0 A
     0   0  8
-[11] __ksymtab_strings    PROGBITS     ffffffff815d7bd8 005d8bd8 00013d9a  0 A
     0   0  1
-[12] __init_rodata        PROGBITS     ffffffff815eb980 005ec980 00003bc0  0 A
     0   0 16
-[13] __param              PROGBITS     ffffffff815ef540 005f0540 00001ac0  0 A
     0   0  8
-[14] .data                PROGBITS     ffffffff81600000 005f2000 00182f60  0 WA
    0   0 4096
-[15] .vsyscall_0          PROGBITS     ffffffffff600000 00775000 000000ce  0 AX
    0   0  1
-[16] .vsyscall_fn         PROGBITS     ffffffffff600100 00775100 0000003f  0 AX
    0   0  1
-[17] .vsyscall_gtod_data  PROGBITS     ffffffffff600140 00775140 00000060  0 WA
    0   0 16
-[18] .vsyscall_1          PROGBITS     ffffffffff600400 00775400 0000003c  0 AX
    0   0  1
-[19] .vsyscall_2          PROGBITS     ffffffffff600800 00775800 00000066  0 AX
    0   0  1
-[20] .vgetcpu_mode        PROGBITS     ffffffffff600870 00775870 00000004  0 WA
    0   0 16
-[21] .jiffies             PROGBITS     ffffffffff600880 00775880 00000008  0 WA
    0   0 16
-[22] .data.percpu         PROGBITS     0000000000000000 00776000 00014628  0 WA
    0   0 4096
-[23] .init.text           PROGBITS     ffffffff81799000 0078b000 0002fde3  0 AX
    0   0 16
-[24] .init.data           PROGBITS     ffffffff817c8df0 007badf0 00035410  0 WA
    0   0 16
-[25] .x86_cpu_dev.init    PROGBITS     ffffffff817fe200 007f0200 00000018  0 A
     0   0  8
-[26] .altinstructions     PROGBITS     ffffffff817fe218 007f0218 00000a4c  0 A
     0   0  8
-[27] .altinstr_replacement PROGBITS     ffffffff817fec64 007f0c64 00000266  0
AX     0   0  1
-[28] .exit.text           PROGBITS     ffffffff817feeca 007f0eca 00000cbe  0 AX
    0   0  1
-[29] .smp_locks           PROGBITS     ffffffff81800000 007f2000 00009000  0 A
     0   0  8
-[30] .data_nosave         PROGBITS     ffffffff81809000 007fb000 00001000  0 WA
    0   0  4
-[31] .bss                 NOBITS       ffffffff8180a000 007fc000 044db158  0 WA
    0   0 4096
-[32] .brk                 NOBITS       ffffffff85ce6000 04cd8000 00020000  0 WA
    0   0  1
-[33] .comment             PROGBITS     0000000000000000 007fc000 0000001d  1 MS
    0   0  1
-[34] .symtab              SYMTAB       0000000000000000 007fc020 0013a238 24  
    35 37376  8
-[35] .strtab              STRTAB       0000000000000000 00936258 00126280  0  
     0   0  1
-[36] .shstrtab            STRTAB       0000000000000000 00a5c4d8 00000192  0  
     0   0  1
+[ 1] .text                PROGBITS     ffffffff81000000 00200000 003d0bd5  0 AX
    0   0 4096
+[ 2] .notes               NOTE         ffffffff813d0bd8 005d0bd8 00000024  0 AX
    0   0  4
+[ 3] __ex_table           PROGBITS     ffffffff813d0c00 005d0c00 000040c0  0 A
     0   0  8
+[ 4] .rodata              PROGBITS     ffffffff81400000 00600000 001b2f02  0 A
     0   0 64
+[ 5] __bug_table          PROGBITS     ffffffff815b2f08 007b2f08 000053f4  0 A
     0   0  1
+[ 6] .pci_fixup           PROGBITS     ffffffff815b8300 007b8300 00001720  0 A
     0   0 16
+[ 7] __ksymtab            PROGBITS     ffffffff815b9a20 007b9a20 0000bc00  0 A
     0   0 16
+[ 8] __ksymtab_gpl        PROGBITS     ffffffff815c5620 007c5620 00005e30  0 A
     0   0 16
+[ 9] __kcrctab            PROGBITS     ffffffff815cb450 007cb450 00005e00  0 A
     0   0  8
+[10] __kcrctab_gpl        PROGBITS     ffffffff815d1250 007d1250 00002f18  0 A
     0   0  8
+[11] __ksymtab_strings    PROGBITS     ffffffff815d4168 007d4168 00013d9a  0 A
     0   0  1
+[12] __init_rodata        PROGBITS     ffffffff815e7f10 007e7f10 00003bc0  0 A
     0   0 16
+[13] __param              PROGBITS     ffffffff815ebad0 007ebad0 00001530  0 A
     0   0  8
+[14] .data                PROGBITS     ffffffff81600000 00800000 00182f60  0 WA
    0   0 4096
+[15] .vsyscall_0          PROGBITS     ffffffffff600000 00a00000 000000ce  0 AX
    0   0  1
+[16] .vsyscall_fn         PROGBITS     ffffffffff600100 00a00100 0000003f  0 AX
    0   0  1
+[17] .vsyscall_gtod_data  PROGBITS     ffffffffff600140 00a00140 00000060  0 WA
    0   0 16
+[18] .vsyscall_1          PROGBITS     ffffffffff600400 00a00400 0000003c  0 AX
    0   0  1
+[19] .vsyscall_2          PROGBITS     ffffffffff600800 00a00800 00000066  0 AX
    0   0  1
+[20] .vgetcpu_mode        PROGBITS     ffffffffff600870 00a00870 00000004  0 WA
    0   0 16
+[21] .jiffies             PROGBITS     ffffffffff600880 00a00880 00000008  0 WA
    0   0 16
+[22] .data.percpu         PROGBITS     0000000000000000 00c00000 00014628  0 WA
    0   0 4096
+[23] .init.text           PROGBITS     ffffffff81799000 00d99000 0002fde3  0 AX
    0   0 16
+[24] .init.data           PROGBITS     ffffffff817c8df0 00dc8df0 00035410  0 WA
    0   0 16
+[25] .x86_cpu_dev.init    PROGBITS     ffffffff817fe200 00dfe200 00000018  0 A
     0   0  8
+[26] .altinstructions     PROGBITS     ffffffff817fe218 00dfe218 00000a4c  0 A
     0   0  8
+[27] .altinstr_replacement PROGBITS     ffffffff817fec64 00dfec64 00000266  0
AX     0   0  1
+[28] .exit.text           PROGBITS     ffffffff817feeca 00dfeeca 00000cbe  0 AX
    0   0  1
+[29] .smp_locks           PROGBITS     ffffffff81800000 00e00000 00009000  0 A
     0   0  8
+[30] .data_nosave         PROGBITS     ffffffff81809000 00e09000 00001000  0 WA
    0   0  4
+[31] .bss                 NOBITS       ffffffff8180a000 00e0a000 044db158  0 WA
    0   0 4096
+[32] .brk                 NOBITS       ffffffff85ce6000 00e0a000 00020000  0 WA
    0   0  1
+[33] .comment             PROGBITS     0000000000000000 00e0a000 0000001c  1 MS
    0   0  1
+[34] .shstrtab            STRTAB       0000000000000000 00e0a01c 00000192  0  
     0   0  1
+[35] .symtab              SYMTAB       0000000000000000 00e0aaf0 00138018 24  
    36 37012  8
+[36] .strtab              STRTAB       0000000000000000 00f42b08 001261ae  0  
     0   0  1
 
 Program Headers:
   Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz
  Flg Align
-  LOAD           0x001000 0xffffffff81000000 0x0000000001000000 0x5f1000
0x5f1000 R E 0x1000
-  LOAD           0x5f2000 0xffffffff81600000 0x0000000001600000 0x182f60
0x182f60 RWE 0x1000
-  LOAD           0x775000 0xffffffffff600000 0x0000000001783000 0x000888
0x000888 R E 0x1000
-  LOAD           0x776000 0x0000000000000000 0x0000000001784000 0x014628
0x014628 RW  0x1000
-  LOAD           0x78b000 0xffffffff81799000 0x0000000001799000 0x071000
0x456d000 RWE 0x1000
-  NOTE           0x3d1bd8 0xffffffff813d0bd8 0x00000000013d0bd8 0x000024
0x000024     0x4
+  LOAD           0x200000 0xffffffff81000000 0x0000000001000000 0x5ed000
0x5ed000 R E 0x200000
+  LOAD           0x800000 0xffffffff81600000 0x0000000001600000 0x182f60
0x182f60 RWE 0x200000
+  LOAD           0xa00000 0xffffffffff600000 0x0000000001783000 0x000888
0x000888 R E 0x200000
+  LOAD           0xc00000 0x0000000000000000 0x0000000001784000 0x014628
0x014628 RW  0x200000
+  LOAD           0xd99000 0xffffffff81799000 0x0000000001799000 0x071000
0x456d000 RWE 0x200000
+  NOTE           0x5d0bd8 0xffffffff813d0bd8 0x00000000013d0bd8 0x000024
0x000024     0x4
 
  Section to Segment mapping:
   Segment Sections...
@@ -77,53624 +77,53260 @@
    04      .init.text .init.data .x86_cpu_dev.init .altinstructions
.altinstr_replacement .exit.text .smp_locks .data_nosave .bss .brk
    05      [RO: .notes]
 
-Symbol table [34] '.symtab' contains 53613 entries:
- 37376 local symbols  String table: [35] '.strtab'
+Symbol table [35] '.symtab' contains 53249 entries:
+ 37012 local symbols  String table: [36] '.strtab'
   Num:            Value   Size Type    Bind   Vis          Ndx Name
     0: 0000000000000000      0 NOTYPE  LOCAL  DEFAULT    UNDEF 
Comment 4 H.J. Lu 2010-04-22 21:22:06 UTC
A patch is posted at

http://sourceware.org/ml/binutils/2010-04/msg00338.html