Commit 06a09a5b authored by Tamar Christina's avatar Tamar Christina Committed by Ben Gamari
Browse files

rts: Fix bss initialization on Windows

This patch fixes BSS initialization such that it is
initialized to 0 as you'd expect.

Test Plan: ./validate, test T7040_ghci

Reviewers: bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, carter

GHC Trac Issues: #15669

Differential Revision: https://phabricator.haskell.org/D5364
parent 86f6890e
...@@ -1437,8 +1437,8 @@ ocGetNames_PEi386 ( ObjectCode* oc ) ...@@ -1437,8 +1437,8 @@ ocGetNames_PEi386 ( ObjectCode* oc )
{ {
bool has_code_section = false; bool has_code_section = false;
SymbolName* sname; SymbolName* sname = NULL;
SymbolAddr* addr; SymbolAddr* addr = NULL;
unsigned int i; unsigned int i;
COFF_HEADER_INFO *info = oc->info->ch_info; COFF_HEADER_INFO *info = oc->info->ch_info;
...@@ -1567,11 +1567,10 @@ ocGetNames_PEi386 ( ObjectCode* oc ) ...@@ -1567,11 +1567,10 @@ ocGetNames_PEi386 ( ObjectCode* oc )
Allocate zeroed space for it */ Allocate zeroed space for it */
bss_sz = section.info->virtualSize; bss_sz = section.info->virtualSize;
if (bss_sz < section.size) { bss_sz = section.size; } if (bss_sz < section.size) { bss_sz = section.size; }
bss_sz = section.info->alignment;
zspace = stgCallocBytes(1, bss_sz, "ocGetNames_PEi386(anonymous bss)"); zspace = stgCallocBytes(1, bss_sz, "ocGetNames_PEi386(anonymous bss)");
oc->sections[i].start = getAlignedMemory(zspace, section); oc->sections[i].start = zspace;
oc->sections[i].size = bss_sz; oc->sections[i].size = bss_sz;
addProddableBlock(oc, zspace, bss_sz); section = oc->sections[i];
/* debugBelch("BSS anon section at 0x%x\n", zspace); */ /* debugBelch("BSS anon section at 0x%x\n", zspace); */
} }
...@@ -1592,9 +1591,9 @@ ocGetNames_PEi386 ( ObjectCode* oc ) ...@@ -1592,9 +1591,9 @@ ocGetNames_PEi386 ( ObjectCode* oc )
if (sz < section.info->virtualSize) sz = section.info->virtualSize; if (sz < section.info->virtualSize) sz = section.info->virtualSize;
start = section.start; start = section.start;
end = start + sz - 1; end = start + sz;
if (kind != SECTIONKIND_OTHER && end >= start) { if (kind != SECTIONKIND_OTHER && end > start) {
/* See Note [Section alignment]. */ /* See Note [Section alignment]. */
addCopySection(oc, &oc->sections[i], kind, SECTION_NOMEM, start, sz); addCopySection(oc, &oc->sections[i], kind, SECTION_NOMEM, start, sz);
addProddableBlock(oc, oc->sections[i].start, sz); addProddableBlock(oc, oc->sections[i].start, sz);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment