<p dir="auto">by <strong>happyalu</strong>:</p>
<pre class="notranslate">When using cgo to compile for linux/386 on a linux/amd64 host, I get this error:
unexpected GOT reloc for non-dynamic symbol. 

Small Code to reproduce the error is at <a href="http://play.golang.org/p/WfasIPKzKH" rel="nofollow">http://play.golang.org/p/WfasIPKzKH</a>

Running:
$ GOARCH=386 go build

produces:
unexpected GOT reloc for non-dynamic symbol x

The reloc in question here is a R_386_GOT32 reloc for the global 'x'.

--- Disassembly Snippet
00000020 &lt;g&gt;:

  20:   53                      push   %ebx
  21:   e8 fc ff ff ff          call   22 &lt;g+0x2&gt;
            22: R_386_PC32  __x86.get_pc_thunk.bx
  26:   81 c3 02 00 00 00       add    $0x2,%ebx
            28: R_386_GOTPC _GLOBAL_OFFSET_TABLE_
  2c:   83 ec 08                sub    $0x8,%esp
  2f:   e8 fc ff ff ff          call   30 &lt;g+0x10&gt;
            30: R_386_PLT32 f
  34:   3b 83 00 00 00 00       cmp    0x0(%ebx),%eax
            36: R_386_GOT32 x
  3a:   0f 94 c0                sete   %al
  3d:   83 c4 08                add    $0x8,%esp
  40:   0f b6 c0                movzbl %al,%eax
  43:   5b                      pop    %ebx
  44:   c3                      ret    

---

cmd/8l/asm.c seems to handle only the MOVL instruction for R_386_GOT32 reloc of
non-dynamic symbols. The instruction this code generates is CMP.

I was able to work around this problem by basically adding a GOT entry for the symbol,
as if it were a dynamic symbol. That seemed to work both for this minimal example and
the real code I was trying to get working. 

But I not quite sure what the actual fix here is :)

Which version are you using?  (run 'go version')
go version devel +7cb3730e3f37 Fri Feb 08 19:24:50 2013 +0400 linux/amd64</pre>
<p dir="auto">by <strong>ckolbeck</strong>:</p>
<pre class="notranslate">Before filing a bug, please check whether it has been fixed since
the latest release: run "hg pull -u" and retry what you did to
reproduce the problem.  Thanks.

What steps will reproduce the problem?
1. visit <a href="http://golang.org/pkg/os/#Variables" rel="nofollow">http://golang.org/pkg/os/#Variables</a>

What is the expected output?
Single entry

What do you see instead?
Double entry

Please provide any additional information below.
as of 10/1/10 1100 PDT</pre>