Skip to contentSkip to conversation

need NOTES in vmlinux.lds.S

PATCH David Mosberger-Tang 4 participants 5 messages Aug 9, 2007

lore
Share & tools
lore
#0 lore raw

Without the attached patch, the current GIT trees fail to build for me with error:

ld: .tmp_vmlinux1: section `.text' can't be allocated in segment 0
ld: final link failed: Bad value

This is with binutils v2.17.50.20070804 and is apparently due to the recent --build-id changes (see
http://www.uwsg.indiana.edu/hypermail/linux/kernel/0707.2/3490.html).

I may not have picked the best possible place to stick the NOTES macro (according to Roland, it should only be a few read-only bytes that are hardly ever read), but at least the kernel builds again and it even seems to boot (on my zx2000, anyhow). ;-)

Thanks to HJ Lu for his help in tracking down this bug.

--david
--
Mosberger Consulting LLC, http://www.mosberger-consulting.com/

[IA64] Add NOTES to linker script such that the kernel can be built with
recent versions of binutils. Without this patch, final link fails with this error:

ld: .tmp_vmlinux1: section `.text' can't be allocated in segment 0
ld: final link failed: Bad value

This error is due to the fact that the --build-id option is used with newer linkers to include a .notes section on the kernel, but without the NOTES macro, that section won't be included in the kernel which then leads to the above error message.

arch/ia64/kernel/vmlinux.lds.S +2 -0
index 83e8067..71eb550 100644
@@ -62,6 +62,8 @@ SECTIONS
 
   /* Read-only data */
 
+  NOTES
+
   /* Exception table */
   . = ALIGN(16);
   __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET)
#1 lore raw

That placement is probably fine (the standard size is 36 bytes, so don't fret too much about how optimal its location is). Since ia64 has an explicit PHDRS, it would be ideal to add there a "note PT_NOTE" and then use:

NOTES :code :note
code_continues : { } :code

Instead of the second line you can append :code to the next brace group. (Without one or the other, the following sections will also be included in the size of the PT_NOTE segment.)

Adding the PT_NOTE phdr is not essential, but it keeps vmlinux holding to that standard ELF convention, and it's what the other machines do.

Thanks,
Roland

#2 lore raw
In reply to David Mosberger-Tang
Quoted 7 lines · Roland McGrath

That placement is probably fine (the standard size is 36 bytes, so don't fret too much about how optimal its location is). Since ia64 has an explicit PHDRS, it would be ideal to add there a "note PT_NOTE" and then use:

NOTES :code :note
code_continues : { } :code

Quoted 6 lines

Instead of the second line you can append :code to the next brace group. (Without one or the other, the following sections will also be included in the size of the PT_NOTE segment.)

Adding the PT_NOTE phdr is not essential, but it keeps vmlinux holding to that standard ELF convention, and it's what the other machines do.

Sure, that sounds reasonable. Updated patch attached.

I tried this patch with Linus' 2.6.23-rc2 tree and the resulting kernel boots fine, though there are some scary-looking error messages:

WARNING: at /data/sc/linux-2.6/kernel/irq/resend.c:70 check_irq_resend()

Call Trace:
 [<a0000001000132e0>] show_stack+0x80/0xa0
                                sp=e00000407ff97bc0 bsp=e00000407ff90f58
 [<a000000100013330>] dump_stack+0x30/0x60
                                sp=e00000407ff97d90 bsp=e00000407ff90f40
 [<a0000001000db860>] check_irq_resend+0x1e0/0x200
                                sp=e00000407ff97d90 bsp=e00000407ff90ef8
 [<a0000001000dadd0>] enable_irq+0x210/0x240
                                sp=e00000407ff97d90 bsp=e00000407ff90ec8
 [<a0000001004f9aa0>] probe_hwif+0x440/0x1800
                                sp=e00000407ff97d90 bsp=e00000407ff90db0
 [<a0000001004fc7d0>] probe_hwif_init_with_fixup+0x30/0x180
                                sp=e00000407ff97d90 bsp=e00000407ff90d80
 [<a0000001005037c0>] ide_setup_pci_device+0x160/0x1c0
                                sp=e00000407ff97d90 bsp=e00000407ff90d40
 [<a0000001004e2670>] init_setup_cmd64x+0x30/0x60
                                sp=e00000407ff97da0 bsp=e00000407ff90d18
 [<a0000001004e25c0>] cmd64x_init_one+0x140/0x160
                                sp=e00000407ff97da0 bsp=e00000407ff90cf0
 [<a000000100933a10>] ide_scan_pcidev+0xf0/0x180
                                sp=e00000407ff97e00 bsp=e00000407ff90cb8
 [<a000000100933b20>] ide_scan_pcibus+0x80/0x2e0
                                sp=e00000407ff97e00 bsp=e00000407ff90c80
 [<a0000001009338c0>] ide_init+0xc0/0x120
                                sp=e00000407ff97e00 bsp=e00000407ff90c60
 [<a0000001009003c0>] kernel_init+0x1a0/0x6a0
                                sp=e00000407ff97e00 bsp=e00000407ff90c00
 [<a0000001000113b0>] kernel_thread_helper+0xd0/0x100
                                sp=e00000407ff97e30 bsp=e00000407ff90bd0
 [<a000000100008dc0>] start_kernel_thread+0x20/0x40
                                sp=e00000407ff97e30 bsp=e00000407ff90bd0

and a bunch of these:

target0:0:6: FAST-80 WIDE SCSI 160.0 MB/s DT (12.5 ns, offset 62)
sd 0:0:6:0: [sdb] Device not ready: <6>: Sense Key : Not Ready [current] : Add. Sense: Logical unit not ready, initializing command required

However, the kernel still works fine, as near as I can tell and I don't think these errors are due to my patch. ;-)

Tony, can you apply this to your tree?

--david

Signature · 1 line
Mosberger Consulting LLC, http://www.mosberger-consulting.com/

[IA64] Add NOTES to linker script such that the kernel can be built with
recent versions of binutils. Without this patch, final link fails with this error:

ld: .tmp_vmlinux1: section `.text' can't be allocated in segment 0
ld: final link failed: Bad value

This error is due to the fact that the --build-id option is used with newer linkers to include a .notes section on the kernel, but without the NOTES macro, that section won't be included in the kernel which then leads to the above error message.

arch/ia64/kernel/vmlinux.lds.S +4 -4
index 83e8067..446f12d 100644
@@ -20,6 +20,7 @@ PHDRS {
   code   PT_LOAD;
   percpu PT_LOAD;
   data   PT_LOAD;
+  note   PT_NOTE;
 }
 SECTIONS
 {
@@ -62,6 +63,9 @@ SECTIONS
 
   /* Read-only data */
 
+  NOTES :code :note		/* put .notes in text and mark in PT_NOTE  */
+  code_continues : {} :code	/* switch back to regular program...  */
+
   /* Exception table */
   . = ALIGN(16);
   __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET)
@@ -276,10 +280,6 @@ SECTIONS
   .debug_typenames 0 : { *(.debug_typenames) }
   .debug_varnames  0 : { *(.debug_varnames) }
   /* These must appear regardless of  .  */
-  /* Discard them for now since Intel SoftSDV cannot handle them.
-  .comment 0 : { *(.comment) }
-  .note 0 : { *(.note) }
-  */
   /DISCARD/ : { *(.comment) }
   /DISCARD/ : { *(.note) }
 }
#3 lore raw
In reply to David Mosberger-Tang
Quoted 4 lines

Sure, that sounds reasonable. Updated patch attached.

I tried this patch with Linus' 2.6.23-rc2 tree and the resulting kernel boots fine, though there are some scary-looking error messages:

These come from some debug code added by Thomas ... adding him to this thread so he can see the trace that his code generated ...

WARNING: at /data/sc/linux-2.6/kernel/irq/resend.c:70 check_irq_resend()

Call Trace:
 [<a0000001000132e0>] show_stack+0x80/0xa0
                                spà0000407ff97bc0 bspà0000407ff90f58
 [<a000000100013330>] dump_stack+0x30/0x60
                                spà0000407ff97d90 bspà0000407ff90f40
 [<a0000001000db860>] check_irq_resend+0x1e0/0x200
                                spà0000407ff97d90 bspà0000407ff90ef8
 [<a0000001000dadd0>] enable_irq+0x210/0x240
                                spà0000407ff97d90 bspà0000407ff90ec8
 [<a0000001004f9aa0>] probe_hwif+0x440/0x1800
                                spà0000407ff97d90 bspà0000407ff90db0
 [<a0000001004fc7d0>] probe_hwif_init_with_fixup+0x30/0x180
                                spà0000407ff97d90 bspà0000407ff90d80
 [<a0000001005037c0>] ide_setup_pci_device+0x160/0x1c0
                                spà0000407ff97d90 bspà0000407ff90d40
 [<a0000001004e2670>] init_setup_cmd64x+0x30/0x60
                                spà0000407ff97da0 bspà0000407ff90d18
 [<a0000001004e25c0>] cmd64x_init_one+0x140/0x160
                                spà0000407ff97da0 bspà0000407ff90cf0
 [<a000000100933a10>] ide_scan_pcidev+0xf0/0x180
                                spà0000407ff97e00 bspà0000407ff90cb8
 [<a000000100933b20>] ide_scan_pcibus+0x80/0x2e0
                                spà0000407ff97e00 bspà0000407ff90c80
 [<a0000001009338c0>] ide_init+0xc0/0x120
                                spà0000407ff97e00 bspà0000407ff90c60
 [<a0000001009003c0>] kernel_init+0x1a0/0x6a0
                                spà0000407ff97e00 bspà0000407ff90c00
 [<a0000001000113b0>] kernel_thread_helper+0xd0/0x100
                                spà0000407ff97e30 bspà0000407ff90bd0
 [<a000000100008dc0>] start_kernel_thread+0x20/0x40
                                spà0000407ff97e30 bspà0000407ff90bd0
#4 lore raw
In reply to David Mosberger-Tang
Quoted 9 lines · Tony
Quoted 4 lines

Sure, that sounds reasonable. Updated patch attached.

I tried this patch with Linus' 2.6.23-rc2 tree and the resulting kernel boots fine, though there are some scary-looking error messages:

These come from some debug code added by Thomas ... adding him to this thread so he can see the trace that his code generated ...

WARNING: at /data/sc/linux-2.6/kernel/irq/resend.c:70 check_irq_resend()

I know. I'm working on a fix for that. The warning message is harmless and was added to debug the ne2k-pci breakage which was caused by the delayed irq disable.

tglx