This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Bug fix for gldelf_i386_place_orphan in elf32.em [version 2.20.1]
On Wed, Jan 12, 2011 at 03:48:50PM +0800, Sheng, Yongjie wrote:
> Please see my small linker-test.tgz test package.
> With "-gstabs" compiling option, a hello world (binutils-2.20.1) links with a mangled-section.o(two section names are mangled, being orphan sections).
> It will crash in running (in ld-linux.so.2).
> It will not crash if built with binutils-2.17.50 (FC8).
Thanks. That nicely illuminates the bug, which is that using
lookup->prev can result in hold[orphan_nonalloc].os equal to
hold[orphan_bss].os. If that happens, then orphan bss sections and
orphan non-alloc sections might be intermingled.
I'll test the following patch overnight, to find the inevitable
testsuite failures this will cause..
Index: ld/emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.216
diff -u -p -r1.216 elf32.em
--- ld/emultempl/elf32.em 20 Dec 2010 13:00:14 -0000 1.216
+++ ld/emultempl/elf32.em 12 Jan 2011 13:30:55 -0000
@@ -1788,7 +1788,7 @@ gld${EMULATION_NAME}_place_orphan (asect
{ ".sdata",
SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_SMALL_DATA,
0, 0, 0, 0 },
- { 0,
+ { ".comment",
SEC_HAS_CONTENTS,
0, 0, 0, 0 },
};
@@ -1880,7 +1880,6 @@ gld${EMULATION_NAME}_place_orphan (asect
if (!orphan_init_done)
{
- lang_output_section_statement_type *lookup;
struct orphan_save *ho;
for (ho = hold; ho < hold + sizeof (hold) / sizeof (hold[0]); ++ho)
@@ -1890,16 +1889,6 @@ gld${EMULATION_NAME}_place_orphan (asect
if (ho->os != NULL && ho->os->flags == 0)
ho->os->flags = ho->flags;
}
- lookup = hold[orphan_bss].os;
- if (lookup == NULL)
- lookup = &lang_output_section_statement.head->output_section_statement;
- for (; lookup != NULL; lookup = lookup->next)
- if ((lookup->bfd_section != NULL
- && (lookup->bfd_section->flags & SEC_DEBUGGING) != 0)
- || strcmp (lookup->name, ".comment") == 0)
- break;
- hold[orphan_nonalloc].os = lookup ? lookup->prev : NULL;
- hold[orphan_nonalloc].name = ".comment";
orphan_init_done = 1;
}
--
Alan Modra
Australia Development Lab, IBM