This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
I tracked down some mips-elf libstdc++ failures to a problem with the MIPS linker scripts. They aren't handling all of the sections emitted by gcc-4.x for C++ code. The particular failure I looked at was a segfault in free, because the malloc meta-data got corrupted. Gcc emitted two variables into .gnu.linkonce.b.* sections which weren't explicitly handled by the linker script. The linker's orphan section handling code ended up putting the sections after the .bss section, which is correct, but unfortunately it was also after the _end variable. So the result was that malloc started allocating space on top of the last two variables in the program. Eventually one of the variables was written to, corrupting the malloc meta-data, causing the segfault in free. I ran objdump -x | grep linkonce on libstdc++.a to see what sections gcc was currently using. Only the .gnu.linkonce.b.* and .gnu.linkonce.sb.* sections are used and missing from the mips linker scripts. I added the missing sections, and fixed the existing linkonce lines to eliminate ambiguities. Using a mips-elf gcc-4.1.0 toolchain build, and doing a libstdc++ make check, I get 187 unexpected failures without the patch, and 66 unexpected failures with the patch. For mips64-elf, the failures go from 187 to 102. I fixed idt.ld which is needed by the dejagnu mips-sim target, and pmon.ld, which is needed by the dejagnu mips64-sim target. Both of these changes have been tested with a libstdc++ make check. I think all of the linker scripts here should get the same fix. I'm willing to extend the patch for that, but I'm not willing to run a libstdc++ make check for all of them. I'm not willing to spend that much time on this patch. -- Jim Wilson, GNU Tools Support, http://www.specifix.com
Attachment:
patch.libstdc++.sections
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |