Subject: toolchain/33129: Orphaned section handling can break when linker scripts involved
To: None <toolchain-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <nick.hudson@dsl.pipex.com>
List: netbsd-bugs
Date: 03/22/2006 09:21:20
>Number: 33129
>Category: toolchain
>Synopsis: Orphaned section handling can break when linker scripts involved
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: toolchain-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Mar 22 09:21:20 +0000 2006
>Originator: Nick Hudson
>Release: NetBSD -current since binutils 2.16.1 import
>Organization:
Hah!
>Environment:
System: NetBSD -current
Architecture: All
Machine: All
>Description:
http://mail-index.netbsd.org/tech-kern/2006/02/11/0031.html
>How-To-Repeat:
Link a kernel with a linker script missing a .rodata section
description.
>Fix:
Index: gnu/dist/binutils/ld/emultempl/elf32.em
===================================================================
RCS file: /cvsroot/src/gnu/dist/binutils/ld/emultempl/elf32.em,v
retrieving revision 1.4
diff -u -p -u -r1.4 elf32.em
--- gnu/dist/binutils/ld/emultempl/elf32.em 2 Feb 2006 22:03:57 -0000 1.4
+++ gnu/dist/binutils/ld/emultempl/elf32.em 22 Mar 2006 09:18:29 -0000
@@ -1393,7 +1393,8 @@ gld${EMULATION_NAME}_place_orphan (lang_
else if (strncmp (secname, ".rel", 4) == 0
&& (s->flags & SEC_LOAD) != 0)
place = &hold[orphan_rel];
- else if ((s->flags & SEC_CODE) == 0)
+ else if ((s->flags & SEC_CODE) == 0
+ && hold[orphan_rodata].os != NULL)
place = &hold[orphan_rodata];
else
place = &hold[orphan_text];