Browse Source

Fix external globals

This broke the allocator on ARM, and with that the blinky example.
pull/6/head
Ayke van Laethem 6 years ago
parent
commit
bfff0c33e4
No known key found for this signature in database GPG Key ID: E97FF5335DFDFDED
  1. 1
      arm.ld
  2. 5
      compiler.go
  3. 4
      ir.go

1
arm.ld

@ -80,4 +80,3 @@ __bss_end__ = _ebss;
/* For the memory allocator. */
_heap_start = _ebss;
_heap_end = ORIGIN(RAM) + LENGTH(RAM);
runtime.heapptr = _heap_start; /* necessary? */

5
compiler.go

@ -252,7 +252,7 @@ func (c *Compiler) Parse(mainPath string, buildTags []string) error {
}
global := llvm.AddGlobal(c.mod, llvmType, g.LinkName())
g.llvmGlobal = global
if !strings.HasPrefix(g.LinkName(), "_extern_") {
if !g.IsExtern() {
global.SetLinkage(llvm.InternalLinkage)
initializer, err := getZeroValue(llvmType)
if err != nil {
@ -745,6 +745,9 @@ func (c *Compiler) initMapNewBucket(mapType *types.Map) (llvm.Value, uint64, uin
}
func (c *Compiler) parseGlobalInitializer(g *Global) error {
if g.IsExtern() {
return nil
}
llvmValue, err := c.getInterpretedValue(g.initializer)
if err != nil {
return err

4
ir.go

@ -220,3 +220,7 @@ func (g *Global) LinkName() string {
return g.g.RelString(nil)
}
}
func (g *Global) IsExtern() bool {
return strings.HasPrefix(g.g.Name(), "_extern_")
}

Loading…
Cancel
Save