Skip to content

Commit

Permalink
avoid orphan .bss.* sections in hw/arch/i386/kern.ldscript
Browse files Browse the repository at this point in the history
include .bss.* input sections in .bss output section

If .bss.* input sections are not added to some output section, ld orphan section
placing logic will add them after the .bss output section.
However: _end will still point at the end of the .bss section.

Since _end is used by the loader to place the alloc_bitmap at the next page,
.bss.* section content that crosses this page boundary will be corrupted.

this is the cause for issue #28 where:
- _end set to location after .bss (by ld)
- orphan .bss.* sections (c++ statics) placed after .bss (by ld)
- _end is on a page boundary (by pure chance at first)
- .bss.* sections set to 0xff (by bmk_pgalloc_loadmem in loader)
- abort (c++ init code throws in constructing objects from corrupted statics)
  • Loading branch information
sg2342 committed Jun 17, 2015
1 parent 984c4a3 commit ef5da31
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions platform/hw/arch/i386/kern.ldscript
Expand Up @@ -67,6 +67,7 @@ SECTIONS
AT (LOADADDR(.text) + (ADDR(.bss) - ADDR(.text)))
{
*(.bss)
*(.bss.*)
*(COMMON)
*(.bootstack)
}
Expand Down

0 comments on commit ef5da31

Please sign in to comment.